4 ms·
I started writing a small static site generator for myself using JavaScript and QuickJS by Fabrice Bellard[1]. QuickJS is not quite complete, and there are some
by toastercat 3y ago
I started writing a small static site generator for myself using JavaScript and QuickJS by Fabrice Bellard[1]. QuickJS is not quite complete, and there are some cross-platform inconsistencies, but overall I found it pleasant to use and its libc wrappers to be powerful enough. I also found that JavaScript is actually pleasant to use when I'm not using classes, or dealing with metaprogramming/Babel, or implicit globals. Dependencies are just pure .js files I keep in a /lib directory and import.
I still think JS is a nice language although I tend to side with Crockford (before he started promoting the "next" language) in that JS has some good parts, and you can write clean and powerful software with it if you ignore most of its warts (even if you're using Node). My best advice is be very careful with what dependencies you choose; and also, don't feel pressured to be at the bleeding edge all the time. The Node/React world is a constant hype machine that flip-flops on best practices every 6 months. Be very skeptical of them, and don't let them spoil JS for you.
[1] https://bellard.org/quickjs/ https://bellard.org/quickjs/
- synergy20 3y agowhat's the use case for quickjs? can it be used for a light-weight runtime for JS on resource restricted embedded devices? by the way, comparing to angular and vue2-vue3, react is actually the one without python2-python3-alike breakages over the years to me, I would say it's the best out of the 3 options(angular,vue,react) so far, which could explain by market share that it remains to be dominant.
- schemescape 3y agoNot OP, but I experimented with QuickJS for my SSG and, on my super slow laptop, it started up about 200ms faster than Deno, but ran about 5 times slower overall (and the binary was much, much smaller). My original motivations were: Deno doesn’t support Raspberry Pi and I was running lots of short-lived processes to support incremental rebuilds using a Makefile. In the end, my requirements changed, so I’m not using QuickJS, but it was very easy to pick up and use. So: portability, startup time, and small code size seem to be the advantages of QuickJS.
- toastercat 3y agoYeah, the QuickJS interpreter is less than a megabyte compare to Node/Deno's >60MB or more install. My use-case was that I wanted something lightweight that I can run on lower-end hardware or in a CI pipeline to generate my site. At first I looked at bash, but I find bash gets unwieldy for more complex operations. I like JS as a scripting language, and QuickJS seemed to fit my YAGNI approach. Indeed, React the library is generally stable. But React the ecosystem is not; best practices change every 6 months. Libraries gain popularity and then are abandoned, or people just realize the cost of using them. SSR vs SPAs? Wait you're telling me CRA is basically deprecated now? etc etc.