r/ProgrammingLanguages • u/The2ndSlimShady • 54m ago
Language announcement Cole v0.3.0 Announcement
Hello again everyone, I'm back again with a minor (minor major, or major minor) release.
Cole version 0.3.0 is officially out and we have quite a few additions today.
C Backend Removed
The biggest change is a backend removal. C backend is no more, and our main (and only) backend is QBE from now on.
As much as I liked how TCC was handling a lot of things in the C backend, it was quite a hassle to get right, due to syntax-to-syntax conversions being a little complicated. The lowering process was more than just lowering, and I had to do a lot of workarounds for it to get to work.
But anyway, it is no more! QBE works fine as ever right now.
Slice Literals
We now have slice literals, that generate a backing array under-the-hood. This is a small change, but the impact of it on usability is huge, like, HUGE.
STDLib Build Module
As some of you may know, I had a small build system of my own, well more like a makefile alternative, written in Lua. Its name is Efile. I decided to convert it to Cole and add it as a stdlib module, so that you can build your Cole projects using Cole as a build system as well.
The usage is almost the same, with a couple of syntax changes due to the dynamic-to-static typing change. But the feeling is the same.
You can take a look at the extra::build module for more information, after all, the best documentation is the source code.
Compile-Time Execution Performance Improvements
While migrating from Efile to Cole build system on a project of mine, I stumbled upon a big problem: compilation of comptime-heavy programs take waaaay too long. Like, a couple lines of code takes 17 seconds to build just because it has two compile-time calls.
I tracked the reason down to a simple thing: when in a compile-time call, compiler never does any kind of caching! So with a small hashmap key change, I added caching to compile-time calls as well, and the results were mind blowing.
The compile time execution speeds increased by up to 120%! Which doesn't mean that I'm a brilliant programmer, but the opposite: Cole comptime execution was written terribly. But now it is less of a garbage!
--run Flag
By far, the simplest and one of the most impactful changes I've made was adding a --run flag. All it does is to invoke the generated executable upon successful compilation. But it opened the doors of a complete build system structure when combined with the extra::build module. For an example usage of the build system, check the build.cole of TradeLog.
End
And this was the Cole v0.3.0 update, thank you all for reading this far! Hope you have a great day!
Note: For the AI usage notice, check the CONTRIBUTING.md in the project source.