React Hooks vs Svelte

  Рет қаралды 8,563

Coding with Jesse

Coding with Jesse

Күн бұрын

Пікірлер: 57
@CodingwithJesse
@CodingwithJesse 3 жыл бұрын
If you enjoyed this video, check out my video course The Joy of Svelte at www.joyofsvelte.com/
@IfyDon
@IfyDon 5 жыл бұрын
Svelte is pure developer joy
@CodingwithJesse
@CodingwithJesse 5 жыл бұрын
Well said!
@kaidoesthingsxyz
@kaidoesthingsxyz 3 жыл бұрын
Svelte was the first framework I used and I love it
@ChumX100
@ChumX100 3 жыл бұрын
Since Svelte is a compiler, it's syntax can be pretty much whatever devs prefer and at the same time, the browser receives the code that it likes. No compromises: Happy devs, happy browsers. Genius!
@CodingwithJesse
@CodingwithJesse 3 жыл бұрын
Well said, Duke!
@Anonymous42282
@Anonymous42282 4 жыл бұрын
Nice! You could have removed the outer divs which was necessary for React but not for Svelte - saves 2 more lines.
@paul_devos
@paul_devos 3 жыл бұрын
Great comparison/example. Coming from Python. e.g. we hate boilerplate, this was awesome.
@tim_t
@tim_t 4 жыл бұрын
You can remove the div tags! 😆 It took me too long to realize that I don't have to nest a file's elements in a single parent div.
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
Great point! I could've made it even simpler! :)
@jonty3551
@jonty3551 3 жыл бұрын
Wow... thats great....
@danielpiedraquintero
@danielpiedraquintero 5 жыл бұрын
simplicity and elegance... thats why I love svelte! I have been trying to learn vue/nuxt and I have to say it feels messy and like I need to write twice as much code as in svelte. for some reason I do not feel as comfortable as when writing some svelte component.
@anarcus
@anarcus 4 жыл бұрын
What the... I've looking into Svelte for like 2 days and i already love it xD I used React, but i hated all that unnecessary stuff that it has I also tried Vue, but for some reason i still didn't like it's syntax I know that Svelte's syntax is close to Vue but still, i feel a lot more comfortable with Svelte! I already know what my next project is gonna be written on :D
@stephaniemay9090
@stephaniemay9090 3 жыл бұрын
is there something in react that svelte cannot do? (literal question, because i just learned how to code javascript and im looking into svelte!)
@CodingwithJesse
@CodingwithJesse 3 жыл бұрын
I don't think so! React is JavaScript, whereas Svelte is really a new programming language that includes and builds on JavaScript, so anything React can do, Svelte can do better 😉
@maskman4821
@maskman4821 4 жыл бұрын
what an awesome comparison !!! svelte without a doubt beats react, no question at all !!!
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
Thanks! I think so too :D
@ajdegol
@ajdegol 4 жыл бұрын
Hooks certainly made things better in React, but all my new projects are Svelte these days. There are teething issues for sure, but then you always forget the pains you went through to learn your current tools.
@ThatGuyAnonymous
@ThatGuyAnonymous 4 жыл бұрын
Svelte is what every framework should aspire to be, I love react but if doing common things like form, for example, requires heavy wiring with third-party libraries than there is something fundamentally lacking form the framework. there is too much plumbing and hacking to get anything done.
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
I agree. I hope Svelte inspires a new generation of amazing programming languages and tools.
@IamSH1VA
@IamSH1VA 2 жыл бұрын
Svelte is much simpler & very very performant 👏🏻💪🔥
@roblesrt
@roblesrt 4 жыл бұрын
Awesome, simple and easy to understand example! Keep it up sir!
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
Thank you so much!
@NoahNobody
@NoahNobody 4 жыл бұрын
Any plans to do more comparison videos like this? Like useEffect, useRef etc...
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
I hadn't planned that but that's a great idea! I'm working on my Svelte course ( joyofsvelte.com ) right now, but I'll think about making more React-vs-Svelte videos once it goes live.
@Ricardoromero4444
@Ricardoromero4444 3 жыл бұрын
How about custom hooks? In react I could declare a function that returns [counter, increase, halve, double] and I'd have a reactive variable and functions to mutate it. I haven't found out how to do something similar in svelte. Tl;dr: how do you share logic across components in svelte?
@CodingwithJesse
@CodingwithJesse 3 жыл бұрын
Good question! You can use custom stores to share reactive state across components. svelte.dev/docs#svelte_store
@yt-sh
@yt-sh 5 жыл бұрын
So will we see more Svelte projects from you?
@CodingwithJesse
@CodingwithJesse 5 жыл бұрын
Absolutely! Subscribe to my newsletter for updates: tinyletter.com/jesseskinner
@josbexerr5166
@josbexerr5166 4 жыл бұрын
Excelente, el compilador svelte mi sorprendio graicas
@pablowbk
@pablowbk 4 жыл бұрын
Very good explanation, thanks
@vexkiddy
@vexkiddy 4 жыл бұрын
Love Svelte!
@torb-no
@torb-no 4 жыл бұрын
I take bit issue with your claim of simplicity. The surface level simplicity is there for sure, but in reality Svelte compiles what you write into more complex JavaScript. With React it's still just running the very code you wrote. This can potentially be relevant if you need to very precisely understand what's going on in your code. The tradeoff might be worth it of course! It's just a complication I think ought to be recognised. Additionally: I don't think this video fairly compares React Hooks as one of the big advantages of hooks is how you can easily refactor and compose functionality in a reliable way. Does Svelte also have functionality that let's you do that? I'm not being rhetorical here, I'm genuinely wondering, cause the comparability of react hooks is brilliant and I'd love to see equivalent functionality in other places.
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
Thanks for the comment. The code Svelte compiles to is actually quite simple and readable, you can see it in the right pane of the REPL, if you're curious. I'd argue that the React library itself is more cryptic and unreadable and stands in the way of understanding precisely what is happening, particularly when it comes to the magic of hooks. As for the ability to refactor, Svelte's reactivity does need to happen within Svelte itself, but if you want to refactor some of that reactive code out of Svelte into plain JavaScript, you can use a Svelte store to achieve this. svelte.dev/docs#svelte_store
@pushpithageeganage7992
@pushpithageeganage7992 4 жыл бұрын
A cool guy right there !!
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
You're too sweet :)
@johannes.schaffer
@johannes.schaffer 4 жыл бұрын
Imba makes reactivity even shorter
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
Oh cool, I hadn't heard of Imba before, thanks. I wonder what the click button example would look like in Imba...
@johannes.schaffer
@johannes.schaffer 4 жыл бұрын
This example wouldn't be much of a different in Imba. You really cannot make this any shorter. But if it comes to things like changing values (in Svelte you have to reassign them), or recomputing values (in Svelte you have a special, though very short, syntax), imba shines. You can do things like array.push, and imba does the rest. In Svelte you would have to use the more verbose spread syntax for that.
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
@@johannes.schaffer Ah nice, I'll have to check it out sometime.
@johannes.schaffer
@johannes.schaffer 4 жыл бұрын
If you have a "framework" like React or Svelte, wether it uses a VDOM or the real DOM, they both have to know what exactly changed in the code, to update the specific Node in the DOM. Therefore they have a more verbose syntax. Imba on the other hand rebuilds the entire DOM each time and is still WAY faster than Svelte or React (On there website they say 20x faster than React). Imbas approach is called memoized DOM
@fibonacciinvestments2091
@fibonacciinvestments2091 4 жыл бұрын
Facebook employees thumbed down this video.
@und0
@und0 4 жыл бұрын
Cool video! You've demonstrated how svelte indeed is simpler especially for beginners! With that said I have to disagree with you a bit, I wouldn't consider importing React, function statement and return statement as "boilerplate" I can buy the useHook as boilerplate however. I have a lot of optimism about svelte I love the concept and how it's a truly reactive framework instead of a virtual DOM run time based framework. What I think svelte gets wrong is the mutability, the reason you need a bit of boilerplate for react is because you aren't directly mutating anything, you're calling pure functions instead of assigning. This is why in simple contexts svelte appears to be much simpler than React but in more complex scenarios mutability with the "let" initialize tends to lead to poorer quality code. Where svelte gets it right is the performance, compiling before instead of running at runtime is a huge performance advantage. Unfortunately in many scenarios this is not a huge factor. I've been playing around with svelte a bit and I must say I like it a lot but React is still superior in my opinion. I know Svelte is young and I can't wait to see awesome new libraries extending svelte come out. I'm thinking about making a couple myself :)
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
Thanks! I disagree about mutability leading to poorer quality code, though. I think it leads to a lot simpler code. But if you're into FP, there are lots of other options out there.
@m3rl1on
@m3rl1on 5 жыл бұрын
yep this is why i love svelte. unfortunately, i can't get a job only by learning Svelte though, because most of them still uses the big three.
@danielpiedraquintero
@danielpiedraquintero 5 жыл бұрын
Jessen's Channel do you keep an eye on twitter.com/sveltejobs ?
@CodingwithJesse
@CodingwithJesse 5 жыл бұрын
That's true, to a point. But a few years ago none of them were using the big three, because the big three didn't exist yet. I mean, it's hard to know what'll get you a good job next year.
@maorben3313
@maorben3313 4 жыл бұрын
The simplicity goes away with the compiler. It is no longer javascript... It gives strengths but cancels others. And React is javascript (+jsx) so i dont know how i feel about calling “function” and “return” a boilerplate
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
That's true, it's better than JavaScript :) And fair enough, "boilerplate" might be overstating it, but it is extra code that isn't needed anymore.
@maorben3313
@maorben3313 4 жыл бұрын
@@CodingwithJesse I personally think that Angular and Vue did wrong with making their own templating language. That’s why JSX is so powerful it is not javascript but it’s kinda is(??) I don’t like learning new syntax that is unique to a single framework. My brain cells are occupied enough 😎😎
@rishabghosh595
@rishabghosh595 4 жыл бұрын
now you have a global variable.. congratulations..
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
It's not global, it's scoped to the instance of that component, just like state in a React component.
@Chana999
@Chana999 4 жыл бұрын
When you say something and you don't know what you are talking about ...
@jsonkody
@jsonkody 4 жыл бұрын
you obviously don't know what you are talking about :-/ Svelte is amazing. And as I know it follows the best practices by default (if you explicitly doesn't tell otherwise) .. like component scoped variables or css
@aghileslounis
@aghileslounis 4 жыл бұрын
it is bad practice to manipulate data like this, and in real world project we need something to manage state in a very strict way. Also i'm sorry but Svelte is not Elegant to write, so much tags and new syntax, not intuitive i guess, the thing i hate the post is when i need to write logic inside html AND in a new way {#if } common Beside that the way you teach is very interesting, clear and efficient
@CodingwithJesse
@CodingwithJesse 4 жыл бұрын
Thanks! I disagree about this being a "bad practice" though. Reminds me of the talk that introduced React to the world, Pete Hunt's "Rethinking Best Practices". Besides, if you want strict state management, you can use a custom Svelte store. Of course, if you don't like the syntax, there are lots of other tools out there. It's always best to choose the tools that you enjoy using most.
@aghileslounis
@aghileslounis 4 жыл бұрын
@@CodingwithJesse thank's for taking this as good comment, beside what i said, i really like the idea of svelte i think it is the future and the next step after virtual DOM.
React VS Svelte...10 Examples
8:35
Beyond Fireship
Рет қаралды 591 М.
Understanding Effects In Svelte 5 And When To Use Them
27:31
Joy of Code
Рет қаралды 9 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН
1% vs 100% #beatbox #tiktok
01:10
BeatboxJCOP
Рет қаралды 67 МЛН
Scott Tolinski - From React to Svelte
32:25
Svelte Society
Рет қаралды 13 М.
SAPPER SVELTE STARTERS GUIDE IN 2020
15:37
Program With Erik
Рет қаралды 12 М.
Svelte Society Day 2020: Rich Harris: Frequently Asked Questions
29:36
Protect SvelteKit Routes with Hooks
21:10
Huntabyte
Рет қаралды 60 М.
Basic React To Svelte Conversion - Weekly Svelte
8:06
Syntax
Рет қаралды 3,9 М.
Custom Hooks in React (Design Patterns)
12:56
Cosden Solutions
Рет қаралды 55 М.
Svelte Tutorial - Is it better than React?
54:53
freeCodeCamp.org
Рет қаралды 52 М.
Build Once, Use Anywhere: Microfrontends with Svelte
24:35
Evan Payne
Рет қаралды 21 М.
Rich Harris - Rethinking reactivity
36:45
You Gotta Love Frontend
Рет қаралды 322 М.
She made herself an ear of corn from his marmalade candies🌽🌽🌽
00:38
Valja & Maxim Family
Рет қаралды 18 МЛН