Clojure Tip 💡
semantics over syntax
He said that they would have rather use an existing library, but in their research, they felt that no library managed to target the right layer. There were libraries a layer below the command-line tool, which give you lots of control, yet require you to become the pipeline yourself. Your code is low-level byte-marshalling instructions, handling interrupts when new frames of audio are ready to move to the next step in the pipeline.
It took a lot of work from Ryan and his team to research the actual model that ffmpeg uses internally. It’s quite a rich model, but it’s readily accessible only to those who use ffmpeg a lot. They then went through and experimented with representations of that internal model. They found one that seemed to maximize ease of use while maintaining high accuracy. Then they devised a way to serialize the model down to linear ffmpeg command-line options.
Takeaways from the story
Understand the model You’ve got to understand the thing your are modeling very well in order to write a good representation of it. This seems obvious, but I don’t think people practice as much as the obviousness says they should. Ryan was lucky that the model was created by people and documented. Many phenomena in the world are not yet modeled and so you have to play scientist to model them.
Iterate Good software design, like any kind of design, is about exploring a design space. It’s very hard to know ahead of time how software will feel to use before you’ve written it. We don’t allow ourselves enough time to try different implementations and throw most of them away.
Semantics, not syntax Notice that Ryan’s team aimed to model the correct meaning of the command-line arguments. He didn’t just focus on making the syntax more convenient. Most programmers would say that the reason ffmpeg’s options are hard to understand is because of the syntax. That’s part of the truth. But it’s not because they’re highly abbreviated. It’s because they don’t reveal the semantics like some other syntax—a diagram, for instance—would. Focus on the meaning and the a nice syntactic representation may reveal itself.
Fessonia is a great example of good software design making programming easier. They understood the domain and iterated toward a solution. But more importantly, they sought to accurately represent the meaning first, with a convenient syntax second. Too much software design advice is basically a style guide—constraints on the syntax. It doesn’t focus on capturing meaning, and iterating on what meaning to capture.
Our industry’s current discussion of good design is way too heavily focused on style over substance. It’s a bit like people giving advice about sentence structure and word choice but totally missing character development and theme exploration. Rhyme and meter vs imagery and meaning. They’re all important, but we’re focused to much on the stylistic elements.
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.
Also, if you just want to subscribe for a paid membership, I have opened them back up for the moment. Register here.
Stay healthy. Wash your hands. Stay at home. Wear a mask. Take care of loved ones.
Get ready to vote 🇺🇸
If you’re a US citizen, one of the most important things you can do is vote in the upcoming election. The lovely Clojurists at TurboVote have instructions for registering in every state. Today is the last day to register in many states, so follow their easy-to-use instructions and they’ll set you up. They also send you reminders tailored to you to learn where you are supposed to vote, what documentation you might need, and the dates of upcoming elections. It’s a great service! And it’s running on Clojure 🙂
Who you vote for is a personal choice. I don’t think this is a good channel for advertising any particular candidate. If you want more personal commentary from me (including more political stuff), you can check out my Twitter feed.
Clojure Challenge 🤔
Last week’s challenge
Please do participate in the discussion at the submission links above. It’s active and it’s a great way to get comments on your code.
This week’s challenge
Big change: Please submit your solutions as comments on the gist linked below.
The well-tempered ergodox
This week, we’re going to learn some guitar. Write a function that takes the string number and fret number and returns the note you get when plucking it. You can use the chart linked to at the bottom of this page as a guide.
;; third string, second fret (note 3 2) => :A ;; first string, sixth fret (note 1 6) => :A#
Open strings (no fret) are represented by
You can represent sharps with a
# and flats with a lowercase
There are obviously different ways to represent it. Try to find one that captures the underlying model of frets and intervals.
Please submit your solutions as comments to this gist. Discussion is welcome.
Big change: Please submit your solutions as comments on the gist linked above.