PurelyFunctional.tv Newsletter 373: Don't sweat the stack
From OO to Clojure Workshop!
Watch my free workshop to help you learn Clojure faster and shift your paradigm to functional.
Issue 373 - April 13, 2020 · Archives · Subscribe
Clojure Tip 💡
Don't sweat the stack
I was listening to the defn podcast and Martin Kavalar had a really interesting comment. He said that he spent a ton of time choosing the web stack he used. Compojure or something else? Jetty or Undertow? Middleware or interceptors?
But then, he said that it didn't matter. It's so easy to change your decision, you should just pick one. I really think this is great advice, but why?
I think it mostly has to do with the immense success of the Ring Spec and Clojure's philosophy of simplicity.
The Ring Spec is basically a lingua franca for all web libraries in Clojure. It's made for handling web requests on your server, but even some clients use a very similar data structure. And even competing web models, like Aleph and Pedestal, use the keys defined in the Ring Spec. That means that switching between them could be relatively isolated from your application logic.
The philosophy of simplicity also plays a big role. The ecosystem has carved out small, simple jobs for libraries. For instance, routing, at its simplest, is just a function from path to route name, perhaps with some parameters parsed out of the path. This job doesn't change much from library, so swapping them out is work but it's not difficult.
So, because it's easy to change between libraries, why sweat the decision? Just pick one that looks good now and move forward. If it turns out it was the wrong decision, swap it out for a better one.
Quarantine update 😷
I know a lot of people are going through tougher times than I am. If you, for any reason, can't afford my courses, and you think the courses will help you, please hit reply and I will set you up. It's a small gesture I can make, but it might help.
I don't want to shame you or anybody that we should be using this time to work on our skills. The number one priority is your health and safety. I know I haven't been able to work very much, let alone learn some new skill. But if learning Clojure is important to you, and you can't afford it, just hit reply and I'll set you up. Keeping busy can keep us sane.
Stay healthy. Wash your hands. Stay at home. Wear a mask. Take care of loved ones.
Clojure Challenge 🤔
Last week's challenge
The challenge in Issue 372 was to find subsets of numbers that sum to a given number. You can see the submissions here.
You can leave comments on these submissions in the gist itself. Please leave comments! You can also hit the Subscribe button to keep abreast of the comments. We're all here to learn.
There was an error in the description in the newsletter. I've corrected it on the submissions gist.
This week's challenge
Tic Tac Toe
Write a function that takes a completed tic tac toe game and returns the
:draw. The tic tac toe game is a vector
of vectors containing
:o, or nil for an empty space. You can
assume the game was played correctly.
(winner [[:x :o :x] [:o :x :o] [:o :x :x]]) ;=> :x (winner [[:o :o :o] [:o :x :x] [nil :x :x]]) ;=> :o (winner [[:x :x :o] [:o :o :x] [:x :x :o]]) ;=> :draw
Thanks to this site for the challenge idea.
You can see the instructions here. I might update them to correct errors and clarify the descriptions. That's also where submissions will be posted.
As usual, please reply to this email and let me know what you tried. I'll collect them up and share them in the next issue. If you don't want me to share your submission, let me know.