
V8 release v7.2 - stablemap
https://v8.dev/blog/v8-release-72
======
drinchev
> V8 v7.2 adds support for public class [1] fields. Support for private class
> [2] fields is planned for a future V8 release.

For those who don't know private class fields add the weird "#" character for
defining them inside the `class {}` block.

    
    
        class IncreasingCounter {
           #count = 0;
           get value() {
               console.log('Getting the current value!');
               return this.#count;
           }
           increment() {
               this.#count++;
           }
        }
    

This looks way worse than having what TypeScript did by introducing `public` /
`private` keywords. Is there any body which votes for es-next features such as
this one? I wonder how the "#" private field popped up in Chrome specs.

1 : [https://developers.google.com/web/updates/2018/12/class-
fiel...](https://developers.google.com/web/updates/2018/12/class-fields)

2 : [https://developers.google.com/web/updates/2018/12/class-
fiel...](https://developers.google.com/web/updates/2018/12/class-
fields#private_class_fields)

~~~
__ryan__
The rationale for the "#" syntax is that it makes it clear that the field is
NOT an object property. This is an important distinction because you can do
this:

    
    
      class Example {
          #myVar = 100;
    
          getPrivateMyVar() {
              return this.#myVar;
          }
    
          getLocalMyVar() {
              return this.myVar();
          }
      }
    
      const example = new Example();
    
      example.myVar = 200;
    
      console.log(example.getPrivateMyVar()) // 100;
      console.log(example.getLocalMyVar()) // 200;
    

I agree the syntax is terrible. But you need to be able to distinguish between
the own object property _myVar_ and the private field _myVar_.

~~~
Illniyar
Access modifiers, as the name suggest, are an accessibility feature not a
scope feature (like let).

example.myVar = 500 should throw an access error.

You don't need to distinguish because you shouldn't be shadowing private
variables.

~~~
Klathmon
If `example.myVar = 500` can throw errors, then is the private field really
private? Since now it's existence can break the public interface, and changing
it to `myOtherVar` during a refactor can break existing code.

That removes a major benefit of private fields (which is to be able to change
implementation details without breaking the public interface)

I don't think anyone really loves the syntax, but there doesn't seem to be
much of a better way of doing it.

~~~
franciscop
What happens if you do `example.#myVar = 500`? Does it throw an error?
Wouldn't it be the same situation?

~~~
__ryan__
The difference is that when you type _example.myVar = 400_ you are setting a
property names "myVar" on the object to 400. When you type _example.#myVar_
you are trying to set example's _private field_ to 400. The intentions are
distinct and it is not costly to determine at the call site what you're trying
to do.

~~~
earthboundkid
What if I have private values I want to access programmatically? Ie. fields =
['#foo', '#baz', '#bar']; fields.forEach(field => { this[field] =
frobnicate(field) }); ?

~~~
__ryan__
I don't know what the spec's solution for that would be, but what you've typed
would not work. Specifically because when I say `this.#foo` it is not a
property on the object named "#foo". It is just the syntax for looking up a
private field referenced by the literal #foo.

~~~
Klathmon
The spec's solution is to not solve that problem ;)

Dynamic property access isn't allowed for private fields, so it kind of side
steps that whole issue.

------
AdmiralAsshat
What happens when it reaches version 8.0?

~~~
styfle
Google search results will be rendered useless.

"V8 release v8"

At least when it's spelled out like this, they always use capital V8 for the
engine and a lowercase v8 for the version.

I can imagine the verbal V8/v8 confusion probably forces everyone to say
"version 8"

------
zimbatm
Unrelated but .dev is a new Google TLD where all the domains have HSTS enabled
by default.

[https://shop.gandi.net/en/domain/suggest?search=hackernews.d...](https://shop.gandi.net/en/domain/suggest?search=hackernews.dev)

~~~
darkhorn
.app domains have HSTS enabled by default too. I think all domains should be
HSTS enabled by default in the near future.

------
jerrysievert
Personally, i’d like to see them focus less on super-rapid releases, and more
on consistency of builds and stopping major breakages across platforms.

It makes it much more difficult to maintain downstream builds when the build-
system breaks completely for indeterminate amounts of time.

------
chrismorgan
I wonder how many people will skip using Intl.ListFormat because it insists on
Oxford comma in English. I know I’ll be skipping it. CLDR really missed the
semantic nuance there—not that it could readily have included it. The problem
is that it’s just too blunt an instrument. (Further reading:
[http://cldr.unicode.org/translation/lists](http://cldr.unicode.org/translation/lists),
[https://en.wikipedia.org/wiki/Serial_comma](https://en.wikipedia.org/wiki/Serial_comma)
.)

~~~
dhritzkiv
Out of curiosity, why is the API's insistence on the Oxford comma a downside,
seeing as it works for almost all lists? Is it due to overriding editorial
preference - e.g. news orgs style guides?

~~~
chrismorgan
The linked Wikipedia article is long, but goes into some depth on reasons and
situations where it may or may not be desired. In American English it seems to
be mostly a matter of preference and style guide, but in Australian English
there is also semantic meaning to the comma, where it is possible in a
carefully crafted sentence to convey quite a different meaning by the addition
or removal of a comma; and unless there is semantic or possibly parsing value
to be gained by the inclusion of a comma, it is broadly (though not
universally) agreed that you shouldn’t.

As noted by narrowtux, not all English locales use the Oxford comma; en-AU
also doesn’t, which mollifies me.

The simplest style of example I can think of is nesting conjunctions: “the
difference between A and B, and C and D”. (This example isn’t great because it
depends on nesting and has only two items in each list; but it’s the first
that springs to my mind. There are others that don’t require nesting or only
two items, though normally not quite so clear-cut.) Removing the comma or
shuffling things around in any way would completely change the meaning of the
sentence. This is the sort of subtle thing that some will miss when writing,
but in speech it’d be very clear.

------
Bogdanp
I suppose I could look this up, but maybe someone here knows. Is cached JS re-
parsed on every page load or is the AST (or some sort of bytecode) stored as a
blob on disk for faster loads from cache?

~~~
tyingq
It looks like you can leverage this:

[https://v8.dev/blog/improved-code-caching](https://v8.dev/blog/improved-code-
caching)

using this:

[https://www.npmjs.com/package/v8-compile-
cache](https://www.npmjs.com/package/v8-compile-cache)

Or see the options with "cache" in their name, here:
[https://nodejs.org/api/vm.html#vm_new_vm_script_code_options](https://nodejs.org/api/vm.html#vm_new_vm_script_code_options)

~~~
Bogdanp
Thanks! Looks like the first link answers my question.

------
PunchTornado
why focus on facebook when measuring performance?

I thought they have like 10.000 websites they measure

~~~
dana321
Well.. Facebook runs like a dog, so any improvement is great news.

~~~
rsaarsoo
I consider dogs to be pretty fast :)

~~~
Skunkleton
Some dogs. Most dogs even. Not my dog. He is a good boy though.

------
velcrovan
Headline is hilarious

~~~
TomMarius
Not yet. I can't wait for V8 v8.

~~~
forgot-my-pw
Spoiler: V8 release v8.0 · V8

------
truth_seeker
Wow. Very impressive. They are improving at very fast rate. I wonder do we
still need to invest in WebAssembly ?

~~~
Skunkleton
What? How are these even related?

~~~
truth_seeker
How are they not related ?

