by zeveb · 9y ago · 0 comments
I still wonder what might have been if Eich had been allowed to write the Scheme system he had been hired to do. While I'm not a fan of Scheme by any means, it is approximately 281,757,423,024,353 better than JavaScript.
And Scheme's a great little language for implementing other languages. Imagine, we could have had transpiling years ahead of time. We might be using S-expressions instead of JSON. Heck, we might even have moved to an S-expression syntax for HTML & CSS by now.
Imagine, one syntax for everything (thanks to https://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_... & https://www.w3schools.com/css/css_howto.asp for the examples):
(html (head (title "Example")
(style (body (background-color linen))
(h1 (color maroon)
(margin-left (px 40)))))
(body
(h1 "What can JavaScript do?")
(p (@ (id "demo")) "JavaScript can " (em "change") " HTML content.")
(button (@ (type "button")
(onclick (set! (inner-html (get-element-by-id document "demo"))
"Hello JavaScript!")))
"Click me!")))
The world could have been so much better.I imagine that folks would have cottoned on to the advantage pretty quickly. And those that didn't … I guess they could have always become telephone cleaners or something:-)
Not to mention that there were other ways to execute code in the browser in those days. We have 'no choice' but Javascript today simply because it's the option that people eventually gravitated towards, forcing the others out of the market.
If JavaScript had had Lisp syntax, then everyone would still be using Flash. Or some other plugin that provided a language with a more popular syntax.
IME it's a learned thing from only knowing languages that at least superficially resemble ALGOL.
JS is a first language for a lot of people - because their goal was to make a website do something. Scheme would not have been any different.
If people disliked the syntax enough to avoid the language (and the browser that uses it), I imagine that other browsers would've started supporting other languages, and something else would've dominated.
In IE world, things were actually even crazier, because the whole scripting story was extensible (via Active Scripting). So you could use Perl, for example...
Did you see the '(set! (inner-html (get-element-by-id document "demo")) "Hello JavaScript!")' bit? That's DOM-handling in Scheme. Not a really great API, but it's not terrible either.