Live data from Hacker News

Svelte is a language

gist.github.com

41–50 of 95 posts

Re: Svelte is a language

#41
post #15

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…

Author means explicit after compiling.

Re: Svelte is a language

#42

Give 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?

There is nothing holding anyone back from using (expression ? val1 : val2) in svelte though. So, we're not missing anything that JSX/react has got. The {#if} thingy is just a bonus which is welcome in my opinion.

Re: Svelte is a language

#43
post #32

Earlier 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…

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

#44
post #30

Earlier 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

very interesting, i wonder what's your opinion on tools like htmx which work on the exact opposite basis

Re: Svelte is a language

#45
post #43

Earlier 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.

Because React is JS and Svelte isn't

Re: Svelte is a language

#46

Svelte 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 disagree. But I am someone who deals with frontend tech sporadically as opposed to spending all/most of my time working on UI.

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

#47
post #38

Earlier 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

Angular template syntax is correct HTML syntax. It's nothing like the examples abovd.

Re: Svelte is a language

#48
post #43

Earlier 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

React is JSX*

Nothing preventing them from making an …… component

Re: Svelte is a language

#49
post #15

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.

First we were excited for the virtual DOM which is good for batching updates, flexibility, efficiency, etc. But now the cool thing is to get rid of it?
Post reply on HN