Hacker News new | ask | show | jobs
by gricardo99 444 days ago
My favorite Tcl story is a little side note about how Tcl could have been the language of the web[1]

  the founding of Netscape   occurred at the same time I was deciding where to go in industry when I left Berkeley in 1994. Jim Clarke and Marc Andreessen approached me about the possibility of my joining Netscape as a founder, but I eventually decided against it (they hadn't yet decided to do Web stuff when I talked with them). This is one of the biggest "what if" moments of my career. If I had gone to Netscape, I think there's a good chance that Tcl would have become the browser language instead of JavaScript and the world would be a different place! However, in retrospect I'm not sure that Tcl would actually be a better language for the Web than JavaScript, so maybe the right thing happened.

Too humble Dr. Ousterhout! It would have been a far better language.

1 - https://pldb.io/blog/JohnOusterhout.html

5 comments

I was leading a Tcl project around then, and, though there were some very neat things about the unusual Tcl evaluation model, I wasn't a fan of using it for nontrival work. For example, it wasn't a natural fit for working with graph structures like I had to, and like you might want for browser DOM.

(That said, Tcl would've been much better than JS, and I suspect that Ousterhout would've figured out some smart things to make it good for the browser.)

Maybe 5 years later, I was meeting with Tim-Berners Lee, and I kinda pitched Scheme to him, without planning to, but he was very interested when he asked what I'd been working on.

But then he went and did a conference keynote, in which he promoted Python as the language for ordinary people doing Web stuff. And I think he referenced one of the things I'd written in support of Scheme... as an anti-requirement for his populist vision for the Web. :)

(I wish I could've been involved in that, because I could've made a case for a populist spin on Scheme at the time.)

Why does JavaScript get some much hate?

TCL has an extremely loose runtime model, not to mention everything in the language is basically a string and all that entails.

I’ve been using JavaScript since the early 2000s, just before ES5 dropped.

Like all languages it has its curveballs but it really isn’t all that bad. It simply has oddities due to the quirky nature of the niche it was designed to fill (namely, to be a scripting language that was forgiving to web designers)

"Why does JavaScript get some much hate?"

I don't get it either? I've only used it occasionally but it has always struck me as a really impressive example of what can be built on minimal (minimalist?) foundations. Its semantics can understood in 5 minutes.

It reminds me of Scheme in this regard. Writing an interpreter or compiler for it would be easily within reach of an undergraduate student. Contrast with other currently popular (more respected?) languages like Rust, C++, Java, C# or even Python.

I've only recently been expose to Typescript and again, I'm really impressed. I haven't encountered a type system so elegant and orthogonal since first being exposed to ML like languages.

> Its semantics can understood in 5 minutes.

Your definition of "semantics" must be different from mine, or you perhaps haven't seen https://javascriptwtf.com/ (linked in a sibling comment)

Your comment actually made me wonder whether those cited artifacts were implementation bugs or actually in the specification and ... lol, this shit reminds me of people who put comments above functions that just restate the function's name: https://tc39.es/ecma262/2024/#sec-addition-operator-plus

> Writing an interpreter or compiler for it would be easily within reach of an undergraduate student

Surely you don't really believe that? Or is the rest of the sentence "... eventually, over the course of their undergraduate career"

The 15th edition of the standard is 816 pages and now includes specifying the Memory Model. What I suspect you mean is "could write a parser for the 1st edition spec from 1997"

I'm claiming that its semantics are simple, not that they've made great choices in the design of the language. For example, I've barely used Javascript, but I think I would have scored fairly highly if that javascriptwft page was turned into a quiz. Most of the examples are fairly transparent once you know the implicit casting rules. I've read certain wtfs associated with C++ or even Java far more puzzling despite years of experience with them.

And yes I do believe that writing an interpreter for Javascript would be no more difficult than doing one for Scheme (which I had to do as a student) - the parser would be more difficult admittedly.

I can find oddities like this in all languages. Arguably C and C++ have more warts, particularly C++ where I always hear people talk about how it’s only reasonable to use a small subset of the language. Also how C/C++ compilers don’t all support the same features of the purported language they compile.

I won’t argue that JS doesn’t have warts - it does and if it wasn’t for backward compatibility I imagine they’d have been removed from the language - but the entries on that website are quite small compared to others - like C and C++ - that I can think of

> not to mention everything in the language is basically a string and all that entail

I disagree with that to at least some extent. Everything is a string works well in TCL because the language is built around that abstraction. It works at least as well as other dynamically typed languages in small projects, and is definitely preferable to Javascript's rather weird weak typing.

It also does async and multi-threading really nicely, and encouraged event driven long before it look off elsewhere.

I used Tcl briefly to build an interface way back with Tcl/Tk, and it is a terrible language. "Everything is a string" is not what you want in a solid programming environment for larger projects. It's a LISP-like gimmick, but without the advantages of LISP.

That said, plain JS is not a good fit for larger projects, either. It really needs TypeScript for that. But it does have some very fast engines.

In the early days at least part of the problem was marketing. The fact that it’s got Java in the name when it’s actually a very different language to Java confused a lot of people. They tried to use the language like Java, had a bad time and concluded the language was bad.
Honestly? I think the biggest cause of JavaScript hate is that a huge percentage of developers have very little choice but to use it.

The web ate almost everything else for a host of reasons, and JavaScript is still the only language that the web natively supports. You can compile to JS or use WASM with occasional callouts to JS, but you can't get away from it entirely.

Most other languages have a greater sense of choice surrounding them. For backend work you can pick pretty much anything, and mobile is still a small enough chunk of the ecosystem that if you really hate Swift you can just find a job that isn't iOS dev. It's not so easy to get out of web dev without dramatically shrinking your job pool.

All I can say is that’s the cost of doing business with the browser being the main platform.

If devs want to interact with it less then focus on moving more to the server. You can still serve HTML and CSS and get a long way without ever touching JS.

It’s no different than other domains where one or two particular languages largely dominate. Like I don’t hear developers decrying the existence of C/C++ every chance they get

I think the hate is entirely unjustified. It’s fine to have preferences but so often it goes beyond that.

FWIW, I agree totally, and I don't find JavaScript to be bad at all.
> Like I don’t hear developers decrying the existence of C/C++ every chance they get

I guess you haven't encountered the monkey zoo of rust cultists yet

I have, but they’re not quite as zealous. The anti JS campaign has been running almost as long as I’ve been using it, which is pushing two decades now.

Now I know why PHP devs sometimes get a little defensive

Guess I’m garbage :(
The joke is that it comes down to prejudice.
I think Tcl as it was back then especially would have been a terrible DOM manipulation choice. I love the language but the hacks frameworks like openacs used to use to imitate basic stuff like a list of database records are among the ugliest upvar/up level hacks I've seen.

But that being said it's an incredibly adaptable language and I have zero doubt it could have been adapted to make DOM manipulation ergonomic.

If I remember correctly early HTML specs actually used Tcl as an example for script tag content.

It was definitely possible that Tcl could have ended up the web sripting language.

> It would have been a far better language.

I like Tcl and I think it has some very admirable traits. That being said, I don't even want to picture the hellscape of an ecosystem that would have flourished if it became the language of the web. JS was the better timeline I will admit begrudgingly, and that includes the Scheme timeline as well.

Does Tcl have lexical scoping yet? If not, I'd have to disagree that it would have been a better language. JS is not one of the better languages I know, but it does have lambdas and lexical scoping. And as bad as JS's type system may be, at least it's not stringly-typed.
Allow me to introduce you to upvar https://www.tcl-lang.org/man/tcl9.0/TclCmd/upvar.html and its uplevel friend https://www.tcl-lang.org/man/tcl9.0/TclCmd/uplevel.html

I cannot possibly imagine the horrors of frontend frameworks that can grab values, or execute, in someone else's context willy nilly

Exactly, it's dynamic scoping. As far as I know, Tcl is the only language that still has this skeleton in its closet.
With great power comes great responsibility :-)
In that world, Netscape might have also acquired Naviserver instead of AOL. Wasn't the plan at Netscape to make money on their server software?