For some motivations I am not going to go into, I found myself writing a piece of software that would transform a data structure representing a query and transform them in SQL statements, something like Datalog
There have been some items that made me spent more time than I was expecting; I guess these are mostly because I still am not that proficient in Clojure and in the spirit of openness (or more like, I wanted to write something no matter what) here is what I've noticed:
- I am still not used to the idea of running the REPL and keep it running forever. I’d run it to test some commands and then close it only to realise I needed it again. Doing this more than 30 times — well it’s probably a 3-4 minutes lost in waiting the REPL to spin up
- I’ve paused multiple times on functions that have logical conditions and pondered whether it would’t be better to write a multi-method. Then I would do so and thought that it was not really a great idea, and revert the code back.
- I’ve noticed an hard to hold desire, when writing a piece of code, to rewrite it more succinctly because you just remembered that there’s a function in the core library that does exactly what you’re trying to do. I’ve rewrote functions multiple times from using
cond->>and then go back to
- Sequence functions on strings do not work in the way I was expecting. They all return a char array, so (concat “hello” “ world”) won’t give me the result I was expecting. Then I figured there’s `clojure.string
- Since I am still missing the “muscular” memory for the core functions, I had the clojuredocs website opened all the time, looking up functions, usages and doing small tests before writing the actual code
- Apparently there are some situations where you have to please the compiler. The multi method dispatcher appears before — so that the subsequent function can use it; then the singular methods can be defined later. This specific case is a circular dependency so order matters. I wish the compiler would figure that out on its own but I understand that in Clojure the reader is single pass. I just wish I’d have know that earlier :)
Here are the two big ones:
Setting up the cognitec test runner took a while. I was not familiar with it, and although it has a decent documentation it took some time to make it run correctly. In particular I had to figure out the class path convention with filenames, the extra-paths to add in deps.edn, the namespace that has to end with “-test". While I haven’t really been counting the time, I feel I’ve spent somewhat between 25 - 35 minutes on this.
This was the worst. When I finally got used to the idea of keeping the REPL opened forever, it just hit back to me very hard. It appears that the REPL does not reload the dispatching multi method function (it’s cached?), so no matter the changes I was doing, the REPL just would not pick them up. I haven’t been able to understand why for very long time and I ended up disassembling the entire program chasing an
ArityExceptionthat I simply was not there. I figured exclusively because I closed the REPL one more time by mistake and when reloading, it worked again. Suspicious, I googled the issue and got some confirmations. I do not know how much time I spent on this, but it was significant for sure.
Believe me, when I figured this one out I was undecided whether throwing the computer or myself from the window :)