Kalan's Blog

Software Engineer / Taiwanese / Life in Fukuoka

Current Theme light

In the previous chapter, it was mentioned that I fell in love with Svelte. The core concept of Svelte is to "reduce runtime work through static analysis + compilation", which reduces the time for Virtual DOM diffing and a large amount of runtime work.

However, the path taken by Svelte also inevitably encounters some problems, the main one being that Svelte cannot do too much for you at runtime.

For example, this issue (Render slot fallback content when there's no content). When the slot content in Svelte is empty, it should render the fallback. However, because there is code like this inside:

<Box>
	{#if foo}
		something
	{/if}
</Box>

During static analysis, it can only detect that there is an if statement inside, and it will assume that there is content. As a result, the actual rendering will be blank instead of using the fallback.

Although it is called compilation, it still has some runtime mechanisms behind the scenes to track dependencies and updates. As long as the browser does not implement reactivity, the framework must handle this. Additionally, although the current compiler tries to minimize the generated code, as the functionality increases, the bundle size may gradually catch up. In larger projects, the difference may not be so obvious.

Another issue without Virtual DOM is testing. Virtual DOM provides an abstraction that makes it easy to implement according to the interface. Unlike React, which is very easy to test, this relates to both developer experience and user experience.

Furthermore, when writing code, I really dislike seeing statements like "XXX framework is awesome! Everything else is garbage". This kind of thinking not only hinders personal career and technical growth but is also detrimental.

Of course, this does not mean that everyone is equally great and that every framework or language is equally good. The choice of framework/language also represents your taste.

In the anime "Ping Pong", there is a line I really like:

It's creepy to bet your life on table tennis.

Although "creepy" may be a bit exaggerated, there is no framework that you must cling to. Your ability should depend on your mastery of the framework, rather than being controlled by it.

To summarize, if you want to introduce this framework into the company, you may need to observe it for a while. However, for quickly building small (or even medium-sized) projects, I personally find it very useful and can start development right away. In short, it is a framework that makes me excited, and I look forward to its future development.

Prev

Svelte — What made me meet you like this

Next

Rollup error encountered with Svelte with apollo-boost

If you found this article helpful, please consider buy me a drink ☕️ It'll make my ordinary day shine✨

Buy me a coffee

作者

Kalan 頭像照片,在淡水拍攝,淺藍背景

愷開 | Kalan

Hi, I'm Kai. I'm Taiwanese and moved to Japan in 2019 for work. Currently settled in Fukuoka. In addition to being familiar with frontend development, I also have experience in IoT, app development, backend, and electronics. Recently, I started playing electric guitar! Feel free to contact me via email for consultations or collaborations or music! I hope to connect with more people through this blog.