Archive for the 'Software' Category

Clojure Web Programming and Ring

Saturday, December 14th, 2013

Just some notes to myself… If you find it helpful, great! If you find it confusing, my apologies.

Ring is the lowest level integration point between a Clojure application and a web server; it’s at about the same level as Ruby’s Rack, or Python’s WSGI, or Tomcat’s AJP. However, unlike in those other languages, most Clojure web applications and frameworks don’t sit much higher than Ring, so it’s pretty important to understand how Ring works.


Compiling Afner fails with gcc 4.5+

Friday, August 26th, 2011

WARNING: Googlefood, thus boring…

Issue: Afner compiled fine with GCC 4.4, but when trying to compile Afner with GCC 4.5 or later, the compilation dies with:

suffixtree.h:66:14: error: class ns_suffixtree::suffixtree::node is protected
suffixtree.cpp:208:19: error: within this context
suffixtree.cpp:208:1: error: ns_suffixtree::suffixtree::node::node names the constructor, not the type

Problem: Between GCC 4.4 and 4.5, the compiler changed to support “specializing C++ constructor templates.” This caused the meaning of “class X::Y::Y” to change.

Fix: Edit src/suffixtree.cpp, and at line 208: change suffixtree::node::node * to suffixtree::node * (i.e. delete the trailing ::node.)

I would have sent it upstream, but Afner doesn’t appear to be under development any more, there’s no open repo that I can check if this is already fixed and just not released yet, and I don’t really want to take responsibility for forking the project just to fix one line. :)

Note that the general fix should work for any “X::Y::Y names the constructor, not the type” error – Drop the duplicate ::Y. Of course, your mileage will undoubtedly vary.


Software Development in a nutshell

Monday, February 16th, 2009

Jeff Atwood reminds us of the only eternal software development methodologies:

  1. DRY: Don’t Repeat Yourself
  2. KISS: Keep It Simple, Stupid
  3. YAGNI: You Ain’t Gonna Need It

These, of course, are mere stepping stones on the road to development nirvana, the Cardinal Virtues of a Programmer, which are:

  1. Laziness: Lazy programmers do not like to write the same code more than once. Thus, a lazy programmer is much more likely to write code to be reusable and as applicable in as many situations as possible.
  2. Impatience: Impatient programmers do not like to do things that they know very well the computer could do for them. Thus, impatient programmers (who are also lazy) will write programs to do things that they do not want to have to do themselves. This makes these programs more usable for more tasks.
  3. Hubris: If programmers have hubris, they are much less likely to write unreadable code. A good bit of hubris is useful–it makes programmers want to write code that they can show off to friends. Thus, hubris, when practiced in the conjunction with laziness and impatience, causes programmers to write reusable, complete and readable code.

Note 1: This post exists because tattooing all this on my forehead would be too painful, and then I wouldn’t be able to see them either.
Note 2: The definitions of LIH are taken from Picking Up Perl by Bradley M. Kuhn.