My penguin avatar

Kiesel Devlog #7: Happy Birthday!

Published on 2024-04-28.

As of today Kiesel, the JS engine I'm building in my spare time, is one year old! This post is a short overview of where we are, how we got there, and where we're going.

commit 929bb044ffcd1776c850a5b924f9992915277e58
Author: Linus Groh 
Date:   Fri Apr 28 19:48:13 2023 +0100

    Initial commit

    Writing another JS engine seems like a fun project for learning Zig :^)

Why Are You Doing This, Again?

What it says in that commit message is true, I did need a project to learn Zig. It's a simple yet powerful language so that didn't take very long. Nowadays I'm doing this purely for fun :^)

I'm happy if Kiesel will be useful to someone some day, but in the end that's not really my motivation. In fact, from my past involvement in open source projects I know that something having users means more work for me. That's also the reason why I initially prevented anyone from participating by disabling both issues and PRs for the repo on Codeberg. That has changed since then but it allowed me to not worry about maintainership and just enjoy the process.

And that's still what this is: recreational programming at its best!

Conformance

Last week Kiesel passed 50% of test262, and it's still around that number — 50.4% at the time of writing. Progress has slowed a bit over time as more and more of the low hanging fruit were implemented.

Graph showing test262 score over time

Something that really helped here is learning from the mistakes made in LibJS and avoid them entirely, including getting the object model and cross-realm interactions right from the beginning.

Another lesson learned from LibJS was that having spec comments on everything is incredibly helpful. You will get things wrong otherwise, unless you run test262 from the beginning, which you can't because it needs a somewhat working runtime.

I enforced this in LibJS at some point, introduced it in Kiesel right from the beginning, and have been seeing this style in various other engines since then. It's great!

Making Progress

If you've never worked on a project of this scale it can seem intimidating. I'm somewhat surprised by the amount of progress myself, but the gist of it is: commit to making a little bit of progress frequently instead of a lot of progress infrequently — at least for me the former works much better.

This extends to a few other patterns, like not blocking yourself on implementing something fully. Both async functions and generators are not fully implemented yet and useless for practical purposes. They don't support await and yield respectively, so why would I commit that code?

Well, already having implemented 80% of what's needed means that those last missing pieces will be much easier to do than if I were to do everything at once :^)

You can see the different phases of development in the LOC graph below:

Graph showing lines of code over time

Side note: Those who know me will not be surprised that I have a Grafana dashboard for this :^)

Roughly it went like this:

Speaking of lines of code, scc currently reports:

$ scc
───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Zig                        113     62768     9273     14038    39457       5732
YAML                         4       130        8         3      119          0
Markdown                     2       136       36         0      100          0
License                      1        21        4         0       17          0
gitignore                    1         2        0         0        2          0
───────────────────────────────────────────────────────────────────────────────
Total                      121     63057     9321     14041    39695       5732
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $1,289,044
Estimated Schedule Effort (organic) 15.15 months
Estimated People Required (organic) 7.56
───────────────────────────────────────────────────────────────────────────────
Processed 2533110 bytes, 2.533 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────

Ignore the part that says I'm a time traveller, 7.5 people, and someone owes me 1.2M USD.

Side Quests

A couple of other projects started as a result of this one:

Thanks!

While this is still largely a me problem project there were a handful of other contributors:

$ git shortlog -sn
  1425  Linus Groh
     7  Carter Snook
     1  Ali Mohammad Pur
     1  Andrew Kaster
     1  Dominique Liberda

Especially seeing CxByte and Andrew show up with some small contributions made me quite happy, I haven't really kept in touch since leaving SerenityOS. Related fun fact: 100% of Kiesel contributors are also SerenityOS contributors. :^)

I've also had countless conversations with CanadaHonk and became friends with them over the last year while they were hacking on their JS engine, porffor. It's been really fun to have that in the absence of a community around Kiesel! They also made test262.fyi which I still look at almost daily.

Very recently Domi provided me with a much more powerful CI runner, shortening build times from 35 minutes to less than 10. This should now allow me to look into running test262 in CI instead of relying on the nightly external test262 run to catch regressions. She's also the author of this banger of a post <3

Lastly the folks from the Zig project have been very responsive to my bug and regression reports, and I even contributed a few patches myself. In a year Zig has already replaced Python as my favourite general purpose language, and I used that for close to a decade!


Overall this has been heaps of fun and I'll at least continue for another year. If this prediction is right I'll be done by then, and in the meantime you're welcome to join the fun :^)


Loading posts...