Tag: code

Clojure proxy

Next up in the series complaining about Clojure’s Java interop is proxy. While vararg method calls are inconvenient at worst, there are some (I’d say common) things that simply cannot be achieved with proxy.

Once again this is something I ran into while working with Netty. In one of the HTTP/2 examples, they have one implementation extending AbstractHttp2ConnectionHandlerBuilder<T, B> (have I mentioned I find these extremely long Java class names just hilarious?). The Java implementation is pretty straightforward: implement the abstract method of the class and be done with it.


Clojure vs Java varargs

Variable length argument lists (varargs) have been around since Java 5 (so quite a long while), yet I get the impression that many people either don’t know about this feature or their tools don’t support it. I ran into one of them working with Netty from Clojure and it wasn’t trivial at all how to use them through interop.


Partition of integer into exactly the given number of distinct parts

Ran into this issue in a programming challenge on HackerRank and I was surprised there weren’t any “simple” solutions online. The math related is mostly focused on finding the number of possible partitions of an integer, instead of generating even just one such partition.

A very naive approach might be to enumerate all partitions and then filter them down to those with exactly the wanted number of summands and then filter further to those with distinct parts and pick the first that fulfills the conditions.

But when the subject integer can be 1018 then that simply isn’t realistic. Insert sophisticated simile involving the heat death of the universe.


The algorithms

Honing your skills on CodeWars or HackerRank is definitely a good idea. I’ve myself spent months on the former and some time on the latter, and right there is a display of my issue with them: I lose interest. At first it’s really nice to tackle a bunch of “interesting” problems and feel successful, but as the difficulty of the problems goes up, it soon turns into “how do I get around the shortcomings of the language I use?”

That’s naturally something worth considering, but it just feels so weird when I have to overcome performance tests aimed at C in Ruby (or Clojure). It’s doable (most of the time), but it’s a whole different kind of measure. I recall a problem for which solutions in C were mostly pretty naive loops while something similar in Ruby would fail even the first few load tests.


Counting the milliseconds

I’ve been building a Netty-based web server in Clojure. While I haven’t had the strength to do much with it these past few months because I prioritized the climbing season, now that Hacktoberfest is incoming I’m planning to go pedal to the metal with it (and with my git GUI work-in-progress).

I’m building iny (named after a fox from Fekete Istvan’s Vuk) with the clear goal to replace Aleph. While I’m a huge fan of Aleph and the libraries around it (like Manifold) it’s no longer maintained, which is simply not acceptable when we’re now looking at http/3 coming out sooner than later (support is already in browsers after all).


Going green

There is kind of a status to having your GitHub contributions chart covered in green. For those unfamiliar, it’s a calendar-like chart that shows how active you are on GitHub any given day. It’s assumed that the greener the better. I’m not so sure anymore.

From the start of May to the end of July, I tried filling it up. Do something every day. My conclusion is that this is a typical case of Goodhart’s law. Basically as soon as a certain metric (in this case turning that chart green) becomes a goal in itself, it ceases to be a meaningful metric anymore.


Iced to Electron

I got really frustrated by GitKraken. I’ve been using it for years now both for work and for hobby projects without much to complain about really. Then again I’m not a heavy git user: mostly I just commit and push, only occasionally squashing or cherry picking. I don’t even remember when was the last time I needed a rebase, but it wasn’t yesterday.

However recently GitKraken started having these weird problems with my work repositories. These can get pretty big (by my standards) with tons of branches getting pushed to in parallel (and in the early days some very large blobs got checked in too). Because the branches move really quick it’s important that I can keep my own up to date by merging the head branch back.


GitOps and Kubernetes persistence

A while back I wrote about bootstrapping a Kubernetes cluster. I’ve been refining the setup so that it requires as little manual kubectl‘ing as possible. I still use ArgoCD to get everything rolling, and there is one bit that kept going red: persistent volumes.


可変個! 可変個! そして手動gensym!

Clojureを紹介する記事はよくマクロの存在を最強の武器としてあげているが、実際にマクロはそう頻繁には使わない気がする。個人的にマクロを作る目印になるのはとあるウィキの記事に書いてある基準。

C++を主にみたデザインパターンの考え方の批判で指摘されるのは、ああやってパターンを繰り返し適応するのはまだコード化できてないなんらかの抽象化があることを示している。

コードに規則性や繰り返しが現れるのは、今使っている抽象化が十分ではない印。例えばマクロに任せるべきコード展開を手動でやっている。

Paul Graham: Revenge of the nerds

Hacktoberfest

After last year, I once again decided to take part in the Hacktoberfest fun. I have plenty of repositories lying around (sadly much less well maintained by yours truly than preferable). Of course this also means that I can gather the necessary contributions from updating dependencies in my own repositories, but I’d prefer to instead contribute to those dependencies.