Hacker News new | ask | show | jobs
by dTal 3264 days ago
I think the closest thing to a migration path is the Racket programming language.

When you get right down to it, "working on ASTs" basically means working in lisp. The idea is you have a canonical, external format for the AST; it might as well be s-expressions. The trouble is that lisp culture is highly resistant to any other syntax than raw s-expressions. They say things like "making alternate syntaxes is a rite of passage, but everyone gets used to the parentheses in the end."[1]

Racket alone encourages the creation of alternate syntaxes, and provides the tools to make it easy. You can have any syntax you want, and yet never be hamstrung by syntax decisions because you can always make a new version of your #lang, and it'll all be nicely compatible because it gets turned into s-expressions anyway. This isn't just theoretical - you can for example already write Python in Racket [2], except with full access to all of Racket's libraries as well as Python's. This turns the social aspect to its advantage. Imagine if Python had been written in Racket to begin with - the 2->3 nightmare would have been a non-issue.

I hope that eventually, all languages will have swappable syntaxes with a canonical s-expression form, and be distinguished purely by their fundamentally incompatible semantics. We may find we need far fewer incompatible silos that way.

Incidentally, and I don't think it's a coincidence, Racket's IDE is the furthest along the non-textual route of any "real" language I've seen. It's very next-gen - you can paste an image file directly into source code, for instance (try it, (define my-image <pasted image>) actually works!).

[1] I view all "rites of passage" with suspicion. Like the "rite of passage" of wielding 'rm' incautiously, they usually indicate a human factors failure.

[2] https://github.com/pedropramos/PyonR

1 comments

Lisp has various parser for language implementations. There is even a relatively complete Python implementation in Lisp.

Having Python syntax doesn't give you access to all the Python libs. Lot's of things need the Python runtime and also its support for non-Python extensions.

Literally hundreds of languages had been implemented on top of Lisp over the years. My Symbolics Lisp Machine had already in the 80s full C, ISO Pascal, Fortran, Ada and Prolog implementations written in Lisp. I was running on my Lisp Machine the original X11 server written in C and TeX written in Pascal...

Python is also not an alternative syntax on top of Racket or Lisp ... it's a different language.