Svelte 5 Runes - How to talk to the compiler ft Rich Harris

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ธ.ค. 2024

ความคิดเห็น • 43

  • @nyashachiroro2531
    @nyashachiroro2531 4 หลายเดือนก่อน +80

    The fact that the code produced by the Svelte compiler is actually somewhat readable and understandable is impressive, especially compared to what's produced when other libraries are transpiled.

    • @rbnzdave
      @rbnzdave 4 หลายเดือนก่อน

      actually react maps work really well if you dont use .jsx as an extension. if you use .js, chrome at least shows the original code nicely, have found it hates me when i leave as jsx before transpiling.

    • @ndykhng
      @ndykhng 4 หลายเดือนก่อน +3

      ​@@rbnzdave OP's point is the transpiled code looks nice (the resulting .js), not just the code that you write (.jsx)

    • @avwie132
      @avwie132 4 หลายเดือนก่อน +1

      Why would I care how the compiled code looks?

    • @Hugos68
      @Hugos68 4 หลายเดือนก่อน +3

      @@avwie132 The compiled code reflects the simplicity of svelte 5. The compiler merely adds boilerplate, not as much magic as svelte 4. Which is great for debugging.

    • @dand4485
      @dand4485 4 หลายเดือนก่อน +3

      @@avwie132 Asking why the transpiled code matters, guess you've never had to debug anything?

  • @DavidHust
    @DavidHust 4 หลายเดือนก่อน +16

    Rich is a beast. He's been doing these same interviews for about a year, and he's still excited to show it off.

  • @b1mind
    @b1mind 4 หลายเดือนก่อน +15

    Really enjoyed this deep dive into the compiler. Excited about Svelte5!!

  • @everythingisfine9988
    @everythingisfine9988 4 หลายเดือนก่อน +10

    Upgrading Svelte 4 👉 5 and everything still works. That's such a *BIG* win for svelte. The only major technical advantage React had was seamless upgrades and Svelte just achieved that 🏆

  • @Ripstikerpro
    @Ripstikerpro 4 หลายเดือนก่อน +3

    The ability to use classes as stores is such a nice improvement, I love it

  • @WebJeda
    @WebJeda 4 หลายเดือนก่อน +7

    Svelte is the only framework that sparked joy for me ✨

  • @TrostCodes
    @TrostCodes 4 หลายเดือนก่อน +21

    Svelte Summer is just so so good!

  • @adriablancafort
    @adriablancafort 4 หลายเดือนก่อน +6

    I love svelte 5! Can't wait

  • @ymi_yugy3133
    @ymi_yugy3133 4 หลายเดือนก่อน +1

    The svelte repl is amazing. It's my go to place whenever I need to try some web related thing

  • @registro_pedagogico
    @registro_pedagogico 4 หลายเดือนก่อน +1

    Svelte es mi framework favorito, estoy ansioso de que salga la versión estable

  • @justadevlog1667
    @justadevlog1667 4 หลายเดือนก่อน +5

    Ok i lost my mind for second when i saw bind: in action Holly that's insane

  • @robotempire
    @robotempire 2 หลายเดือนก่อน

    @16:32 I suppose $.source is a "source" of reactive signals, while $.proxy is proxying the array primitive which contains sources? So the thing produced by $.proxy is like a signal controller, maybe? I reckon any iterable object would be compiled down to a proxy or something like this? interesting conversation all around regardless

    • @robotempire
      @robotempire 2 หลายเดือนก่อน

      @20:34 seems like maybe i wasn't too far off wrt proxies being controllers in some sense

  • @m_raez
    @m_raez 4 หลายเดือนก่อน +1

    Since Runes are still Runtime-Reactivity, you can easily build an API to your liking using them as primitives

  • @dei8bit
    @dei8bit 4 หลายเดือนก่อน +2

    Que hermosura svelte ♥

  • @DamonMedekMusic
    @DamonMedekMusic 4 หลายเดือนก่อน +2

    Wow, what a rockstar.

  • @DomskiPlays
    @DomskiPlays 4 หลายเดือนก่อน +3

    Yoooooo lets go. I love Svelte 5 the only thing I hate is how destructuring loses reactivity which was super confusing at first

    • @Antonio-fo4fl
      @Antonio-fo4fl 4 หลายเดือนก่อน

      You can use the $derived rune to preserve reactivity of destructured values. Ofc read only though

    • @TheStickofWar
      @TheStickofWar 4 หลายเดือนก่อน +1

      ​@@Antonio-fo4fl it would be strange and cause extreme problems if derived values in any framework could affect what they were derived from. Think of them as pure functions only

    • @Antonio-fo4fl
      @Antonio-fo4fl 4 หลายเดือนก่อน

      @@TheStickofWar did you not see where I said the derived destructured values ofc would be read only?

    • @DomskiPlays
      @DomskiPlays 4 หลายเดือนก่อน

      @@Antonio-fo4fl I know but often I want to destructure a stateful prop and bind to it and the only way to do it is with xyz.item :/

    • @maloxi1472
      @maloxi1472 2 หลายเดือนก่อน

      He was simply pointing out why that had to be the case

  • @everythingisfine9988
    @everythingisfine9988 3 หลายเดือนก่อน

    I use jsDocs + default function parameters (when possible) & raw-dog everything else ✌️

  • @DannniScript
    @DannniScript 4 หลายเดือนก่อน

    hipe! 🧡

  • @Lemmy4555
    @Lemmy4555 4 หลายเดือนก่อน +4

    You don't have to use a class, you can also just write a function that returns an object where the fields are the fields of the class, and you can also expose methods that can use this.foo to access the fields of the object itself, for simple use cases it's less verbose than classes

    • @mixed_nuts
      @mixed_nuts 4 หลายเดือนก่อน

      There's a reason he uses a class. Mainly for performance.

    • @abdel17
      @abdel17 4 หลายเดือนก่อน +4

      classes in Svelte are less verbose actually
      class Todo {
      text = $state("");
      done = $state(false);
      constructor(initial) {
      this.text = initial;
      }
      }
      function createTodo(initial) {
      let text = $state(initial);
      let done = $state(false);
      return {
      get text() { return text },
      set text(v) { text = v },
      get done() { return done },
      set done(v) { done = v },
      };
      }

    • @Lemmy4555
      @Lemmy4555 4 หลายเดือนก่อน

      @@abdel17 mmmh i see, yeah i assumed that classes and objects worked the same because they do in regular js, but here svelte is doing something special for classes, weird in my opinion. However you can always return the plain object and wrapt in in $state later but then:
      function createTest(initial) {
      return {
      text: initial,
      setText(v) {
      this.text = v
      }
      };
      }
      let todo = $state(createTest('hello'))
      {todo.text}
      todo.setText('ola')}>
      clicks

    • @Sammi84
      @Sammi84 4 หลายเดือนก่อน +1

      ​​@@Lemmy4555that looks redundant and actually does less than when you just pass an object directly to &state, because it doesn't do proxying.

    • @Lemmy4555
      @Lemmy4555 4 หลายเดือนก่อน +1

      it does proxy, i checked, looks like svelte 5 wraps into proxies everything that is not a primitive value, so function calls are wrapped into proxies.
      eg:
      function createTest(initial) {
      return ''
      }
      let todo = $state(createTest('test'))
      //becomes
      function createTest(initial) {
      return '';
      }
      let todo = $.source($.proxy(createTest('test')));

  • @figloalds
    @figloalds 4 หลายเดือนก่อน

    11:44 yo what's this undocumented sorcery he just did there? Wow 👏
    I love to have learned this

    • @Hugos68
      @Hugos68 4 หลายเดือนก่อน +1

      Anything inside markup between {} is an expression, so any type of js, console.log included. And since that {} block depends on a reactive variable it will rerun. You should use $inspect for this though.

  • @Animadroids
    @Animadroids 4 หลายเดือนก่อน

    Runes Bloody Runes