7 ms·
Simulating Machines in Clojure
- rcgorton 6y agolet me understand this. It takes how many MBs of source code to interpret 1.00+4.00? And how many more MB of code to get it correct? I strikes me that 'Closure' is 'DumbAss'
- deleted 6y ago[deleted]
- grimgrin 6y agoit's a cool way to think about what we take for granted, and definitely the author had a blast reading SICP
- stopachka 6y agoThanks for the kind words grimgrin!
- zrkrlc 6y agoDid you do the entire book in Clojure or just this part? Thinking of forking SICP Distilled and was wondering if there's a reason why it stopped other than the author losing interest.
- stopachka 6y agoWe went through the whole book :) https://github.com/nezaj/clj-sicp https://github.com/nezaj/clj-sicp < here are the answers to the questions we chose to do. Hope it helps in your adventure!
- rtpg 6y agoI think this is a fun article, really fun little rawing. But "imagine an SR latch!" is always funny to me in these kinds of explanations. The base circuitry for electronics have really powerful primitives, but if you are coming from first principles then it's like.... where did you get this from? In itself it's a really non-intuitive device, and only starts making sense in a larger context. It's of course also what we actually do, just I think not something anyone would ever come up with in a vacuum if they were thinking "how do I build computers"
- stopachka 6y agoIndeed rtpg -- going deeper, these latches did trip me up! You may enjoy this question on SE: https://electronics.stackexchange.com/questions/524618/how-does-electricty-flow-in-a-flip-flop-circuit-i-cant-understand-how-memory-b https://electronics.stackexchange.com/questions/524618/how-d... -- ended up getting a great answer for how this worked beyond the abstractions I was comfortable with. Plan on using what I've learned to write something about simulating RAM -- that may get us closer to building up the base circuitry
- alexott 6y agobtw, do you have the RSS or Atom feed for your blog? I want to include your Clojure posts into https://twitter.com/planetclojure https://twitter.com/planetclojure - drop me email to alexott at gmail, or create a pull request to https://github.com/ghoseb/planet.clojure https://github.com/ghoseb/planet.clojure thank you
- FartyMcFarter 6y ago> If you were dropped in a forest…you could create your own computer. Could you really? I've heard of fun things like water-based logic gates, but even with primitive elements like that it doesn't seem at all easy to come up with anything even mildly useful. Another option would be pulleys: https://www.youtube.com/watch?v=CNbScb8v-MI https://www.youtube.com/watch?v=CNbScb8v-MI
- filoeleven 6y agoOne thing that stuck with me from a good Clojure book(1) is that using < is greatly preferable to using >. Coming from an OO background and reading left-to-right, this made sense to me: list the args from smallest to largest. (< 1 2 3) ;; true is a lot more intuitive to me than (> 3 2 1) ;; true even if one or more of those literals is replaced with an argument. It’s especially apparent with the two-arg use of the function. This is one of the few places where I still feel like infix notation has an advantage. This isn’t even a nitpick about the article, just a remark about some cognitive dissonance seeing > used here. (1) Maybe Elements of a Clojure? Not sure that’s it; it was a book referenced on HN which has a whole chapter on naming things.
- jb1991 6y agoThis is true in other languages as well, even Clojure's polar opposite, C++, where operator< is canonical tool used for sorting and other things.
- fulafel 6y agoThe historical preference of < over > seems to be widespread in programming languages, here's a credible sounding explanation of the origins: https://stackoverflow.com/a/12146965 https://stackoverflow.com/a/12146965
- mehrdadn 6y agoRegardless of the origins, < is just a more natural operation than >. I kind of mean that both figuratively and literally: the most "natural" numbers are the "natural numbers", which follow 1 < 2 < 3... and not 1 > 2 > 3...
- fulafel 6y agoI see what you mean. But if we consider endianness and reading direction arbitrary conventions does it still hold? Maybe it does, since in your latter example the reading direction is inverted in any case and endianness applies only intra-number.
- ngcc_hk 6y agoWhilst I like the separation of () and [] etc I am not sure I like the recursive syntax or requirement. A bit ugly.