5 ms·
Well, it's possible that if it hadn't been for Java JavaScript might have had a decent, parens-based syntax. I still wonder what might have been if Eich had be
by zeveb 10y ago
Well, it's possible that if it hadn't been for Java JavaScript might have had a decent, parens-based syntax.
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_inner_html https://www.w3schools.com/js/tryit.asp?filename=tryjs_intro_... & https://www.w3schools.com/css/css_howto.asp 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.
- nessus42 10y agoI'm a HUGE fan of Scheme. And of Lisp, in general. But having seen in the "real world" how so many people are so adverse to Lisp's beautiful syntax, I'm pretty confident that JavaScript would never have caught on if it looked like Lisp rather than like C.
- zeveb 10y agoThey wouldn't have had a choice, though, just as folks don't have a choice with JavaScript. 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:-)
- brlewis 10y agoPure Scheme would not be sufficient. You need at least DOM-handling libraries. And if those libraries were poorly designed, then people wouldn't cotton onto the advantage quickly. Look at DSSSL.
- shakna 10y agoJust about every modern Lisp has an X-Expression library, and having used Racket's in production, it's a hell of a lot better than the DOM browsers have today.
- fiddlerwoaroof 10y agoBecause of macros lisps are more resistant to bad APIs than other languages, in my experience.
- brlewis 10y agoThat is a very good point.
- zeveb 10y ago> You need at least DOM-handling libraries. 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.
- tmzt 10y agoWell we could all be using VBScript. If Netscape had failed to establish a defacto standard, Microsoft was waiting in the wings.
- nessus42 10y agoYou underestimate the average programmer's aversion to Lisp syntax, despite it being the clearly superior syntax. 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.
- deleted 10y ago[deleted]
- willtim 10y agoThey could have used "Scheme" with angled brackets instead of parens, which would have made it look much more like an extension of HTML.