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

Neil Girdhar mistersheik at gmail.com
Mon Sep 3 03:28:46 EDT 2018


I prefer Python's syntax.  

In the Keras example, Python pays off compared to the XML or YAML or 
whatever as soon as you need to define something programmatically.  For 
example, if your model is generated based on some other input.  

Anyway, most of your time is not spent typing punctuation.  Most of your 
time is spent debugging.

I wish that LaTeX, the DSLs I use, were implemented as a Python package.  
There are a thousand terrible design decision in latex that could all be 
fixed if it had been done as one good Python package.  Maybe LuaTex will 
end up fullfilling the dream.

On Thursday, August 30, 2018 at 9:41:46 PM UTC-4, Guido van Rossum wrote:
>
> On Fri, Aug 31, 2018 at 3:19 AM, Michael Selik <mi... at selik.org 
> <javascript:>> wrote:
>
>> On Thu, Aug 30, 2018 at 5:31 PM James Lu <jam... at gmail.com <javascript:>> 
>> wrote:
>>
>>> It would be nice if there was a DSL for describing neural networks 
>>> (Keras).
>>>
>>> model.add(Dense(units=64, activation='relu', input_dim=100))
>>> model.add(Dense(units=10, activation='softmax'))
>>>
>>>
>> Why not JSON or XML for cross-language compatibility?
>>
>
> Presumably because those are even harder to read and write for humans.
>
> I believe that the key issue with using Python as a DSL has to do with its 
> insistence on punctuation -- the above example uses nested parentheses, 
> commas, equal signs, and quotation marks. Those are in general needed to 
> avoid ambiguities, but DSLs are often highly stylized, and a language that 
> doesn't need them has a certain advantage. For example if a shell-like 
> language was adopted, the above could probably be written with spaces 
> instead of commas, parentheses and equal signs, and dropping the quotes 
> (though perhaps it would be more readable if the equal signs were kept).
>
> I'm not sure how we would go about this though. IIRC there was a proposal 
> once to allow top-level function calls to be written without parentheses, 
> but it was too hard to make it unambiguous (e.g. would "foo +1" mean 
> "foo(+1)" or "foo + 1"?)
>
> -- 
> --Guido van Rossum (python.org/~guido)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180903/3b379e08/attachment-0001.html>


More information about the Python-ideas mailing list