Live data from Hacker News

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

news.ycombinator.com

71–80 of 105 posts

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

#71
post #60

Earlier quoted context omitted.

A Svelte store can hold a deeply nested object. It's up to you how fine-grained you want the stores to be, anywhere from one store per value to one store for the entire application. I think a middle ground is best.

Yes you can, I didn't say otherwise. (I did criticize Vue though) My point is that Svelte stores are tedious and ironically seem to go against Svelte's filosophy of lean code. Here are the docs if anyone wants to take a look: https://github.com/sveltejs/rfcs/blob/master/text/0002-react...

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 component, you would not use a store. If it is used in other components, you would typically define and export the store in another .js file and import it everywhere it is needed.

My point is that this is a very simple way to share state between components and nowhere near as complex as the page you shared might indicate. That's because you do not need to use derived stores or custom stores. The simple writable store works in most cases.

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

#72
I've written applications using JQuery, AngularJS, Angular, Polymer, and Vue. And I can easily say Svelte provides the best development UX of the bunch.

I get more done with less code, the code is more readable. I notice other frameworks creating hacky solutions to solve simple problems that Svelte just handles out of the box.

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

#73

Earlier quoted context omitted.

> The ramp up time for a new dev on a framework that isn't widely adopted yet will be way higher What, like a couple more weeks? I find it hard to believe that an experienced React/Vue/Angular dev would take a long time to pick up Svelte.

Finding all the intricacies and gotchya's of a new framework does not happen in a couple of weeks. Also, a total workflow change is not adapted to in a couple of weeks.

> Finding all the intricacies and gotchya's of a new framework does not happen in a couple of weeks

That's how you know you picked the wrong framework.

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

#74
I've been using Svelte for nearly 4 years now, with nearly 3 of those in production. Our entire site https://beyonk.com as well as our admin, backend, and client apps, widgets, and SDKs are all built in Svelte.

I'm a competent all-round developer, but I (was) more comfortable on the server-side than the client-side. However, Svelte has been the first framework (I've used Angular a lot, Vue a lot, and React somewhat) where I've felt fully comfortable working on the client-side too. It's clean, understandable, fast, and it makes sense. It's easy to maintain, and scale my frontend, whereas I've not felt that when I've built similar sized applications with other frameworks.

Svelte, logically, makes sense to me - the API is consistent and sensible, and I can often take a good guess at how to do something without reading the docs. Having no client-side dependencies makes it an absolute ideal fit for distributable libraries too - people can just "slot" our widgets into their site, in one line.

My criticism, as somebody else voiced, is testability. I'm a huge fan of testing, and I generally look for libraries and frameworks which are test-first/test-centric - for instance I use Hapi on the backend, not Express, for this exact reason. That's not to stay that Svelte isn't testable, it's just not been a focus of the framework, and I'd really like it to be. I've had success using [https://github.com/testing-library/svelte-testing-library](h..., and it works well.

I originally built Beyonk in Nuxt but I switched over to Svelte as I had prior knowledge of it, and felt like Vue wasn't quite as nice to code in. After doing so my code was much terser, cleaner, and easier to understand, so I stuck with it and built out the other applications directly in Svelte.

I don't think I could face using any other framework after using Svelte, it would feel like a backwards step. Single-file components are a massive bonus, and scoped styles... I don't know how I lived without them.

It's worth mentioning that when I first learned Svelte (v1) it took me 45 minutes to get the basics and build what I wanted to build. I think the current v3 API could be learned from scratch by a decent frontend developer within a day. That learning curve is drastically lower than that of any other frontend framework I know, and for that reason I'm not concerned about hiring for Svelte.

I think that's about it really. I really enjoy, and in fact, look forward to writing code in Svelte on a daily basis - and for me, that was historically something I never expected to say!

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

#75

Looks neat but I don't know why you'd choose it over one of the big 3 (React/Vue/Angular). Seems to have far less community support and 3rd party libraries available. If you're a business it's probably harder to hire for too as it's less well-known.

I don't think it's fair to compare the community of a framework which is less than half the age of the ones you are comparing it to, but I agree community is a big one - luckily I've found the Svelte community super helpful, so I've really not suffered at all.

As for 3rd party libraries - it's ludicrously easy to integrate anything you want with Svelte. I've built wrappers for Vue and React before, and I can safely say that it isn't necessary for Svelte. Things just work.

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

#76

Earlier quoted context omitted.

> The ramp up time for a new dev on a framework that isn't widely adopted yet will be way higher What, like a couple more weeks? I find it hard to believe that an experienced React/Vue/Angular dev would take a long time to pick up Svelte.

Finding all the intricacies and gotchya's of a new framework does not happen in a couple of weeks. Also, a total workflow change is not adapted to in a couple of weeks.

That's sort of the beauty of Svelte. The surface area is minimal, and as such - though there are gotchas, you can almost count them on one hand.

I learned to use Svelte (granted, v1), in 45 minutes, and build something using it. I guarantee that a developer won't need 2 weeks to become comfortable in it.

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

#77
post #8

It's cute but I can't recommend it for a project with more than one developer. Lack of TypeScript support and the hacky component model (specifically, Svelte's equivalent of React props) are the two big deal-breakers.

As somebody who doesn't want typescript support, at all, I relish the lack of typescript support!

Also the component model isn't "hacky". It's logical, unopinionated and straight-forward. I don't know how much you know about Rich Harris but he's not one for producing "hacky" public APIs.

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

#78
post #60

Earlier quoted context omitted.

Yes you can, I didn't say otherwise. (I did criticize Vue though) My point is that Svelte stores are tedious and ironically seem to go against Svelte's filosophy of lean code. Here are the docs if anyone wants to take a look: https://github.com/sveltejs/rfcs/blob/master/text/0002-react...

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 of the rectangle I would simply modify the x and y observable properties.

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

#79
post #77
post #8

It's cute but I can't recommend it for a project with more than one developer. Lack of TypeScript support and the hacky component model (specifically, Svelte's equivalent of React props) are the two big deal-breakers.

As somebody who doesn't want typescript support, at all, I relish the lack of typescript support! Also the component model isn't "hacky". It's logical, unopinionated and straight-forward. I don't know how much you know about Rich Harris but he's not one for producing "hacky" public APIs.

> As somebody who doesn't want typescript support, at all, I relish the lack of typescript support!

That's a pretty strange statement. TypeScript support does not mean you have to use TypeScript. It's purely additive by design.

By hacky I mean "define some global variables and the compiler will do some checks to make sure you don't do anything untoward". You can see my other post in this thread for examples where this model falls apart.

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

#80
I wish the template syntax is similiar to Blazor. I feel the {#await} block is a bit too magical. Also, I'm afraid the template syntax can't keep up with Js syntax which keep evolving.

I like how Blazor approach the template syntax by allowing C# control flow syntax (if, for, ...) but disallow expression and assignment. I think if svelte template syntax allow Js syntax with the same rule as Blazor, it can keep up with Js evolution, especially when it support pattern matching. Also, _maybe_ it will make it easier to implement the autocompletion in the svelte langserver.

Ah yes, one feature request. What about make props and reactive assignment reflect on custom css variable too? (which mean --css-var need to be locally scoped same as how .class is locally scoped).

Post reply on HN