Python is readable

Chris Angelico rosuav at gmail.com
Thu Mar 22 09:17:49 EDT 2012


On Thu, Mar 22, 2012 at 11:47 PM, Nathan Rice
<nathan.alexander.rice at gmail.com> wrote:
> Having one core language with
> many DSLs that can interoperate is infinitely better than having many
> languages that cannot.  A language designed in such a way would also
> prevent issues like the Python 2 -> 3 fiasco, because two versions of
> a DSL can be separate, and code can reference them independently while
> being able to interoperate.

This is either utterly impossible, or already available, depending on
your point of view.

To have an infinitely-configurable program, you must make its
configuration equivalent to writing code. There is already an
infinitely-configurable program in Unix: "gcc config.c; ./a.out" takes
a simple-format text file called "config.c" and processes it.

You want infinite DSLs? Behold!

$ ./module1 | ./module2 | ./module3 | ./module4

Each one has a shebang that tells you what they are (Python 2, Python
3, something else entirely). There's a very strict interoperability
protocol between the modules - they pass information around through
stdout and stdin. You can write any module in any language, and you
can rewrite module1 for Python 3 without affecting any other or the
invocation sequence.

Problems always come when you want to share data between dissimilar
modules. There's no single perfect data-transfer protocol that works
across all languages. What does it mean to "call a function"? If you
truly want this level of flexibility, the best thing to do is to
separate sections cleanly. In fact, the pipe system I show above could
be used that way, although it's stupidly ugly. Everything going on
stdout/stdin has a two-word dispatch envelope with a from and a to,
and each module reads a line, and if it's not addressed to it, passes
it on to stdout. Responses get sent out with their from and to
reversed. All you need is for the last module's stdout to be linked
back into the first module's stdin (not sure if you can do that or not
- it has the feeling of plugging a power strip into itself), and it'll
work perfectly. Add a bit of boilerplate so that the application
developers don't see what's happening underneath, and you could
pretend that dissimilar languages are able to call into each other.
Doesn't mean it's efficient though!

TLDR version: Infinite flexibility means you're doing nothing.

ChrisA



More information about the Python-list mailing list