Scherprechter neemt poolshoogte

(I decided to limit myself to one rant a year. This is it.)

Just saw this blog post (via Hacker News): Dear Python. In it, the author lists a number of complaints he has about Python.

There is so much wrong with this article that it’s like shooting fish in a barrel.

First of all, the post seems to imply that Python started out great, but then added inferior copies of features found in other languages:

But then you got jealous of the big players. You saw that others had things you didn’t have and you wanted to compete in a game that you were never destined to play. And who could blame you? The megaliths in the crowd like Java and c++ were beginning to overshadow the small guys and were even starting to overtake some of the oldest and wisest players: c, Fortran, lisp. What did they have in common? Objects.

Objects have been around since the very first public release of Python (0.9.1). They were not added because of “object envy”. Hell, Java didn’t even exist when Python first came out.

But you weren’t ecstatic about objects. You didn’t really like them and you didn’t trust them. So you decided to only give them a little. You cut corners. You made objects but you made them hard to use. That was a mistake.

That’s another odd argument… IMHO, Python’s objects are *much* easier to use than, say, Java’s, or C++’s, where you have to micromanage access (public? private? protected?), write (often superfluous) getters and setters, and deal with such niceties as as “final” classes, checked exceptions, abstract classes, interfaces, etc. In Python, I can just write the class, stick in it whatever I want, *use* it however I want, and move on.

There is no encapsulation. There are three tiers to OO. One of them is encapsulation. Having OO without encapsulation is about as nice as sawing a leg off a three legged stool. I can hear you yelling, “That third leg is completely unnecessary. We’re all consenting adults here. Just balance, like this…” *crash*.

I am assuming that by “encapsulation” the author means “data hiding”. Python’s philosophy here is that in order to separate interface from implementation, data hiding is not necessary. That’s where the “consenting adults” idea comes from; you are *supposed* to talk to the object using its interface (methods or properties, usually), but if you really have to, you can easily access any attribute. There are ways to make this harder, but (again, IMHO) they are not very Pythonic.

Also, the notion of “three tiers to OO” really depend on which definition you go by. Java, C++, C# and their ilk are neither the first word in OO, nor the last. Languages like Smalltalk, Self and Io have (sometimes radically) different ideas about what objects are and how they are handled.

Then, libraries:

However, these libraries are inherently static. This means that if the library doesn’t do what you want it to, you are screwed. There is no diagnosing or fixing errors in the library. If they happen, pack up and try a different language.

I’m not sure in what sense Python’s standard library is “static”… there are a few built-in modules written in C, but most of them are in pure Python, and the source code is readily available. You could change them if you must, but a better approach would be to subclass them and replace the offending features/bugs. (Note that there are no “final” classes and private attributes to get in your way here. :-)

(The httplib problem mentioned looks like it can be solved by setting a proper timeout value, by the way. I’ve written several web crawlers in Python, and never encountered this issue.)

Then there’s the tired old “explicit self” argument again:

[...] But sadly, this is exactly how python is. It doesn’t really take care of anything for you. You have to have “this” as the first argument to every function in a class. Once in a function, you have to use “this” to access any variables or other functions.

I’ve written about this before (in 2003!) so I’ll just links to those posts here, rather than repeating it:

And here’s what Guido himself has to say about it: Why explicit self has to stay.

The Java way is better. The implied this is easy to understand. Some IDE’s even highlight the class variables with a different color than the local variables, allowing an easy distinction. In the end you save tons of characters by having an implied “this”.

The implied this (in a method’s argument list) may be easier, but Java gets away with this because it doesn’t have actual functions. Python, as a multi-paradigm (god I hate that word :) language, does, and in fact methods are really just functions that you stick in a class.

Also, the “tons of characters” you save don’t mean much, when a typical Java method definition starts with stuff like “public static final void …”!

To add insult to injury, python has no explicit support for member definition. A class’s members are created by setting them equal to something. There is no way to explicitly define them in the class definition. Anybody, anywhere, can add (or remove) members variables from a given object. Classes in Python are more like dictionary objects with functions attached than classes.

Um, yes, the lack of declarations is one of the factors that makes Python code shorter and more flexible. And indeed a class (or an object) is much like a dictionary with some special rules added. Hint: the same is true for languages like C++ and Java, except they hide that dictionary behind a ton of cruft, so you won’t notice it as much.

I agree that removing attributes from a class or object generally isn’t a good idea, but then again this doesn’t happen a lot, unless in special cases.

After much frustration at using your broken OO, I decided to give it a rest. Maybe python would make more sense if I just treated it as a flat procedural language. Then I noticed lambdas. [...] They can only be one line.

Agreed, Python’s lambda sucks compared to functional languages (and even Ruby). However, it was intended as a shorthand for simple functions, not as a full-fledged alternative to def.

Python, you are just like the little kid Peter. You see something others have, decide you must have it, and then you just stick it somewhere. To become a better language, you must outgrow this little kid copy cat phase.

If you want objects, implement objects all the way. This includes things like encapsulation and variable definitions. But if you don’t want objects, then don’t implement them at all. It is no help for anybody when you implement something that you don’t want people to use.

This really makes no sense. “Implement OO like Java, or don’t implement it at all”. Gee, go tell that to the authors of Smalltalk, Io, Self, CLOS, Simula, OCaml, even Ruby. Again, what “object oriented” means isn’t written in stone, and Java’s implementation of it certainly isn’t the gold standard. I don’t think the original inventors of OO intended the language to get in your way constantly, for starters.

~

Granted, Python has its problems. Over the years, these have become more clear to me. I am mostly infatuated with ultra-dynamic and/or functional languages at the moment (but that is a different story…). I don’t like the join method on strings, the fact that we have classmethods/staticmethods/etc now and all that drivel, and I would have liked the language to be more flexible, for example. But all of these criticisms are fairly minor. Python is still the language I am most comfortable with, and the language I reach for first in many cases.

So, yeah, I can understand people’s frustrations with the language, but this is just completely wrong. And what is this !@#$ about Python being a copycat language?! Yes, some features were borrowed from other languages — list comprehensions come to mind — but there aren’t that many examples of it, and it’s hardly the only language that does this. In fact, if I’m not mistaken, Java, C++ and C# all have grown features borrowed from dynamic languages… except such features tend to have limited use in a environment that is statically typed.

:: Comments (3)

iPad

Fortunately for all rumor mongers, it was indeed a tablet that was announced by Apple today. They would have looked quite silly if it had been something else. :-)

From what I’ve seen so far, I like it. As usual, there’s a large number of bloggers and commenters who disagree, sometimes with valid arguments, but most of them seem to be of the flavor “oh noes it has no camera” or “it’s just a large iPod Touch”. Whatevs. Most people won’t care, they will just use it for videos, music, web surfing, reading books and magazines, email, instant messaging, and much more, without a steep learning curve. Sure, it’s not a replacement for a “real” laptop or desktop computer, but I don’t think it was intended to be anyway.

Personally speaking, I do want one, but not immediately when it becomes available. Not only do I not have the funds for it at the moment (I was unemployed for ~5 months last year, remember), but also, from what I have seen, it’s better to wait when buying hot new Apple products. (Remember the iPhone price drop?) Chances are the price will go down, or the low-end model will be beefed up. They will likely also need time to iron out the wrinkles in the operating system, and developers would need time to start writing apps specifically for the iPad.

(When/if I have money to blow, I would probably sign up for the developer program and start writing apps. And in spite of the App Store restrictions, I might be able to use Scheme! :-)

One thing I am wondering is if the touch screen will work (or can be made to work) with a stylus… essentially you’d then have a Wacom drawing pad. Coupled with the right software, that could be a great tool for artists. (Or musicians… imagine a Kaossilator app…)

:: Comments off

Fun with Gentoo

So I installed Gentoo Linux the other day… I then spent most of Friday night and Saturday (I know, I am lame =) trying to set the console font to a size that I liked.

Backstory: Gentoo insists on booting up in a resolution of 1024×768 on the iMac, and then sets the console dimensions to 128×48, which leads to a font that is just a little too small for me to read comfortably on this screen. So I spent a lot of time trying to set the resolution to 800×600, hoping that this would lead to a larger font. Under OS X, that resolution works fine, but under Gentoo, the machine refuses to recognize it. Or rather, it ignores video settings that I pass, or the screen goes blank and the computer seems to hang. Pretty weird. At some point I even tracked down the driver in the kernel source, changed it to boot into 800×600, recompiled and reinstalled… which had the same effect as manually setting the resolution, i.e. the computer hangs.

So eventually I started looking for larger console fonts. There aren’t many… there’s the Sigma font, and Terminus… I am using that last one now, and I don’t like it too much, but at least I can read what I’m writing. :-) Fortunately, the sources of both fonts are available, which means I can change them to my liking, or create my own font (eventually). ^_^

Other than that, Gentoo works great on the iMac. Network worked right out of the box, which is essential as many packages can be downloaded using emerge.

Well, back to my hacking configuration hell… :-)

:: Comments (2)

The penguin has landed

So, I got my old/new iMac yesterday. I figured I’d try installing Gentoo on it, and if that didn’t work, try an easier install like Ubuntu or Yellow Dog. As it happens, the install worked fine. I did a minimal install, compiled the kernel, etc… and to my surprise, ended up with a working Linux system. :-) (I expected it to be crazy difficult, but it wasn’t so bad.)

I recommend trying this; it’s a great learning experience when you don’t know much about what makes Linux tick. I learned a lot, anyway.

Although the PPC version is not “official” (it’s supported by the community), it appears to be up-to-date and the installation went well. Granted, there were a few parts in the handbook that worked a bit differently in the newest version of Gentoo, but nothing I couldn’t figure out. Overall, the manual did an excellent job of guiding me through all the steps (many of which I had never done before, like setting up a file system from the command line, or preparing and compiling a kernel).

Now I just need to find a way to set the text mode to something lower than 128×48, and I’m golden… =)

:: Comments off

Dear lazyweb: Which Linux distro should I use?

So this week I will be getting my “new” iMac, and I want to install some version of Linux on it. However, the following restrictions apply:

  • This is actually an old iMac from around 2000-2001 or so. Specs: G3/450, 256 Mb of memory, 20 Gb hard drive, DVD-R. (Note that this is a PowerPC.)
  • Linux should run in text mode only. (For various reasons, e.g. to save space, because the machine isn’t really equipped to run GUIs smoothly, and because I actually LIKE text mode. :-)
  • I want to do as much as possible with this machine, so any distro that caters to text mode users (more so than usual), gets extra points.
  • Although I have a few years of experience with Unixoid systems, I am not all that familiar with Linux per se, so the distro should probably not require expert knowledge.

So far I am considering Ubuntu (server install), Debian, and maybe Gentoo. (Although I don’t know how difficult it is to use… the compilation part doesn’t scare me… and the Portage package management system is apparently written in Python, which is interesting.)

Are there any other distros that would be suitable for a PPC with limited hardware?

:: Comments (5)

Grrr

WordPress just ate my post. Don’t you just love web apps? It’s going to be even better when (as people predict) *everything* will be “in the cloud”, so I can spend all day typing in a cramped input field in a browser window, and then be unable to access my data OR my programs when my internet connection acts up. >=(

:: Comments (1)

Eeuwenoud

Sorry, maar dit moet ik even kwijt. Ik zie steeds meer artikelen die de uitdrukking “de jaren tachtig van de twintigste eeuw” gebruiken (of jaren negentig, enz). Wat is dat voor onzin? Waarom niet gewoon “de jaren tachtig”? Dat het niet over de jaren tachtig van deze eeuw gaat, snap ik ook wel. In plaats daarvan voegen we het volslagen nutteloze “van de twintigste eeuw” toe, alsof dit heel erg lang geleden is. Misschien zijn deze teksten geschreven door personen van 15 jaar oud of zo, die zich de twintigste eeuw niet kunnen herinneren?

:: Comments off

2010: Return of focus … maybe

Ah… 2010. It seems my website survived, and so did I.

I don’t really have any resolutions, other than that I generally want to move toward more simplicity and minimalism, in my personal projects (programming-related and otherwise), but also in my life.

One of the things I want to try is to set up a dedicated machine that only has a command line interface, no GUI or other kind of desktop environment. To this effect, I picked up an iMac G3 from eBay (for $70 including S&H — can’t beat that :-). When it gets here next week or so, I plan to install some sort of Linux on it… maybe Debian or an Ubuntu server edition for PPC. I want to use the “new” machine for as much as possible: hackery, but also stuff like blogging, chat, and maybe keeping up with social networks, as long as they have command line interfaces. (But all the important stuff should work: Emacs, vim, svn, git, programming languages, zsh, IRC…)

Of course I won’t be able to do *everything* on an old iMac with a text prompt. Work will be done on my new HP Mini 311, for example. Other things like burning CDs, reading comics or blaring my music will still be done on the MacBook. Etc.

But, the idea is that the command line should help me focus. Modern computing environments can be very distracting. Multitasking operating systems are great (wouldn’t want to go back to the MS-DOS days, which was the last time I really used text mode), but that doesn’t mean I want to see everything at once. As more and more applications become web-based, this only becomes more of an issue, as many web pages are overloaded with links, sidebars, menus, ads, search boxes, irrelevant images, etc. Not too mention that it’s way too easy to click on this link, and that one, and oh yeah did I get an email back yet, and who’s on Facebook right now?

I am not a luddite… but it may be a good idea to have an alternative environment where all of this information overload doesn’t necessarily happen. Or at least, where it’s not right in your face.

I also, finally, figured out that I love text. Many of the projects I did, am doing or want to do, are centered around text. Some of these things keep coming back, like writing text adventure frameworks, interpreters / compilers / assemblers, client-side blogging tools, text editors, even roguelikes (still text!). I love languages (both programming and “natural”), reading, writing, blogging… so what better environment to do all this than a text prompt? :-)

(Using a text editor sure beats having to type your blog post in a 400×200 frame inside a browser window, I tell ya.)

Related to this are a few minor sub-goals, by the way. I turned off aMule. I got a Palm Zire last year that has been helping me become more organized. Keeping workroom and bedroom tidy (well, as far as that works around here :-) seems to help too, and so does getting rid of stuff you don’t really need or use. Hopefully all this means that I will have more time for important stuff, like studying, spending time with family, or maybe picking up some old pastimes, like painting.

I talk too much… apparently the focusing has not taken effect yet. :-) Happy new year!

:: Comments (2)

2009 reprise

Another year went by. Much has happened. … OK, maybe not that much. Still, here’s an overview.

  • Health-wise, we’ve been doing relatively well. My wife’s condition is stable. Baby Amari is doing well, walks around now, talking up a storm (although nobody knows what she’s saying :-). Myself, I am pudgy as usual, and had high blood pressure for a while, but that seems to be taken care of.
  • Professionally, things didn’t go so well… The 20 hours at iTrackr became none at all, after which I spent several months looking for work. Applied to a ton of places, sometimes got an interview out of it, but no success (other than a two-month contracting job for Sean McKay, which helped us staying afloat). Eventually I was re-hired by Oasis Digital, a previous employer of mine, to work on the same system that I originally wrote for them during 2002-2007. (Besides maintenance, we are going to do some more interesting stuff as well, like porting the code base to IronPython.) I actually like that a lot better than iTrackr… =/
  • Family life has been chaotic as usual, but it has been improving. People still do stupid stuff, is all I will say about it here.
  • Programming languages are still one of my main interests… so I dabbled in many of them, some new, some old, e.g. Clojure, Miranda, Haskell, OCaml, SML, Q, J, Io, Common Lisp, D, etc. I also wrote a few toy interpreters (see my projects page).
  • I finished the Magi-Nation Search project (well, mostly). This is really more for personal use since nobody plays Magi-Nation anymore, but still. It also gave me the opportunity to get some experience with Google App Engine.
  • Didn’t travel much; went to Disney, that’s about it. :-) No visit to the Netherlands this year; maybe in 2010?
  • Reconnected with old friends and acquaintances on Facebook and elsewhere. (Hi, Mirella. ;-)
  • Being unemployed and all, I sold some stuff on eBay so I could get new gear for work. (Lesson: 80/20 rule applies here… 20% of the items account for 80% of the money.) I had been looking at netbooks for a while, and eventually decided on getting a HP Mini 311. I like it, but that’s a topic for another post.

:: Comments (1)

Top 10 8 of 2000-2009

Everybody has been posting their lists of the decade… especially music. Here’s my list of the best albums of 2000-2009. I couldn’t even find ten that were consistently good, actually. *frown*

In no particular order:

  • Styles of Beyond: Megadef
  • Osdorp Posse: Tegenstrijd
  • Ugly Duckling: Taste the Secret
  • The Donnas: Bitchin
  • Northern State: Can I keep this pen?
  • Le Tigre: This Island
  • 1200 Techniques: Consistency theory
  • ‘t Hof van Commerce: Ezoa en niet anders

Artists that should have released albums that would be in this list, but didn’t:

  • Rakim (Wat een slecht album. Rakim had dat natuurlijk gewoon met Seda en DJ Daan moeten opnemen…)
  • Beastie Boys
  • Clawfinger
  • IAM
  • Public Enemy

Honorable mentions:

  • Jawat (one of the few Dutch rappers that is any good, now that the OP is gone)
  • Duo Kie, Triple XXX, Keyo, Jefe de la M, Arma Blanca (Spanish rap)
  • Svinkels (French rap)
  • Massilia Sound System
  • Nitro Microphone Underground (would be in the list, but I’m not sure if “Colaboraciones vol 1″ is a real album…)
  • Jurassic 5
  • Hammerfall
  • Blind Guardian

But overall, I discovered *many* more pre-2000 albums (and often pre-1990) that were much better than most of what I heard in the 2000s. I guess my musical taste is firmly grounded in the 80s. But then again we *knew* that… :-)

:: Comments off

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »