What’s new in V8/JavaScript

Поділитися
Вставка
  • Опубліковано 22 гру 2024

КОМЕНТАРІ •

  • @prabodhmeshram2164
    @prabodhmeshram2164 4 роки тому +82

    Optional chaining is definitely I've been waiting for years, checking a deeply nested property was very painful exercise. I always thought why JS is not working on this direction or am I the only one felt there could be a better way to handle such things. Thanks for this feature.

    • @georgjr2
      @georgjr2 4 роки тому +2

      Well yes, but you could still use `get` from lodash

    • @VipinYadav1
      @VipinYadav1 4 роки тому +1

      I had this problem two weeks ago.. Where I had to code like this (data.options || {}).tag
      Optional chaining would have helped a lot

    • @Nurutomo
      @Nurutomo 4 роки тому

      @@VipinYadav1 Ruby implement this too

  • @Textras
    @Textras 4 роки тому +81

    "I'm making a new chat app - something of a strength for Google Engineers" HA, we see what you did there. :b

    • @deepak3303
      @deepak3303 4 роки тому

      There are lije 7 or 8 out there

    • @badboygoodgirl
      @badboygoodgirl 4 роки тому

      I almost didn't catch that

    • @johncerpa3782
      @johncerpa3782 4 роки тому +1

      LMFAO

    • @lairely
      @lairely 4 роки тому +2

      The best part is the guy on the right smirked and then rolled his eyes after 2 seconds at this lame joke

  • @peripona
    @peripona 4 роки тому +25

    Love the disclaimer about the weakRef :D 😁

    • @bestformspielt
      @bestformspielt 4 роки тому +3

      It is the one moment when Leszek breaks out of his scripted presentation mode and is fighting the urge to laugh. :D

    • @RingxWorld
      @RingxWorld 4 роки тому +2

      i thought i was listening to side effects on a medicine advertisement with that one

    • @pruthvishetty5656
      @pruthvishetty5656 4 роки тому +1

      I literally had to check if my playback speed moved up or something

    • @Zellie1994
      @Zellie1994 4 роки тому

      Sounds like he was reading the terms and conditions.

  • @MrRushifyIt
    @MrRushifyIt 4 роки тому +24

    My code is going to look hella confused now...

  • @amithbhagat
    @amithbhagat 4 роки тому +2

    Thanks, for a practical example on memory leak and also optional chaining, nullish-coalescing operators.

  • @semproser19
    @semproser19 4 роки тому +1

    In Angular templating there was what everyone called the Elvis operator, but was actually the "Safe navigation operator", which you guys are now called Operational Chaining. I really missed this feature having moved to React.

  • @dvikauglaumishrauca
    @dvikauglaumishrauca 4 роки тому +2

    Thank you for all the optimizations and hard work.

  • @justdoityourself7134
    @justdoityourself7134 4 роки тому

    Glad to see memory segmentation ( Pointer Compression ) making it into the V8 engine. This is one of my goto methods for speeding up critical code sections too as it promotes better CPU cache utilization as well as memory usage.

  • @enijar
    @enijar 4 роки тому +5

    I like the WeakRef feature, but it would be so much nicer if classes has a "deconstruct" method, so when calling "delete classInstance" it would automatically call the "deconstruct" method.

    • @download333
      @download333 4 роки тому

      Yeah, a dispose or deconstruct method seems like it might still be needed. In their example, the WeakRef can protect heavy stuff, but there's still a memory leak in that `wrapper` won't get cleaned up. The wrapper functions will keep piling up in memory. It'll take longer for the heap to get big, but it'll still get there.
      EDIT: Nvm, watched the rest of the video

    • @robertluong3024
      @robertluong3024 4 роки тому

      I think given what classes actually are in JavaScript, it'd be an odd implementation to the spec.

  • @DwiAjiKurniawan
    @DwiAjiKurniawan 4 роки тому +17

    It seems .dispose() method is far simpler than WeakRef

    • @asendiamayco
      @asendiamayco 4 роки тому +4

      Methods like .dispose() & .close() often cause production issue since we, humans usually forget to call them at the right time, Golang even creates defer statement to help solving this issue.

    • @DwiAjiKurniawan
      @DwiAjiKurniawan 4 роки тому

      @@asendiamayco I think that point should be introduced briefly in the video

    • @hope_s
      @hope_s 4 роки тому +1

      @@DwiAjiKurniawan It is. 10:35

  • @johnyepthomi892
    @johnyepthomi892 4 роки тому

    These two are hilarious and engaging with simplicity (and complexity lurking) . Really loving the improvements in performance and the fact that you don't give up and become complacent. You keep improving.

  • @justdoityourself7134
    @justdoityourself7134 4 роки тому +3

    You can never escape from Memory Management. It will always haunt programmers.

  • @ankurshah32
    @ankurshah32 4 роки тому

    I am creating a web app which analyse the data in client browser and draws the different types charts according to user selection. Now question is that whenever i am having millions of records to analyse the data and renders the whole dashboard(i.e. charts) which is have functionality of filters as well. Will it be feasible to do that?

  • @apphacker
    @apphacker 4 роки тому +11

    This was a really good video, I learned much, thank you. I'm not excited to use weak references, it sounds like a nightmare. :

  • @notthere83
    @notthere83 4 роки тому

    Great call on not making parsing block the main thread. I guess soon I don't have to use web workers to load huge libraries any more. At least I think that's what I did to solve this problem - it's been a while.

  • @Torxed
    @Torxed 4 роки тому

    Why isn't WeakRef() a variable scope/type instead? like `weak = new FinalizationRegistry()` or something similar. Would make the syntax look way better and since the behavior of the return value from WeakRef() is a loosely tied variable, shouldn't it be a variable definition rather?

  • @kailiu1863
    @kailiu1863 3 роки тому

    great video, learned a lot

  • @irapk79
    @irapk79 4 роки тому +1

    0:10 how to make such drawing?

    • @1e1001
      @1e1001 4 роки тому

      Yah draw

  • @rishavbhowmik7778
    @rishavbhowmik7778 4 роки тому

    Ok I need some help Regarding Garbage collection of event listeners with NodeJS, else this will bug me for my life
    In Socket.io
    when my users connect to my server this is triggered
    io.on('connection', (socket)=>{
    //user is connected
    var memory = "allocating a..... long ....... string"
    })
    Now when the user disconnects what will happen to {memory} ?
    Will, it deallocated or stay forever.
    If it stays alive forever, does that mean socket.io a broken framework?

    • @LeszekSwirski
      @LeszekSwirski 4 роки тому +1

      In this exact case, as given here, you'll have exactly one instance of "memory" shared between all connections/users. This is possible because it's the same string for all connections, and strings are immutable. So you won't make copies on each connection (and therefore won't have any copies to destroy in each disconnection), but as long as that connection event is attached to the socket, you'll always have that one copy of the string.
      If this string was dynamic and not shareable, then the answer would depend on whether anything else keeps it alive after the connection event is triggered. In this example nothing does, so it would be collectable, but in a more complex example it might not.

  • @k5v296
    @k5v296 4 роки тому +1

    If optional chaining done by itself in inbuilt makes code more readable I guess

  • @Theraot
    @Theraot 4 роки тому

    17:46 pre-allocate… Sounds like we will need those exabytes after all.

  • @reyronald
    @reyronald 4 роки тому +1

    Amazing! This was fascinating and very fun to watch. Keep content like this coming

  • @samuelgrahame3617
    @samuelgrahame3617 4 роки тому +3

    Instead of declaring a stop function just have a dispose function.

  • @sculpt0r
    @sculpt0r 4 роки тому +7

    There is lot's quite same concepts as C# have... good :)

  • @tim.e.l
    @tim.e.l 4 роки тому +1

    Weakref looks way more confusing and complicated and more code than just removing the event listener when you null out the instance. If you have a lot of listeners why not write a deconstruct method that nulls out the instance you pass in and also all event listeners its tracking in an array in that instance.
    I am pretty slow when it comes to this stuff and all this new syntax so I probably just have no idea what Im missing lol.

    • @LeszekSwirski
      @LeszekSwirski 4 роки тому +1

      In this simple example you're right, the dispose is probable less confusing and good enough. When things get more complex though, e.g. multiple owners of the disposable class, or the possibility of the _owner_ of the disposing class getting collected before calling something like "stop", is when this starts becoming really cool. This example, jokes about chat apps aside, is a very simplified version of a real memory leak we found.

    • @tim.e.l
      @tim.e.l 4 роки тому +1

      @@LeszekSwirski I appreciate the insight. Thank you very much!

  • @mustafwm
    @mustafwm 4 роки тому

    Thanks for the very informative cast.
    What does deref() stand for? de-reference?

  • @evvveeeeeeee
    @evvveeeeeeee 4 роки тому +1

    Thank god for optional chaining. I’ve been using object unwrapping to do this but it’s too verbose and painful to implement

  • @trappedcat3615
    @trappedcat3615 4 роки тому +5

    Plot Twist. These are Python Devs.

  • @tekno679
    @tekno679 4 роки тому

    love the null-safe kotlin feature!

    • @will1am
      @will1am 4 роки тому

      You mean c# :D.was introduced waaay sooner than kotlin did :)

  • @giorgichkhvirkia244
    @giorgichkhvirkia244 4 роки тому +3

    Great talk. Thank you guys. It would be useful to add time codes to video as well.

    • @johnfridja
      @johnfridja 4 роки тому

      time codes?

    • @johnfridja
      @johnfridja 4 роки тому +2

      also how is your comment a week ago?? the video just got released! :O

    • @zamfofex
      @zamfofex 4 роки тому +1

      Creators can add timestamps to the video description, and they’ll show up on the video timeline as “sections”.

    • @giorgichkhvirkia244
      @giorgichkhvirkia244 4 роки тому

      @@johnfridja Haha yeah thats strange :D

  • @vsDizzy
    @vsDizzy 4 роки тому

    What if GC collects an event listener before it fire? Then we will facing randomly swallowed events. Now imagine someone debugging this... I think you should provide better use case for a WeakRef.

    • @LeszekSwirski
      @LeszekSwirski 4 роки тому

      The socket, or whatever your attaching the event listener to, will hold the event listener strongly, so it won't be collected before firing unless it's detached before firing.

    • @vsDizzy
      @vsDizzy 4 роки тому

      @@LeszekSwirski No, we're adding weak reference to the socket message event. So it could be collected at any time. See their very misleading article v8.dev/features/weak-references

    • @LeszekSwirski
      @LeszekSwirski 4 роки тому

      @@vsDizzy "They" is me, I'm one of the authors of the article. The whole point is to be able to collect listeners when that listener stops existing, but that listener is held strongly by the only thing that cares about the events (in the article, by MovingAvg). Hence swallowing events is actually desired. The strong reference I was referring to was the strong reference to the wrapper listener, and that one is indeed strong and has to be explicitly disconnected (by the finalizer).

    • @vsDizzy
      @vsDizzy 4 роки тому

      @@LeszekSwirski, nice to meet you. Well actually it makes sense after looking at "reachability diagrams" provided in the article.

  • @vasoelias
    @vasoelias 4 роки тому +2

    Good content and funny characters :)

  • @tejasn3835
    @tejasn3835 4 роки тому +1

    1:56 isn't that just typescript

    • @deepak3303
      @deepak3303 4 роки тому

      Typescript doesnt live in run time

    • @gamechannel1271
      @gamechannel1271 4 роки тому +1

      It only exists in Typescript because it was an upcoming Javascript spec. Typescript doesn't just add new features (unrelated to typing) willy nilly.

  • @jaiveer9012
    @jaiveer9012 4 роки тому

    Nice video 👌👌👌👌👌👌

  • @renwar
    @renwar 4 роки тому +1

    Advanced level of experience

  • @BenWeigt
    @BenWeigt 4 роки тому +4

    Every day we stray further from legibility.

  • @kaizoey
    @kaizoey 4 роки тому

    Already in ts

  • @lucasfelipe-ze5sy
    @lucasfelipe-ze5sy 4 роки тому

    Nice

  • @MikesGlitch
    @MikesGlitch 4 роки тому +5

    It almost looks like c#

  • @wepranaga
    @wepranaga 4 роки тому

    great

  • @VladimirMinkin
    @VladimirMinkin 4 роки тому

    Oh, why Google can give their staff good microphones? Interesting info, but sound is so bad.

    • @1e1001
      @1e1001 4 роки тому +1

      You can still understand what they're saying, and also having a expensive mic won't help if the area you're recording in has poor acoustics.

  • @pineschan9787
    @pineschan9787 4 роки тому

    useful

  • @samuelgrahame3617
    @samuelgrahame3617 4 роки тому

    Is it me or is JavaScript is turning to csharp

    • @Nurutomo
      @Nurutomo 4 роки тому

      I think its Ruby

  • @isvladxxe
    @isvladxxe 4 роки тому

    WeakRef is cool ! ))

  • @elontang2358
    @elontang2358 4 роки тому

    WeakRef and FinalizationRegistry makes javascript to c++. :(

  • @MrChaosi
    @MrChaosi 4 роки тому

    its 2020 why does this insanely convoluted language still exist?

  • @patel324
    @patel324 4 роки тому +2

    Copied from C#

  • @oursbrun4243
    @oursbrun4243 4 роки тому

    I am telling you guys... Typescript is the new JS...

    • @arkanciscan
      @arkanciscan 4 роки тому

      Typescript is the new Coffeescript

    • @oursbrun4243
      @oursbrun4243 4 роки тому

      @@arkanciscan Well, the idea wanted to express is the shipping of some of typescript functionnalities into JS, and the fact this could end with typescript replacing JS in the future. But I shouldn't assert those things since I have never read any V8/JS specifications and features proposal and those languages are probably growing together (although TS is faster).

  • @ManuelBTC21
    @ManuelBTC21 4 роки тому

    Optional chaining, welcome to CoffeeScript anno 2010. Only took a decade.

    • @ilin76bb
      @ilin76bb 4 роки тому

      anoo 1610 i think was the game called . sorry didnt played since long time

    • @ManuelBTC21
      @ManuelBTC21 4 роки тому +1

      @@ilin76bb Anno 1602. Their game numbering always has the digits sum up to 9 btw: 1701, 1503, 1800, 2070

  • @ankitrathore3946
    @ankitrathore3946 4 роки тому

    Steal optional chaining from kotlin..