Live data from Hacker News

Ask HN: What are your experiences with Svelte (JS framework)

news.ycombinator.com

81–90 of 105 posts

Re: Ask HN: What are your experiences with Svelte (JS framework)

#81
post #78

Earlier quoted context omitted.

You can do complicated things with Svelte stores, but in my experience most of the time you only need something like this using a writable store: import {writable} from 'svelte/store'; const person = writable({name: 'Mark', zip: 63304}); function handleChange(event) { const name = event.target.value; person.set({...$person, name}); } Hello, {$person.name} at {$person.zip}! Of course if person is only used inside this…

Right but this is still a lot of code for changing the name of a person. Also, this works with pojos and primitive values. What happens when you add class instances, relationships, children, etc? For example in a project I was working I had geometrical figures in my reactive data model. With classes I could simply do: rectangle.getArea() With MobX this was super simple to implement. If I wanted to change the position…

@pier25 You got me curious about this. I've never seen this done with Svelte, so I decided to try it. Check this out: https://github.com/mvolkmann/svelte-with-classes/blob/master....

The key is that when you update a Svelte store you must return a new value. It's enough to just return the value you updated. You see that happening here on lines 16 and 21.

I take your point that this is not as transparent as when using observables. But at least you can use classes that have relationships and call methods that modify the objects when those objects are in Svelte stores.

Re: Ask HN: What are your experiences with Svelte (JS framework)

#82
Not using in production but really willing to do so, because the concept is just beautiful. Writing components is a pleasure. Fresh view at animations, which I haven’t tried much, but it looks very promising and convenient (and ofc fast, - first of all). Very, very good tutorials!

However, there’s a couple of unwilling moments:

- A lot of boilerplate code in a newly generated project (very easy to get it outdated when new versions come)

- A popular one: still no good typescript support

And... I think that’s all? Pretty much all the rest is just beautiful.

I think these are two things which bind me from going all in, and use it everywhere, on every new project

Re: Ask HN: What are your experiences with Svelte (JS framework)

#83
post #47

Earlier quoted context omitted.

I haven’t done much React, but I’ve played around with svelte a bit recently and I haven’t found any severe issues with the props model. What don’t you like about it?

Since Svelte props are just variables it's pretty easy to do weird things. Also it's kind of a pain to need to open up a file and read through a dozen lines of code to figure out what the props are. The most important thing is it makes it difficult to build the same tooling that other frameworks have. For example, in React you can either define your props as a TypeScript/Flow interfaces or use the `prop-types` librar…

You could just use the undocumented but totally available $$props object.

Re: Ask HN: What are your experiences with Svelte (JS framework)

#84
I love it. I am working on a project using NW.js for a desktop application. I first did it in Vue, then moved to Mint, and now using Svelte. I had to move away from the other two due to limitations that I could not figure out how to get past. Also, moving to Svelte had the final build 1/3 of the size of the other two (Mint uses React under the hood).

I'm also redoing my GitHub pages website to use Svelte to dynamically create the pages with the pages on GitHub as markdown files. This way, I just push new markdown file to the github site. Much quicker and easier.

I've been trying to use Hugo for my site, but I can't get it to do what I want. I'm most likely not patient enough to work with others code. But, by doing my own, I can get it to do what I want easily.

Svelte has totally changed the way I approach web based work!

Re: Ask HN: What are your experiences with Svelte (JS framework)

#85
I recently switched a debugging component that ships with https://boardgame.io/ to Svelte (previously React) and it has been quite nice to work with.

Previously, only React users were able to use this debugging component (even though the library ships with an API for non-React vanilla JS users as well). After moving to Svelte, all users have a consistent experience, and it's now easy to create wrappers for Vue / Angular without much effort because a Svelte component can be used in all those places in a framework agnostic manner.

Re: Ask HN: What are your experiences with Svelte (JS framework)

#86
post #78

Earlier quoted context omitted.

Right but this is still a lot of code for changing the name of a person. Also, this works with pojos and primitive values. What happens when you add class instances, relationships, children, etc? For example in a project I was working I had geometrical figures in my reactive data model. With classes I could simply do: rectangle.getArea() With MobX this was super simple to implement. If I wanted to change the position…

@pier25 You got me curious about this. I've never seen this done with Svelte, so I decided to try it. Check this out: https://github.com/mvolkmann/svelte-with-classes/blob/master... . The key is that when you update a Svelte store you must return a new value. It's enough to just return the value you updated. You see that happening here on lines 16 and 21. I take your point that this is not as transparent as when usin…

Exactly but this could become complicated pretty quickly.

Right now you have 1 update operation for an XY translate. What if you wanted to be able to change multiple properties of more complicated classes? You'd need more boilerplate for each update.

Like I said in a previous comment, my favorite approach right now is what Mithril and Imba do: no reactivity. You change your state and when you're done you tell the rendering engine that the state has changed.

https://mithril.js.org/redraw.html

https://www.imba.io/guides/essentials/state-management#state...

Since this is all vanilla you can do pretty much anything you want with your state. Mutable, immutable, etc. You don't need to add the weight and overhead of something like MobX/Redux/Vuex and you can add as much or as little bureaucracy/boilerplate as the project requires.

Re: Ask HN: What are your experiences with Svelte (JS framework)

#87

Svelte (and Sapper) has the potential to be huge. I normally don't participate on any online forum but signed up specifically to comment on this topic. I've experienced building web sites starting with cgi-bin handlers to React apps and everything in between. React reminds me of the Java days when we would use the Spring framework - huge tooling and setup, architecturally moribound (in a sense, dont flame me), and to…

I almost flamed you.. but After xteen years I still try to like web development but I still fail to comprehend why the web dev world struggles to reinvent programming starting mid air and working towards foundations, starting with a flawed high level language and going towards "assembly", starting with an incomplete set of high(er) level UI primitives (input, button, select, p, div) and a primitive rigid layout system and working towards components and more complex forms of declarative layouts. Please someone make a Svelte compiler in Go.. I can't stand Node.js and I can't install it on my machine without feeling dirty. Please don't flame me..

Re: Ask HN: What are your experiences with Svelte (JS framework)

#88

Earlier quoted context omitted.

>Looks neat but I don't know why you'd choose it over one of the big 3 Vue is backed and influenced by Chinese corporations, and React is FB, if you dislike both and can somehow afford to avoid depending on them you might become a happier dev.

Even if Vue was influenced by China, does it matter? It's an open source front-end library. It's there for everyone. And React being supported by Facebook isn't a bad thing either. Means more development time is able to go into it from professional developers.

It matters if devs who depend on donations for a living get their donations cut because someone they know or even themselves do something China doesn't like.

With React it's different of course, objectively you're right, but subjectively, using React doesn't feel right if you dislike FB, and using FB technology can scare of customers if they get aware of it. If you want to trash a competitor in a space that's somehow privacy focused, just mention that your competitors tech stack is from FB!

Re: Ask HN: What are your experiences with Svelte (JS framework)

#90
post #86

Earlier quoted context omitted.

@pier25 You got me curious about this. I've never seen this done with Svelte, so I decided to try it. Check this out: https://github.com/mvolkmann/svelte-with-classes/blob/master... . The key is that when you update a Svelte store you must return a new value. It's enough to just return the value you updated. You see that happening here on lines 16 and 21. I take your point that this is not as transparent as when usin…

Exactly but this could become complicated pretty quickly. Right now you have 1 update operation for an XY translate. What if you wanted to be able to change multiple properties of more complicated classes? You'd need more boilerplate for each update. Like I said in a previous comment, my favorite approach right now is what Mithril and Imba do: no reactivity. You change your state and when you're done you tell the ren…

It seems like both Mithril and Imba do some form of DOM diffing. It’s easy because you just tell it to update the DOM using the latest state. Imba in particular says it has a really fast way to do that. But isn’t it that case that no matter how fast they can make it, it is still doing way more work than an approach that can determine what parts of the DOM need to be updated without DOM diffing?
Post reply on HN