4 ms·
Svelte 5 is not JavaScript is why I like Svelte 5. There are two major ways I think it's reasonable to do frontend/web: 1. Static HTML or server rednered temp
by barnabee 2y ago
Svelte 5 is not JavaScript is why I like Svelte 5.
There are two major ways I think it's reasonable to do frontend/web:
1. Static HTML or server rednered templates with maybe HTMX .
2. Compile-to-JavaScript languages/platforms. At a minimum TypeScript but given that I think HTML and CSS are actually pretty good (for many things), JSX, React, Tailwind, etc, are right out, and Svelte 5 along with a few other frameworks actually improve things over vanilla TypeScript in my opinion.
So much so that Svelte 5 is the clear winner in category 2 for me.
It has nice HTML templating, easy and sane state propagation, and features that make it easy to write modular code. It works great with CSS and you can often build simple throwaway apps and tools in one or two files, as well as bigger, more serious applications. It's less magical and surprising that Svelte 4, and honestly a joy to use. Luckily I don't care about IndexedDB.
I have no clue why anyone would choose to write a single line of JavaScript in this day and age, but each to their own.
- prophesi 2y agoYou'll still be writing Javascript/Typescript with Svelte. What the article means by "Svelte 5 is not Javascript" is that all of your code outside things like Stores will be compiled in a manner that makes it harder to debug, since it's not normal Javascript but a Svelte-compiled JS that won't make sense in the debugger. I would opt for better debugger tooling specifically for Svelte than strip away the abstractions. Its the lack of a runtime managing a virtual DOM that makes it unique and performant, and frameworks like React also essentially have their own compilation step that obfuscates code. Source maps won't help much by itself; the React debugger is where you have a better view on your components and how things are wired up.
- barnabee 2y agoDebugging seems fine to me, theres even the {@debug …} tag. TypeScript is a better scripting language than JavaScript, Svelte is a better language/model/platform than HTML+TypeScript. React may be your cup of tea but I’d rather write Svelte templates every day! Not to mention per-component styles. Sure, a component inspector devtool would be neat, though. Nobody’s going to complain about better tooling :)
- deleted 2y ago[deleted]
- nonchalantsui 2y ago> I have no clue why anyone would choose to write a single line of JavaScript in this day and age, but each to their own. You should already have a clue, you have to write a lot of JavaScript in order to get Svelte doing what you'd expect outside of very simple components. See these actions as an example, and check out the JS file! https://svelte.dev/tutorial/svelte/actions https://svelte.dev/tutorial/svelte/actions Svelte makes more sense if you enjoy the JavaScriptisms. In which it provides enough "magic" for most things, but still lets you enjoy JavaScript.
- barnabee 2y agoNo, I write a fair bit of TypeScript when I need to make a frontend in Svelte.