YUI Compressor

One of the things I love about programming is that you are always learning new things. You have to learn new things to keep up.

One of the benefits of using the Plotr Javascript library for the language popularity stats I did is that instead of having to download separate images for each statistic, a user just fetches the library once and then a few small bits of data for each chart, which is probably a net savings, especially when I start to add more statistics. However, Plotr, plus its various supporting libraries, is fairly hefty, so I needed to find a way to compress it. One of the helpful people on the freenode IRC network’s #javascript channel pointed me at Yahoo’s YUI Compressor, which is a nicely done project that squeezes quite a bit out of Javascript files. I would recommend it to anyone else who needs to pare down their production JS files to the bare minimum. Best of all, it’s available under a very liberal open source license!

Incidentally, over the course of the language stats project, I was surprised at how much helpful stuff Yahoo provides, first and foremost, a real API for their search engine, something that Google no longer has. Hopefully, it’s a sign of better things to come for them (if for no other reason than to keep Google on their toes!).

By the way, for those interested in the language stats project, I set up a forum with RSS feeds, where I will be posting updates, and accepting suggestions for further improvements.

Programming Language Popularity

My latest fun project:

http://www.langpop.com

Of course, the results aren’t very scientific, but they’re interesting, nonetheless. I’ll be adding some more charts like trends once I have data over a few months.

I ran some similar stats a few years ago, but this time I’ve geared up to automate the whole process, so results should be updated regularly, once everything is up and running.

Seinfeld on the word “blog”

Jerry Seinfeld on The Daily Show:

Is that the worst new word of the culture, blog? It’s so unattractive. It’s like something that you spit up and its, it has like, it congeals, and is, you know, and you kick dirt on it.

I couldn’t agree more. I’ve always disliked the word, although to me it sounds more like something you have to call a plumber to deal with after having drained a couple of bottles of some caustic agent down the toilet, in an unsuccessful attempt to eliminate the “blog”. It’s even worse as a verb – “I blogged it” instead of having simply written something, as people have been doing for several thousand years.

Chartr – Plotr generation for Rails

I’ve been working on a project that uses graphics created with Plotr, and I wanted to automate that from Rails, so I created Chartr. It’s not very complete, but works well enough to create stuff like this:


<script src="http://chartr.rubyforge.org/excanvas.js" type="text/javascript"></script>
<script src="http://chartr.rubyforge.org/plotr_uncompressed.js" type="text/javascript"></script>
  <canvas id="results_chart" height="300" width="500"></canvas>
</div>

var dataset = {“Number/Decade”: [[0, 1000], [1, 5000], [2, 20000], [3, 22000]]};
var options = {colorScheme: “#22aa22”, legend: {position: {}}, axis: {x: {ticks: [{label: “1960”, v: 0}, {label: “1970”, v: 1}, {label: “1980”, v: 2}, {label: “1990”, v: 3}]}}, padding: {left: 100}, background: {}, stroke: {}, legend: {position: {left: ‘120px’}}};
var discvar = new Plotr.BarChart(“results_chart”, options);
discvar.addDataset(dataset);
discvar.render();


Help is more than welcome! I think the API is still a bit clumsy, more chart types need adding, and there are other things that could probably be improved, but it does work.

Open Source Licenses, Network Effects, and Competitive Strategy

I was recently talking with some people who develop a BSD licensed product who are a bit worried about competition. I had this to say, and I thought I would share it.

I think the concern is the “Sun Microsystems situation”, where there is a second project (B) based on open source project (A), and code only moves in one direction, towards B, a, commercial project. That can be kind of scary, especially when the commercial project has some sort of advantage. There is a real risk that as users and developers move towards project B, network effects take over, and B comes to dominate.

The GPL is one answer to this problem, that the Apache Software Foundation, and others in the “BSD camp” have chosen to eschew, in favor of another solution: 1) making the development community broad enough and strong enough to make it hard to vacuum up all the talent over to project B, and 2) moving fast enough with the project that development outstrips that of project B.

Of course, that strategy is not always possible, but that’s the direction to take, I think – make it so that it’s a big effort to ‘keep up’ with project A for the commercial guys, to the point where they don’t want to diverge very far from the main development line for fear of not being able to keep up with all the good stuff coming out of it. One of the ways this can happen with a BSD style license is to get lots of companies contributing to the common code base, something that is at times easier if they have no worries about restraints the license may place on their future directions.

Incidentally, I also think people may like the GPL because it makes things “fair”, without worrying so much about putting in the effort to “outrun” the competition in terms of code or community.

These are some of the reasons why I don’t get too worked up about there being a “best” license. It really depends on the situation, and the goals of the people involved, too much to get fixated with one license being “superior”.

Feisty to Gutsy Upgrade

I have a computer with a RaLink RT2561/RT61 wireless card that never worked very well under Feisty, so I decided to try out Gutsy, on a whim.

The good:

The card now works! So that’s good news. Other than that, none of the features listed here is a big deal for me, but it’s nice to get a lot of programs updated to newer versions.

The bad:

https://bugs.launchpad.net/ubuntu/+source/linux-source-2.6.22/+bug/115616

Luckily it’s easy to fix.

The ugly:

Upgrading emacs was a pain, as a lot of packages seem to cause breakage with emacs22. That’s not really the fault of the Ubuntu guys, but it would be wonderful if they’d fix it prior to release.

I haven’t used the computer much yet, but consider the release isn’t official yet, it’s not bad, but I think it still needs a little bit of work. Anyway, I’m happy that my card works, I’m happy.

Languages: worst case vs average

This is a pretty good take on Tim Bray vs Erlang. However, I’d like to focus on something said at the end:

The fact is, all languages optimize for particular problem domains and I don’t think that a universal programming language exists that would perform well on all tasks. Bray rapidly found out that Erlang isn’t optimized for doing line-oriented I/O and it’s regex library sucks. So what? While those problems could be eliminated from Erlang, the fact that Ericsson has deployed large telecom gear without having to fix those issues means that Erlang is ideally suited to its original programming domain.

The problem is that learning new languages is difficult for many people. They’re not going to bother starting from 0 with a new language if what they’ve got is only 10/20% worse than the other guys. For companies, developing expertise (and trying to maintain it) in lots of languages is probably less productive than picking a few (Google only has four: Java, Python, Javascript and C++, and they’re not exactly lacking in brainpower or cash). This is why “the right tool for the right job” works for things like saws and hammers, but not for complicated, idiomatic things like programming languages.

Therefore, it’s important that languages that aim to be widely used do lots of things pretty well, and try to avoid doing anything really badly. This is something I’ve always admired about Python, even if I don’t use it anymore. It’s a language that you can do a very wide variety of tasks with, and you can be sure there’s probably some code out there already, and that Python will be ok for your task, even if it’s not the best thing. Performance is a weak point compared to compiled languages, but even there, get the libraries right and things aren’t so bad.

In any case, my point isn’t to bash Erlang (which I like), or put Python on a pillar (I prefer Ruby and Tcl), but to say that a widely used programming language doesn’t need to be the best at everything, but it should aim to make people comfortable using it, safe in the knowledge that they can probably do most things ok if needs be. That’s a far better situation than being able to do one thing realy well, and perform poorly at many other tasks, forcing its users to look elsewhere for solutions to those tasks.

Personally, I think that for concurrency, Erlang is in a bit of a race right now – they’re pretty far ahead in terms of concurrency (and also fault tolerance, but fewer people care about that), but behind in other areas (less library code). Other languages don’t have as good a tools for concurrency, which isn’t an easy problem. So, what will happen first – Erlang catches up elsewhere, other languages get “good enough” concurrency solutions, or a new language (like Scala) comes along and takes the lead?

Hecl Tutorial

The guys at Free Software Magazine just published a Hecl tutorial that I wrote.

They’re a pretty good outfit – you won’t get rich, but since the article is under a free license, I’ll be able to integrate it with the Hecl documentation pretty quickly, which was more important to me than a few dollars here or there.

Erlang

As someone who tries to read a lot about my field, I feel I have my “ear to the ground”, so to speak. And right now, I’m picking up a lot of hype-rumblings about the Erlang programming language. I have a little bit of experience with it, having used it briefly about 3 years, and having made a few minor contributions.

Why are people interested in it? Picking up new programming languages is fun for some people, but in general, unless it’s something backed by millions of dollars of marketing and development (Java, C#/.Net) there needs to be a ‘killer feature’ to drive adoption. Tk and Tcl, ease of developing simple dynamic web content with PHP, Rails and Ruby, and so on. Erlang, in many people’s eyes:

  1. gets concurrency right, or at least is a big improvement over existing models (threads).

  2. Makes distributed computing easier and does it naturally.

  3. Is a solid base on which to construct reliable applications.

That appears to be enough to have nudged Erlang into a position where it has a chance at the big time.

While I would highly encourage people to learn a bit of Erlang, and to seriously consider its use for the type of systems for which it was created, I have some doubts about it becoming that widespread. Please read the following as the thoughts of a critical mind, and keep in mind that it’s far easier to zero in on defects than it is to create something from scratch, so do not misconstrue my writing as being “against” Erlang (I do use it, enjoy it, and recommend learning it!), but as an honest appraisal colored by my own view of the world, which might not be like yours.

To begin with the superficial, its syntax is a bit odd. For a professional programmer, that shouldn’t present much of an obstacle, and indeed isn’t after a few days of using it, but there are a few things that I do find a bit annoying despite being used to the syntax, first and foremost being the use of . and , to separate lines of code, rather than a newline, or ; (which is used elsewhere). They’re like little mouse droppings – hard to spot, and they get in your way when you swap out bits of code here and there. The last line of a function must end with a ., but other lines are separated with commas, so when you’re cutting and pasting lines from here to there, you end up having to recheck the line endings each time.

Erlang is a functional programming language. Once again, someone with a wide exposure to many programming styles will not find this difficult after a week or so of practice, to wrap your mind around a different way of thinking. However, I have some doubts as to whether a functional language will be able to bring on board the numbers necessary to be widely adopted (see Scaling Down).

One of the benefits of wider adoption is, indeed, having a wider set of libraries – it’s a “positive network externality” in terms of economics. Other people have written about the relative lack of Erlang libraries to do various things, but it’s actually not one of the things I’m worried about – it’s something that will take care of itself if the language grows in popularity. After being spoiled by Ruby’s gems, what I really miss, though, is a nice, simple, easy distribution mechanism.

Related to making it easier for J Q Programmer to adopt, the error messages are at times not the most helpful I’ve seen in the computing industry:

Error in process <0.29.0> with exit value:
{undef,[{shell_default,sfdsf,[]},{erl_eval,do_apply,5},{shell,exprs,6},{shell,eval_loop,3}]}

In English, that means that I tried to execute the function sfdsf(), which doesn’t exist. It seems that there ought to be a way to keep the nice, computer parseable error messages, and add in something that humans would find just a bit easier.

Other people have already covered the problems with Erlang’s strings, so I won’t belabor the point. Suffice it to say that, in my opinion, is_list([foo, bar, baz]) and is_list("hello") should probably not both be true.

Which brings us to another issue. Erlang is a language used in big, reliable systems like telephony switches. That’s not the sort of environment where you want to break things, so I doubt that Erlang will ever see big changes that introduce incompatibilities, like Python has recently done. This one is a tradeoff – stable, reliable and backwards compatible is simply not compatible with rapid development of the language – it’s a zero-sum game, you want more of one, you get less of the other.

Related, is the “open sourceness” of the language. It is open source, which for me is very nearly a prerequisite for dedicating my time to a language, but Ericsson appears to maintain firm control over it. This is another thing that’s both good and bad. Having the backing of a large corporation means that developers are paid to work on and enhance Erlang, which is beneficial to everyone. On the other hand, as some people say, open source is just the start, open development is important too. Random thought: I bet Erlang would make a nice Apache project, but I’m sure the bureaucracy involved would be a nightmare.

In terms of the language itself, beyond the syntax, it feels a little bit too verbose. Perhaps not as much as Java (that would be difficult, wouldn’t it)… maybe I’m just used to Ruby, which is about as concise as I’m comfortable with while still being readable. Sometimes, though, there is a little bit more ‘repeat yourself’ than I would like to see. For instance, in this implementation of string_join (something else that ought to be in the standard library, but still isn’t), it’s necessary to create the same function, with different arity, simply to work around the fact that it’s not possible to say the default separator should be ” “:

string_join(Items) ->
    string_join(Items, " ").
string_join(Items, Sep) ->
    lists:flatten(lists:reverse(string_join1(Items, Sep, []))).

Which is a lot more typing than string_join(Items, Sep=" "). This is pure opinion, and very subjective, but Erlang to me feels like it falls more in the “systems programming language” category than “scripting language”. It’s a bit more verbose, it needs to be compiled to run it, modules need to have an entry point… it’s not as suitable to quick throwaways as Ruby, Tcl or Python. Of course, it is certainly higher level than C, and leaner than Java, but still falls an the other side of an admittedly fuzzy line in my head. Its command line options reinforce that. Whereas “scripting” languages do the obvious thing first:

ruby foo/bar.rb

Erlang is a little bit more complex:

erl -noshell -pa foo/ -run bar

A minor detail, once you get used to it, but still, I prefer the “do the obvious thing first, and let the user have some say in the matter if they want to do something else” approach to systems design.

One of the wonderful things about Ruby on Rails, is that it uses Ruby throughout, templates included. Without getting into the merits of using templates vs other systems, my own opinion is that Rails gets them right, and demonstrates the flexibility of Ruby by using it as the language for the templates, rather than inventing some other solution. I don’t see the same flexibility in Erlang, which is unfortunate, as it blows Ruby out of the water in terms of being a very solid solution to deploy on a server (no fiddling with proxies and load balancers and single threaded mini-servers + hot code replacement = nice).

Of course, there are lots of good things about Erlang, as mentioned at the beginning of this article – concurrency and distribution, but also language features like pattern matching that are a lot of fun to use, a pleasant syntax for dealing with binary data, list comprehensions, first class functions, tail recursion, and lots of other goodies. However, if I had to try and predict the future, I could easily imagine another language grabbing some of Erlang’s good ideas and running with them, perhaps being more “conventional” in other respects – this isn’t uncommon in the languages field, as we’ve seen with things like Lisp and Smalltalk. On the other hand, one of the reasons I am quite happy with Erlang is that it is most certainly not a proof of concept – it is a very practical language that excels at solving certain classes of problem, and does so in many commercial settings. If you’re the kind of person who enjoys new things, check it out!

Stuff To Do now open source

Since it’s not really my primary focus these days – there are simply too many things like it out there – I decided to release Stuff To Do as open source under the GPL. I chose that license, because as a complete application, I don’t see it being that much of an issue, as compared to, say, a library, where I find the GPL annoying. If you would like to use some portion of the code under a more liberal license, feel free to ask – I’ll almost certainly say yes, even if it’s for your own proprietary project. The code isn’t very elegant, I was in a hurry to create the whole thing, and was still learning with Rails, but it does work. It currently has zero documentation, in terms of describing the code.

If all that sounds exciting, the RubyForge project is here: http://rubyforge.org/projects/stufftodo/