Live data from Hacker News

At some point, JavaScript got good

jonbeebe.net

11–20 of 24 posts

Re: At some point, JavaScript got good

#11
post #4

I read the entire article based on the misconception that the title was "At some point, JavaScript not good", which I thought was an amusing title, and also a pithy way to express what I've felt for a long time. So I read and read, expecting to get to the part where the author explains why JavaScript is not good at some point. But it never came. I spent four years building an in-browser digital ad auction manager in…

The problem is that once you spend any reasonable amount of time with something that doesn't suck it becomes hard to look at JS/TS the same way. The warts feel so much worse when you know it doesn't need to be that way.

Re: At some point, JavaScript got good

#12
I started using kotlin-js a few years ago. That was after using typescript in a project. Unlike typescript, kotlin-js is very unapologetically Kotlin first. It has some facilities to enable interfacing with javascript libraries (mainly the dynamic keyword) but mostly it's just Kotlin. Which means things like refactoring works. The compiler stops you from deploying broken code. And it's a nice language that is well suited for frontend development as demonstrated by its popularity on Android (and increasingly IOS via compose IOS).

I come from a Java background and have mostly done server side until a eight years ago when being in charge of a startup meant I could not be picky about what I did and had to be able to do all of it (web, server, devops, etc.). That started with me inheriting a javascript code base. As javascript codebases go, it wasn't horrible but still pretty mediocre compared to what I was used to. No tests, obviously. And a lot of very verbose gibberish dealing with promises and what not.

I took the opportunity to learn typescript and migrated quite a bit of javascript code to that. I like typescript; it's great. But it is a bit of a compromise in that all javascript is valid typescript. Meaning, you inherit all the ugliness and weirdness with typescript and you need to be careful with how you use it. But it's a fine language and having a decent static type checker just wipes out whole categories of bugs that I don't need in my life. I found plenty of those migrating the Javascript code. Or rather the compiler did. I just fixed them as it found them. Cheap success IMHO. The downside of migrating javascript code is that a lot of it is still javascript and you end up either replacing a lot of its ugliness or not touching it until you have to because, for example, it's obviously broken or not right.

Fast forward a few years and another startup and I had a frontend developer whose only experience was Kotlin on Android. And I needed a webapp in a hurry and had no budget for bringing in re-enforcements. I considered doing react and typescript and training the person up. But instead, we evaluated using kotlin-js. Much to my surprise, this was actually pretty good. I had been using Kotlin server side for a few years and it obviously worked well on Android. But kotlin-js on the web felt risky. Yet a few weeks in we were getting kind of productive. We had integrated a few javascript libraries, picked a ui framework (fritz2) and my frontend developer was getting quite productive with it.

That was three years ago. That app still exists. As a technology choice it's been great. It was definitely a wild ride though in terms of being an early adopter. We were dealing with a rapidly evolving library ecosystem (kotlin multi platform), compiler bugs, a complete compiler rewrite in several steps (2.0 RC2 was released a few days ago), and a lot of other things. However, life is pretty good doing kotlin-js these days. If you want a break from typescript, it's well worth checking out. It would probably be considered cutting edge or risky in a lot of places. But it definitely worked well for us.

Re: At some point, JavaScript got good

#13
post #11
post #4

I read the entire article based on the misconception that the title was "At some point, JavaScript not good", which I thought was an amusing title, and also a pithy way to express what I've felt for a long time. So I read and read, expecting to get to the part where the author explains why JavaScript is not good at some point. But it never came. I spent four years building an in-browser digital ad auction manager in…

The problem is that once you spend any reasonable amount of time with something that doesn't suck it becomes hard to look at JS/TS the same way. The warts feel so much worse when you know it doesn't need to be that way.

Oh yes -- 100%.

Why would anyone use JavaScript when there are web stacks that JavaScript-free? You can use Flutter on the front end (people rave about how nice it is to program in Dart and Flutter) and there are also options like Elixir/Phoenix/LiveView and HTMX, which allow you to build modern web apps without messing with JavaScript.

I can't stand the fact that every other tech startup is using Node on the backend.

Everything can be so much simpler and better and nicer, but it is not.

Re: At some point, JavaScript got good

#14

This is something I have always found interesting. Most people cannot write JavaScript but think they can because the syntax looks familiar and then complain when the result is shit. There is some hidden assumption this language should reflect some other language a given programmer is formerly trained in and then disappointed when JavaScript is not their favorite pet language. Further interesting is that there is no…

You bring up a good point, but as you know, there's a certain amount of intuitive knowledge that gets carried over when learning another programming language (which is why it's much easier to learn additional languages than it was the first one you spent a considerable amount of time with). The problem is, JavaScript does look a whole lot like the languages you mention, it's just that some things behave vastly differently (ie. function scoped variables, behavior of double equals, etc.), which is what causes the confusion and sometimes you don't learn about these things until they bite you at some point.

Re: At some point, JavaScript got good

#15

I started using kotlin-js a few years ago. That was after using typescript in a project. Unlike typescript, kotlin-js is very unapologetically Kotlin first. It has some facilities to enable interfacing with javascript libraries (mainly the dynamic keyword) but mostly it's just Kotlin. Which means things like refactoring works. The compiler stops you from deploying broken code. And it's a nice language that is well su…

Considering how much I like TypeScript, kotlin-js sounds tempting based on your comment, but unfortunately it's a no-go for me the because I use React heavily, and the solutions I've seen for that look less ideal (for me) than using JSX.

Re: At some point, JavaScript got good

#16
post #7

Block scoping has been -huge- for me. ES6 'let' has very similar semantics to perl's 'my' and the absence of an equivalent elsewhere has always made me feel like I was missing a limb. There's currently a proposal (which I think looks likely to succeed) to add a 'do BLOCK' syntax to ES6 as well, which is (now I get sane scoping) the top perl feature I miss All The Time when writing JS, and I can't wait. (in the cases…

I didn't know about the do BLOCK syntax that's (possibly) coming, that's interesting, thanks for bringing that up.

Regarding your last comment about Ruby and Python. I've been thinking about this for a while and I think a lot of the hate people have towards JavaScript is due to the fact that (being the only "official" web language) lots of people were forced to use it without any other choice, which adds a lot of resentment.

On the other hand, Ruby and Python are deliberate choices of which there are many options. People who choose to use it love it, and people who don't can move onto something else. It's not the same with JavaScript. If you want (or need) to do frontend development, you had to use JavaScript.

I observed this with Lua community in the past. I hardly ever see anything negative about it, but it has its own oddities (such as 1-based indexing, global by default variables) and is in a lot of ways similar to JavaScript being a prototype-based language (the only other one that I know of actually).

Re: At some point, JavaScript got good

#17
post #11

Earlier quoted context omitted.

The problem is that once you spend any reasonable amount of time with something that doesn't suck it becomes hard to look at JS/TS the same way. The warts feel so much worse when you know it doesn't need to be that way.

Oh yes -- 100%. Why would anyone use JavaScript when there are web stacks that JavaScript-free? You can use Flutter on the front end (people rave about how nice it is to program in Dart and Flutter) and there are also options like Elixir/Phoenix/LiveView and HTMX, which allow you to build modern web apps without messing with JavaScript. I can't stand the fact that every other tech startup is using Node on the backend…

Joining as a lead engineer in a startup, everything we do on the web will be Elixir. After three stints with Next.js “backends” at previous places I have vowed to myself to never use it or take a job where they use it ever again.

Re: At some point, JavaScript got good

#18

I started using kotlin-js a few years ago. That was after using typescript in a project. Unlike typescript, kotlin-js is very unapologetically Kotlin first. It has some facilities to enable interfacing with javascript libraries (mainly the dynamic keyword) but mostly it's just Kotlin. Which means things like refactoring works. The compiler stops you from deploying broken code. And it's a nice language that is well su…

Considering how much I like TypeScript, kotlin-js sounds tempting based on your comment, but unfortunately it's a no-go for me the because I use React heavily, and the solutions I've seen for that look less ideal (for me) than using JSX.

Kotlin has internal DSLs. They are a quite nice alternative to JSX. Easier to refactor, auto complete, etc.

You can use react with kotlin-js btw. Lots of people do this.

Re: At some point, JavaScript got good

#19
post #7

Block scoping has been -huge- for me. ES6 'let' has very similar semantics to perl's 'my' and the absence of an equivalent elsewhere has always made me feel like I was missing a limb. There's currently a proposal (which I think looks likely to succeed) to add a 'do BLOCK' syntax to ES6 as well, which is (now I get sane scoping) the top perl feature I miss All The Time when writing JS, and I can't wait. (in the cases…

I didn't know about the do BLOCK syntax that's (possibly) coming, that's interesting, thanks for bringing that up. Regarding your last comment about Ruby and Python. I've been thinking about this for a while and I think a lot of the hate people have towards JavaScript is due to the fact that (being the only "official" web language) lots of people were forced to use it without any other choice, which adds a lot of res…

I am honestly drooling for it,

    my $thing = do {
      my $intermediate_1 = foo(...);
      my $intermediate_2 = bar($intermediate_1, ...);
      baz($intermediate_2);
    };
type code is something I use quite a lot to be able to name the intermediates while keeping them from escaping into the containing scope. So

    let thing = do {
      let intermediate_1 = foo(...);
      let intermediate_2 = bar(intermediate_1, ...);
      baz(intermediate_2);
    };
is going to make me a very happy camper.

My other major irritation these days is that 'let' is a statement in JS, whereas 'my' is an expression in perl, and I'm very used to writing

    if (my $token = $user->admin_token) {
      ...
    }
and similar constructs. In JS currently I have to write

    let token;
    if (token = user.admin_token()) {
      ...
    }
(and wrap that entire construct in its own block if I don't want the 'token' variable to continue to exist afterwards, which generally I don't)

The javascript-viable version of that is probably to have a special cased 'if let' just like 'for let' was added already.

I'm unaware of a proposal for that - yet.

Though the 'match' proposal currently in flight IIRC assumes 'do BLOCK' is available, and that will probably give me something sufficient to stop grumbling about that one.

(learning lisp, then applying the same "lexically scope as tight as possible" aesthetic I developed there to my perl code, then trying to use ... pretty much anything else ... has been an irritating experience on occasion ;)

Post reply on HN