Programming With Less Than Nothing
49 points by xyproto
49 points by xyproto
I appreciate the website's JS code highlighter giving up 10% of the way through the final program.
Is there a awesome-like list of technical fiction? I remember reading a horror story about compiler bootstrapping, loosely based upon the idea of "trusting trust", the compiler affected by the virus leading to emergence of sentience or whatever.. it was quite intriguing; but forgot where I read it. Edit: rsaarelm on IRC found this story for me: https://www.teamten.com/lawrence/writings/coding-machines/ Now that I read it again, I feel a certain odd sense of empathy for the digital species described in it, slowly evolving with the help of human intellect.
Also, a collection of computing folklore in general; a good example of a lore, I suppose, is the story of Mel. Similarly, stories about hard-to-find-and-fix bugs, e.g. a bug that can only be observed depending on lunar phase or something, I can't find them now.
In this category: https://aphyr.com/posts/340-reversing-the-technical-interview. At the bottom the post links to other posts like this one, which are similar but in other languages. Each one gets better!
+1 Would love this!
The koan about “objects are a poor man's closures” comes to mind. Also qntm's horrifying story about mind upload, “Lena”.
Less about programming, but still adjacent, is "When Sysadmins Ruled the Earth" by Cory Doctorow
It's maybe not on the same order as more technically-focused stories, but I've always been very partial to The Codeless Code. There are 234 stories written in the style of Zen koans; the name is a reference to The Gateless Gate.
I started compiling a list of programming blog posts with esoteric prose a while ago: https://github.com/kaikalii/mystical-programming
For stories about hard-to-find bugs, there's the case of the 500 mile email and OpenOffice does not print on Tuesdays.
500mile.email is a pretty cool site that collects stories like the case of the 500 mile email.
I’m getting a bit tired of this type of story—even if the model of computing that’s shown off is cool.
Aaaah, here's my dose of professional humility for the day! well done
This is absolute self-promotion, but:
This article adopts the perspective on combinatory logic that is the most common among programmers: it emphasizes the construction of Turing-complete systems from SK, and it adds the bird book as further reading and as a naming scheme. In other words, it advertises combinators as a basis for theoretical computation and as a recreation (both of which they are).
But I feel I'd be remiss if I didn't also plug for the concept of combinators as actual programming tools. Combinators (as alluded to in the text) let you perform eta-reduction, that is, they let you eliminate names from your code without changing its sense. And that might make your code better!
Thus: here's a point-free version of Fizzbuzz. It uses the same elements that the text does, but it chooses names that are meaningful for programmers rather than logicians or mathematicians, And it doesn't use them to reconstruct the entire syntax and standard library of a programming language, but rather just to fill in the necessary bits. Hopefully if you squint you can see how they're related.
Finally, I've grabbed comb-cond from here—you can read there for a deeper treatment of the same topic.
Below, find in Janet an imperative, non-clever version of Fizzbuzz, followed by a helper function to perform cond with combinators, and then my own combinatory Fizzbuzz.
(use ./apcl)
(defn fizzbuzz
  []
  (each n (range 1 101)
    (cond
      (= 0 (mod n 15)) (print "fizzbuzz")
      (= 0 (mod n 3)) (print "fizz")
      (= 0 (mod n 5)) (print "buzz")
      true (print n))))
(defn comb-cond
  [& pairs]
  (fn [x]
    (label result
      (each [pred f] (partition 2 pairs)
        (if (pred x)
          (return result (f x)))))))
(defn fizzbuzz
  []
  (map (comb-cond
         (comp zero? (partial (flip mod) 15)) (comp print (constant "fizzbuzz"))
         (comp zero? (partial (flip mod) 3)) (comp print (constant "fizz"))
         (comp zero? (partial (flip mod) 5)) (comp print (constant "buzz"))
         (constant true) print)
       (range 1 101)))
(fizzbuzz)
In what ways would you say the above point-free take on fizzbuzz is better than the imperative one?
I would say the theoretical benefit of point free programming over imperative programming is that it can reduce the incidence of names, and in any given scope, ceteris paribus, fewer names is better than more.
I wouldn’t say that this example is better than the standard imperative version. But all of my work in this area is testing the hypothesis that some types of programs, and some patterns of function application, would benefit from it.
In this case, for instance, I might make the argument that in a language with syntactic currying and composition, a pointfree version would more effectively communicate the intent of the logic.