Hacker News new | ask | show | jobs
by drblast 2028 days ago
The industry is cyclical and to be forward thinking all you have to do is describe what's already happened and assume it will happen again. ;-)

The things being done with JavaScript today are not new, nor is the idea that a server and client would coordinate to run interactive apps. That fundamental concept has been reimplemented in many different ways until we've landed on the current rube goldbergian monstrosity that are web apps.

It shows that the desire to have users interact with a service in particular ways will not go away. The technology used to do that is mostly irrelevant.

4 comments

I'm not surprised that the architecture isn't new, I'm surprised that web apps were already being talked about this way using JS specifically. JS's early design flaws are often written off as, "well it was never intended to be a real programming language like it is today". But from reading this, that doesn't sound to be the case.
I don't so much think of them as flaws... the first use case was form validation, and most of the fuzzy type coercion makes a ton of sense through that lens, where ''. 0, etc. coercion to falsy is easy for dealing with user input. It's also why it's one of my favorite options for ETL workloads.

It's just a matter of understanding the langauge. That said, it's been my favorite language since well before the "good parts" book.

I use JS every day; I would say I like it. I would even say that in 2020, if you know what you're doing, it's a pretty good language on the whole.

But I don't think it's controversial to say that the following were objectively bad decisions (in hindsight, of course, but still):

- Automatic casting behavior between the core types (you're the only person I've ever heard suggest that this might be a good thing)

- Automatic semicolon insertion

- A core Date object that lacks basic control over time-zones and reasoning about time-zones

- Assigning to an undeclared variable silently creates a global

- Allowing duplicate function parameter names where later ones just hide the earlier ones

- Distinction between undefined and null (this one might have a few defenders)

Some of these are now prevented by "strict mode". Others have been patched-over, for example by the addition of === which prevents casting behavior for comparisons at least. Others can be bridged by libraries (Moment.js) or by best-practices (use foo == null to smooth over the null/undefined distinction, never use a value's implicit falsiness in a conditional, etc).

But the point is that JavaScript has this giant asterisk that will never go away, of things you need to do/avoid/utilize in order to get the most basic behaviors right.

I would suggest that today, you're best off using TypeScript for anything more complex in terms of applications development. Will probably play around more with Deno bundling if I get the time, though currently using Parcel, which is nice enough, but slow.

I didn't like TS at first, but using the most recent version has been relatively pleasant and working with less experienced devs has been almost required in order to do further refactors. I killed a month trying to do a complex refactor ad-hoc, in circling around, I was able to convert the entire project to TS in a couple days, introduce typing for core state and a few other areas which allowed me to do the rest of the refactor in a couple days. That sold me on TS, as long as I don't HAVE to type everything, or jump through the hoops as I did on my first experience with TS, which was combined with Angular projects.

The casting behavior is definitely a foot-gun, but it's powerful as I mention for validation and ETL type workflows. The "falsy" values list is literally my guide marker in interviews for JS devs. It's usually a pretty good benchmark for how well a developer understands the language itself..

Totally agreed on the Date object. Absolutely horrible, and moment, while useful was huge and most other hacks aren't all that great either. The Date object really should be extended as probably the next major bump in usability in the system. Even if it was just extended enough for parity for what C#/.Net offers for their DateTime/DateTimeOffset then other libraries could flush it out and be much smaller.

One useful thing to know, is that assigning an object property to undefined will skip that property as part of json serialization and is faster than delete on the property I'll often do something like return JSON.stringify(Object.assign({}, original, {propToHide: undefined}) in node APIs. This is about the only useful bit from undefined I can think of off hand.

Global variable assignment by default is definitely a flaw.

> Automatic casting behavior between the core types

This is (mostly) awesome for quick/light glue scripting and a (almost entirely) a horrible pain for most other programming. As the scale of JS apps has gone up, this has gone from probably being a net win from the way JS was used early on on the web to being a net harm.

> Distinction between undefined and null

This existence of this distinction is, IMO, a very good thing, but there's some big ergonomic issues with the implementation. (The rest of your list I agree with.)

Netscape 2.0:

    "foo" - 1
    //raises "is not a numeric literal"
    "" == false
    //raises "is not a numeric literal"

    "foo" + new Object()
    //"foonull"
    "foo" + new Array()
    //"foonull"

    0 + true
    //1
    0 + false
    //0

    1 + new Array()
    //raises "null is not a number"
    new Object + new Object
    //raises "null is not a number"

    true.foo
    //raises "true has no properties"
    1..foo
    //raises "1 has no properties"
Ten days language was not that silent.
TypeScript makes almost all of those asterisks go away.
I think JS' early design flaws were a result of being written in a day more than anything to do with a specific purpose (I exaggerate but not by much). Though it is true that most people at the time used JS (if they used it) for much simpler tasks than described in the article.
I think in some ways the problems people have experienced come back to a language design that is fairly ambitious.

Specifically the inclusion of a prototype OO system is confusing if you aren't aware what that is and have only been exposed to Java-like OO programming. But in fact it's very powerful and not so hard to learn once you realize you have to.

As with other web technologies, it's simple at first glance but the learning curve gets steeper at some point.

It was written in 9 days, which is astounding. I suspect that the project was given a week to complete and it came 2 days late. In any case it seems unlikely that it’s problems would go away if given another 5 days. A lot of the wired things in a scripting language only become obvious at scale.
> already happened and assume it will happen again

So say we all!

Under appreciated BSG reference. Well done!
Yes for sure..I worked as a corporate contractor for AT&T in 1990's and I was doing client/server apps using MSVC++ that are basically identical to React-type wideweb dev...

Indeed, your absolutely correct in saying it was obvious where webapps had to go, and that HTML and CSS just wasn't going to get us there.

Nitpick: "...and that HTML just wasn't going to get us there" (CSS came out in 1996).
And CSS wasn’t widely used until a few years into the ‘00s. Only then did more consistent layout engines finally make it viable for stuff other than just styling text.
Damn...I've forgotten more about the timelines of this stuff then most people know.
Me too. But your comment surprised me as I remember hearing about this new thing "JavaScript" waaaaay earlier than about CSS. I didn't actually know they came out this close together.
I agree with your basic premise. However, in this particular instance, what would have been the historical equivalent ("already happened") of scripts sent by the server to the client during the request response cycle, which could perform layout and logic in the client?

If you're simply referring to code that could run on both client and server, your point is clearer to me.

AJAX is part of the request response cycle?

Let's face facts...AJAX is the real secret sauce with JS and what makes it truly useful.

Long before the term "AJAX" was coined, we used hidden iframes to do the same thing.
Display PostScript[1] maybe? Developed by NeXT in 1987.

Or NeWS[2], also based on PostScript.

[1] https://en.m.wikipedia.org/wiki/Display_PostScript

[2] https://en.m.wikipedia.org/wiki/NeWS