jump to navigation

Another reason why I need to learn Lisp 31 August 2009

Posted by manniwood in Uncategorized.
add a comment

Today’s Hacker News linked to Why Lisp macros are cool, a Perl perspective, and it made me want to learn Lisp. I just need to make the time…

One thing that Lisp doesn’t have going for it is its syntax. Lisp syntax is so uniform that it’s not particularly user-friendly. It’s macro-friendly (read the above link and you’ll see why) but not as human-readable as programming languages with more syntactic sugar.

Apparently, Perl 6 is going to have Lisp-like macros, even though Perl 6 will still have Perl-like syntax. It will be interesting playing with that when Perl 6 (Rakudo?) has a beta release. Is it possible that we could have it all? Richer, less-uniform syntax, and yet still the power of macros? That would be nice…

Notes on Design Patterns, Frameworks, Ever-Higher-Level Languages, and Why I Want to Learn Lisp 29 August 2009

Posted by manniwood in Programming.
2 comments

Here’s a shout-out to a blog entry that says “Design patterns are common structures that appear in computer programs, but that can’t themselves be abstracted into a reusable component”.

I remember early on, when porting some of my Java code to Python, I wanted to make a singleton in Python. I turned to my copy of the Python Cookbook, and found that singletons are very rarely needed in Python, because Python’s modules exhibit essentially the same behaviour. It was one of those learning moments for me, when I realised that I was trying to write Python like Java, and that I should try to write Python more like Python. (In my own defence, we all do this when learning a new language. :-)

Here’s an observation by the always-fascinating Steve Yegge on design patterns:

About half of all design patterns out there (not just the GoF patterns) appear to be ways take perfectly natural design ideas and twist them to fit into someone’s static type system: recipes for pounding square pegs into round holes.

—Steve Yegge, Is Weak Typing Strong Enough?

Yegge’s quote also rings true to me, because I just don’t find myself doing a lot of design-patterny stuff in Python, presumably because Python’s dynamic typing and powerful built-in data structures (lists and dictionaries) prevent me from having to use a lot of objects and their attendant design patterns in the first place.

This makes me want to really, really learn Common Lisp, or Arc, or Scheme, or some language with full-fledged macros. What does this have to do with design patterns? I can’t really tell you, because I don’t know Common Lisp yet.

But here’s a sneaky suspicion I have.

I suspect that the same way half of the design patterns that Yegge mentions were invented to compensate for languages that lack dynamic typing and higher-level constructs, the other half of design patterns, and even entire frameworks (think: Ruby on Rails, Django) compensate for languages that lack true macros.

Now it could turn out that I’m wrong about this, or that there’s only a kernel of truth in my suspicion, but that the whole truth is more complicated.

But readers of my blog know that I give a lot of credence to Paul Graham’s idea that mainstream programming languages are slowly converging on the feature set of Lisp.

I’ve never heard of a Lisp or Arc framework for building database-backed web sites. Where’s Lisp’s Django, or Arc’s Rails, or Scheme’s Struts? I suspect that these languages don’t need frameworks, because macros are essentially tools for building project-specific frameworks.

Who among us has taken a framework like Django or Rails or Struts, and used the parts that solved our problems, and re-written or ignored the parts that didn’t solve our problems, or that introduced new problems? Now imagine what it would be like using a programming language that was essentially a framework construction kit; that allowed you to write a framework more quickly than learning and adjusting to a pre-existing framework?

The only higher-level abstraction I can think of off the top of my head is a language that enables you to easily construct your own domain-specific languages. (I like regular expressions for text searching and manipulation, and SQL for data searching and manipulation; imagine your own DSL for your exact business problem! That would even beat frameworks or even macros…)

Apparently, Perl 6 and the Parrot VM are going to try to tackle that exact problem. The problem is, Perl 6 hasn’t shipped yet. (I’ve only been waiting 10 years… ;-)

In the meantime, I really need to learn Lisp or Arc once and for all. I really want to learn about macros.

Does the Internet No Longer Operate on Internet Time? 27 August 2009

Posted by manniwood in Java, Programming.
add a comment

As sectors of the economy get more established, it seems that progress slows down and becomes more incremental. I’ve been wondering lately if the Internet no longer runs on Internet Time (a popular phrase from the roaring 90s).

I have two reasons to believe that the Internet is slowing down:

1) IE6 is still around.

2) Java is still the top programming language for web sites (although perhaps I’m ignoring the popularity of C#)

IMPORTANT NOTE: First off, I want to point out that I am not equating Java with IE6’s badness. Whereas I think most developers would cheer if IE6 disappeared tomorrow, I don’t think anybody wants to drive a stake into the heart of Java. I promised myself I’d try to make nuance a feature of my blog, so let me put some nuance right here: I’m not gunning for Java the way I am for IE6.

I’ll address IE6 first. In the late 90s, when IE became more popular than Netscape, Netscape seemed to disappear within a few years. It didn’t take long for most sites to simply stop supporting Netscape.

But when you look at how small the browser population was back then, in retrospect it seems like it would have been easy to turn away from Netscape in a couple of years, like turning a small boat.

On the other hand, when you look at the popularity curve of IE, waiting for it to go away will be more like trying to turn a battleship. Happily, the mindshare of developers is fully focused on the newer browsers; fortunately, even Microsoft wants everybody to upgrade to IE8; fantastically, large sites are starting to post warnings about discontinuing support for IE6.

But when you look at the longevity of IE6, even if its popularity dropped off a cliff tomorrow, it’s had a much larger, longer run than Netscape ever had. It’s as though the Internet is slowing down as it gets larger.

Now let’s look at the continuing popularity of Java.

Why do I equate the continuing popularity of Java with a slowing Internet? Because I think that if the Internet moved as quickly as it did in the roaring 90s, the current crop of Java programmers would happily be using what they deemed to be Java’s worthy successor by now, the way a lot of C developers switched to C++ (perhaps after some grumbling) and the way a lot of C++ developers switched to Java (perhaps after some more grumbling).

When you look at a rough time line, C seems to have been ascendant for about a decade, and then C++ for another decade, and now there seems to be Java. Java’s already been going strong for a decade, but unlike C and C++, it’s very unclear at this point if Java is on a downward slope or not.

If we are to believe Bruce Tate’s book Beyond Java, published four years ago, we would think that Java would be on its way out by now. Tate did a good job describing Java’s pain points. All languages have them, and Java is no more exempt from this than C or C++ are. But four years on, we are definitely not beyond Java.

It seems sort of inevitable that the same way C++ tried to correct C’s shortcomings, and Java tried to correct C++’s shortcomings, that some Java-community-anointed successor language should be here trying to correct Java’s shortcomings. After all it’s been more than 10 years since Java took over (largely) from C++ (not to mention clobbering Perl/CGI in the web application realm).

I suppose a whole blog entry could be written on why Java has no clear successor. Both Ruby and Python do not follow the C/C++/Java syntax, and that’s probably a real no-no in trying to win over Java developers. The Java community itself seems to be incrementally improving Java rather than creating a new successor language the way C++ aspired to succeed C, and Java aspired to succeed C++.

But today’s blog post is not going to try to explore the many reasons, good or bad, for why the Internet seems to be slowing down. I’m just going to use IE and Java as two data points to observe that the Internet is, in fact, no longer running on Internet Time.

RDBMS Static Typing vs. General Purpose Language Dynamic Typing 23 August 2009

Posted by manniwood in Programming, Python, SQL, Uncategorized.
add a comment

One thing that’s fun about being on the job interview circuit is that you get to re-think a lot of your biases and tastes.

Something that has occurred to me is that I prefer to program in dynamically typed languages when I can (lately that would be manifested as a preference for Python over Java) and yet this fails to explain my love for RDBMSs, and the static typing that goes with them!

For general-purpose programming, Paul Graham’s opinion definitely rings true, so I’ll quote him at length:

As far as I can tell, the way they taught me to program in college was all wrong. You should figure out programs as you’re writing them, just as writers and painters and architects do.

Realizing this has real implications for software design. It means that a programming language should, above all, be malleable. A programming language is for thinking of programs, not for expressing programs you’ve already thought of. It should be a pencil, not a pen. Static typing would be a fine idea if people actually did write programs the way they taught me to in college. But that’s not how any of the hackers I know write programs. We need a language that lets us scribble and smudge and smear, not a language where you have to sit with a teacup of types balanced on your knee and make polite conversation with a strict old aunt of a compiler.

—Paul Graham, Hackers and Painters

What’s interesting is that I find for the projects I’ve worked on, I really like to nail down the data model in an RDBMS, and then code the business logic and display code using as flexible a language as possible. I think this bias comes from two requirements I’ve encountered a lot in my programming career:

1) make stuff easy to report on

2) change data capture and display on a fairly routine basis.

To make stuff easy to report on, it’s nice to have constraints and other forms of data integrity enforcement, so that your reports are already half-way complete just because of how your RDBMS stores (or refuses to store) your data: you know your data are correct, and you just have to aggregate them. Honestly, I sometimes find RDBMSs a bit too rigid to deal with the ever-changing needs of business, but all mature RDBMSs seem to have good support for alter <anything> commands.

And if you can get your data stored in a consistent way in an RDBMS, SQL is at your beck and call to report on your data in all sorts of interesting ways. This generally pleases the business very much.

For the projects I’ve tended to work on, after all that hard work has gone into getting the data model right, I generally prefer to make as thin a layer as possible over that database, so that the database can essentially speak for itself. A dynamically typed language comes in handy here, because it will have good support for lists and maps, and not a whole lot of casting or type conversion has to happen to shuttle data back and forth from the display to the RDBMS, and vice versa. Manipulating and validating form input is generally much easier in higher-level languages as well, with their somewhat easier out-of-the-box implementations of regular expressions, etc, etc.

Of course, this leaves open some interesting possibilities. If my next project has ever-changing needs, and a data model cannot really be pinned down, will I try to squeeze that design into an RDBMS, or will I try to find a more flexible, non-traditional data store? I can easily imagine turning to a non-traditional data store if the data are too unruly, and don’t follow the sorts of patterns that would suggest using an RDBMS.

If the data were to rarely be reported on, I might not even miss SQL that much. After all, SQL really shines when it comes to reporting.

But if I had to generate reports from non-relational data, that might start to get interesting. As much as I love dynamically typed languages, this might be one area where I’d wish for SQL’s strong typing, because programatically preparing reports would feel sort of like re-inventing the SQL wheel.

I don’t know if I’ll ever be able to explain the seeming inconsistency in my love of dynamic typing in general-purpose programming languages, and my love of SQL and the strong typing that goes with it. Maybe it’s because I like storing my data in a formal way (when the data are amenable to it), but I like manipulating my data in a flexible way, especially when I know I can count on them being correct.

All I know is that on the projects I’ve worked on, it’s been a great combination. But I also know that all projects are different, and that not all data are relational. Maybe one day I’ll work on a project that uses dynamic typing from top to bottom. That would be interesting.

Excited About Non-Traditional Data Stores 21 August 2009

Posted by manniwood in Programming.
add a comment

Any readers of my blog will know that my experience with data lies almost exclusively in data that are best modelled in a relational way. So I have a lot of biases that have evolved through playing a lot in that problem space:

  • I like SQL a lot, but realise the SQL standard is an imperfect implementation of the relational model.
  • (Heck, I know what the relational model is, after reading lots of C. J. Date.)
  • I like writing SQL by hand, (roughly analogous to the way designers like to code their HTML/CSS by hand) because I think I get the best results that way.
  • I think the object/relational impedance mismatch is best solved by simply avoiding the situation: don’t use ORM.
  • If your data set is small but must be accurate (as has been the constraint on most of my projects), use a database that does this for you. (That is, declaring constraints in DML and having your RDBMS do the rest is a beautiful thing.)

On the other hand… :-)

I’ve been interviewing a places that use non-traditional data stores, sometimes on massive data sets, where ACID compliance is not paramount.

The challenges some of these project face sound really cool, and the tools they are using to meet those challenges would be a lot of fun to learn.

So first off, I should make something really clear: I have reasonably passionate views about RDBMSs, especially regarding small, accurate data sets, because I’ve done a lot of work in this area, with real-world consequences if I didn’t get things correct.

However, I also feel that not all data are relational!

Although I agree with C. J. Date that no other data model compares to the relational data model (at least in terms of being able to be specified in a rigorous way), not all data have to be stored in a way that conforms to the relational model.

For instance, I remember being a little bit afraid early in the development of Windows Longhorn (later to become Vista) when it seemed like they were going to make the entire file system a database. Really? I rather like the hierarchical file system! It turns out the Windows design team came to the same conclusion too.

Take server access logs. They are stored as flat files. Would they benefit from being stored in an RDBMS? I don’t know. It would be nice being able to run SQL queries on them. But you could also make the argument that sometimes a flat file is just a flat file.

Take documents. Some people store them in Lotus notes, some people store them as binary blobs in RDBMSs, and most of us still keep documents on whatever hierarchical file system our operating system currently uses.

Although I love the relational data model, as soon as you decide to use it for your data, you are immediately making certain decisions about the nature of your data, either implicitly, or explicitly.

I’ve played in the relational world for quite some time now, and am excited about looking at data through a different lens.

So maybe I’ll work on a project where modelling the data with objects rather than relations is the absolute right thing to do!

Maybe I’ll be on a project where transactions and constraints have to be enforced in the application layer, because the underlying data store cannot enforce these things itself (and that would be because the underlying data store has other strengths).

Maybe I’ll be on a project where the object model can be the definitive data model, because no other applications are ever given direct access to the underlying data store; so the data store will not have to be the final arbiter of what the data model is. Instead, the data will only ever be accessible as a web service, and so the API that we expose to the data will be the only legitimate view of the data.

I’ve played in the world of small, accurate relational data sets for quite some time. It could be fun to work with really large, semi-structured data sets, and see what sorts of solutions they require, and maybe challenge some of my core assumptions about data.

Will Python Make Me A Better Java Programmer? 21 August 2009

Posted by manniwood in Java, Programming, Python.
add a comment

As I said in J2EE Still Rules the Roost, the Python jobs are few, and the Java jobs are many.

So I’ve been interviewing primarily for Java jobs lately.

But it strikes me that knowing Python is perhaps an advantage. For instance, employers generally want to know that you’re excited about learning new technologies, and that you have a proven track record of doing so. Well, if you’ve taught yourself a new language and migrated your latest project to that language, that’s pretty good proof, right?

Also, more generally, the world of technology is always moving forward. We all have to keep up, and we should all ideally be forward looking.

I happen to be particularly impatient for that future to arrive, so when left to my own devices, I tend to embrace newer technologies. This is why I’m still chomping at the bit to learn Lisp, or maybe even Arc: I think Paul Graham is on to something when he says that languages are converging towards the feature set offered by Lisp. (Even if not the syntax offered by Lisp. Apparently, Perl 6 is going to have Lisp-style macros—if it ever ships.)

More immediately, will my knowledge of Python help me or hinder me if I end up programming Java at my day job? I think it will only help. Any time you’ve got knowledge beyond what you are required to know to solve the immediate problem at hand, I think it can only be a good thing.

J2EE Still Rules the Roost 19 August 2009

Posted by manniwood in J2EE, Java, Programming.
1 comment so far

Two blog posts in a row today!

This is another one about my on-going job search, and things I’ve been learning.

In Beating the Averages, Paul Graham talked about how using a high-level language like Lisp helped make ViaWeb a success. In one of his other essays, Great Hackers, he talks about how which language a business chooses to develop in determine the quality of programmers they can hire (on the assumption that great hackers are more willing to learn off-the-beaten-path languages).

And I must say, at the startup where I currently work, switching from J2EE to PythonDjango definitely made a difference with getting our product completed.

But the Python jobs are few, and the J2EE jobs are many.

Python and Ruby haven’t really broken through yet. Books like Bruce Tate’s Beyond Java (already four years old!) still remain hypothetical, describing a possible future that hasn’t arrived yet.

I’m still glad I know Python, and still glad we switched to it on my current project. Learning a new language gives you a new way of looking at the same problems. And hey: at least my knowing Python shows that I’m not a one-trick pony. When I say I like learning new things, my knowledge of Python supports that.

I still eagerly interview for Python positions when they come up.

But Python and Ruby, in terms of popularity, are still nibbling at firmly-entrenched Java. Python is a great language, and I hope it goes far, but Java is still where the market and the jobs are at.

What can ORM do for you? 19 August 2009

Posted by manniwood in Programming.
2 comments

One thing I like about the job interview process (as I am going through it now) is that you learn what your blind spots are as a developer. It’s not very much fun to find out what those blind spots are, but I did get into this profession because I liked learning new things. And what’s more useful than learning about your weaknesses?

I had a great discussion with a coder I used to work with today, and he pointed out something that was staring me right in the face: I may agree with Ted Neward, Jeff Atwood, et. al. about object-relational mapping being an insurmountable problem (the Vietnam of computer science, as Neward called it) but my coder friend said:

“Look at the market place! ORM has won!”

And he’s right! So what I need to be asking myself is, if ORM really is the Vietnam of computer science, why is everybody using it? There’s an opportunity for me to learn something here, and my attitude towards ORM is not reflective of my more nuanced attitude towards a lot of other things.

Case in point: I was recently asked my opinion on stored procedures in the context of building web applications, and I gave my typically nuanced answer about their strengths and weaknesses, and how they had their uses, but did not need to be embraced 100% nor rejected 100%.

And that same truth is staring me in the face with ORM, and I’ve been ignoring it.

I have mostly worked on sites where the data model was already written, was quite messy, and the CRUD (create, read, update, delete) operations were all non-trivial. My blind spot so far has been assuming all situations are like this. The popularity of ORM seems to indicate that this is not always the case.

In fact, in discussions with other developers, I find that most projects take a hybrid approach to ORM: they use it where it speeds up development and does not adversely affect application performance, and they do not use it where hand-coded SQL is the better way.

My programmer friend recommended I take a look at ibator, a code generator for iBATIS that is sort of like a reverse ORM: it introspects your database, and creates all the CRUD code and Java objects for you. I don’t think I’m quite ready to dive into Hibernate yet, but ibator seems like a good place to start. If I get time, I will blog about my experiences with ibator.

Don’t Worry: IE6 Is Still Dying 14 August 2009

Posted by manniwood in Uncategorized.
add a comment

I’m a fan of Hacker News, and a few days ago, I read the following headline:

IE6 is not going away for a long time because of corporate nightmares like these (sprint.com),

which simply links to a site at sprint.com that explains why one of their tools requires users to downgrade to IE6.

Makes sense to me. It all comes down to money, as everything in our market-based economy does.

It is in Sprint’s interest not to spend money on code that works perfectly well on IE6.

On the other hand, Facebook, Youtube, and others are starting to not support IE6 because not supporting IE6 is what saves them money. Even Microsoft wishes people would upgrade to IE8, now that the Redmond giant has finally started to move into the cloud: it even costs Microsoft money to develop compelling web applications for IE6.

We are nearing a tipping point where the amount of money saved by abandoning IE6 will be greater than the amount of money saved by continuing to support/require it. As with all things in our market-based economy, it will come down to votes (measured in dollars) as to whether or not IE6 stays or goes, and, with enough time, IE6 supporters will be outvoted. This will happen more quickly than people who fear “a long time” think.

The item I have my fingers crossed on is people skipping over IE7 and heading straight to IE8 the same way many will evidently go from Windows XP to Windows 7. (I can’t muster up the levels of hope to wish for people moving from IE6 to Firefox/Chrome—but I’d love to be wrong on that one, naturally.)

Another way to look at the REPL: it’s a sketch pad 13 August 2009

Posted by manniwood in Programming.
add a comment

I just finished re-reading Paul Graham’s hackers and painters essay (I actually have the book), and my love of the REPL came at me from another angle.

Graham talks about how programming is like painting, and it struck me that I like the REPL because it’s like a sketch pad. If I was painting some large work, and I came to something that I wasn’t good at (let’s say a house on a hill, and I was not very good at houses yet), I’d do a few test houses on some bits of paper or maybe even a small canvas, to sort of explore how to do houses well, and how I wanted my house to look. Then, after I was confident of a good result, I’d go back to my larger work and paint the house in.

(And, as Graham points out, because I’d be working in oils, if I really messed the house up, I could always paint over it. Apparently, X-rays of paintings show that even the great masters did this.)

I admire Graham because he so fully understands what an exploratory process programming is—in the real world, anyway. So anyway, if my main project is a large canvas, the REPL is my sketch pad.