Choosing a programming language in 2024

2024-02-22

Welp. I want to write a simple backend service and have it low maintenance for the upcoming decade. I will probably want to write other simple backend services in the upcoming decade and I’m getting old so I’d rather stick to fewer than more languages. But also I’d rather the languages to be tidy. This is a stream-of-thought for my own reference, but I might end up pushing the “publish” button anyway.

Without further ado, the contenders:

Haskell

I already wrote 30 lines of Haskell to do very simple API call forwarding, so I’m not starting from scratch here. The ergonomics just aren’t there:

  • Stack downloads a lot of things and uses exorbitant amounts of disk space. I’m running on a $5 DigitalOcean droplet!
  • With such strong typing I want an amazing IDEs but mostly end up typing things in vim.
  • Haskell is not a beautiful language. Yes it maintains backwards compatibility. Why fmap on functors and map only on lists?
  • I count six different string types and I’m trying very hard to count as few as possible. If one wanted to count as many as possible, I shudder to think what the number would be. Ideal number of string types is one.

On the plus side, stack is in my distro’s repos

PHP

Hey, I have three-ish things running PHP on the aforementioned $5 DigitalOcean droplet. Less beautiful language than Haskell, very low maintenance, just works. But hey it’s not 2004 anymore…

Python

It’s everywhere and there’s no hope of it ever going away. Its library ecosystem is amazing, its package management story is atrocious. Reads like pseudocode, but all bugs are runtime. Probably a practical choice, but is it really that much better than PHP? If I’m getting invested in another language apart from PHP, I’d like it to be nicer.

Scala

Maybe. Having worked with Scala professionally for 7 years, I know it well and like it enough. It seems to be losing a lot of steam recently, as in its cake eaten completely by the inferior Kotlin. But it’s not disappearing completely, is it? And the ecosystem of Java (and Kotlin!) libraries is there.

F#

F# is a nicer language than Scala. But it’s not that much nicer and reportedly the .NET ecosystem is worse. It’s also an ecosystem I don’t know at all. There’s ASP.NET and .NET and .NET core and .NET framework and perhaps they’re complementary or one replaces the other and the naming is confusing…

Idris and PureScript and Roc

Idris is Haskell without the warts, but no one uses Idris and it has no libraries. Nor even a package manager really.

PureScript requires a lot of imports and seems to be more of a frontend language, but perhaps I’m just being uncharitable to it. And uh JavaScript as its main compile target. It makes sense for a frontend language, of course. I use Elm and don’t complain about JavaScript being the compile target. PureScript looks real nice!

ROC is not even a thing yet.

All three a bit too much bleeding edge.

Conclusion

There is no conclusion! The only conclusion I can possibly come up with is that the nicer the language, the worse its ecosystem. The worse the language, the nicer its ecosystem. Here’s, uh, an infographic:

objective ranking of programming languages

Tiling gradients

2024-02-08

Here’s a test. A simple diagonal gradient from white to black, first full size, then four tiles of the same, and lastly sixteen tiles:

It does not tile very nicely. Neither does one which has white-black-white:

And neither white-black-white-black one:

But the following one does! White-black-white-black-white:

Then for 6, 7, and 8 it again does not tile (showing just the four tile versions):

For sequence of 9 it tiles! And sequence of 13 too! And… umm, 17 again?

Proof by induction!


I’m sure this is like some very trivial mathematics. But I do not know it. And the grayscale is a little dreary, make it pop! Let’s have three colours:

Call them purple, teal, yellow. Unsurprisingly, the three colours don’t tile when it’s purple-teal-yellow (sequence of 3), neither purple-teal-yellow-purple (sequence of 4), neither purple-teal-yellow-purple-teal (sequence of 5), neither sequence of 6:

But for sequence of 7 (purple-teal-yellow-purple-teal-yellow-purple) it tiles! Then for 13 and 19 and 25 it does too.


Uh oh, let us take four colours now. Purple, blue, green, yellow.

Green green, green green. Yellow? Yellow!

For sequence of 4 the tiling doesn’t work, but for sequence of 9 it does! And for 17 too, and 25.

This looks very much like 2n + 1


Five colours!

That’ll be 11, 21, 31, 41, 51, …

And lastly ten colours, with sequence of 21:


Why 2n + 1 ?

This is perhaps too embarassingly simple to write a blog post about, but I found none and found a lot of people on the internet confused by their gradients not aligning.

The n here is the number of different colours in your gradient. The 2n + 1 is how many colours you need to include in your code.

The +1 is simple: the last colour of the palette needs to be the same as the first, as they “touch” in the corner.

The 2n is not that difficult either: when it was n, the corners touch just fine, but the sides are shifted by half against each other, not lining up. 2n makes the sides line up, too.

Bonus time?

Here, have an animated one:

Valmorel

2024-01-21

In the nineties, when I was about ten, my parents took me to Valmorel, a ski resort in French Alps. It was my first time skiing in the Alps and I enjoyed the trip a lot. After a week of skiing, when we were leaving, I cried in the bus. My mother said don’t worry, we’d go again. But I knew this was it, there would be no other experience that could compare to going to Valmorel for the first time in my life.

Looking back, I’m surprised how correct and prescient my reaction was. There was no other Valmorel. I’d gone skiing in the Alps many times since, almost every year. It is fun. But the magic of the first time is long gone.

There will be other experiences, good and bad, repeated and unique. There will never be another Valmorel.

Pure.css

2023-01-27

I’ve been using Pure.css whenever I need to use CSS, and love it:

  • It’s tiny (about 1/10th the size of Bootstrap).
  • It’s simple. Go-read-the-code simple.
  • It gets out of the way.
  • They release about twice a year, usually adding a single feature or so. Why move fast when slow is enough?

Back in the day, I used Twitter Bootstrap for the Tsumego Collections. It’s very heavy, there’s an infinite number of classes, one has to fit in within the framework very precisely for it to work, and it requires JavaScript for the menus (???).

The main drawback of Pure.css is its ungooglability and multitude of names. The web address is purecss.io, the logo says “Pure.css”, the page title says “Pure”, the left menu shows “PURE”. I honestly have no idea what the project name actually is.

Thoughts on representing variations and commenting on them

2022-11-07

This is an exploratory post, trying to gather my thoughts on the topic and kindly requesting feedback.

I enjoy playing abstract board games: Go, TwixT, Hex, etc. I play Go on a torus board and TwixT on large boards. After playing a game, it’s helpful to be able to discuss what went right, what went wrong, and what could be improved. This is best done in the real world, but there are some wonderful facilities to do it online too. These use different ways to comment on games and show variations.

The three ways I’ve seen to comment on games and show variations/branches (do have a look at the linked examples; they’re much clearer than my explanations):

  1. The usual tree of moves (nodes) with comments on any node. Most popular, used by eg EidoGo, KGS, and Sabaki. Henceforth “tree”.
  2. A linear sequence of moves, with comments on any node creating expandable variations inline. Seen used only on GoKibitz. Henceforth “inline variations”.
  3. A linear sequence of moves, with a global linear sequence of comments. Each comment can show an arbitrary number of variations starting from any move. Seen used only on TwixT Commentator. Henceforth “global comments”.

The tree is the most ubiquitous, and I’m sure it’s the best if you want to analyze a game extremely thoroughly. The main drawback is that it’s not obvious in which order you should visit the variations and read the comments.

The inline variations allow you to go through the game and see the variations from each move as you visit it. If there are more comments by different people on these variations, they will be ordered by time and easily skimmable. I feel this is the better user experience than the tree, perhaps unless the variations are extremely numerous with a lot of branching (in which case no one will understand them anyway).

The global comments take inline variations to the extreme. It is a true conversation between people, you can see all the comments at once and choose which variations you want to explore based on the words that accompany them. I like this system a lot, though I guess it’s suited for light commentary and might fall apart for particularly heavily commented games.

Which one is the best depends on the use case. Analysing a situation to death requires different tools than two casual comments after the game. Still, I’m leaning towards the inline variations. They’re simple, and should be easy to convert to global comments, and also it should be easy to display the full tree from them. Appears to me like the most flexible solution, leaving the most doors open. (Not necessarily saying opening those doors is a good idea.)

Smiling

2022-10-22

He was smiling. An unassuming middle aged man waiting to cross a busy street with no pedestrian crossing, patiently standing by the side of the road with cars whizzing by.

In such situations my instinct is to be annoyed. Why are there so many people in cars? Can’t they take the public transport or walk? I’d like to cross already! Should I make a run for it or wait until it clears? I have other things to do, and certainly don’t want to spend my precious time standing by the road, inhaling your exhaust fumes. Why don’t they paint a crossing here?

Isn’t it unfair that this man was smiling while I’d be upset in the same situation? After some pondering, I recalled a quote by Thich Nhat Hanh:

So next time you’re stopped at a red light, you might like to sit back and practice the fourth exercise: “Breathing in, I’m aware of my body. Breathing out, I release the tension in my body.” Peace is possible at that moment, and it can be practiced many times a day – in the workplace, while you are driving, while you are cooking, while you are doing the dishes, while you are watering the vegetable garden. It is always possible to practice releasing the tension in yourself.

Perhaps it was a holy road-crosser. Perhaps he was standing there just to remind me that we can influence what we think and can decide how we feel in the situation we find ourselves in.

Oh Ubuntu

2022-10-15

I’ve been a happy Ubuntu user for 17 years, since 2005.

Ubuntu always pushes something on me I don’t want. They pushed Unity, and I hated it. Then Unity was replaced by stock Gnome and I longed for Unity. I got used to Gnome by now. It actually is pretty customizable.

Snaps. Everyone hates them. I swore I’d switch to Debian because of snaps. And yet… I’m on Ubuntu 20.04 and my neovim is old. I’d like to try a newer neovim. Well, apt remove neovim && snap install nvim. Eh, that was almost too easy?

Sirens

2022-09-10

The sound of police sirens.

If it’s an ambulance or firefighters, that’s cool. But with police or politicians, it always annoys me. Who are you, so important you have to disturb my and other peoples’ peace?

Well, I watched King Charles’ first audience with the prime minister1 and there it was: the sound of sirens. And who are you, so important you have to disturb both the king and the prime minister?

  1. I just wanted to see how old he looked and how he was holding up. This was the first video that popped up. 

Social loops

2022-06-09

It has happened again!

I’m friends on Facebook with people called TK and VBV. They have never met, don’t know each other, and aren’t Facebook Friends™.

There exists a person with initials PC, whose Facebook profile I noticed because he’d organized a tournament of Through The Ages. Now PC is friends with both TK and VBV, but I have never met PC nor knew about his existence until about five minutes ago.

Interestingly, TK and VBV are in a similar situation: each of them knows both me and PC, while not knowing each other.

Such situations, in which each of the four people knows exactly two others but not the third, apparently arise pretty often. I’m not a very advanced Facebook stalker, yet I’ve seen this happen at least five times. Wild, isn’t it?

Some back-o-the-napkin calculations:

Say there’s 10 million Czechs.1 Say an average Czech has 200 other Czechs friended on Facebook.2 Say the distribution is random. To count the number of friends of friends, 200×200=40k, but I guess there’s vast overlap among those, so say 10k friends of friends per person? So for each friend-of-a-friend, there is a one in 10m/10k=1k chance they’re also a friend-of-another-friend. With 10k friends of friends, about 10 should be connected through two different friends.3

However, the distribution is not random. The people one hangs out with and the other people one hangs out with probably have something in common. With TK and VBV and PC, we all come from towns with 10k+ inhabitants, and each of us has lived in one of the two largest cities in the Czech Republic.4 This clustering further increases the number of shared friends-of-friends. So perhaps this is not so surprising after all?

  1. For simplicity, let’s limit this to the Czechs. I’ve seen this happen with a person where one of our common connections was a Czech non-go-player and the other was a foreign go player, which is even wilder. 

  2. In 2012, an average Facebook user had 245 friends according to WaPo. By 2019 supposedly 338 friends on average. Not all of them will have been Czechs. Furthermore, I don’t care about accuracy. Ballpark is fine. 

  3. For 10k unique friends of friends, it’s 10 connected through two different friends. For 20k it’s 40, for 30k it’s 90, and for 40k it’s 160. The number of shared friends of friends grows exponentially with how many friends people have. 

  4. In fact I’m the only one of us four who has never lived in Prague! And it just began to dawn on me – maybe I’m the weird one! They all lived in Prague, no surprise some of them met. But, how did it happen I met both VBV and TK? 

My programming career

2022-04-26

I started my programming career writing Idris. It’s a programming language similar to Haskell, with dependent types. That means types are first class citizens, so you can perform computation on them. It’s quite a bit of hassle, all for the dubious benefit of program correctness. The library ecosystem was almost nonexistent.

Then I had a brief stint with Elm and Scheme Lisp. Elm is like an easier Haskell or Idris, with friendly error messages. I no longer had to deal with the higher-kinded types. Scheme is a language with almost no syntax, hence very well suited for beginners like me.

After that, my career progressed to Scala, the first commercially successful language I’ve used. Oh boy, let me tell you about Scala – apart from the functional programming paradigm, it supports object-oriented programming, allowing one to mutate shared state. Also it runs on the JVM, which is pretty cool, with many third party libraries available.

I’ve also used Python a bit meanwhile, and who hasn’t? Yes the 2 vs 3 was a fiasco but the ecosystem is amazing and it reads like pseudocode, nevermind that one doesn’t know which functions mutate things in place and which return new things. Also I drink a beer every now and then, one only lives once (OOLO), leave me alone mmkay?

Later I’ve come to the pinnacle of my programming career: PHP. I’ve spent a good deal of time with PHP, using domain driven development, test driven development, and doing continuous integration, like a good developer should. The language might have its warts, but the productivity is amazing. We used Vagrant and Chef to manage our environments, also we’d deploy things using Docker.

Finally, I stopped using the Symfony Framework, and started using various in-house frameworks, and sometimes even no frameworks at all. At some point I stopped using Subversion and started copying PHP files straight to the web servers. Also I found out that apart from object-oriented programming, PHP also supports “imperative programming”. This means one does not have to write code within classes and instantiate objects, rather one can directly mutate global state. This further decreased the ceremony and increased my productivity.

One Friday, upon coming back from lunch break, I learned the customer wanted to have a points-based eshop ready by Monday morning. Their customers had been collecting points for doing whatever, and now was the time for them to buy merch using those points. Here’s the list of the merch, including photos and prices in points, please send us a weekly list of who ordered what, ta! Do you think I spent the weekend working? Nope! I buckled up, wrote five hundred lines of PHP in several hours of perfect flow, tested it a little, fixed a bug or two that came up, copied the files over to the production server, called it a day, and went home for the evening. Come Monday, everything worked just fine.


Is this a joke? Well, the timeline, perhaps, a little bit. Apart from that, not so much. I really did write the points-based eshop in PHP in an afternoon, and it really did work. As people grow their career, they achieve more and more. Me, I achieve less and less. I really don’t have anything to point at that I wrote in Idris. [insert shrug emoji]