Live data from Hacker News

Migrating from Vue 2 to Svelte

escape.tech

261–270 of 289 posts

Re: Migrating from Vue 2 to Svelte

#261

Not sure what they mean by "typed events: vue 3: no". It's possible, I did it today. Here's the doc: - Typed component emits: https://vuejs.org/guide/typescript/composition-api.html#typi... - Typing event handlers: https://vuejs.org/guide/typescript/composition-api.html#typi...

And the discussion of store for Vue neglected pinia which is de-facto the store.

Personally, after going all in with Pinia, I went back to no store. I just use refs and computeds exported from files. I have a dummy pinia store loading all of them to provide a basic devtools ui.

Re: Migrating from Vue 2 to Svelte

#262
post #91

When will mithril.js get the hype it deserves, I'm a sucker for simple tiny libraries with no dependencies and no build steps that are mature as well (6 years). I guess it doesn't have a flashy community with talks and developer advocates :/. I feel the same about htmx, another simple tiny library with no deps and no build steps. Why don't people recognize the advantage in that.

Because bell curve. Mediocre developers are the curve and they evaluate tech differently. When most developers evaluate tech based on engineering metrics alone, we would make progress a lot faster. (The business benefit automatically comes with the curve).

Re: Migrating from Vue 2 to Svelte

#263
post #229

It's ridiculous to me to read that for some people it is desired to have CSS, JS, and HTML in the same file. I would never consider it an improvement.

That’s an interesting opinion as react, Vue, svelte are all in favour of having css and templates together with js. What do you prefer? IIRC, Vue allows you to move link to a separate html,css and js file from vue sfc file should you want it

You are right, I prefer exactly this - to separate CSS, HTML, and JS/TS.

I know that “smaller components are better”, I agree with this rule, but I prefer to draw the boundaries myself, not forced by the capabilities of my code editor.

Re: Migrating from Vue 2 to Svelte

#264
post #4

It seems worrisome that front end frameworks needs to be changed after just two years of use. Glad I'm not working with front end...

React is almost 10 years old, if you used React in the last few years you haven't really been changing more than the average backend. The "frontend changes so often" meme made sense years ago but doesn't seem to be that different than backend nowadays. I mean in the last ~10 years we had the new hotness of moving from cloud hosted servers -> docker images -> kubernetes, C# made a massive move when going to .net core,…

Laughable, React is almost 10 years old but Hook is not yet a consensus of the best way to do state and effect. This is what people are actually talking about, they have constantly been in R&D mode while people shipping that codes to prod.

Re: Migrating from Vue 2 to Svelte

#265
post #42
post #36

I'm missing the raw numbers. Increased performance? Faster code execution? By how much? I'm sure Svelte is faster, but if we're talking 10% improvement it doesn't really matter. Additionally... {@html Prism.highlight(code, Prism.languages[lang], lang) } looks very unsafe to me. (Vue example has the exact same problem)

i dont understand, you’d have to do the same in react? mostly this code injection comes from trusted sources like your CMS. if you’re displaying arbitrary user input then yeah better sanitize it but thats a problem common to all frameworks react included as for perf i mean the main thing is “are you downloading 100kb just for the framework” whereas many svelte apps come in under 10kb. beyond that agree it doesnt real…

It's 136.4kB minified (react+react-dom), for a zero app is crazy. The app size that will justify 136.4kB is probably 700kB which is 836.3kB total, is also crazy. So no hello world argument because it sucks (in engineering metrics) at all range of apps.

According to https://web.dev/optimizing-content-efficiency-javascript-sta... the js size budget is about 800kB minified (1s to parse/compile). So if an app max out the budget, the framework part is considerably 17.05%.

Not bad, but if the median of react app is around 300kB which means the framework part is 45.4%. This is bad!

Re: Migrating from Vue 2 to Svelte

#266

Svelte & SvelteKit has been wonderfully productive for me. It's a bit insane that I have adopted it across so many projects of mine despite the fact it is pre 1.0 (well that has more to do with me I guess), but I am just faster with it. I have used a lot of frontend frameworks over the years, and before SvelteKit Vue & Nuxt were what I was warming up to. The article really focused on measurable things like type check…

Just noticed my formatting faux pas.

Even after this many years on HN…

Re: Migrating from Vue 2 to Svelte

#267
post #31

Earlier quoted context omitted.

Because in many cases, manipulating the DOM with vanilla JS sucks way more than writing declarative code with a framework.

It's really not that bad. At least not in 2022. With the caveat that you can keep your UI (DOM manipulation) code from your business logic code. Which I'm sceptical of given the front-end code bases I've seen in the wild. But no one writes blog posts about how Vanilla JS 2 is no longer supported so they had to migrate to Svelte :)

[deleted]

Re: Migrating from Vue 2 to Svelte

#268

Earlier quoted context omitted.

How is typescript support? I found that a bit lacking when I was using Svelte (and I otherwise love svelte)

Typescript support in Svelte is one of the biggest problems with the framework I’ve encountered. We have a couple of production Svelte apps at my job and overall the frontend DX is excellent. However, not being able to use generically typed components is a big missing feature. We have a number of custom core components which work really well, but not being able to create a new component with something like MyTable =…

I may be missing something (I haven't used Svelte, SvelteKit, or TypeScript much), this doesn't seem accurate. I was going to link to a direct example, but I'm not sure I understand exactly what you're looking for. More information here: https://github.com/ivanhofer/sveltekit-typescript-showcase

Re: Migrating from Vue 2 to Svelte

#269

Earlier quoted context omitted.

SvelteKit is going ot be Django/Ruby on Rails of frontend frameworks. Due to integration and polish, it is so much easier to use than anything I have developed with on Angular, React and even older stacks like jQuery.

How is typescript support? I found that a bit lacking when I was using Svelte (and I otherwise love svelte)

I added some more information in another reply, but Svelte has officially supported TypeScript for a couple years now. It provides some tooling to get started and there are also existing projects that may make certain things easier or more useful.

Announcement (some things have changed, surely): https://svelte.dev/blog/svelte-and-typescript

More info in the GitHub repo I linked to elsewhere.

Re: Migrating from Vue 2 to Svelte

#270

Earlier quoted context omitted.

I would say you can equally learn the core of Vue and React in a day, so that you’re actually building your app before the day has finished.

Quirks.. I mean rules of hooks in one day? You're not being serious.

You could easily read https://reactjs.org/docs/hooks-overview.html , https://reactjs.org/docs/hooks-reference.html#basic-hooks , and make a quick React UI with Vite in half a day for a junior dev. You're not being serious.
Post reply on HN