Last active
July 8, 2017 23:40
-
-
Save nickbauman/d10c102f95c16bf4fa7122ecbca604ae to your computer and use it in GitHub Desktop.
Go vs. Clojure: Habits of Thinking
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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