malloryerik

malloryerik

Svelte - what do you think about it?

Any thoughts on Svelte?

Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do the bulk of their work in the browser , Svelte shifts that work into a compile step that happens when you build your app.

Instead of using techniques like virtual DOM diffing, Svelte writes code that surgically updates the DOM when the state of your app changes.

Most Liked

dorgan

dorgan

I’ve used it, both svelte and sapper.
My opinions:


The good:
It’s reactivity works well, you get used to the special syntax bits very quickly, so don’t be afraid of it.

Overall it’s quite fast, both for those synthetic benchmarks(look at how I render a million dom nodes with my library instead of using canvas!) and for real use cases.

It comes with a state management solution(stores), animations and transitions out of the box.

Sapper makes sense, and is a fast and quite batteries included solution for both SPA and SSR. You can get an decent SPA with SSR website up and running in a couple minutes. Handling cookies can be a bit confusing at first, though.

It’s relatively easy to integrate with other js libraries, I wrote some bindings for prosemirror while learning it and it worked quite fine.


The bad:
It’s output doesn’t work in legacy edge nor older browsers(try to see any NYT article featuring Rich Harris visualisations on an older browser, it just doesn’t load).

There’s no way to access child nodes. If you want to wrap individual childs(say, receive a list of components and wrap each of them in some other component, like you would do with special list items), you can’t.
For example, I created a ListStream component that imitates discourse’s cloaking behaviour(unmount out of screen dom nodes), and I had to pass the list items as a prop for the ListStream to wrap them, which is a horrible workaround in my opinion.
There was a discussion about that in the svelte’s discord when this article was published and there was no solution. Responses from contributors were too defensive from my pov(part of that was valid: the medium article wasn’t particularly good, but it had valid criticism on svelte’s lack of reflection) and ranged from “yes you can” or “why would you do that”, but no examples of how is it possible was given, and it was proven to be impossible.

That discussion and Rich’s responses in his Why I don’t use web components article, where people addressed his criticisms and he replied with snarky comments or refused to continue the discussion left me with a bitter taste. I would like to see more transparency and discussions about svelte’s weak points too, so they can be addressed properly.

Typescript support was bad a couple months ago, though it is supposed to improve sometime in the future.


Overall it’s very good, and it’s worth trying out.

I’m not currently using it though, since I want to render as much html as possible with Elixir Phoenix and custom elements are more suitable for that usecase.

fzngagan

fzngagan

We’re at an opposite end of the spectrum working with Ember.js. Kinda maximalists :wink:

dimitarvp

dimitarvp

Sadly never worked with it – just heard a lot of good feedback from JS devs.

It’s kind of like Rust for JS, meaning that it compiles to “native” JS without you having to carry the framework with you. Which I quite like.

Popular Frontend topics Top

PragmaticBookshelf
You work in a loop: write code, get feedback, iterate. The faster you get feedback, the faster you can learn and become a more effective ...
New
PragmaticBookshelf
JavaScript is no longer to be feared or loathed—the world’s most popular and ubiquitous language has evolved into a respectable language....
New
andresriveros
I’m very interested in the Stimulus reflex approach for frontend development: It is a great way to integrate action cable very easily ...
New
finner
Some resources for Spring Home of Spring Spring Initializr Head First Spring with Reactor
New
First poster: bot
Fable 3.1.2 has been released. Link: Release 3.1.2 · fable-compiler/Fable · GitHub
New
First poster: bot
Fable 3.1.16 has been released. Link: Release 3.1.16 · fable-compiler/Fable · GitHub
New
New
ClaudiaGiv
I have a sveltekit project that is using GoTrue library for authentication. In development mode (npm run dev) everything works but when I...
New
First poster: bot
Yew yew-v0.19.3, yew-router-v0.16.0 and yew-agent-v0.1.0 has been released. Link: Release yew-v0.19.3 · yewstack/yew · GitHub Link: R...
New
Reinis
For the last few months I’ve been (re)-learning vanilla CSS. Initially I did not ‘get’ how to structure CSS to take advantage of the ‘cas...
New

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
AstonJ
If it’s a mechanical keyboard, which switches do you have? Would you recommend it? Why? What will your next keyboard be? Pics always w...
New
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
Maartz
Hi folks, I don’t know if I saw this here but, here’s a new programming language, called Roc Reminds me a bit of Elm and thus Haskell. ...
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
NewsBot
A new PostgreSQL blog post/announcement has been posted! Get the full details here: https://www.postgresql.org/about/news/pg_auto_reind...
New