[Python-ideas] Why shouldn't Python be better at implementing Domain Specific Languages?
Guido van Rossum
guido at python.org
Thu Aug 30 21:40:22 EDT 2018
On Fri, Aug 31, 2018 at 3:19 AM, Michael Selik <mike at selik.org> wrote:
> On Thu, Aug 30, 2018 at 5:31 PM James Lu <jamtlu at gmail.com> 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/20180831/235a84c7/attachment.html>
More information about the Python-ideas
mailing list