Wednesday, December 28, 2011

JavaScript Is Not A Language

Recently people presented arguments for and against using CoffeeScript. I felt the argument against was pointless and obviously wrong, but I couldn't figure out why, and I thought the counterargument for was kind of toothless and irrelevant. I've figured out the real issue.

The real argument for CoffeeScript is that JavaScript is not really a language.

Years ago I read something which explained, in my opinion, why Lisp has never achieved the mainstream adoption its passionate advocates believe it deserves. Lisp projects experience a degree of balkanization because everything is left wide open; you can use more than one object-oriented paradigm (potentially even at the same time), you write your own this, you write your own that, you write your own everything.

At Canada on Rails in 2006, somebody asked DHH why Rails didn't have a to-do list generator, and he said it was the wrong level of abstraction; to-do lists are always application-specific enough that any generator worth a damn would be as complicated as Rails itself, and probably as many lines of code. It's not something you can solve at that level of generality.

Lisp fails to recognize this, and rather than being a language, it is an abstract syntax tree manipulation system. An abstract syntax tree manipulation system is something every language needs and is built on, but it is not a language, any more than a skeleton is a person. Programmers who say Lisp is better than any other programming language are really saying that they prefer manipulating the abstract syntax tree directly vs. using somebody else's user interface for the same task, which is all a programming language ultimately is.

JavaScript is a Lisp with hideous syntax. Not surprisingly, it sees similar balkanization. Consider writing modular code. Do you use CommonJS, require.js, or something else? The question is idiotic; it should be answered at the language level. Do you choose which modular code-sharing system to support when you sit down to write your module? If you have three different solutions for writing modular code, you can't write modular code.

I use CoffeeScript for the same reason I use Ruby. Manipulating the abstract syntax tree directly is way more fun, but insufficiently pragmatic.

Update: I realize this blog post gets a bit idiotic with regard to technical details, and I've seen some Lisp fanatics ranting about what appear to be many entirely legitimate objections to the "JavaScript is a Lisp" meme, but I think my basic point here is pretty much dead on. Writing CoffeeScript just feels like using a language in a way that writing JavaScript just doesn't -- and I was doing drag-and-drop widgets before even Prototype existed.

Monday, December 26, 2011

Happy Holidays And All That

Wednesday, December 14, 2011

Comedian Louis CK Abandons Traditional Entertainment Industry Business Model, Makes Bucketloads

The experiment was: if I put out a brand new standup special at a drastically low price ($5) and make it as easy as possible to buy, download and enjoy, free of any restrictions, will everyone just go and steal it? Will they pay for it? And how much money can be made by an individual in this manner?

...this was a premium video production, shot with six cameras over two performances at the Beacon Theater, which is a high-priced elite Manhattan venue. I directed this video myself and the production of the video cost around $170,000.

The development of the website, which needed to be a very robust, reliable and carefully constructed website, was around $32,000...

The show went on sale at noon on Saturday, December 10th. 12 hours later, we had over 50,000 purchases and had earned $250,000, breaking even on the cost of production and website. As of Today, we've sold over 110,000 copies for a total of over $500,000. Minus some money for PayPal charges etc, I have a profit around $200,000 (after taxes $75.58). This is less than I would have been paid by a large company to simply perform the show and let them sell it to you, but they would have charged you about $20 for the video. They would have given you an encrypted and regionally restricted video of limited value, and they would have owned your private information for their own use. They would have withheld international availability indefinitely.

(PS: when he says

I want to thank Caspar and Giles at Version Industries, who created the website.

that is in fact a different Giles.)

Tuesday, December 13, 2011

Pixels Made Of Flammable Gas

via gizmodo. project originates with the Danish MIT

Seriously Awesome Live Drumming D&B

And this is just a tech demo! The drummer here is Michael Shack, who's working on the Netsky tour.

Sunday, December 11, 2011

CNN LED Ticker Tape Hacked?

Here in Los Angeles, CNN has a skyscraper -- I think it's their headquarters -- in Hollywood, at Sunset and Cahuenga. The ground floor showcases several big TVs running CNN, as well as a big LED "ticker tape" display running a constant stream of headlines and short, one-sentence stories.

I went by there yesterday on my way home from somewhere and saw the following two messages:

"GOP proves they do not care about consumers"

"It's sometimes a good idea to turn off the television if the news pushes your blood pressure beyond acceptable levels."

Either CNN got hacked in LA last night, or they've made a major change in editorial direction.

Wednesday, December 7, 2011

Firefox Vibrator API

I learned from HTML5 Weekly that Firefox has a new Vibrator API.

Tuesday, December 6, 2011

Fuck Yeah, Browser Sticky Pads

The Post-It Note will always be, for me, an icon of the "why didn't I think of that?" kind of brilliance that (like Rails) represents something which everybody needed -- and which anybody could have created -- a long, long time before the inventor actually made it happen. Thus, this product is noteworthy (heh) not just because if you know what it's for, you want one, guaranteed, but also because this is a Post-It Note type "why didn't I think of that?" product made out of actual Post-It Notes, making it a recursive Post-It Note.

Go, UI Stencils, go!

Monday, December 5, 2011

Why Is CSS Not Object-Oriented?

There's a brilliant but unreadable book called Pro CSS And HTML Design Patterns which attempts to analyze CSS and HTML and isolate design patterns, like the OOP classic. It fails and it succeeds. The author does identify commonalities and unifying principles within CSS, but these don't really qualify as "design patterns" as they don't have cohesive characteristics or nameable identities. In OO design, it's easy to understand what the Singleton pattern represents -- it's a single thing, instead of one of many. Nothing so comprehensible exists in this book.

I highly recommend this book, but as a mountain to climb, not as a silver bullet. The attempt to treat CSS and HTML like object-oriented software fails, because the DOM is just one massive object whose design cannot be changed, and CSS is not object-oriented at all. It is an incredibly coarse, brittle query language combined with an unimaginably complex set of decorating notations. Object-oriented CSS would be awesome, but faces tough questions. Which is the fundamental unit of CSS: a rule? a cohesive visual element on the page? the DOM tree a rule applies to?

CSS maps a tree of style rules to a tree of DOM objects. These mappings falter and frustrate, because mapping a tree to another tree is no task for human minds -- it's the whole reason compilers were invented -- but they also represent a tremendous improvement over the pre-CSS model, wherein a tag conveyed both styling and semantics.

This suggests an evolution, in which CSS compilers should ultimately exist, and indeed, some already do -- e.g., Front Page and Dreamweaver -- but they suck beyond belief, and the open source avenues to this destination are still very young.

Kyle Neath created a cool project called KSS which addresses the confusion CSS always creates. It's a simple and powerful system for documenting CSS. I think it's a step in the right direction, like Sass, but I also think that the world will be a much better place when we finally get CSS compilers built for grownups -- by which I mean people who could write the output code themselves, but have better things to do, like the intended user base for Rails generators or CoffeeScript.

KSS uses cohesive visual elements on the page as its idea of the fundamental unit of CSS:

You should document a rule declaration when the rule can accurately describe a visual UI element in the styleguide. Each element should have one documentation block describing that particular UI element's various states.

That sounds very object-oriented to me. The end result looks like this:

In keeping with this philosophy, KSS allows you to document an implicit object hierarchy with your section numbering:

KSS documentation is hierarchical in nature — any documentation blocks at [any point within the] styleguide hierarchy apply to the documentation blocks [beneath] that level. This means that documentation for 2.1 applies to documentation for 2.1.3.

For instance, you can cover "Buttons" in section 2.1, "Login Buttons" in section 2.1.1, and "Navigation Buttons" in section 2.1.2.

I plan to retrofit an old project with KSS in the next few days, firstly to get a better feel for it and secondly because I'm very curious if it helps me uncover an implicit object hierarchy which is already there in the code. I'll blog about it some more if I find out anything interesting.

Saturday, December 3, 2011

Four Books On Drumming

I got four books on drumming which I'm pretty excited about: two on fundamental skills and techniques, two on the specific types of music I'm most interested in. Stick Control seems to be a time-honored classic on snare drum rudiments, and Mastering The Tables Of Time had a terrific review:

the buzz is strong inside drum circles that this book is the "Stick Control" of the future, so I took the plunge and indeed, it was a revelation!

Meanwhile, Jungle/Drum & Bass For The Acoustic Drum Set addresses the specific rhythms of my favorite form of electronic music, and The Breakbeat Bible aims at a comprehensive overview of breakbeats, including hip-hop, soul, drum & bass, acid breaks, and even a chapter on dubstep. Both these books falter a little bit -- one of them calls Goldie "DJ Goldie" and the other calls him "Goldi" -- but both feature transcriptions of real, credible work from people like Caspa, Rusko, PFM and Origin Unknown.

Friday, December 2, 2011

Tech-Trance Track: Shifting Bells

I tweeted this when I first created it, on September 1st of this year, but I want to blog a few notes about it. A book by Mark Butler prompted me to put together an experiment in shifting grooves back and forth across the beat. The rest of the track formed around that experiment.

To explain, Butler's book (among others) explains how the juxtaposition of groove and meter forms a major element in techno. (In the precise sense of the term.) Say you have the same rhythm, which mechanically repeats a hundred times, but in some repetitions lands ahead of the beat, in some repetitions lands behind the beat, and in very few repetitions actually lands on the beat. Some techno works by taking repetitive elements like that, stacking them in layers, and then moving them back and forth across the beat at various speeds, so that although every groove repeats with inhuman mechanical precision, the aggregate groove composed of all the stacked layers never repeats itself exactly and the variations therein give the machine sounds an ultimately human feel.

Butler is a professor of music theory and his book's pretty deep. In this track, I actually only use that approach for one part, because I after I got started, I kind of got distracted and made something else out of it. I didn't achieve the textured forest of metric juxtapositions Butler describes in his book, but I like the way it sounds anyway. If you listen to the bells, they shift throughout the track both in terms of their texture and in terms of their timing.