NetBeans could make the Ruby on Rails experience great

NetBeans could make the Ruby on Rails experience great for the vast majority of developers who are using Windows, where installing Ruby, Rails, PHP, MySQL, Python, etc is always a pain and the end result is ugly. But it falls short in some important ways which turned my experience with it into a nightmare.

The reason I say “for developers using Windows” is because I believe that for everybody else, the experience is great already. Or as good as it can be and NetBeans can be an excellent IDE, but not improve the installation and managing experience.

This is my story, my rant.

I downloaded the latest NetBeans and installed it. When creating my first Ruby project, I encountered the first problem. Ruby chocked on my username, which was “J. Pablo Fernández”. You could say it was my fault. Windows 7 asked for my name and I typed it. I wasn’t aware it was asking for my username. Even then I would have typed the same, because Windows 7 doesn’t distinguish between usernames and names, and in the 21st century, computers should be able to deal with any character anywhere.

I know it’s not NetBeans’ fault, it’s Ruby’s. But! Can you imagine a Software Engineer telling Steve Jobs “oh, copying files in a Mac behaves weirdly because it uses rsync and that’s its behavior, you see, it makes sense because…”? Of course Steve would have interrupted: “You’ve failed me for the last time”. The next developer would have patched rsync, trying to get the patch upstream, or creating an alternate rsync or stop using rsync.

I’ve spent many hours creating another user, migrating to it, which in Windows is like 100 times harder than it should.

Hours later, as soon as I created a project I got a message saying that I should upgrade gem, Ruby’s package manager, because the current version was incompatible with the current Rails version. By then I had already played with NetBeans’ gem interface telling it to upgrade everything, it should have upgraded gem as well, not just the gems. Every single developer out there running NetBeans must be encountering this error, and indeed there are quite a few threads about it on forums.

Trying to upgrade gem with NetBeans was impossible. I think what they did to install and upgrade gems in NetBeans is excellent, but failing to upgrade gem itself was a huge drawback. This one was NetBeans’ fault. Neverfear, let’s do it from the command line.

When doing it from the command line I encountered another error:

\NetBeans was unexpected at this time.

Looking around it seems it’s because of the spaces in “Program Files (x86)”. That means that the command line environment for Ruby that NetBeans installs is broken for everybody. I repeat: everybody. The answer: install it somewhere else.

Well, I have two things to say about it: first, fix the freaking thing, Ruby, gem, whatever. Paths can have spaces and all kind of weirdness. It’s a big world full of people speaking languages that can’t be represented with ASCII and people that believe computers should do our bidding, instead of the other way around. “If I want spaces you better give me spaces, useless lump of metal and silicon”.

Second, if you know one of your dependencies is broken, try to avoid triggering the broken behavior or at least warn the user about it. “We see you picked C:\Program Files (x86)\ to install NetBeans, which is pretty standard, but you know, Ruby is broken and can’t work in there, not even JRuby, so if you plan to use those at all, please consider installing it somewhere else.”

I uninstalled NetBeans, or tried to. The uninstaller didn’t work. I deleted it and tried to install it on C:\ProgramFilesx86, which failed because some other directory created by NetBeans somewhere else existed from the previous installation, which halted the installation. I started a dance of run installer, remove dir, run installer, remove dir, run installer… until it worked.

Once I finished I found out that NetBeans installed in C:\ProgramFilesx86\Netbeans 6.7.1. Yes, that’s a space. Oh my…

As a bonus, NetBeans can’t automatically find Sun’s JDK in its default directory. I had to point to it by hand. Sun was, as usually, absolutely disrespectful of the platform conventions and installed its crap in C:\Sun. I would have picked another place but I thought “I’m sure some stupid program will want to pick that shit from there”. Silly me.

12 hours have passed and I still haven’t been able to write a single line of source code. I contemplated installing Ruby by hand, but it’s so ugly that I decided I’m not going to use Windows for this. I’m going to work on another platform where installing Ruby is trivial and where I would probably never touch NetBeans because I have other editors.

I know there’s a lot not really related to NetBeans here, for example, the fact that working with Python, or Ruby or MySQL in Windows is a pain; but it’s a great opportunity for NetBeans. There are developers wanting to use those languages and environments and if NetBeans makes it easy for them, they will pick NetBeans not because of its editor, but because of everything else (which is what I was hoping to get out of NetBeans).

Aside from doing some usability tests, the people working on NetBeans should learn from the people working on Ubuntu (not the people working on Evolution) and instead of asking me for debugging traces when I report a simple obvious bug and then tell me it’s not their fault, they should submit those bugs upstream, to Ruby, gem, or whatever. Whenever someone like me submits that bug to NetBeans they should mark it as duplicate of an existing open bug that points to the upstream bug. I would have followed that link and told the Ruby developers “wake up!”. As it is, I didn’t. It’s too much work for me.

Reviewed by Daniel Magliola. Thank you!

Advertisements

Reviewers in a WordPress blog

In an effort to increase the quality of this blog I’ve engaged a couple of friends in reviewing my posts before they go out. I’m after typos, grammar and also “Are you serious? are you going to publish that crap?” or “You are going to get into trouble with that”.

The best way to do this, in my and in the opinion of many, is to let the reviewer modify the post freely and then check the diff. I suppose we are too used to work with source code, where diffs are a necessity.

I was positively surprised that WordPress can provide very nice colored diffs between each save of each post. Praise to WordPress! I was also surprised, but negatively, that WordPress doesn’t have a reviewer role. Users with the reviewer role would be able to edit unpublished posts but wouldn’t be able to modify published posts or publish drafts.

I was pointed to Role Scope, an amazing plug in for WordPress. I spent an hour creating a group and trying to give it the proper access, and as that failed, trying to limit the Editor role to only edit drafts. I failed at that too.

When I gave up and I went back to the usual blogging I found that Role Scoper allows you to give edit access to each post to any user. And that’s it. That’s what I’m using. Whenever I want something reviewed I give access only to that post to the user I want to review it. Quite simple.

Reviewed by Daniel Magliola. Thank you!

Deferred Twitter posting

twitter-woodHere’s an idea for those Twitter clients, web and desktops out there: deferred posting.

One tweet per hour during eight hours is much more effective than 8 tweets in a row. But sometimes you want to write eight tweets in a row and I find two reasons to do that.

You are using Twitter professionally, for your work, as a marketing and social tool. You want to minimize the hit it takes on your productivity so you limit yourself to 15 minutes of tweeting per day. In those 15 minutes you generate tweets for the whole day, you want them to be automatically distributed through the day.

When you open twitter after some hours of not using it, like after sleeping, you’ll find yourself replying to lot’s of stuff as you go through it. That’s specially true if you are 8 timezones away or so from most people you follow.

I think a Twitter client should do the distribution automatically. It could distribute them evenly through the day, depending on how many you have on your queue. Whenever you want to tweet you just add it to the queue.

Why limit itself to one day? why not leave tweets for tomorrow? And if not one day, how long? A way to solve the problem is to try to maintain your speed constant, minimize acceleration and deceleration.

For example. If you normally tweet 5 times a day, and you have 10 tweets in your queue, do 7 today and leave 3 to tomorrow so that you don’t double the speed, you just increase it a little bit. If tomorrow you add another 10, you’ll have 13 and you are at a speed of 5.2 (previously you were at 5, but yesterday with 7 you sped up a little). So today you get 9 published and 4 left for tomorrow and so on.

You’ll have different speeds on weekends and business hours. There’s a curve of speed and the Twitter client should try to match it with what you have on the queue.

If you want to direct tweet, you can do that, just fine.

Another interesting way is to match the curves of you readers instead of your own. The tweeter client would measure when your readers are posting more, and presumably, also reading more. It’ll make an average and it’ll have the curve of speed of your network. Instead of posting following your previous curve, it’ll post following your network’s curve maximizing the amount of people that is likely to read your Tweet.

I would call that, Professional Tweeting.

Another interesting feature would be to set importance to your tweets. More important tweets are sent when the chances of getting it read are highest, when the curve reaches its peak.

Reviewed by Daniel Magliola. Thank you! Twitter carved-wood icon by gesamtbild.

It's time for search and replace

searchWeb browsers, like Firefox or Chrome, are no longer document viewers, but application platforms. I’d like to see browsers start to implement search and replace. Of course not modifying the page, just replacing the matching strings in forms.

I’m really surprised it’s not implemented yet. In the last two weeks I needed this feature about 5 times. It’s time for search and replace in web browsers already.

Reviewed by Daniel Magliola. Thank you!

Formating strings in C#, like in Python

I like Python’s way to format strings because you can use it everywhere, it’s part of the strings. You can do

print("Welcome %s!" % user.name)

as you can do

Console.Writeln("Welcome {0}!", user.Name)

But then in Python you can also do

randomMethodThatTakesAString("Welcome %s!" % user.name)

In C# it gets trickier, because the call to Console.Writeln takes extra arguments for the string arguments, while RandomMethodThatTakesAString doesn’t. It just takes a string. So the only way to go is

RandomMethodThatTakesAString(String.Format("Welcome {0}!", user.Name))

which is ugly.

Thanfully C# 3.0 has extension methods, so I quickly wrote this method:

blah blah

and now I can write:

RandomMethodThatTakesAString("Welcome {0}".Args(user.Name))

which is more verbose that Python’s version, but equally nice in my eyes.

If you can understand why allowing the language to be extendable in one aspect was a win here, then you can understand why so many, me included, love Lisp that is extendable in every possible way.

Reviewed by Daniel Magliola. Thank you!

Update 2009-09-17: For those complaining that I didn’t show how I did it, here is the Args method:

public static class StringExtensions {
    public static string Args(this string str, params object[] args) {
        return String.Format(str, args);
    }
}

The 7 facts of lists of N things

1321 Lists of N things are a joke

For most lists, saying that they are a joke is a derogatory statement which might as well be true. For this one, instead, because this is tha list, it’s true. This is a joke built out of Paul Graham‘s essay The List of N Things. If you were after some real information, stop being lazy and read Paul’s essay. If you weren’t, read it anyway before reading this list. And if you go there and never come back to finish reading this, no problem. I forgive you.

2 Readers like lists of N things

It’s simple, they are easier to read than a regular article. They are a degenerate case of essay. An essay can go anywhere the writer wants. In a list of n things the writer agrees to constrain himself to a collection of points of roughly equal importance, and he tells the reader explicitly what they are.

3 Lists of N things can be read in any order.

Because the main points are unconnected, the list of n things is random access. There’s no thread of reasoning you have to follow. You could read the list in any order. And because the points are independent of one another, they work like watertight compartments in an unsinkable ship. If you get bored with, or can’t understand, or don’t agree with one point, you don’t have to give up on the article. You can just abandon that one and skip to the next. A list of n things is parallel and therefore fault tolerant.

But be sure to read point 1 of this list.

4 Sometimes writers want them

There are times when this format is what a writer wants. One, obviously, is when what you have to say actually is a list of n things. Another reason is when a deadline is coming fast like a train, building up a list is easier than just elaborating on a matter.

5 Lists of N things are easier for writers

The list of n things is easier for writers as well as readers. When you’re writing a real essay, there’s always a chance you’ll hit a dead end. A real essay is a train of thought, and some trains of thought just peter out. That’s an alarming possibility when you have to give a talk in a few days. What if you run out of ideas? The compartmentalized structure of the list of n things protects the writer from his own stupidity in much the same way it protects the reader. If you run out of ideas on one point, no problem: it won’t kill the essay. You can take out the whole point if you need to, and the essay will still survive.

6 The classic 5 paragraph essay is really a list of 3 things

Because the list of n things is the easiest essay form, it should be a good one for beginning writers. And in fact it is what most beginning writers are taught. The classic 5 paragraph essay is really a list of n things for n = 3. But the students writing them don’t realize they’re using the same structure as the articles they read in Cosmopolitan. They’re not allowed to include the numbers, and they’re expected to spackle over the gaps with gratuitous transitions (“Furthermore…”) and cap the thing at either end with introductory and concluding paragraphs so it will look superficially like a real essay.

7 Lists starting with “the” are dishonest

There is one case where the list of n things is a dishonest format: when you use it to attract attention by falsely claiming the list is an exhaustive one. I.e. if you write an article that purports to be about the 7 secrets of success. That kind of title is the same sort of reflexive challenge as a whodunit. You have to at least look at the article to check whether they’re the same 7 you’d list. Are you overlooking one of the secrets of success? Better check.

It’s fine to put “The” before the number if you really believe you’ve made an exhaustive list. But evidence suggests most things with titles like this are linkbait.

Reviewed by Daniel Magliola. Thank you! 1, 3, 2 picture by Damien Franco.

The advantages of OpenID

forgot-passwordOpenID has many advantages. For the average user, the main one is not having to remember a thousand passwords. That’s obvious. But also consider not having to remember the username. Many web sites use the email address as username and that’s nice, but many don’t. And most people are not lucky enough to have a username that’s free everywhere. For my wife, remembering the username is sometimes as hard as remembering the password.

Not having to worry about poorly programmed web sites leaking your password because they stored it in plain text and they have phpMyAdmin open without any password is also a big plus, but not something the average user would see.

But for the developer, it has many, many advantages.

Not having to decide on what identifier to use for your users (users vs emails vs ids). Not having to implement a log in screen, which means not having to worry about SSL encryption which means not having to get a dedicated IP address, a certificate, configure the web server accordingly and ensure that the site switches to https when it must.

Not getting password for the user means you don’t have to store a password. You don’t have to figure out what is the appropriate encryption mechanism so that if your encrypted password leak, they are not readable. Not using plain text is not enough, as some encryption mechanisms are easily broken. Not having to worry about that is huge.

You don’t have to create a signup page, people just log in. You don’t have to validate the password by asking for it twice or validate its strength or any other stuff like that.

You don’t have to create a remember password page, which means one less place where you have to deal with sending emails. That’s always good. Also it means that you don’t need to store the email of the user. You may want to, but that’s your option.

I’ve always been a fan of canned authentication and authorization systems. I’ve been using them since the days of PHP 4.0 and I used them in Django and ASP.NET (MVC). But with OpenID, it seems the authentication became almost trivial. Canned solutions were always troublesome because they had to work for everybody so they implemented a lot of stuff you don’t actually need and sometimes you spend more time fighting the bureaucracy of the system than producing something.

Is it possible that without OpenID authentication and identity for the developer of a web site becomes something simple and trivial? Where rolling your own solution not only is simple enough, but also the way to go. I’m looking forward to my users being just in the user table, and not all over the place in users, profile, membership, etc. I’m giving the roll-your-own-with-OpenID a try. I hope to post positively about it soon.

Complexity of writing software

Broken bridge, picture by Ghost V

There seems to be a lot of discussion about software complexity, and although I think many people are talking about different stuff, here’s my take on it. We often compare writing software with other professional disciplines, like civil engineering and medicine, which allows us to pick at possible futures of writing software.

I believe writing software is hard, very hard, extremely hard. Probably one of the hardest thing to do. Any non trivial piece of code has an amazing amount of moving pieces. I bet the average software project is more complex than a car or a bridge. But how do we reconcile that with the fact that we have children programming and not children building cars or bridges?

Well, we do have children building cars and bridges, just that they are toy cars and toy bridges. Toy cars and bridges are very different from real cars and bridges. Toy software is not much different from real software. The path for going from toy to real in software, unlike in medicine, motor and civil engineering, is smooth. You don’t jump from building toy software into building real software, you just build better and bigger software until it’s real or professional.

That makes sense because software is abstract. Software is like ideas. There’s no jump between having toy ideas and having real ideas. If you don’t buy it, let’s do the analogy with math. There’s no jump between doing toy math and real math. You learn more math, more operations, more tools, but the sums and multiplication you learned when you were 5 years old are the same you use in civil engineering. There’s no toy sums vs real sums.

At some point in time, ages ago, math was primitive. A 12 year old could discover something new in math. We are at that period in the world of software writing. We are young and there’s not a lot out there. That’s why even though it’s extremely complex, a kid can still do something meaningful.

There’s something special about software. Even though it is abstract like math, it has a concrete impact, like civil engineering. So the 12 year old kid can do something new and it’s not just a piece of paper with a couple of numbers on it. It’s a real usable thing that other people can start, well, using. And that’s why I believe programming is so wonderful.

There’s another very important property of software that makes it so complex and still approachable. Imagine the world ages ago when 12 years old where doing math discoveries. Probably 99.9% were wrong in what they discovered as 99.9% of the software written by kids is wrong in the way it has bugs. But buggy software is still software and it’s still usable. Buggy math is wrong and should be discarded, buggy bridges kill people. Buggy software is a nuisance, but usable.

There’s some code in which only very smart and professional people put their hands on. Code written at NASA has something like 10 times more code to test it. Code put in a machine that can kill people, like a robot at a factory or a radiotherapy machine is written quite differently than the latest web toy or even the operating system you are using (last time I checked my analytics, nobody was using QNX to access this web site).

Rocket picture by SWP Moblog

As software becomes more important in our lives, more of it has to be written rigorously. You can accept the latest web toy to crash, but you cannot accept your phone to crash. And then, the latest web toy becomes very important, like Twitter, and you cannot accept it to crash. The way code is written at NASA is more similar to the way a civil engineer makes a bridge: accounting for all possible variables.

It’s a real possibility that in 20 or 30 years all code will have to be written very rigorously. That means that you probably won’t be able to get a job working as a programmer in many, many places unless you have a proper degree, certification and license. I know it sounds crazy, but extrapolate about who was building bridges ages ago (anybody) and who are building them now (civil engineers) to who is building software now and who is going to be building software tomorrow.

For me, that sounds very depressing. I like the chaos of innovation that software is today. I probably couldn’t live in a rigorous software environment. One aspect that I haven’t analyzed is that, unlike civil engineers, software programmers will most likely always be able to build software by themselves, put it out there and be out of the loop of rigorous working. Anyone can build a bridge in their back-yard and nobody will use it, because it doesn’t stand a chance of being useful. But the back-yard of a programmer is the Internet. The only question is whether people will use that crapy web toy built by a 12-year old 20 years from now. I honestly hope so because that will keep the thriving environment of chaotic innovation that programming is today.

Reviewed by Daniel Magliola. Thank you! Broken bridge picture by Ghost V, rocket picture by SWP Moblog.