Tip: Uncaught Invariant Violation

Uncaught Invariant Violation: onlyChild must be passed a children with exactly one child.

Are you using Reagent and Bootstrap with ClojureScript, and getting this error?

In my case, the cause was that I had a when inside an OverlayTrigger. Seems like a no-no. Further testing showed you can’t have an if either. Looks like OverlayTrigger can only wrap data, not something that might change.

In my case the solution was simple enough, once I figured out the cause: I just extracted when to wrap the OverlayTrigger, instead of the other way around.

Stop abstracting early

When I started working with Clojure, I wanted everything to be Clojure.

HTML? Vectors through Hiccup.
Configuration? Clojure maps.
SQL queries? Clojure lists.

After all, I might one day need to take advantage of Clojure’s functional abstractions to… um… well… I might need it, right?

Learning Clojure Fast

There have been several questions floating lately to the effect of “How do I get started fast?” or “What’s the bare minimum I need to know to get hired?”.

In case you’re wondering how to do that… you’re not going to like this answer.

ClojureScript tip: mind the Clojure version

Updated the ClojureScript version, and now you’re getting build errors? Check the Clojure version.

If you do an upgrade through lein ancient update, it will not upgrade the Clojure version. But if you have a ClojureScript dependency, it will be upgraded, and you may run into a case like this when building:

No such var: string/index-of, compiling:(cljs/source_map.clj:260:54)

I got this error when going from ClojureScript 1.8.34 to 1.9.93. I wasn’t using index-of directly, which is a Clojure 1.8 function… but ClojureScript was.

Complexity is the mind-killer

Chess moves

Last week I read an article from the MIT Technology Review that looked into what causes people to make mistakes. The approach was one I hadn’t seen before: it used data mining on a set of chess games. Their rationale was that:

  • There’s a huge database to feed your model from,
  • Chess is a deterministic domain where you can objectively evaluate good and bad moves,
  • There are clear criteria for the skill level of the participants, even when disparate, which allows you to balance.

As spoiled by the title, complexity was the main factor whenever a player made a mistake.

The bottom line is that the difficulty of the decision is the most important factor in determining whether a player makes a mistake.

So what’s the big deal?

Relevance is now open source

I’ve released Relevance, my smart tab organizer for Chrome, under the MIT license. You can find the ClojureScript source code on GitLab, and the extension on the Chrome web store.

Drifting away from .Net

Fatigue?

I don’t think there’s .Net fatigue, in the same way as described on Eric Clemmons’ Javascript Fatigue. At the very least, I don’t think it’s the same feelings at play, considering how people breaking up with Javascript talk about it.

I just think .Net may have missed the love boat altogether.

But let me back up a bit here.

Flexibility Through Immutability, part 2: How and When?

The second part of the original text for “Flexibility Through Immutability“.

The first part focused on the why of immutable data. On this part I’ll review what to do about if you’re working on an object-oriented language.

Flexibility Through Immutability, part 1: Why?

Here’s the original text for “Flexibility Through Immutability“, for those of you who prefer reading to watching a video.

It’s a bit of a long read, so I’ve divided it into two parts. The first one focuses on the motivations behind preferring immutable data, and the second one (which will go up on Wednesday) on how to go about it.

The framework mirage

OK, this is going to be a tough one. Strap down, even if it pisses you off at first - I wouldn’t be writing it if I didn’t think it was helpful.

Stop me if you’ve heard this one before

A programmer has something he wants to build.

He finds a framework.

It looks easy enough to get into. There’s a few tutorials available, which show step by step how to build a basic application of just the right type.

He’s happy. He feels really productive. CRUD just “drops out” of the framework’s design. It’s like it was created with his problem in mind.

Then he’s done with the tutorials. He starts plugging in his own, specific requirements. Every so often he hits a snag, but that’s OK, he can just twist the framework’s arm a bit, right?

It all goes well for a while. Then he hits a big one. The framework doesn’t do quite work the way he wants it to.