Thursday, February 21, 2013

Quick Drum & Bass Snippets

Since 2009, I've done an on-again, off-again "new mp3s every day" thing on Twitter under the name @djgoatboy.

I've started putting some of the better ones on my SoundCloud account. Here's a pair from this fall:

Tuesday, February 19, 2013

The Myth Of Convention Over Configuration

Rails claims that convention over configuration is one of its core principles.

When Rails first arrived, in many instances, it took the greatest ideas and most common use cases of Web development, streamlined them, simplified their developer interface, and repackaged them within cleaner APIs.

There are certainly exceptions, but at that time, "convention over configuration" accurately described a sizeable majority of Rails design decisions. Calling convention over configuration a core principle of Rails was, at that time, in my opinion, entirely accurate. In its early incarnations, Rails replaced configuration with convention in a very literal way — for instance, using code generators to automate database migrations, because there's nothing more ridiculous than endlessly typing the same things over and over again.

When Rails imposed its new convention of RESTful APIs, back in 2006 or so, it departed from this, while still using the same phrase to describe it.

"Convention" comes from a Latin word, convenire, also the root of words like "convene" and "converge." Convenire means to come together. In modern usage, and since at least the year 1440, the word "convention" has not just signified an agreed-upon norm, as in Rails, but also a process of having arrived together at the agreement which ratified that norm.

In other words, it is literally impossible to impose a convention on a community. It is a contradiction in terms, Orwellian doublespeak, and the human-language equivalent of a syntax error.

Fast forward from 2006 to today, and you find Rails often imposing "conventions." In the case of RESTful APIs, this was great. CoffeeScript is a more recent example, and another great design decision in my opinion. And then you get "Rails Is Omakase." (original text here, performed as a comic monologue here)

If you want to use words in English to represent the concepts that they actually mean, with precision, specificity, and integrity, and you've heard that Rails values convention over configuration, but you don't know the secret Orwellian "real meaning" of that phrase, then "Rails Is Omakase" makes absolutely no fucking sense at all. It is literally insane. A person who valorizes convention while disregarding the opinions of other people is an impossible contradiction in terms.

For example:



And what are we supposed to call the incredible transformative influence that Rails has had on so many other frameworks in so many other languages? Should we refer to it as a phase in the history of computer science in which it became conventional to use unconventional conventions? It simply fails at being words.

However, if you know, as all experienced Rails developers do, that

convention over configuration really means curation over configuration,

and that the entire Rails culture has just been using the wrong word for almost a decade now, then "Rails Is Omakase" makes perfect sense. It might still seem a bit silly or overblown, but the words have meaning again.

Curating means picking and choosing the best options. When you go to an omakase restaurant, the chef not only prepares the meal but curates it from the available alternatives. When you read Ruby Weekly or Hacker Monthly you're reading curated links or articles. And when you use CoffeeScript instead of JavaScript because Rails automates that decision for you, which was absolutely NOT a conventional choice at the time, you benefit from a curated technology.

Rails once valued convention over configuration, a very long time ago, but today values

curation over configuration.

Let's just all be honest about that.

Naming is one of the hardest problems in programming, but it's worth it to get names right. Good naming enables you to have discussions which are both precise and accurate. We refactor our code. We should refactor our terminology as well.

I realize that David Heinemeier Hansson has contributed more and better code to the world of open source than I have, or likely ever will, but I think there's also value in using words without breaking them.

An All-Time Favorite Cat GIF


Sunday, February 17, 2013

I Fasted For 7 Days

From Feb 2nd to Feb 8th, I ate no food at all, consuming only water. I am not a doctor; none of this is medical advice. But people have asked me about it, so I'm going to explain a little.

Geeks will have an easier time understanding fasting than regular people.

Garbage Collection

I got most of my information from a book by Dr. Joel Fuhrman, a doctor who's guided very large numbers of different patients through fasts. The book explains that fasting longer than 3 or 4 days triggers a protein-sparing process, which geeks can understand as a garbage collector.

During the first few days of a fast, the body will burn muscle for glucose, causing muscle loss, but after those few days, the metabolism switches to a different method of generating energy, and although this process also uses cells from the body as fuel, the garbage collector prioritizes which cells.

The garbage collector first burns fat. I lost at least 20 pounds during the week I fasted. After it finishes burning the available reserves of fat, it then progresses to various types of useless cells. As an example of useless cells, some fasters have literally seen warts and moles disappear, or even simply fall off their bodies. But there's a much more dangerous type of useless cell which the body will recycle first.

I have coronary artery disease, which means I have a large number of cholesterol lesions in my arteries. Cholesterol lesions consist both of actual cholesterol, and of cells which bind that cholesterol to the walls of the arteries. In a long enough fast, the garbage collector recycles these cells, releasing the cholesterol and using it as fuel.

Although not strictly necessary, this would have obvious benefits for me. Unfortunately, I had a lot of fat to burn first, and I only fasted for a week, so I probably did not get to this stage in the process.

Why Only A Week?

I had hoped to go a full month, but I was aware it might not get that far; I kind of looked at this fast as a trial run. I've done similar trial runs: for instance, I did several small fasts in 2010, either 24 or 48 hours each.

But I drew this fast to a close after only a week because of unexpected physical reactions — specifically, acid indigestion and vomiting. I only vomited twice, on day 5 and day 7, and the book (along with countless discussion forums on the web) had already told me that throwing up a little on the 3rd or 4th day happens in a few cases. But this happened a few days later than predicted, and neither the book nor any forum said anything about acid indigestion.

Eventually I tracked down a forum post from somebody in a very similar situation, on Dr. Fuhrman's private forums, with a reply from Dr. Fuhrman himself. The TL;DR version: acid indigestion that far into a fast usually indicates toxins in the liver, and if it happens, and accompanies vomiting, you should end the fast. Which was kind of what I had been thinking at the time anyway.

Nutritarianism

"Toxins," in this context, can include many things most people have in their systems, including biochemical byproducts of digesting meat. You have to achieve a good level of nutritional excellence before you fast, and "nutritional excellence" has a very specific meaning here. Dr. Fuhrman advocates nutritarianism, which is (basically) a rule of only eating foods with very high nutrient content. No meat, no oil, no white bread, no sugar, no alcohol; nothing that does not have a high ratio of nutrients per calorie. It's a simple system, and has worked flawlessly in the past for me, as well as thousands of other people, but many people seem to consider it extreme.

When I first discovered nutritarianism, it improved my health in a staggering number of ways. Most obviously, I lost 82 pounds — with maybe the first 60 or more coming off inside of 6 months — and I kept it off for a year or two, but after a while I got bored and started eating in restaurants like anyone else, and then I gained the weight back. More recently I've gotten back on the wagon — mostly. I've also been sneaking in samosas, fried plaintains, mushroom tacos, olive oil, and bits of chocolate here and there, which is probably what undermined the fast.

I got the impression from brief online conversations with Dr. Fuhrman, back in 2009 or something, that fasting for 7 days at home, on your own, without medical supervision, is a smidgen risky but basically OK. So that's what I did. However, if/when I actually do a bona fide month-long fast, I'll definitely go with medical supervision instead. It's just such a weird experience that it's good to have a guide.

(And again, please remember, this is not medical advice.)

What Fasting Was Like For Me

Fasting weakens you. After a week, I could only stand up for a minute or so at a time. You also become a bit more susceptible to cold. Your body and your energy levels work differently than they usually do, so it's little disorienting, but other than that, it's pretty easy. I wrapped myself in a blanket, watched a lot of TV, and did a little reading. (I wanted to do it the other way around, but reading takes more mental energy.)

Since I did research before doing my fast, I knew I wouldn't have much energy for anything. When my acid indigestion began, it was uncomfortable, but up until that point, the worst part of the experience was being bored, and spending too much time on Twitter as a result.

The actual start of the fast was easy. It took discipline, but it wasn't uncomfortable. Eating the nutritarian way results in very stable blood sugar. It's very easy to go without food for a few extra hours if you're a nutritarian; there are no hunger headaches, there's no feeling of physical weakness, nothing like that. Hunger itself is very manageable if you have stable blood sugar and you aren't eating anything toxic.

In fact, the last time I got on an airplane, I fasted all day. I started the fast in the morning, because I knew it would be less effort than trying to find food with a very high nutrient-to-calorie ratio in an airport or on an airplane. When my flight was delayed by about eight hours (not even kidding), I just continued the fast all the way through to when I finally arrived at my destination, where I already knew a member of my family would be waiting with a big bag of apples, oranges, and bananas. A planned four-hour fast turned into a twelve-hour fast that day, roughly, and I hardly even noticed.

Of course, the week-long fast was different, but not a lot. After several days of no food, you might expect hunger to have turned into this overpowering sensation for me; in fact, I hit a maximum in terms of perceived hunger at the end of the second day, and then it just stayed at that level the entire time. Pretty soon, it faded away like background noise. I did spend an afternoon dreaming up weird recipes to try as soon as I could eat again, and I caught myself absent-mindedly opening up the fridge a few times, but other than that, I didn't think about it as much as you might expect.

At the risk of stating the obvious, I would never in a million years have tried fasting for an entire week if I hadn't already achieved this nutritarian "superpower." If you eat burgers and bread on a daily basis, don't expect to leap into a week-long fast. It would probably be a nightmare.

(And if you're considering a fast, please do assiduous research first, and talk to an actual doctor with relevant training. This is a long post, but I'm only looking at the tip of the iceberg here.)

Ending The Fast

Just like the fast itself, recovery also took a week. I think ending my fast should have only taken three or four days, but it stalled due to a problem. The first few days, you eat only slices of orange or some kind of juicy fruit. Then you add lettuce, then you scale up to meals.

Unfortunately, I bought my orange slices from a store I can't recommend. The slices come in little plastic containers with expiration dates. For a guy who was too tired to stand up, pre-sliced oranges should have been awesome, but they weren't. I got three containers, and on the third, the expiration date was wrong; the oranges inside were fermented and inedible. It was gross, and dangerous.

Again, I'm not a doctor, but Dr. Fuhrman's book mentions the dangers of eating fermented fruit while recovering from a fast. Long story short: it would have sucked. There would even have been a risk of hospitalization, if I understand correctly.

I had to switch to carrot juice and fruit juice, and that actually cost me at least a day. I also went slowly with my recovery on purpose, partly to be sure nothing went wrong, and partly just because I got full very easily. At one point I had to take a nap because I had eaten an entire bowl of soup. It was a small bowl.

My strength returned pretty rapidly, but even after I started back on full meals, it was several days before I could eat normal portions without feeling monstrously overfed. I'm gaining back a little weight, which is very normal post-fasting, especially as your first few days burn muscle and you want to build that back up again. Anyway, the fast is over now, and I'm following nutritarian dietary rules 100% now too. I hope to blog more about this in the future.

Health Is Cybernetic

Cybernetics, a field whose rise accompanied the invention of object-oriented programming, is the study of messages. If you get nothing else from this blog post, I hope you get that health is cybernetic.

For instance, eating a candy bar is not just unwise because that candy contains sugars, which will be inside you once you've eaten the candy. Your body's not a passive bag; it's a complicated organic system full of counterbalancing ecologies. The blood sugar spike which results from eating a candy bar not only adds physical sugar to your internal chemical inventory, it also acts as a message to many internal systems.

Since the human body evolved in a context where sugar was scarce, you probably don't want to actually send out any of the messages which you can trigger by rapidly elevating your internal blood sugar, unless you're actively attempting to worsen your own health. Depending on other health factors, a rapid blood sugar elevation could be the biochemical equivalent of this:

sudo rm -rf /*

If you're like me, you've wondered all your life why the human body does not implement periodic garbage collection. The body creates tons of unnecessary cells. Why doesn't it clean them up? It does. However, you have to trigger that process by sending a particular message to your internal systems, and you send that particular message by going without food for several days.

This is probably because food scarcity happened much more often in every other stage of our evolutionary history than this one. But don't ask me why; it's a legacy system. Be glad it accepts commands at all.

Sorry, No Arguments

Please no critical tweets or flames on Hacker News. I don't read comment threads, and if your tweets annoy me, I'll just block you. Please just show some self-respect and save me the trouble. This also applies to anyone concerned for my health. If you want me to disagree with Dr. Fuhrman on any health-related topic, it probably won't happen. His books have already saved my life at least once.



PS: I Am Not A Doctor

You got that, right? Just in case: I am not a doctor. Happy to answer polite questions, but my advice to you, in every case, will ultimately be "ask Dr. Fuhrman."

Although probably unnecessary, I've prepared a Venn diagram to illustrate.


Tuesday, February 5, 2013

Node.js Hatred Reveals Significant Dysfunction In The Ruby Culture

A hostile ignorance regarding Node.js seems, to me, to be a pervasive dysfunction in the Ruby culture. For example, Avdi Grimm wrote:

I do share the opinion of a number of my colleagues that using a reactor-based framework in a language lacking native fibers, coroutines, continuations, or threads leads to messy code.

Among the most obvious problems with the above: Node.js is not a framework. A more subtle problem: these remarks came, if you can believe it, in the context of an apology for harshing on somebody's code - specifically, a naive but very well-named and perfectly harmless command-line utility written in Node. Because it was a command-line utility, there was no "reactor-based framework" in question in that code at all. Another subtle problem: Mr. Grimm has gone on record with the opinion that ActiveRecord can lead to messy code, yet I've never seen him laughing at people for using Ruby just because a lot of Ruby code involves ActiveRecord.

In the same way that these remarks about a "reactor-based framework" were completely irrelevant to the matter at hand, Tony Arcieri leveled completely irrelevant criticisms against a blog post I wrote.

In my blog post, I said:

I think listening to Node.js hype at all is foolish.

Mr. Arcieri devoted paragraph after paragraph to Node.js hype in his post, and then told me on Twitter that his post was a point-by-point rebuttal of mine. (In fact, his post frequently argues against points raised by other people, and says so.) He also spent several paragraphs arguing against the position that Rails is no good for JSON APIs, and then very strongly implied that I advocated this position, supplying as proof an unrelated Twitter conversation which contains no words about JSON APIs at all:



The idea that Rails 4 operates on a foundation free of technical debt, by the way, is not just laughable for anyone who's read my own book, Rails As She Is Spoke, it's also hard to take seriously coming from the author of Objects On Rails.

I first learned of the Ruby culture's surprising difficulties with reading comprehension when I described prominent Rubyist Chad Fowler as a werewolf. I used the metaphor of the game Werewolf, which Mr. Fowler had popularized at that time, and which every Ruby developer who went to a single conference that particular year had heard of, thanks to Mr. Fowler popularizing it. This game involves killing werewolves. No actual players die, because it's a game. I recommended that the werewolf in question, namely Mr. Fowler, be killed - in the sense of the game, which literally every prominent Rubyist knew about at the time.

Nonetheless, the community responded by taking my murder recommendation completely literally, despite clearly recognizing that when I said the man was a mythological, supernatural, demonic wolf monster, I was speaking metaphorically. The blog post frequently mentioned the werewolf metaphor, and included several gigantic pictures of werewolves. I still get shit about this today from people who seriously think I wanted to kill the guy in real life.


Apparently this picture is easy to miss.

In retrospect, I regret my post, and consider it immature, although I certainly stand by the actual substance of its accusations, the most important being that Mr. Fowler insulted one of my open source Ruby projects in a very disingenuous way, and that he did this less than 24 hours after he had asked me to review his book. However, it was not a wise thing to post, and the major reason it was so unwise of me to post it: very few responses to it showed any sign of rational analysis whatsoever. Likewise, this hostility to Node.js passes, in both the instance of Mr. Arcieri's blog post, and Mr. Grimm's, into the realm of unreason, by means of faulty logic and irrelevant tangents.

In the instance of my misbehavior, it's easy to see how emotion got in the way of precise reading and rational interpretation. But in the case of Node.js, I find it harder to understand, and I find it impossible to describe as healthy. I want to eradicate this mindless hostility, since it inhibits logical discussion, but I don't know how.

However, I do know an easy workaround. Most Rubyists (myself included) already prefer CoffeeScript to JavaScript. Many other languages compile to JavaScript besides CoffeeScript. ClojureScript and Fay are two of the most interesting. ClojureScript, obviously, is a Clojure implementation which compiles to JavaScript; Fay is a Haskell implementation which compiles to JavaScript. ClojureScript is useful enough that it powers a fascinating new text editor called Light Table.

as of Light Table 0.2.0, the entire thing is now built on top of ClojureScript and the only Clojure left in the system is used for evaling Clojure. With the help of the Node-Webkit project out of Intel, we now use Node.js for all of our platform interaction and we rely on chromium to present our UI. There are many reasons we went down this path and ultimately it has worked out really well for us. ClojureScript, though it has had its moments, has generally been a joy to use and has allowed us to keep our codebase incredibly tight and small despite all of the stuff we've managed to build into LT.

Neither ClojureScript nor Fay replicates their "parent" language with 100% accuracy, but (like CoffeeScript) both provide a more enjoyable syntax than JavaScript, and a subculture with a more mature and sophisticated outlook than the JavaScript culture at large. These seem, to me, to be the major complaints which prominent Rubyists have leveled against JavaScript. I consider both these complaints legitimate, but in the year 2013, I have to call it both provincial and backwards to continue remaining ignorant of these solutions. Criticizing Node.js, without understanding the many ways you can use it, does not seem to me to constitute any useful kind of conversation.

If you're snobbish about JavaScript, I can understand. In many ways, it's a fucked-up language. But Unix is full of utilities which are quirky beyond reason, yet which are nonetheless incredibly useful to learn.



And although it might be fucked up in some ways, JavaScript's not a language whose community is infected with unreasoning hatred, which, at the risk of being repetitive, is always a sign of dysfunction in programming language communities, in my opinion.

More importantly, YOU DON'T HAVE TO USE JAVASCRIPT **EVER** IN ORDER TO BENEFIT FROM THE INCREDIBLY USEFUL V8 JAVASCRIPT INTERPRETER.

The specs I get when I use CoffeeScript and jasmine-node are mind-bendingly fast. They make RSpec look like a steam engine trying to compete with a Lamborghini, and this remains true even when I disentangle Rails from my RSpec specs.

So if you're snobbish about JavaScript, get over it, and just use CoffeeScript, ClojureScript, or Fay instead.

I played with Node.js out of curiousity, like a programmer with a healthy attitude will do from time to time, and I learned a few things. So I created an ongoing series of videos about how to make music with CoffeeScript and Node.js. I'm porting a Ruby project to CoffeeScript in the process of making these videos.

The Ruby project used MIDI to trigger drums in a drum machine, and used probabilistic AI to enable the software to improvise original drum rhythms. So far, the CoffeeScript version can play back pre-programmed drum rhythms (and basslines, and melodies), but I haven't set up the AI stuff yet. Nonetheless, I can already say that the Node.js/CoffeeScript implementation of this Ruby software is completely superior in two important respects.

First, Ruby is slower, even today. When you write software that performs music, you want it to be fast. You need it to be fast, because timing is an essential element of rhythm. Node.js is very, very fast.

Second, I wrote this project in Ruby 1.8, and Ruby 1.8 used a more primitive syntax for lambdas. The Ruby version of this project used lambdas a lot. CoffeeScript, since it is really just JavaScript with less typing, enables you to treat functions as objects without any special lambda syntax. I haven't ported that part of the Ruby project to CoffeeScript yet, because these videos are just a side business, but I know for a fact that when I do, using functions as first-class objects will make my life much easier. I had to alias lambda to L to craft a pseudo-syntax, because I used lambda so much, and the effect on my code was not good.

(Although the Ruby 1.9 syntax for lambdas is more powerful, it is still pretty damn weird, and the CoffeeScript code will still be much more elegant and readable than a Ruby 1.9 implementation would have been. And lambdas remain a less flexible concept than functions as objects.)

I realize that many people use Node.js for many other things, and that building MIDI software is not the most common use case. It's always surprising the range of useful applications which a Turing-complete language can provide. Nonetheless, I find hatred tedious and useless, and I very much wish I did not ever see it anywhere near Ruby.

That's because I still use Ruby a lot, and I still think it's awesome. I praise Rails quite a bit in my book, despite the fact that I also criticize it. Any realistic appraisal of any technology will involve both criticism and praise. I think the same way about Node, and I don't understand why other people don't do the same.

In the words of why the lucky stiff:

when you don’t create things, you become defined by your tastes rather than ability. your tastes only narrow & exclude people. so create.

(And if you're creating music, check out my videos. ;-)




Update: Very soon after I wrote this, I realized how ridiculous it was, at this point, to be surprised by anything revealing dysfunction in the Ruby culture. But I still think we can aim higher.

Also, if you want to tweet anything at me about this, bear in mind that I've uninstalled all my Twitter clients for a few days, because I'm working on something. Sorry! I haven't disconnected my email, but that's mainly because I'm getting to the point where I only look at email every few days or so.

Sunday, February 3, 2013

New Track: Gemini (Moombahton)



I called it "Gemini" because it's basically two tracks in one. The two halves differ quite a bit, but blend a little too closely for a clear separation, sharing the same bass line and some similar elements. The second half steals a little mojo from drum and bass.

I started this track as a sketchpad to figure out an advanced tutorial on programming the Access Virus, a powerful but idiosyncratic synthesizer. It turned into actual music. I used a mixture of playing things live, MIDI sequencing, and licensed, royalty-free samples to make it. No code involved, unfortunately, although my code for music hacking is getting pretty good.