Live data from Hacker News

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

news.ycombinator.com

91–100 of 105 posts

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

#92

My only problem is that I cannot export as custom element. Web component is nice but shadow dom is complicating far too much my use cases

The Svelte compiler does support exporting as a custom element: https://svelte.dev/docs#Custom_element_API

Well, I know that it supports exporting to custom elements, what I miss is the option to NOT use shadow DOM (now it is forced)

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

#93
post #86

Earlier quoted context omitted.

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?

Mithril uses a vdom so yes it's doing diffing. It's certainly slower than Svelte but it's still plenty fast for most use cases.

https://krausest.github.io/js-framework-benchmark/current.ht...

Most importantly Mithril is very lightweight. Check the startup metrics on those benchmarks. This is not a totally fair comparison since Mithril includes a router and an http client and the others do not. Still, it manages to be among the best.

Imba uses memoization and, much like Svelte, direct DOM manipulation.

https://www.imba.io/guides/advanced/performance

Imba was used to build Scrimba (an online code tutorial/editor) which is very impressive.

https://scrimba.com/

I couldn't get past the Ruby-esque syntax, but it is a very impressive effort.

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

#94

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…

Why do you think that React is absurd?

I’m not a Rect developer myself, but it is always interesting to listen to others experiences with it.

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

#95

Our small team is currently evaluating svelte as a replacement to riotjs and vuejs. We have reimplemented several of our projects in svelte and like the results and the easy learning curve for getting our team up to speed. The documentation for svelte has been first rate. The shareable REPL has made asking questions and answering them very easy. The community on Discord has been very helpful. Since we began evaluatin…

What is your opinion on riotjs?

I have followed that project for many years & it has always had an interesting component system, but I have never done anything serious with it. They have recently released a new major version. Very small community.

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

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

You can create a custom store in Svelte and do almost the same:

import { writable } from 'svelte/store';

export default function(state) { const { subscribe, set, update } = writable(state);

  return {
   subscribe,
   getArea() { ... }
  };
};

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

#97
Fantastic.

But it needs a router. I'm using svelte-routing which works pretty well but even in a lightweight package like Svelte I think it's almost essential to provide basic routing as part of the package.

After all, stores are provided even though plenty of third-party store libraries exist.

The refreshing thing about Vue is that it includes a great router solution out of the box. The Vue team obviously realized it couldn't be considered an optional extra, just as stores aren't.

Yes, Sapper has routing, of a specific kind, but a developer shouldn't have to employ a framework like Sapper to get basic routing functionality.

Otherwise Svelte is killing it. Well done.

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

#99

Fantastic. But it needs a router. I'm using svelte-routing which works pretty well but even in a lightweight package like Svelte I think it's almost essential to provide basic routing as part of the package. After all, stores are provided even though plenty of third-party store libraries exist. The refreshing thing about Vue is that it includes a great router solution out of the box. The Vue team obviously realized i…

>But it needs a router.

Sapper. A bit rudimentary but it dovetails nicely. Plus, built in export for static sites.

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

#100
post #99

Fantastic. But it needs a router. I'm using svelte-routing which works pretty well but even in a lightweight package like Svelte I think it's almost essential to provide basic routing as part of the package. After all, stores are provided even though plenty of third-party store libraries exist. The refreshing thing about Vue is that it includes a great router solution out of the box. The Vue team obviously realized i…

>But it needs a router. Sapper. A bit rudimentary but it dovetails nicely. Plus, built in export for static sites.

I mention Sapper above.

Sapper adds a great deal of additional functionality and a framework layout that Svelte on its own does not. All Svelte needs is its own router to be the complete package.

Post reply on HN