Of Jobs, rms and Ritchie

Last two weeks were a complete train-wreck for people in IT: First, Steve Jobs died on October 5. I thought I should write something to “enlighten” some people saying things like “Oh, he did some gadgets, so what?” But, when I was waiting for the dust to settle, rms came with an statement that inflamed a lot of people, including some asking “What this Stallman wrote, after all?” Le sigh. And, again waiting for the dust to settle, another lost: Dennis Ritchie died a week after Jobs. And no press really cared.

But let’s close those points:

First, we have Steve Jobs. Yeah, he was a capitalist who commanded one huge company who did care about creating devices where under their total control.

But, at the same time, he was the helmsman of a company that disrupted everything other companies were doing. In IT, we have the expression of “disruptive technology”, which are things created the shake the market completely. Linux is such thing. And Apple products are other. Tablets changed and got accepted when Apple launched the iPad, even if the idea of such devices predates the device by a long time. Smartphones weren’t really smart till Apple launched the iPhone; MP3 players only became a mass market thing after the iPod; and suddenly we have a whole new wave of ultra-thin notebooks coming around after the MacBook Air.

Apple did hold control of everything they did, yes. But you can’t deny how disruptive the company was for the IT market.

But there is one thing that tops it all: HTML5. When HTML5 was just a thing coming out of draft, Jobs was the voice saying “Kill Flash, ’cause HTML5 is the future”. Sure, he had his motives (the fact that his company hold part of the video standard was one of those), but HTML5 became a big thing when Apple started pushing it. Or would you prefer Adobe position of, for example, saying that “Linux is hard, so no acceleration there” instead of Mozilla position of “We recognize there is a problem with accelerated WebGL/Canvas on Linux, but we are willing to work with developers to improve this situation”?

And then Richard Stallman, also known as “rms” (yes, lower case), came with some… erm… “rude” words about Steve Jobs. And then people came with “And what have this Stallman done? Nothing.”

Well, dear sirs, Stallman is the helmsman of the Free Software Foundation and the creator of the GNU project. The very first thing rms created was the Emacs editor, which influenced the readline library, which influenced, for example, the OS X shortcuts. Oh, and his second project was a compiler called “gcc”, which was the only compiler on XCode till version 3 (version 4 also uses LLVM, but that’s a completely different beast). And what’s XCode? It’s the official application for creating iOS applications. Oh yeah, ladies and gentlemen, part of the success of Apple can be be attributed to the guy that dissed Jobs days after his death.

Not only that, but gcc was the official compiler for NeXTSTEP, the operating system that Jobs started after being fired from Apple. And hey, guess what? NeXTSTEP is the reason Apple bought NeXT and, as Jobs said himself, “was the base of the renaissance of Apple”. Would NeXTSTEP be such interesting operating system for Apple if they had to take the time to design their own compiler?

And, after you brush off the politics of rms message… Can you point anything wrong with it? Isn’t Apple the company that pushed a completely controlled environment? Isn’t that the completely opposite vision of what rms have for software?

And then, on October 12th, Dennis Ritchie died. Ritchie was the co-creator of Unix operating system and the C language.

“Whateves” is what those attacking rms and saying “meh” to Jobs are probably thinking now. Unix is the power behind OS X today (with the Mach kernel) and its main developing language is Objective C, which is C with some added features (Wikipedia page lists it as “adds Smalltalk-style messaging to the C programming language).

Not only that, but rms idea with the GNU project was to create a completely open source Unix — which later was achieved with the help of the Linux kernel — including a C compiler (the gcc I mentioned before).

If Apple went long, it’s because it stood in the shoulders of giants like rms. If rms managed to fulfill his dream of an open source operating system, it’s because he stood in the shoulders of giants like Dennis Ritchie.

You May Have Talent, But You’re Not an Underdog

There is yet another video floating around about a kid in some “Got Talent”-like show, telling his sad history and then singing in some ok fashion.

Now you must be asking yourself “What video is this?” and that’s the core of the point I’m trying to make: Every single “Got Talent” video that hits the web is about some kid, man or woman who had some hard time in their lives and then got a chance at the show. Sure, there is the eventual “person who sings/dances/talks incredible bad it’s too funny to pass away”, but the great majority is the underdog who finally got their chance.

So this kid from a middle class family, who managed to get some guitar/singing lessons from time to time, managed to have his time to practice and such, learnt the tricks of trade, created a band with some friends, practices every weekend… well, sorry for you, you don’t “Got Talent” ’cause you’re not an underdog.

Kinda reminds me of those “Reality TV” shows where people are invited and they have to do some crazy shit. I mean, what’s the reality when you have to stay standing for 12+ hours non-stop? Do you stay 12+ standing non-stop at your house, by any chance?

Your Editor Shows the Flaws of Your Language

In a recent update of Sublime Text 2, my programming editor of choice of these days (only ’cause I wanted a break from VIM, for the fun of having to learn how to edit things in the “normal person” way) got a “Vim mode” and I decided to enable all the other features, just for kicks. One of those features was the “auto close brackets” (or whatever name they call that these days).

The only thing I’m using the “auto close brackets” feature is to make sure all the mess with opening square brackets inside functions inside functions would have the proper closing element. It’s somewhat easy to get lost in a str_replace(' ', '', trim($param['string'])) line.

But that’s only one thing editors do that are only there to work as a “walking stick” for the language you’re working on.

  • Auto close brackets: As I mentioned, that’s because accessing most array elements requires at least two characters ("[" and "]") or 4 if you use associative arrays/dictionaries/objects. JavaScript does this right by not having associative arrays and making objects. You can kinda do the same with Python objects, but it feels somewhat wrong when you do have dictionaries. You can somewhat fix that with __getitem__ or just monkeypatching the dict object. But in some languages, there is no such option. Also, as you can imagine, the problem is “lessened” with languages where all the basic types are objects: instead of making function return the parameter of another function (like I did above), you simply call function and then the next function. The same example above in Python would be something like param['string'].trim().replace(' ', ''). This obviously reduces the changes of forgetting to close one of the parenthesis.
  • Snippets: Snippets are small pieces of code that you repeat most, but not to the point you can simply write a function to do such thing. C/C++ allow you to somewhat skip that by using macros but one must reckon that macro syntax is a bit cumbersome.
  • Templates: Templates are large snippets that encompass whole files. It seems templates are there not to just solve a language design problem, but a general “language design principle” problem. The most obvious example I can think of is using Eclipse to write a Java application to connect to a database. To do it so, it requires so much boilerplate that Eclipse itself offers a way to create the whole file to you based on a simple database definition.

I’m probably forgetting a lot more programming editors do these days just to cover languages’ asses here. But I guess you start viewing programming languages a lot different when you think any feature in the editor is just to solve a problem with the languages we use today.

Who’s the best captain?

It’s been some time I’m trying to find the perfect timing for a Star Trek post and it seems the celebration of 45 years since the first episode makes it a perfect time for it.

Before I go, I think it’s better to tell you what are my expectations in the Star Trek universe. When Gene Ronddenberry created Star Trek, his plan was to make a series showing that, in the future, humanity would always solve things going the higher ground. The captain of the most important human ship, thus, most embody those qualities.

So, in order from worst to best:

Benjamin Sisko (Deep Space 9)

Deep Spacers forgive me, but Sisko was the worst captain the Federation could get, even if you compare him to Jellico. Maybe Sisko wasn’t a bad captain before he took the helm of Deep Space 9, but after the very first episode, he turned into the reluctant captain: He didn’t want to be the captain of Deep Space 9 and couldn’t get into terms with the loss of his wife — and he didn’t for the whole series.

Not only that, but he did slip every single thing for what the Federation stands for: He accepted, with no regret, about people doing wrong things under his nose (won’t spoil, but it involves Garak and the 19th episode of the 6th season) and used his position of “Emissary” to manipulate a whole system. His actions may had saved the station and brought peace to the region, but it was still wrong. For a series that tried to show the best of the human race, Sisko shown the worse.

Kathryn Janeway (Voyager)

Janeway wasn’t bad per se, she was in a very thought and dark situation — honestly, the darkest of all series: In the other side of the universe, with no hope of getting home in a lifetime… If that wasn’t dark enough, their ship was slowly falling apart, replicators falling and the biological memory slowly going out. Everyone mentions “Janeway slow decent into madness”, but I never noticed that. She does start lacking control of her ship due a fall into depression (in one episode, she isolates herself completely from the rest of the crew), which should probably be diagnosed before she was given the big chair.

Jonathan Archer (Enterprise)

Archer had a hard time in front of him: The Federation and all the prime directives didn’t exist yet and his Enterprise (the one without the NCC-1701 prefix) was the first big human warp ship. No rules, no role-model… Archer was fated to fail. But thing is, he didn’t.

In all the crazinest that happened, he had to deal with the fact that he was, at the same, responsible for exploring the universe, trying to make new alliances and the captain of the biggest space weapon Earth had. In one episode, knowing Earth would be under attack, he tried to reach Earth, but the dilithium crystal was completely drained. On the way, only with impulse engines, they find a merchant ship and ask if they are willing to trade their dilithium crystal for supplies, which the merchant says no. After exploring all the possible options, Archer decides, showing a complete regret on his decision, to steal the other ship dilithium crystal (leaving behind enough supplies for the merchant ship to complete its route, promising his crew that he’ll come back and help that ship once Earth is saved). That puts Archer way above the others, simply ’cause he sees and regrets doing what’s wrong.

James T. Kirk (The Original Series)

Kirk didn’t had a soul of a captain: deep down, Kirk was an adventurer. Being a captain only gave him the perfect tool to go into the greatest adventures a man could be part of. He also knew that he would have to play by the rules, so he does. The fact that he doesn’t like to lose is also the reason he follows such rules (’cause he knows he would lose his ship and had to give up his adventures). Also, following the rules made things hard, which only made the things more exciting.

Surely, he had the greatest crew ever: Bones and Spock played two sides of a conscience (the emotional side and the logical side) and Kirk played the judge of those two. But, deep down, Kirk knew the rules and had a conscience (even if it was only strong enough to hear Bones).

Jean-Luc Picard (The Next Generation)

For the Federation standards and rules, Picard was the perfect captain. He followed rules, he had conscience to do the greater good (even against the rules), he had absolute control of his ship and crew (without a strong hand, like Jellico) and, most importantly, he took the job of being a captain seriously. He did not take vacations ’cause he knew there was a job to be done and he was in the position to do so.

Contrary to Kirk, Picard didn’t need the “conscience personifications” walking around him to remind him of logic and morals: He had that in himself.

And, for being the “better human” Roddenberry expected in his series, and having a soul of a captain, Picard is the better captain.

Little Stupid CSS Insight Of The Day

Today, after fighting several minutes to understand why my form was not being send and then checking it with Firebug and seeing it completely broken (as in “the form had no inputs ’cause it was being closed right after being opened). I checked and rechecked my HTML for errors and nothing. Then I understood why.

This is a <div>. It works like a box (also, you’ll hear a lot about “boxing model” and such).
This is a <form>.
This is a table.

So, if you keep that mind: You can box your desk; you can put a box inside your desk drawers but you can’t cover your desk drawers with your box while putting both inside your desk. It doesn’t work like that.

Honeycomb Looks Already Outdated

Recently, there is a lot of talk about the Android version, named “Honeycomb” for tablets. A video was posted with some sneak peek of it.

The problem is that, to me, it looks already outdated. If you compare the look of the final Honeycomb with the pre-alpha of Meego, you’ll have the impression that the first actually came before (again, remember that this is the pre-alpha version and the final version, released last year, it a bit more polished).

The weird thing is that if you compare Android 2.2 running on a smartyphone with Maemo running on the N900, Maemo is the one that looks outdated.

Personally, as a software developer, if Meego keeps the Maemo tradition of not hiding the hardware from the developer, you can expect that Meego will have some crazier things running on it.

On the other hand, since Meego is being directed by Nokia, I kinda expect that the life of Meego will be hell (with my experience with multiple versions of Maemo).

OAuth paranoia

One day after I posted the lack of respect for OSS apps in Twitter “ecosystem” (a word they seem to like a lot these days), they announced that the API request for trending topics will now return the promoted tweets.

As I was reading this announcement, the paranoid hat fell on my head.

As I explained before, OAuth allows Twitter to simply cut the access of an application at their own will because, as they say, it may “harm the ecosystem”. The problem is that since forever, the line of what is “harmful” to the “ecosystem” was never fully explained and seems to be a moving target: Every day, someone will post on Twitter-Developement-Talk about their applications getting rejected due some not explained reason and being pointed to the Terms of Use.

Now, since Twitter never really explained what the “ecosystem” is and can simply cut any application they want, what may stop them to cut the access of some application that removes promoted tweets in the basis that promoted tweets are good for the “ecosystem”?

Does this paranoid hat make me look crazy?

Medos que se tornam verdade

Quando coloquei que o Tadeu Schmidt deveria calar a boca eternamente, acabei concluindo com uma preocupação (que poderia mais ser um reductio ad absurdum) de que se nos esportes aceitam-se os trocadilhos engraçadinhos e deixa-se a notícia, o fato, de lado, isso logo espalharia para as demais áreas do jornalismo. Obviamente, um grande salto de lógica.

Infelizmente, não levou muito tempo para que eu achasse um exemplo real do meu medo.

Na Zero Hora de hoje, bem na capa, há a seguinte manchete:

“Um goleiro enredado”

É, obviamente, uma alusão à prisão do goleiro Bruno do Flamengo, acusado de ter sequestrado a amante, força-la a abortar e, como a criança chegou a nascer, acabou por planejar a morte da mesma. Ou, pelo menos, é a linha que está sendo seguida pelas investigações da polícia e cujos fatos estão surgindo para confirmar a hipótese.

E, com um caso bárbado destes, a Zero Hora, que deveria ser um jornal sério (em contra-partida com o já não sério Diário Gaúcho), coloca um trocadilho destes. Se jornal tivesse som, a manchete seria seguida por algum imitador do Sílvio Santos rindo.

Um homem abusa da posição de sucesso na mídia para participar de orgias, engravida uma garota de programa, força-a a abortar e depois planeja sua morte e a executa com a ajuda de traficantes. E vira trocadilho de um dos maiores veículos de notícias do estado.

Realmente, “jornalismo” é uma atividade rara no país, sendo gradualmente substituido pela comédia.

“What if” iterable.join()

…or “Let’s keep floging this dead horse”…

Over the weekend I got some reactions over the str.join() vs list.join(). Well, just for fun, this morning I played “what if” in my head.

So, let’s say every iterable got a join() method. So you could

>>> a = ['s', 'l', 'o', 'w']
>>> a.join('')

Exactly as JavaScript does. Mkay. A could even be a tuple and would still work. Or, stupidly enough, a string and still work. But, then, what would be the first thing that would cross you mind when you saw this code for the first time:

>>> a = ['s', 'l', 'o', 'w']
>>> b = ['r', 'u', 'l', 'z']
>>> c = a.join(b)

You have a list in one side and a list in the other with a “join” method. List-join-list. Well, I’d expect another list with ['s', 'l', 'o', 'w', 'r', 'u', 'l', 'z'] which is what extend() does.

But let’s return to the original str.join(): What it does is, join the iterable in the parameters using “self”. Mkay, so what would be:

c = ['r', ['s', 'l', 'o', 'w'], 'u', ['s', 'l', 'o', 'w'], 'l', ['s', 'l', 'o', 'w'], 'z']

Which doesn’t make any sense.

Let’s go further. join() could, possible, call str() for the parameter and still react like JavaScript join(). Why? Well, as you may already know, Python have dynamic typing which means any variable can be used. Just to remember:

var l = ['s', 'l', 'o', 'w']
var j = l.join('')

would result in “slow” in JavaScript. Mkay, so

>>> l = ['s', 'l', 'o', 'w']
>>> r = ['r', 'u', 'l', 'z']
>>> j = l.join(r)

Would result in… guess what, "s['r', 'u', 'l', 'z']l['r', 'u', 'l', 'z']o['r', 'u', 'l', 'z']w" which, not surprisingly, still doesn’t make sense. Ok, if r was a simple string, it would react exactly like JavaScript. But it would be a mess with any other types. And what’s the point of dynamic typing if you force types?

So, str.join() not only makes code simpler and avoid some mess of monkey-patching, it also removes a greater problem: ambiguity.

And yes, I understand that JavaScript list.join(str) makes sense, but it still have the problem with “What about the other types? Are you a racist?”

Edit: Just for curiosity, I wrote a list.join(list) code in JavaScript to see the results. Here they are for you mind-bloggling pleasure:

js> var l = ['s', 'l', 'o', 'w'];
js> var r = ['r', 'u', 'l', 'z'];
js> var j = l.join(r);
js> j

Python: why str.join() and not list.join()

or “Slowpoke finally understands Python

When I was in Australia, one guy kept asking why Python had the “horrible” (in his opinion) str.join() instead of obvious (in his opinion) list.join()?

After working with JavaScript for a while, I can understand his opinion: In JS, you have a list.join() of sorts and it makes a hell lot of sense.

But, then again, this morning it finally hit me: str.join() uses an iterable object as parameter, so any iterable object will work. For example:

>>> p = 'python'
>>> '-'.join(p)

Ok, this is understandable, but why not have a list.join() too? Well, this would mean that every iterable object would have to have a join() method (str.join(), tuple.join(), dict.join(), list.join() and all the new iterable objects that appeared in Python 3.0.) Since the C API for Python doesn’t allow object hierarchies (and all base types are implemented in C), the same method would have to be implemented over and over again. Not only that, but you would have several different ways to join() stuff instead of one, (now) obvious way.

Another way to fix this would monkey-patch every object to have a join() method, but that’s not the Python way. Monkey-patch is never the Python way.

And the same rule applies to len(): it takes any iterable due the same reason.