scalc: It's Alive! \o/

Posted on Mar 20, 2021

YES! I’m happy to say that scalc has grown up from being a simple git repo to a full-fledged project hub with its own mailing lists and all the fuzz! It’s alive! \o/

So, what is all this about? Not much really: it’s a simple calculator. I don’t think it’d be advisable to do your taxes with it, I’m sorry. Although I have been using it to do some “real life” math,1 scalc is actually more an exploration I set out to make to test an idea. Look, I know productivity software is more or less a solved issue; my software is rather about having fun while creating stuff and learning about concepts.

The idea I’m pursuing with scalc is not new and is not my own at all. It’s dwm’s, yep the “dreaded” window manager that is somehow the epitome of “difficult” software. Well, dwm is not precisely the first program that asks you to configure things out by patching the source code: that was commonplace in the old days, as far as I’ve been told, but it’s probably the modern piece of software that made that old way back under the spotlight. config.h files and contrib/ folders have found their ways into some projects lately.

I have used config.h files extensively in my projects, but I wanted scalc to be extensible… yet not another half-baked scripting language like the millions there are out there. Also, POSIX bc and dc are superb mathematical languages, we don’t need a poorer version of them. No, I wanted people to be able to easily add in new functions to scalc, but without implementing a whole plugin system, or, God forbid, implementing a DSL inside scalc, or, EVEN WORSE, embed some popular scripting language into it…

So, why not do it the dwm-way and do it with source code? So, OK, in theory and by definition, all open source software is potentially extensible through patches. If you’ve got the source for something, well, you can extend it, right? Yeah, sure, but the point is not to have people forced to modify things all over the place just to add some new math operator.

That meant placing all operators inside a very tight, independent module, which is where all you need to know about operators in scalc lies. This meant doing basic function pointers stuff in the rest of the implementation as to allow things in the op.c module to be freely modifiable as long as functions there expose their interface as required. Yup, as long as you follow the rules, all C code is valid there. In essence I’m using static linking as my plugin system here.

What’s pending? In the short term, I can think of a couple of things. For some of them I already have some plans. For example, right now scalc prints answers to the terminal without any kind of marker that distinguishes it from user input. I’d like to have something there that is grep-friendly that allows for better readability. Other more complex ideas I’m entertaing are some kind of FIFO interface or maybe implementing some basic memory registers for calculations. At this early stage I’m very open to suggestions, discussion, patches, etc.! If interested, send me an email to ~arivigo/! (or check out the mailing list archives!)

Let’s see how things develop following this path! For now, I’ll focus on writing some more commands and operations, as well as cleaning up some of the code. I’ll be curious to see if someone comes up with some patch to propose a new member to the op.c definitions! In any case, I’m excited :)

  1. Mostly grocery store expenses… and debt… ↩︎