Re:John Carmack working on Scheme as a VR scripting language
by klibertp on Wednesday July 01, 2015 @01:55PM
(#9813813)
To expand on this a little, here is a thing that you can't translate to most programming languages. By defining a simple, pattern-based macro we can get much closer to the Dart version:
(func: hello() => (displayln "Hello world"))
(hello)
All you need to do this - to change the language syntax to look like that - is to write this: (define-syntax func:
(syntax-rules (=>)
[(_ name (formal ...) => expr ...)
(define name (lambda (formal ...) expr ...))]))
If you want to see more realistic examples go to RosettaCode, pick interesting task and look for Scheme, Racket and Clojure entries. You can then compare them to each other and to other languages you know.
The other thing is that your code in Scheme and Dart don't do the same thing at all, unless I underestimate Dart semantics very much. A translation of your Scheme code to JS, with as much semantics preserved as possible, would look something like:
That's quite a bit of work less in Scheme, isn't it? But for when you don't need these semantics you can do a translation the other way round (Dart->Lisps). In Racket your Dart example would look like: Now, that looks better, right? It's worth noting that the Racket version has only one pair of parens than Dart.