[Python-ideas] Why shouldn't Python be better at implementing Domain Specific Languages?

Jeff Allen ja.py at farowl.co.uk
Fri Aug 31 04:00:17 EDT 2018


The word "domain" appears in this sense on the first page of Aho and 
Ullman and ANTLR (which I know you've used) describes itself as a tool 
for building domain-specific languages. Both pre-date Ruby I'm fairly sure.

James Lu, quoting Jonathan Fine, used the term "internal DSL" and 
although that's new to me, people seem to be interpreting it in the 
sense that Gradle is a Groovy DSL (note caps), a build tool a lot of 
software developers will be familiar with. In that case, what you write 
really is Groovy, but the execution environment has been pre-conditioned 
with objects and libraries that (almost) make a new language. When you 
understand what's going on (not sure I always do), it becomes possible 
to mix Gradle statements and Groovy freely. The most immediate benefit 
is that all the apparatus of expressions and types/methods is already 
present. So "internal" is the key word.

The point about punctuation is spot-on, I think: Groovy is relatively 
free of (makes optional) some punctuation, including the parentheses 
that make calls easily identifiable in Python. So quite possibly 
starting from Python is limiting if what you want is an*internal* DSL 
with a grammar you choose: the object system is fantastic-plastic, but 
the grammar is not. DSLs embedded in Python are common, of course 
(f-strings, regexes, SQL), and DSLs can generate Python from fragments 
with almost no constraints on their own grammar. iPython strikes me as 
possibly a Python internal DSL, or Django, but what they've done does 
not take us far from pure Python.

Jeff Allen

On 31/08/2018 05:07, Guido van Rossum wrote:
> <snip>
> Hm. YAML is indeed a great, readable alternative to JSON or XML. But 
> the term DSL implies (to me) more than just nested key-value pairs. 
> (Though who knows maybe that's all Keras needs, and then it's a poor 
> argument for having a DSL.)
>
> Then again maybe I'm confusing DSL (which appears to be a Rubyism) 
> with "little language": http://wiki.c2.com/?LittleLanguage
>
> -- 
> --Guido van Rossum (python.org/~guido <http://python.org/%7Eguido>)
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180831/7980099c/attachment.html>


More information about the Python-ideas mailing list