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.