indutny / candor

Experimental VM for a `Candor` language
http://candor-lang.org/
177 stars 16 forks source link

Make AST a canonical input #28

Closed Gozala closed 12 years ago

Gozala commented 12 years ago

We have started this thread on twitter which is not ideal for such discussions, so I'm moving this here. Let me give you little bit of perspective, I'm coming from:

I have being one of this guys who wrote 2JS compile languages: https://github.com/Gozala/wisp Which happened to be lisp, where syntax is almost AST itself. Transforming from one AST to another is pretty trivial, compiling to readable JS is a lot harder, not to mention debug-ablity and some other constraints that I can imagine to be a lot easier with pure AST.

It also seems that a lot more people try to experiment with languages & js seems to be a pretty sweet target. I think that light & fast vm would attract a lot of these experiments if it was simple to take it and plug your own syntax into it (it would definitely attract me). If it's diff language that I need to compile to it's far less attractive.

I think John McCarthy made few excellent points related to AST on a phone interview with Guy Steel.

I found this summary on the web http://wondible.com/2009/05/02/john-mccarthy-ast-is-king/ which is probably better then watching that interview. Also I'm paste here few interesting points:

First, a programming language should have access to it’s own AST. This means the structure of the > program, apart from the characters used to represent it. Lisp had this in it’s infamous macros.

Second, a language should have multiple concrete syntaxes, all built on the same AST and all for different purposes. Some of the purposes McCarthy mentioned:

  • Easy to write
  • Easy to read
  • Abstract, for language theorists and mathematicians
  • Easy for programs to process

I think ability to have an objective specific syntax may be very powerful

Gozala commented 12 years ago

Also Mathematica takes some interesting approach here that may be worth checking out.

Gozala commented 12 years ago

I guess what I'm trying to suggest is that candor vm could be something like LLVM for a high level languages with GC and etc..

indutny commented 12 years ago

I think JVM fits this much better.

indutny commented 12 years ago

So, I did VM because of language, not a language because of VM. That's why I don't think I'll ever accept this proposal.