Live data from Hacker News

Svelte is a language

gist.github.com

51–60 of 95 posts

Re: Svelte is a language

#52
post #38

Earlier quoted context omitted.

Reminds me of Angular

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

https://angular.io/guide/binding-overview

Haven't looked at angular since 2015 to be honest, but it still seems like they do weird html stuff to me, such as:

{{customer.name}} or Type something: {{customerInput.value}}

Re: Svelte is a language

#53
post #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 rea…

I've done a lot of contracting jobs and I get to see a lot of codebases and had the exact opposite experience, Whenever I see react or vue code, and in particular react, I feel like I have to relearn everything because the combination of external state libraries and to top it with translation specific code and libraries makes it such that each code base is very different from the other. It almost feels like you are learning a new framework altogether. The other issue is not directly related but because there are so many external dependencies, there is this constant slog work to keep everything updated due to constant vulnerabilities that keep popping in our CI tool.

Familiarity wise Angular has been probably the easiest to jump into and maintain long term, but it is a pain to work with due to the amount of ceremony involved to do even the simplest of things.

Svelte codebases due to the very nature of Svelte are simpler and very straightforward to get into, there are some svelte specific things but they aren't too many of them and are simpler to reason about when compared to codebases built on hooks, and even worse are hooks in combination with junior Devs. It is very very easy to write bad react code and you see this way way too often. Most react code out in the wild is badly written, you don't see problems because the browsers and modern computers are performant enough to hide them away but you do notice as the codebase grows and you realize it too late that the very foundation was wrong.

I don't mind Vue and just see svelte as a nicer DSL over it.

Re: Svelte is a language

#54

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?

you're equating it to string interpolation. It isn't. It's a compiler directive which disappears when compiled, which is why it is expressed as a brace expression rather than a tag.

Re: Svelte is a language

#55
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?

not everybody was excited about the virtual dom. people who looked closely at it weren't particularly excited.

Re: Svelte is a language

#56
post #51

Earlier quoted context omitted.

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

You're telling me on:click={toggle} is nothing like (click)="toggle()"?

it's not. `toggle` is a pointer to a function name and "toggle()" appears to be an expression which is parsed and then executed (scary).

you can on on:click={() => toggle()} in svelte which is more similar, but it isn't parsed and executed, it is a pointer to an anonymous function which is directly executed.

on:click={toggle()} in svelte would run the function immediately (probably not what you want) and return the result as the handler for the on:click

so quite different, really.

Re: Svelte is a language

#57
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…

> I don’t follow… in what sense is this JavaScript? >

it's not. it's html. incrementCount is a pointer to a javascript function.

> Or what about this… is this JavaScript? > $: doubled = count * 2;

Yes. $: is a javascript label. We use it to indicate that a function should be reactive - if the count variable changes, the right hand will be rerun and double updated.

> Click me

html again. the |once is a modifier to click which detaches the handler after a single use. It's a directive in the html markup (still valid html) which the compiler picks up and converts into node.removeEventHandler.

Re: Svelte is a language

#58
post #52

Earlier quoted context omitted.

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

https://angular.io/guide/binding-overview Haven't looked at angular since 2015 to be honest, but it still seems like they do weird html stuff to me, such as: {{customer.name}} or Type something: {{customerInput.value}}

I agree with you, it looks weird, but my point was that it's correct HTML syntax, even though you cannot expect it to work if you open an Angular template in a browser, but an HTML parser can tell you it's syntactically correct.

Re: Svelte is a language

#59
post #51

Earlier quoted context omitted.

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

You're telling me on:click={toggle} is nothing like (click)="toggle()"?

One is syntactically correct HTML, and the other is not. That's was the only point of my comment

Re: Svelte is a language

#60
Svelte Kit is great for static is "classic"-like websites.

I've converted my company website to svelte-kit from first Angular, then Vue.

But for SPA it's bad. If you use oidc auth. There's only Auth.JS and it's a confidential client, for Svelte Kit.

If you're not using svelte-kit you can use vite to create a Svelte SPA. There you can use your PCKE client as usual and burden the load on the client.

I have yet to experiment with how well it works with a graphql client. Apollo has its own cache but I'm not sure there is a svelte version of it. There is for Vue. Does it even need one? The default is for React. Is Apollo even needed? Questions over questions.

Why Svelte? Performance. Performance matters, a lot.

Svelte being a "language". First time using a template system? I have to wonder.

Post reply on HN