Long before, I have this theory: Go compiler is so fast that we can use it like an “interpreted” scripting language.
Yesterday, this wild idea surfaced again when I stumbled upon this Reddit post and discussion:
Last year, I saw some early attempts like the one in this post by Eyal in 2017:
However, I stop there as I felt the approach is a bit clumsy. And no, I don’t expect Go Authors to officially bake this support in Go tooling.
The post from Reddit yesterday really pique my interest again. So, I continue reading and discovered this great blog post by Cloudflare (2018):
Next, I proceed to try it out and I found the approach is nearly perfect for my use case.
So, along the way, I learned how Linux executes files. By reading the Linux kernel documentation, kernel support for miscellaneous (your favourite) binary formats.
Who knows that the shebang support is actually implemented in the kernel itself and not in the shell or other daemon/process? At least not me.
Once in a while, I like fiddling with some kernel ‘magic’. Today is the day.
As I think back of today’s tiny experiment, it reminds me again of what important things I’ve forgotten.
One way for me to be a better software engineer, be it for front-end or back-end engineering is to learn the fundamentals (of computer science). That is, to me is the Operating System (OS) like Unix or Linux. Today’s example tells me that almost every time I go back and learn about the Linux kernel, it taught me new things that surprises me.
I suggest, if you have not, you should check The Linux kernel documentation. There are many hidden gems there, like the one I encountered today.
That’s it for today. Thanks for reading.
Have a nice day.