The really exciting thing about svelte is getting rid of the virtual Dom. Having everything just be explicit JavaScript code that modifies the Dom manually makes for really readable code. If you have not tried it, got to the svelte tutorial and look at the output code. It's awesome.
I don’t follow… in what sense is this JavaScript? Specifically, what is on:click? It doesn’t look like JavaScript, and it doesn’t look like the DOM. It looks like a new language which is specific to Svelte. Or what about this… is this JavaScript? $: doubled = count * 2; Or… {#if user.loggedIn} Log out {/if} Or… Click me I am willing to believe that all of that is ergonomic in some way, but it doesn’t appear to me at…
Svelte is a language
41–50 of 95 posts
Re: Svelte is a language
#42Give a quick glance to Svelte. Help me understand, how this syntax {#if expression}...{:else if expression}...{/if} can be seriously invented in our... more civilized age?
Re: Svelte is a language
#43Earlier quoted context omitted.
It’s not the most pretty syntax, but it’s wayyy better than React’s terrible (expression ? … : …) or (expression && …)
react didn't invent that syntax. This is a standard piece of C like syntax that most (but not all) languages with curly braces share. JSX/TSX used in react don't make this choice for you, you can use any javascript syntax which can be used when passing a value (eg in a function invocation, or variable declaration). If you don't like it, you are perfectly free to declare a variable and set its value using a regular if…
Re: Svelte is a language
#44Earlier quoted context omitted.
> Having everything just be explicit JavaScript code This is funny because it's exactly the reason I prefer react
Agreed, I want markup in my logic — not logic in my markup
Re: Svelte is a language
#45Earlier quoted context omitted.
react didn't invent that syntax. This is a standard piece of C like syntax that most (but not all) languages with curly braces share. JSX/TSX used in react don't make this choice for you, you can use any javascript syntax which can be used when passing a value (eg in a function invocation, or variable declaration). If you don't like it, you are perfectly free to declare a variable and set its value using a regular if…
I mean, yeah, the ternary operator is part of JS syntax. But it WAS React’s choice to not include any alternative way to if/else add an element (there is an if/else but only for the entire component, not just for conditionally adding one element within a component). So indirectly this is React’s syntax decision.
Re: Svelte is a language
#46Svelte is a major improvement on vuejs. It is a pleasure to work with. I can’t stand react / JSX. Highly recommend anyone who preferred vue over react to give svelte a try.
I was excited about svelte, but have found that coming back to my svelte project after a month or two of not using it was arduous because of all the myriad language level things. There are just too many little svelte specific things to keep track of in head.
In contrast coming back to a react/vue project is much easier for me, because even if I forget something at the end of the day any vue-directive or react hook is just another js/ts api I can easily lookup.
In particular, I find the DX that volar+vscode offer in a project with vue3, composition API & pug templates to be better than anything else I have seen in the FE ecosystem in last 5 years.
I also don't find the enhancements for local reactivity to be major value additions because most of the times my state resides in a shared store. I find the vue reactivity model to be simpler to deal with because I can create shared stores which can be (deep) mutated from any component and it all just works seamlessly.
Re: Svelte is a language
#47Earlier quoted context omitted.
I don’t follow… in what sense is this JavaScript? Specifically, what is on:click? It doesn’t look like JavaScript, and it doesn’t look like the DOM. It looks like a new language which is specific to Svelte. Or what about this… is this JavaScript? $: doubled = count * 2; Or… {#if user.loggedIn} Log out {/if} Or… Click me I am willing to believe that all of that is ergonomic in some way, but it doesn’t appear to me at…
Reminds me of Angular
Re: Svelte is a language
#48Earlier quoted context omitted.
I mean, yeah, the ternary operator is part of JS syntax. But it WAS React’s choice to not include any alternative way to if/else add an element (there is an if/else but only for the entire component, not just for conditionally adding one element within a component). So indirectly this is React’s syntax decision.
Because React is JS and Svelte isn't
Nothing preventing them from making an …… component
Re: Svelte is a language
#49The really exciting thing about svelte is getting rid of the virtual Dom. Having everything just be explicit JavaScript code that modifies the Dom manually makes for really readable code. If you have not tried it, got to the svelte tutorial and look at the output code. It's awesome.