Categories
Programming

Remote Programming

From the BBC:

Wanted: 12 programmers to live on a remote tropical island for two months to do nothing but write code.

Applicants are being sought for the coding jamboree that will take place on an as yet un-named island.

Those applying will have to submit a proposal explaining what they will work on during the hackathon.

They will also have to complete a psychological evaluation to show they can live in harmony with other coders for the duration of the event.

Part of me thinks this would be a pretty cool way to just focus on whatever project you’re doing. Another part of me thinks island fever would set in after a few weeks. It’s one thing to not be distracted for a large chunk of the day. It’s another thing to pretty much remove yourself from it all for 2 months.

Categories
Programming

The Programmer’s Curse

It's Alive

Programmer’s Curse [proh-gram-er-s kurs] – When a professional programmer sees a problem they think “I can solve this by implementing ________”. They then go on to build something in a manner similar to a mad scientist in an old sci-fi movie.

It’s often associated with eccentric behavior, ingestion of caffinated beverages, late nights and repeated cursing during debugging because it’s “so close”.

Screen capture from the awesome Young Frankenstein

Categories
Funny Programming

Great Programming Book Review

I’m pretty sure this is just a joke…

Best Programming Book Review

Via: @LeeCash

Categories
Photo A Day 2011

Project 365 Week 42

Categories
Programming

On Dennis Ritchie

The past week there has been a ton of recognition for the contributions Steve Jobs had made to computing and society through his work. Steve Jobs was a household name. Dennis Ritchie however was not a household name. Despite this his work was amazingly influential on almost every aspect of our daily lives either directly or indirectly. Everything from the computer I wrote this blog post on to the server sending you this blog post involved his work.

Rob Pike best eulogized his work, copied below for posterity. An amazing legacy.

Categories
Programming

Budget Calculator Dice

When I was in High School somehow dice became popular for the 2000th time since the dawn of humanity. For some strange reason I felt the desire to build a little dice game in my TI 83 calculator in TI-BASIC. I had long forgotten about this, and recently stumbled upon it. I transcribed it to my computer recently since I don’t have one of those cables and decided to just throw it out there on the web.

Looking back on it, I could have written this a lot better 😉 . Regardless it’s a fun trip down memory lane. I believe I wrote most of this little gem while lifeguarding on a Sunday morning. Nobody drowned in the production of this code, I swear.

My favorite part may be the about text “DEPRIVING A VILLAGE SOMEWHERE OF AN IDIOT”. Someone at some point somewhere said that about me, and it stuck for years.

Categories
Programming

The Programmer, Like The Poet

So poetic in itself…

The programmer, like the poet, works only slightly removed from pure thought-stuff. He builds his castles in the air, from air, creating by exertion of the imagination. Few media of creation are so flexible, so easy to polish and rework, so readily capable of realizing grand conceptual structures.

– Fredrick P. Brooks, The Mythical Man-Month (Ch. 1)

Categories
Mozilla Programming Rants

Object-Oriented Masturbation

Doing some research for an upcoming installment of an infamous series of blog posts (to be released at an undetermined date) I’ve come to notice this annoyance. In general I like object-oriented programming. I think it allows you to take a complicated problem and produce simple, more reusable and easier to maintain code. Assuming the programmer is sane individual, and that sometimes is a leap of faith.

I’m not sure if there are programmers who feel the need to complicate things just for the sake of showing off (oh, look at me!), or if they legitimately don’t know any other way. I suspect a little of both. Perhaps the programmer thought it was possible the code would grow in complexity in the future, and just wanted to prepare in advance. I don’t know. But it annoys me.

I consider this abuse of Object-oriented programming to be Object-oriented masturbation since the only one who gets any enjoyment out of it is the developer who does it. Here’s a slightly exaggerated (though not far off) example of Object-oriented masturbation typical of what I’ve seen many times before:

Objective

Sum two numbers and print the result in the format “The answer is: X” where X is the sum of the two numbers.

Correct (sane) Answer

// This is the simple, obvious answer
function sum(x,y){
    document.write(‘The answer is: ‘ + (x+y));
}
 
// To run:
sum(1,1);

Arguably, you could do the math and store in a variable if you are squeamish to doing math in any line containing an output method. Regardless, this is dead obvious and simple. And yes, this technically still does use OOP since it uses document.write().

Insane (masturbatory) Answer

function MathLib(){
    this.answer = null;
}
 
MathLib.prototype.sum = function (x,y){
    this.answer = x + y;
}
 
MathLib.prototype.getAnswer = function(){
    return this.answer;
}
 
function Printer(){
    this.preText = ;
}
 
Printer.prototype.setPreText = function(str){
    this.preText = str;
}
 
Printer.prototype.out = function (str){
    document.write(this.preText + str);
}
 
// To run
var math = new MathLib();
var print = new Printer();
math.sum(1,1);
print.setPreText(‘The answer is: ‘);
print.out(math.answer);

I did the exact same thing in 1 logical line of code (3 if you include the function itself) up above. What was gained from the object-oriented design? I argue nothing. Rewriting the first example would take a minute should something need changing. If there were a need to localize that string, I could pull it out and either make that a 3rd parameter, or some global string the function can use. There’s no benefit here. This is over engineering. There’s nothing truly reusable here. The closest is the Printer.out() method, and in reality it’s a wrapper for document.write().

The bonus joke is that the object-oriented implementation is significantly slower.

Run 1: 0.0266, 0.0451
Run 2: 0.0314, 0.0464
Run 3: 0.0329, 0.0462
Run 4: 0.0268, 0.0468
Run 5: 0.0274, 0.0475
Avg: 0.02902, 0.0464

The first example is also 62.5% faster in Firefox 3.0.4 since the all that overhead is gone. If you have FireBug installed you can check that out here.

object-oriented masturbation
ob-jikt | o·ri·ent-ed | mas⋅tur⋅ba⋅tion

  1. the stimulation or manipulation of one’s own ego by way of using object-oriented code in places where it has no advantage instead resulting in unnecessary complication and bloat.

If your guilty of doing this, please cut it out. It’s annoying. Thank you.

No I will not single out links to the pages that inspired this, but rest assured it litters the web.

Categories
Programming Web Development

PHP Namespacing

The PHP folks have finally announced that PHP will get namespacing in the form of ‘\‘. The universal escape character. They really should have went with the standard ‘::‘ or ‘:::‘. Using ‘\‘ is going to work well.

I was thinking something like this would be more appropriate (background on compatibility here):

......................................__................................................
.............................,-~*`¯lllllll`*~,..........................................
.......................,-~*`lllllllllllllllllllllllllll¯`*-,....................................
..................,-~*llllllllllllllllllllllllllllllllllllllllllll*-,..................................
...............,-*llllllllllllllllllllllllllllllllllllllllllllllllllllll.\.......................... .......
.............;*`lllllllllllllllllllllllllll,-~*~-,llllllllllllllllllll\................................
..............\lllllllllllllllllllllllllll/.........\;;;;llllllllllll,-`~-,......................... ..
...............\lllllllllllllllllllll,-*...........`~-~-,...(.(¯`*,`,..........................
................\llllllllllll,-~*.....................)_-\..*`*;..)..........................
.................\,-*`¯,*`)............,-~*`~................/.....................
..................|/.../.../~,......-~*,-~*`;................/.\..................
................./.../.../.../..,-,..*~,.`*~*................*...\.................
................|.../.../.../.*`...\...........................)....)¯`~,..................
................|./.../..../.......)......,.)`*~-,............/....|..)...`~-,.............
..............././.../...,*`-,.....`-,...*`....,---......\..../...../..|.........¯```*~-,,,,
...............(..........)`*~-,....`*`.,-~*.,-*......|.../..../.../............\........
................*-,.......`*-,...`~,..``.,,,-*..........|.,*...,*...|..............\........
...................*,.........`-,...)-,..............,-*`...,-*....(`-,............\.......
......................f`-,.........`-,/...*-,___,,-~*....,-*......|...`-,..........\........ 
Categories
Mozilla Open Source

Self Serving Sausage Fest?

Does that title accurately describe open source? Via Valleywag I found this blog post from Psychology Today which I’d recommend reading. This is really the most interesting part:

First, there’s street cred: People want to garner approval from their peers and build their reputation. Second, there’s self-actualization: Working on these projects is enjoyable in and of itself, and it also provides the opportunities to practice your skills, collect feedback, and grow as a geek. Third, there’s pure altruism: Let’s save the world, one squashed bug or “[citation needed]” at a time.

Interesting stuff. I definitely fall in the “practice your skills, collect feedback, and grow as a geek” category.

Also noteworthy: 97.8 percent of open source programmers are male. Like there was any surprise that it’s somewhat of a sausage fest on #developers. Anyone ever check the ratio on about:credits? Come up with an automated way to do that’s licensed under MPL/GPL/LGPL and you’ll earn some serious street cred not to mention save the world and practice your text analysis skills.

I guess this is even more extreme than the Dave-to-Girl ratio.