Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Go vs. Clojure: Habits of Thinking
The goal is to insert an integer into an ordered list-like thingy.
Here's Go.
// Given g
g := []int{1, 2, 3, 4}
// Insert 44 in the middle of it
append(g[:2], append([]int{44}, g[2:]...)...)
Here's Clojure.
; Given g
(def g [1 2 3 4])
; Insert 44 in the middle of it
(into (subvec g 0 2) (into [44] (subvec g 2)))
Some people prefer the Go syntax.
Some people prefer the Clojure (Lisp) syntax.
FOR THE SAME REASONS: Each side claims their version is simpler and clearer.
How is this possible? Consider languages very much like Go have come and gone
numerous times starting with Algol. There are scores, perhaps hundreds of them
littering the history of computer programming, each one sweeping away the last
in popularity. Lisp has barely changed and is still in use from its inception.
It's a lesson that nothing changes slower than habits of thinking. And if you're
dissatisfied and decide to restart a thought (value) system using the same initial
states (the same habits of thinking), you often end up in the same place in spite
of many seemingly "unpredictable" changes.
Maybe the constant reboot is a sign that the system has an intrinsic flaw.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment