Live data from Hacker News

V8 Release v9.4

v8.dev

21–30 of 33 posts

Re: V8 Release v9.4

#21

I was expecting the blog post to have a bit more of substance after the introductory line: > V8 v9.4 is filled with all sorts of developer-facing goodies Instead it just describes a single feature, and then DIY: > Please use `git log branch-heads/9.3..branch-heads/9.4 include/v8.h` to get a list of the API changes.

> all sorts of developer-facing goodies From the posts in https://v8.dev/blog/tags/release , looks like the use the same opening paragraph every time. They should probably edit it or pick a default that doesn't promise so much :)

That's an interesting template, wonder what happened here:

v9.2: from V8’s Git master

v9.3: from V8’s main Git branch

v9.4: from V8’s Git master

Re: V8 Release v9.4

#22
post #3

I honestly think the newer ECMAScript features with static blocks, private fields are a little strange. I get that some people really want JavaScript to be object-oriented - but I wonder if we wouldn't be better off embracing and building on its functional side.

With real private fields you can make a minifier that minifies the fieldname/functionname which is not possible before.

Re: V8 Release v9.4

#23
post #3

I honestly think the newer ECMAScript features with static blocks, private fields are a little strange. I get that some people really want JavaScript to be object-oriented - but I wonder if we wouldn't be better off embracing and building on its functional side.

I’m perfectly happy for a language to have feature coverage for others to do what they like. I’ve found incredible success using JS (TS) as a functional language. Oh my god I love it. It’s so easy to test. So easy to reason about. So predictable. State is my enemy. Optimization can be hidden away in the form of memoization rather than partially mutating object state. Does this work for all use cases? Nope. Classes ar…

I’ve found incredible success using JS (TS) as a functional language. Oh my god I love it.

Immutability is still very tedious and kludgy.

Re: V8 Release v9.4

#24

Earlier quoted context omitted.

I’m perfectly happy for a language to have feature coverage for others to do what they like. I’ve found incredible success using JS (TS) as a functional language. Oh my god I love it. It’s so easy to test. So easy to reason about. So predictable. State is my enemy. Optimization can be hidden away in the form of memoization rather than partially mutating object state. Does this work for all use cases? Nope. Classes ar…

I’ve found incredible success using JS (TS) as a functional language. Oh my god I love it. Immutability is still very tedious and kludgy.

Oh yes. I do use Immer for this but I’d kill for first class support.

Re: V8 Release v9.4

#25
post #3

I honestly think the newer ECMAScript features with static blocks, private fields are a little strange. I get that some people really want JavaScript to be object-oriented - but I wonder if we wouldn't be better off embracing and building on its functional side.

I wish they could add pattern matching statements.

That is a stage 1 proposal[1].

[1] https://github.com/tc39/proposal-pattern-matching

Re: V8 Release v9.4

#26

Earlier quoted context omitted.

Some JavaScript people have been hostile to functional concepts since the beginning. See the missed opportunity to make Promise a monad.[1] [1] https://github.com/promises-aplus/promises-spec/issues/94

I’m curious if someone can sell me, practically, in relatively few words, what that would gain us compared to Promises today. That link wasn’t sufficient to teach me. I’m a bit dense. :(

Basically, the current promises take a shortcut. If your promise returns a promise, the two promises are automagically combined into one promise.

    foo
    .then(() => returnsAnotherPromise())
    .then(() => { /*only receives the nested promise*/})
The correct solution would not automatically flatmap

    foo
    .then(() => returnsAnotherPromise())
    .then(innerPromise => { 
      innerPromise.then(() = {}) //now we have access to the nested promise
    })
The second API is easier to statically type (creating a type that automatically, but conditionally removes a type is not necessarily0 easy). The second API makes some abstractions easier. The second API more intutitive for most people new to promises (I've seen it done a lot -- especially a few years ago). The second API allows you to interface with other monads without constantly having to do a special conversion any time you touch a promise.

The current API is way more ergonomic for most current developers.

In any case, it seems like there should a way to create your own proper monad promises along with an interface to normal promises when needed.

Re: V8 Release v9.4

#27

Earlier quoted context omitted.

Yes! In Javascript I write a closure that returns an object full of methods. If I want private state I put the variables in that closure. Nothing bad has happened to me yet. :)

I would argue that that method (no pun intended) is less clear about intent and harder to read There are lots of things like this where the OOP version and the FP version are technically interchangeable in terms of capability, but not in terms of ergonomics or readability. A beautiful thing about working in a multi-paradigm language like JS is that you can reach across the aisle for the best tool for any given job. Y…

I don't get the intent argument.

Closures are private by default while JS classes are public by default. If anything, closures have a more desirable default.

The issue is that private variables cause a ton of implementation complexity. The add more overhead when thinking about classes too.

In the end, they don't add very much of value except allowing Java or C# programmers to feel more comfortable. Meanwhile, it's giving them a giant footgun in the form of class syntax that looks like what they know, but operates on completely different underlying principles.

JS continues to be the only language that people commonly use without having actually bothered to learn properly.

Re: V8 Release v9.4

#28
post #27

Earlier quoted context omitted.

I would argue that that method (no pun intended) is less clear about intent and harder to read There are lots of things like this where the OOP version and the FP version are technically interchangeable in terms of capability, but not in terms of ergonomics or readability. A beautiful thing about working in a multi-paradigm language like JS is that you can reach across the aisle for the best tool for any given job. Y…

I don't get the intent argument. Closures are private by default while JS classes are public by default. If anything, closures have a more desirable default. The issue is that private variables cause a ton of implementation complexity. The add more overhead when thinking about classes too. In the end, they don't add very much of value except allowing Java or C# programmers to feel more comfortable. Meanwhile, it's gi…

There's no need to be rude.

> I don't get the intent argument.

Classes, from day one, have always been about encapsulating state behind a set of methods (or "passed messages" if you want to go all the way back). If I define a class in my JS codebase, it gives strong signals to others about what my intent was with this code, how it works[0], and how it should be used. A newcomer who encounters the closure method, on the other hand, has to mentally reverse-engineer how it works and what its goal is if they haven't seen that pattern before, because closures are much more general than classes and because returning a closure is less common and its behavior less obvious compared to other ways closures tend to be used in JS.

> The issue is that private variables cause a ton of implementation complexity.

I think a case could be made that private members should have been left up to type systems like TypeScript (which I believe virtually every JS codebase should be using at this point anyway) instead of implemented in the JS engine at runtime. At this point I see plain JS as a bit of an "all bets are off" language, so maybe it wasn't worth trying to plug one hole given how many others still remain. But on the other hand, like I've said, I think classes are nearly useless without private members, and they do exist in JS already so there's an argument to be made that we should at least make them useful.

> In the end, they don't add very much of value except allowing Java or C# programmers to feel more comfortable.

It's a tired trope that every single feature associated with Java or C# is "just there to make Java and C# programmers feel comfortable" and is therefore invalid and useless.

> Meanwhile, it's giving them a giant footgun in the form of class syntax that looks like what they know, but operates on completely different underlying principles.

The only footgun I've encountered with the ES class syntax is when passing classInstance.someMethod as a value (`this` is normally unbound because the method exists on the prototype instead of the instance). But a) this is not something (to my knowledge) that you can even do in those other languages, so the proverbial "Java and C# programmers" should have no preexisting expectations around how it behaves, and b) the solution is just "always use arrow syntax for methods if you want this to work the way JS would have you expect". I've worked with many junior programmers who have no problem doing the latter, even when they don't yet have a full understanding of why it's needed.

[0] How it works at the application logic level; the underlying way that classes work is rarely an issue that comes up.

Re: V8 Release v9.4

#29
post #27

Earlier quoted context omitted.

I don't get the intent argument. Closures are private by default while JS classes are public by default. If anything, closures have a more desirable default. The issue is that private variables cause a ton of implementation complexity. The add more overhead when thinking about classes too. In the end, they don't add very much of value except allowing Java or C# programmers to feel more comfortable. Meanwhile, it's gi…

There's no need to be rude. > I don't get the intent argument. Classes, from day one, have always been about encapsulating state behind a set of methods (or "passed messages" if you want to go all the way back). If I define a class in my JS codebase, it gives strong signals to others about what my intent was with this code, how it works[0], and how it should be used. A newcomer who encounters the closure method, on t…

> There's no need to be rude.

I didn't intend to be rude (I'm sorry for any offense it might have caused). It was a general complaint not aimed at you or anyone else in particular.

> A newcomer who encounters the closure method, on the other hand, has to mentally reverse-engineer how it works and what its goal is if they haven't seen that pattern before, because closures are much more general than classes and because returning a closure is less common and its behavior less obvious compared to other ways closures tend to be used in JS.

The second part here is simply not the case. If you want to use any bundler or build tool created in the past 15 years, it's going to use closures for anything but the most recent projects. CommonJS which is still ubiquitous in NodeJS is literally closures. When it was created, it literally wrapped your file in a function that passed in some variables like global or import then called eval on the module it had now created.

Before CommonJS, there was AMD (asynchronous module definition). Before that, libraries would wrap themselves in an IIFE which returned only the public parts of the library.

If someone doesn't know how the module pattern works, they are a junior JS dev and absolutely cannot move on with their career until they understand. At that point, there should be zero issues with them using the pattern.

> It's a tired trope that every single feature associated with Java or C# is "just there to make Java and C# programmers feel comfortable" and is therefore invalid and useless.

When you look into the people pushing for these features, you almost always find a Java or C# developer. There's not a mass push by JS devs to add these features. In the case of private variables, it seemed to be more-or-less the JS community vs the spec committee and the committee just ignored what most devs wanted (without any evidence) because they thought they knew best.

> The only footgun I've encountered with the ES class syntax is when passing classInstance.someMethod as a value (`this` is normally unbound because the method exists on the prototype instead of the instance).

This is too big of a topic for here, but there are many pieces of weirdness in the JS prototypal system. Classes don't fix them, they just add another layer of abstraction with its own rules (eg, methods aren't enumerable). There are lots of footguns and other people run into them even if you and your particular set of devs do not.

Re: V8 Release v9.4

#30
post #29

Earlier quoted context omitted.

There's no need to be rude. > I don't get the intent argument. Classes, from day one, have always been about encapsulating state behind a set of methods (or "passed messages" if you want to go all the way back). If I define a class in my JS codebase, it gives strong signals to others about what my intent was with this code, how it works[0], and how it should be used. A newcomer who encounters the closure method, on t…

> There's no need to be rude. I didn't intend to be rude (I'm sorry for any offense it might have caused). It was a general complaint not aimed at you or anyone else in particular. > A newcomer who encounters the closure method, on the other hand, has to mentally reverse-engineer how it works and what its goal is if they haven't seen that pattern before, because closures are much more general than classes and because…

> If you want to use any bundler or build tool created in the past 15 years, it's going to use closures for anything but the most recent projects. CommonJS which is still ubiquitous in NodeJS is literally closures. When it was created, it literally wrapped your file in a function that passed in some variables like global or import then called eval on the module it had now created.

These are all implementation details; they couldn't matter less to most application developers. I've been writing JS for a decade and while I roughly knew that bundlers did something like this, I've never once had to deal with it directly.

> If someone doesn't know how the module pattern works, they are a junior JS dev and absolutely cannot move on with their career until they understand.

This is extremely not true. Knowing how modules are implemented under the hood is a concern of people who work on bundlers, transpilers, etc. For regular devs, an airtight abstraction is presented and it never needs to be more than that. It's wildly wrong to suggest that a person can't be productive at more than a junior level without knowing how this particular sausage is made.

> When you look into the people pushing for these features, you almost always find a Java or C# developer. There's not a mass push by JS devs to add these features.

Hello. I'm a JS dev who hasn't written Java or C# in over six years, who wouldn't want to write either of them, and yet I think private class members are valuable enough to have them in the language.

> even if you and your particular set of devs do not

I'm talking about the average JS dev doing mainstream JS work, here. I argue that ES classes are useful and mostly devoid of footguns for most, realistic, usage in industry. Not just for myself or for one particular team.

In all I think you're taking a fairly extreme purist stance, where people are disallowed from being productive with a given technology unless they have a deep understanding of how it works underneath. That deep understanding is great to have - it's part of what makes a good lead dev - but plenty of people out there are plenty effective working off of provided abstractions, and it's narrow-minded to dismiss that fact.

Post reply on HN