New contract, new stack, new blog theme & the same dream of functional programming
As you’ve hopefully discovered, my blog runs a bit lighter and faster now. It grew over time, like most software tend to do, and gathered dust some places and bloat others. Lo and behold this new bearblog inspired thing, though: Almost no JS, and a lot less of Everything Else as well.
…Except ridiculous CSS, there’s a bit more of that because I wanted to make the “random recommendation” part on the home page not rely on JS for randomness 🤓.
CSS is, if nothing else, FUN
Who knew you could do this to (pseudo-)randomize the order of things within a grid or flex layout?!
1.entry {
2 order: round(
3 mod(
4 sin(var(--index) * 12.9898 + var(--seed) * 78.233) * 43758.5453,
5 1
6 ) *
7 1000
8 );
9}
Here are some less obscure semi-modern CSS things that make transitions and initial states easier and more straight forward:
interpolate-size: allow-keywords;- this lets us transition smoothly between intrinsic/calculated sizes (likeauto) and others (like10px).transition-behavior: allow-discrete;– this allows us to transition smoothly to/frominvisible/hidden(there’s more to say, but that’s the most useful summary I could muster)@starting style {}– A means to define properties to transition from as something enters the DOM or becomes visible for the first time. This one is really useful!
What’s still JS, though
- The live “
npeople reading this right now” thing on top is Lamdera in an iframe (of course 😆). Fading in with@starting-style. - The Search widget is still Elm, and that’s not about to change. It’s hacky, but it works!
- Sadly, for now, the button on home that shuffles the recommendation entries does
document.getElementById('testimonials').style.setProperty('--seed', Math.random())- I’ve experimented with checkbox-hack-ish solutions with only CSS, but so far they’re too hacky even for my own blog (which says a lot). If you mange to solve it in a clean way without any JS, you’ll get a shoutout in my next blog post though!
(Why this obsession to not use JS, you ask? Well, I like to solve interesting problems, that’s the main reason. Constraints are fun! Also, I’d like to battle the inclination towards always using JS for everything!)
Learning Functional Programming in Go revisited
Confession: I’ve given this book a bit of a bad rep, I’ve even mentioned it on my book recommendation page as something to avoid. But despite my first impression and previous conclusion, that very book was really what kickstarted my functional adventures way back (though not in Go), and for that I’m extremely grateful. At least 6-7 years have passed, and I’ve done my fair share of functional programming since.
Like the title promised, I’m transitioning into a new project these days. My next contract is primarily Golang, with a bit of Python on the side. Domain? GIS and geospatial data for electricity distribution. Can’t wait! So, last night I picked up the book again (to be honest, because I couldn’t find the other Golang book I was looking for), and my more-functionally-oriented-than-7-years-ago self found the table of contents intriguing to say the least. Maybe it wasn’t the best book to get into functional programming, but I suspect it’s a great book for functional programmers trying to keep their brain on in languages often associated with object orientation and/or imperative programming! I haven’t concluded yet, BUT it feels a bit like a full circle to return to full time Golang with a more functional approach than before! And the book is actually a really interesting read on my second try!
Disclaimer: I won’t try to shoehorn the functional paradigm in everywhere at all costs (like trying to create randomness and interactivity without JS on my blog); rather I’ll do what software engineers should always do: solve the right problems in the right way, writing simple and performant code that’s Easy to Change (Pragmatic Programmer, tip #14), to the best of my ability. Golang, which I honestly have always really enjoyed working with, is no different.
Pragmatic, language-agnostic and holistic approach aside, this is still one of my favorite CS quotes:
“Object-oriented programming is an exceptionally bad idea which could only have originated in California.”
— Edsger Dijkstra
I’ll just leave that hanging, so you’ll know the main emphasis on this blog will stay mostly the same regardless of stack. Nothing like some Monday morning controversy to end a pleasant enough post 🤓