Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I'm a primarily React-based developer, but have taken to using Svelte on side projects. Don't get me wrong, I still like React, but Svelte is phenomenally easy to get started and wrap your head around. I've started suggesting it instead of React to people looking to learn front-end JS.


I read the main article which took some time to reach the conclusion a small footprint was the main point.

So I googled, found the Svelte homepage, and I'm still none the wiser as to why it might be an easy intro to web development.

Honestly, if Svelte is as easy as you suggest to get your head around, somebody needs to work on the presentation of that.


I feel like like saying svelte is an "easy intro to web development" is misleading. The svelte compiler "abuses" (I don't mean it in a bad way) existing technology so it doesn't have to create special tooling and works with existing tools. I think that's okay _only if_ you're aware of this as a developer.

If I was hiring a JS dev, and someone _only_ had svelte on their CV, I'd be a bit reluctant to hire them, only because the svelte compiler hides a lot of JS warts (which I think people should be aware of).


Genuine question: where does the svelte complier hide JS warts? I've used Svelte for some production tools and personally in a few projects.

My experience thus far is that if you don't have at least a base-level understanding of JS you really can't use Svelte to its fullest. I can back up that intuition by having observed the svelte support channel on discord, where many of the questions really wind up being questions about javascript rather than Svelte.


I've been working with Vue for front end, but always keeping my eyes open to the future.

What do you feel Svelte is doing that hides "warts"?

Hacky stuff tends to turn me off from a tech. (I consider all my Vue work to be instant tech debt, because I know I will be replacing it down the road...)


If you are referring to my article, "small footprint" is not the main point for me. The main point is ease development due to features like easier component state management, app state management with stores and sharing data between components with context.


To be fair to you I clicked on the article expecting a summary review rather than a technical run through and got as far as Why Consider Svelte on my small phone screen before googling. I can see on a revisit on my tablet it is rather more comprehensive.


Did you walk through the tutorial? It's _easy_. And the tutorial is kept almost 100% up to date with svelte version changes.


No, tbh by the time I got there I had lost interest. I'm not commenting on the value of Svelte, just saying I felt the benefits of investing time in investigating it in the context of a myriad of established tools and frameworks needed to be more clearly sold.


Agreed. Lots of praise, no explanation.


Svelte is:

- smaller (it compiles your app, and doesn't include itself in the results)

- faster (no virtual DOM, the data to elements are mapped at compile time)

- simpler - `age = 30` no boring state management.

You're right about the web page - I wanted them to drop 'Cybernetically enhanced web apps' for 'smaller faster simpler' - there was a GitHub issue for it: https://github.com/sveltejs/svelte/issues/3269


How long did it take to get semi comfy with Svelte (from recent React background)?


For me, it didn't take long. I was initially confused by some "repurposed" syntax in svelte, and kinda felt negatively about it, but I grew to accept it, and even appreciate it (it's a hack, but on the elegant side). There's quite a bit of "repurposing" going on (probably so svelte can work with existing linters and other tooling), but you get used to it.

Svelte has more often "magic" stuff, but the good thing is the magic is simple, and it easy to understand (especially since you can easily look at the compiled output, if you want to double check)


I _left_ Svelte because it was headed in a direction I didn't believe in (all the repurposed syntax). But I gave it a try and had to apologize for disappearing. It is extremely well executed.

One of the primary directives in Svelte is that it all has to be valid HTML so that the tooling can simply treat Svelte like HTML for syntax highlighting. Some of the repurposing is explicitly because of that directive.


I felt the same way when I discovered Vue after a long time using React.


How is it different and what’s so good about it?


The main draw is that Svelte apps have no dependencies at runtime, instead it compiles a pure vanilla js bundle that relies on existing web APIs to do updates. This is attractive to a lot of people, me included, but imo Svelte isn’t quite production ready yet (at least for complex apps). It’s great for small projects though and I highly recommend checking it out


From what I know it's a compiler, so it check all the things at compile time and not waste time at run time.


That's partially true. The other benefit is that there's no vDOM, the way things change is reactive (kinda like in react), but there's no such thing as a no-op change. if you set something to what it was, it would trigger a partial rerender so you have to check before setting. With react you get those checks for free (provided you comply to certain restrictions).


Are you using Svelte for SPAs? If so, what are you using for routing?


I use Svelte with Sapper, which takes care of routing for me. From the FAQ:

> Is there a router?

> You can use any router lib you want. A lot of people use page.js. There's also navaid, which is very similar. If you prefer a declarative HTML approach, there's svero and svelte-routing.

> If you need hash-based routing on the client side, check out svelte-spa-router, or abstract-state-router, a mature router for business software.

> For an official solution, there's nothing that's simply a routing library. There is, however, the official Sapper framework, a Next.js-style application framework built on Svelte, which includes its own filesystem-based routing.


I use Svero. Sapper is alpha and still in flux - I'll check out Sapper again once it's stable though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: