Hacker News new | ask | show | jobs
by leed25d 717 days ago
Lisp. It is possible to write a tiny Lisp interpreter. With its macro support, Lisp is infinitely malleable and can be extended as required.

I have often wondered why Javascript was so widely used instead of Lisp to begin with.

1 comments

Javascript is widely used because, have you noticed it's in every browser, as a conformance requirement to web standards, without which you cannot use most websites?

Why did such a syntax get into every browser? The Wikipedia has a synopsis of the well-known story:

> [Brendan] Eich started work at Netscape Communications Corporation in April 1995. He originally joined intending to put Scheme "in the browser", but his Netscape superiors insisted that the language's syntax resemble that of Java. As a result, Eich devised a language that had much of the functionality of Scheme, the object-orientation of Self, and the syntax of Java.

Java was a hot buzzword around that time.

So one way we can look at it is that it was developed too early. Eich eventually became CTO and then CEO of Netscape. Had he started hacking on a Scheme in the browser at that later time, there would be likely be no vapid "Netscape superiors" who could push the bullshit Java syntax.

Had Eich put Scheme in the browser, it would have had (let ((var ...)) ...) from the get go. Instead, the world had to wait until 2019 (or whenever it was) to get "let var = ...;" that is properly block scoped rather than function scoped.

I think if we had Scheme in the browser instead of Java, we would still have other syntaxes via "transpilation" anyway, just the same.

Transpilation would be nicer because you can use macros to develop a more ideal target language for your syntax, so the transpiler has less to do.

E.g. suppose you want pattern matching. It would make more sense to make pattern matching in Scheme, and then just a syntactic sugar for it that looks Java-like, than to implement the Java-like syntax and the pattern matching expansion in the transpiler. Plus it would be available to more transpilers: different syntactic sugars could easily share the same pattern matching sublanguage. The semantics would be documented just once; to go from one surface syntax to another, you'd just learn how the new one maps onto the semantics you already know.