7 ms·
Java and Javascript are related like Car and Carpet are similar. There was no historical connection between Java and JavaScript beyond renting the brand "Java"
by batmansmk 10y ago
Java and Javascript are related like Car and Carpet are similar.
There was no historical connection between Java and JavaScript beyond renting the brand "Java" from Sun to make the language more credible.
- astrodust 10y agoYes and no. In practice JavaScript was sometimes the thing that detected if Java was present and kicked off a Java applet. It also handled roll-overs before CSS was a thing, doing mundane stuff by comparison to what a full Java app could do. It was intended to be complementary.
- zeveb 10y agoWell, 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.
- 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.