fogus: Code Riffs
Code Riffs
Jan 6, 2023
As soon as upon a time I used to be deep into the MD/DC/VA space punk scene, and consider it or not I performed in my share of bands and took part in my share of punk exhibits — each within the crowd and typically even on stage. I look again on this time fondly, however to be trustworthy I can’t say that I ever contributed any music to the universe of music that was value listening to. That mentioned, whereas I can’t declare to have been a gifted song-writer, like many aspiring musicians I did uncover my fair proportion of riffs alongside the way in which.
A riff is an fascinating little musical phrase that one typically comes throughout while taking part in round with a guitar in an off-the-cuff style. Fairly often riffs kind the seeds of what turns into fully-realized songs. Generally these songs are good and typically they’re not, however normally they’re grown like crystals from the unique musical fragment discovered on the fret-board. For musicians, each training and aspiring, the riff represents a universe of potential out of which any variety of potential works of musical artwork could spawn.
A number of years in the past I devised a phrase that I known as Code Painting describing supply code that: advised a narrative, was often not typically helpful, was superbly summary, and created within the spirit of exploration. Not like a code portray, a code riff is extra atomic and sometimes addresses a singular notion. If I had been to characterize the attributes of a code riff then maybe the next will suffice:
- A code riff exists impartial to a undertaking narrative
- A code riff needn’t be helpful
- A code riff is usually “discovered” throughout the act of playful programming or sprung forth from one’s thoughts
- A code riff ought to be lovely, summary, and as amusing if potential
- A code riff ought to invoke Huh? A ha! Ha ha! 1
In my time I’ve created my share of code riffs; some that impressed one thing extra and a few nonetheless ripe with potential. If you happen to’re fascinated about some code riffs then just a few can be found on Github as Tori Lisp, Evalive, and Unfix and moreover the break
macro in chapter 17 of The Joy of Clojure.
Right here’s a Clojure code riff from a presentation that I gave a few years in the past known as “The Magnificent Seven”:
(def NIL ((fn [x y] (if (= x y) x)) = (= = =)))
(def CAR (fn [[h & _]] h))
(def CDR (fn [[_ & t]] t))
(def CONS
(fn [h t]
(fn ([] h)
([_] t))))
(def FIRST (fn [s] (s)))
(def REST (fn [s] (s NIL)))
(FIRST (CONS 1 (CONS 2 NIL)))
;;=> 1
(FIRST (REST (CONS 1 (CONS 2 NIL)))
;;=> 2
Do you will have any code riffs to share?
:F