Archive for March, 2008

Professor Layton and the Curious Village [DS]

I love this game. It’s basically a collection of small puzzles, disguised as an adventure. The charm of it is that you can pick it up at any time, solve a puzzle or two, and put it back down. Or at least you *could*… I find it very addictive. Some of the puzzles are well-known, like the pitcher puzzle, and a variant of the river-crossing puzzle, etc. Still, unless you do this sort of thing all the time, some of them can be quite challenging.

I like this sort of “brain exercises” better than the Brain Age type games… those tend to be focused on solving problems within a set time, which tends to really annoy me. :-)

:: Comments off

Resume hacking

Good developers might not need a resume, but I probably do. Here’s the current version.

I am not looking for a job at the moment (although not averse to finding a gig that I would really *enjoy* working on!), so this is a good time to take a critical look at the resume. The last time I solicited comments from readers was in 2003. It’s probably time for another overhaul. My job history may not have changed much, but there are parts that are much less relevant than five years ago. For example, I should probably remove ASP and VBScript. I did work with those, but that was back in 2000, and I have no intention of going back and taking up these “skills” again… so they’re really just dead weight.

Comments are welcome. Obviously I already know that I should trim the fat, but I would be very interested in any other tips.

Also, are sites like LinkedIn useful in any way? I’ve been avoiding such sites, but maybe I’m just stubborn.

:: Comments off

Interlude: 3 of 12

It’s almost April… So far it has been one hell of a year. My wife was diagnosed with cancer. Then her brother died last month. My 16-year-old (step)daughter has been a total prick, doing and saying hurtful things over and over again. (I know that is what 16-year-olds are supposed to act like, but she has been taking it a bit far.) Meanwhile, my 20-year-old (step)daughter is pregnant. Huge (medical) bills keep coming in. On top (and probably because) of all these things, I’ve been suffering from crushing depression, which in turn is making it rather hard to do my job right.

Hopefully the turmoil will settle down once two abusive household members will leave (they are expected to do this soon, in April). If not, I am not looking forward to the rest of the year.

This post is not meant to inspire pity or concern in readers, but rather to provide an explanation for if and when I don’t write so much. Real life tends to interfere a lot these days. :-(

:: Comments off

Sunday nitpickery: class-based vs prototype-based OO

This Wikipedia article on ActionScript claims:

“Two important features of ActionScript that distinguish it from later versions are its loose type system and its reliance on prototype-based inheritance. [...] Prototype-based inheritance is the ActionScript 1.0 mechanism for code reuse and object-oriented programming. Instead of a class keyword that defines common characteristics of a class, ActionScript 1.0 uses a special object that serves as a “prototype” for a class of objects. All common characteristics of a class are defined in the class‘s prototype object and every instance of that class contains a link to that prototype object.”

and (emphasis mine):

“[...] ActionScript 2.0 featured compile-time type checking and class-based syntax, such as the keywords class and extends. (While this allowed for a more flexible object-oriented programming approach, the code would still be compiled to ActionScript 1.0 bytecode, allowing it to be used on the preceding Flash Player 6 as well. In other words, the class-based inheritance syntax was a layer on top of the existing prototype-based system.)”

I’m not getting that. Prototype-based OO is, by its very nature, more flexible than class-based. It doesn’t even matter if the class-based OO flavor has bells and whistles like metaclasses, multiple inheritance, class methods, or whatever. All of these become redundant with prototype-based OO. So how can they claim that the addition of class-based syntax allows for “a more flexible object-oriented approach”? Maybe I’m being pedantic here, but that just makes no sense to me at all.

(It appears that the most widely used prototype-based OO language is Javascript. I am aware that its version of OO is often regarded as a hack, but it *is* still more flexible than OO in, say, Java. (And probably Python and Ruby as well, although I haven’t played enough with Javascript to make a bold claim like that. :-) For an example of what a real prototype-based system can do, see Io.)

Of course it’s possible that I misunderstand this, or that AS1′s version of prototype-based OO was so crippled that the class-based successor actually was an improvement over the old situation. I am currently looking into how AS3 handles all this. As far as I can tell right now, there is still some prototype-like stuff left. ^_^

:: Comments (5)

Web comics etc.

The other day, a friend asked what web comics I usually read. I figured I might as well post the list here, for what it’s worth.

In no particular order:

Also:

On a side note, both QC and WS have shown tremendous change in art quality over time. (Compare the first comics with recent ones to see what I mean.)

If you know any good webcomics, feel free to recommend them in the comments. ^_^

:: Comments off

Helio Ocean

Got my Helio Ocean today. I don’t have much to say about it yet… it’s cool, although not insanely cool :-), and some parts are surprisingly well designed, while other parts are, well… lacking. Until I have more to say, good reviews can be found here and here. I will say this though: the battery life seems to be *really* bad. I will have to look into that. You shouldn’t have to charge every few hours.

I like the dual sliders and the keyboard… at least typing text is a lot faster (and a lot less annoying) than using the number pad. I like that I can use the Ocean for both text messages (SMS) and instant messaging (AIM/ICQ, MSN, YIM). I don’t like that so far I haven’t found a way to have the phone notify me when somebody comes online. Oh well, I can’t have everything. :-)

I believe this kind of device is just the beginning… I think they’re going to be much more powerful and useful in the near future. Well, that is hardly a risky prediction… but hopefully it will be easy to write custom programs for them, too. :-) (Chicken on the Ocean… bad puns like Chicken of the Sea come to mind… hmm…)

Update 2008-03-25: According to the Ocean user’s manual, the battery life (when used) is “up to 360 minutes”… which is really unacceptably low. Who wants a phone that needs charging every 6 hours?! (Apparently there’s a reason that there are 4 products in the Helio store that deal with “keeping your Helio juiced”.) Hopefully there are better batteries available out there; I’m going to look around.

:: Comments off

Looking back at last year’s interview…

I love Steve Yegge’s post with Google interview tips. Not because I am currently considering applying at Google, but because it is a nice summary of what a good developer really should know (although by no means an exhaustive list). It also provides a bit of insight in what interviewers might have been looking for, during my Google interview last year.

Algorithms is one area where I tend to think “oh, I know this stuff” but then it turns out I am not as proficient in it as I would like to believe. I am currently reading one of the books Steve mentioned, Introduction to Algorithms, and found it very informative. (Although I tend to skip over the “hard” math stuff and the proofs… that is not really my cup of tea.)

Ironically, I don’t think I did so bad in this area during my interview (although it’s possible that I needed too many hints… I don’t know, they don’t tell you this). 1) I actually felt pretty good about it until my third interview, which was about SQL. I completely blew that one. It’s ironic because at my then-current job I had been dealing with SQL problems for years.

I like the “practice writing on whiteboard” idea mentioned in the article. Coincidentally (or maybe not), the SQL interviewer was the first and only one that required me the use the whiteboard, where all other interviewers let me have a choice. I chose to just sit at the table and scribble on paper, because having to stand and write on a whiteboard, with others watching me, tends to bring back all kinds of unpleasant high school memories and feelings. (I am not saying that this was the reason I did so bad at this part, but it definitely didn’t help.)

And another thing: writing code from scratch on paper or whiteboard is *not* easy! It’s amazing how attached you can get to editors, where you can just write whatever comes to mind, overwrite, delete, change, move stuff around, etc. You don’t realize how much you depend on this until you have to write code on paper. Something else to practice, should they ever want me back for an interview. ^_^’

1) Of course, it’s entirely possible that I didn’t do so well in the other interviews after all, but rather see things through rose-colored glasses, because I liked the whole experience.

:: Comments off

Color redesign

Ostara Easter is a good time to start new things, so it seemed appropriate that I finally got around to redesigning this site’s colors. It’s supposed to be blue and yellow (and light grey, but that doesn’t count). Or so I think. :-)

:: Comments off

Python vs Scheme: using files as both modules and programs

Python has a useful idiom, that allows one to use the same file as both a module and a program. Consider this simple example:

# foo.py

def bar(x):
    print "bar says:", x

if __name__ == "__main__":

    bar(42)

The if __name__ == “__main__” clause is only executed if foo.py is run as the “main program”. In other words, we can do both

$ python foo.py
bar says: 42

and

$ python
Python 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> foo.bar(33)
bar says: 33

Although admittedly a bit of a hack, this construct is well-known and often used.

Now, on to Chicken Scheme. Can we do the same? It required a bit of poking around in documentation and mailing list, but it appears the answer is yes.

;; foo.scm

(define (foo x)
  (print "foo says: " x))

(define (main args)
  (print "args: " args)
  (foo 42))

Now, we can run this as a script with csi -ss (which looks for a function called main and automagically calls it):

$ csi -ss foo.scm
args: ()
foo says: 42

Notice that the main function has an argument args, which contains the command line arguments passed to the program:

$ csi -ss foo.scm 1 2 3
args: (1 2 3)
foo says: 42

We can also import foo.scm from within an interactive session, in which cases main is not called:

$ csi

CHICKEN
Version 3.0.0 - macosx-unix-gnu-x86     [ manyargs dload ptables applyhook ]
(c)2000-2008 Felix L. Winkelmann        compiled 2008-03-05 on niflheim.local (Darwin)

; loading /Users/zephyrfalcon/.csirc ...
; loading /usr/local/lib/chicken/3/readline.so ...
#;1> (use foo)
; loading ./foo.scm ...
#;2> (foo 101)
foo says: 101

But, but! Isn’t Chicken primarily a compiler? Does the above work too when using csc rather than csi? Actually it does, but the invocation is different. I use the following:

$ csc foo.scm -postlude "(main (cdr (argv)))"

$ ./foo
args: ()
foo says: 42

$ ./foo 1 2 3
args: (1 2 3)
foo says: 42

The -postlude option can be used to specify code that runs when the executable is called. (Actually, the official explanation is: “Add EXPRESSIONS after all other toplevel expressions in the compiled file. This option may be given multiple times. Processing of this option takes place after processing of -epilogue.”)

I use (main (cdr (argv))) as the postlude expression, which seems to pass command line arguments the same way as csi -ss passes them to the main function (although there might be a catch that I’m not aware of). The cdr is necessary because the first item of the list returned by (argv) is the name of the calling program (e.g. “./foo”).

(If there’s a better way, please let me know, as my knowledge about the compiler is limited.)

Next up: parsing command line arguments in both Python and Scheme…

:: Comments (2)

spam || !spam

(Or, (or spam (not spam)) in Scheme… :-)

This blog is powered by WordPress. Among other things, it notifies me when somebody posted a comment that needs to be moderated. Notifications go to my GMail address.

The other day, I found two notification mails in GMail’s Spam section, that looked like this:

A new comment on the post #29 “Python vs Scheme: strings” is waiting for your approval
http://4.flowsnake.org/archives/29

Author : Xvyozvcu (IP: 206.53.55.5 , 206.53.55.5)
E-mail : yqufupiy@gmail.com
URL : http://blahblah.com/blah.html
Whois : http://ws.arin.net/cgi-bin/whois.pl?queryinput=206.53.55.5
Comment:
[...lots of bogus text with spammy URLs elided...]

The question is: from GMail’s point of view, is this message spam or not?

My first reaction would be, no, it’s not spam… it’s a valid notification message with comment text that happens to contain spam. But there’s a problem with that: the actual mail *does* contain spam, whether it’s in the context of a WordPress comment or not, and marking it as non-spam might well give the spam filter the wrong idea.

On the other hand, if I do mark it as spam in GMail, then it might conclude that valid WordPress notifications are spam as well! (After all, they share the same header and structure.)

Hmm. Can’t win for losing. Eventually I decided to leave them marked as non-spam, and deleted them manually. I’d rather get a few notifications that contain spam, than miss valid comments because they were mistakenly thrown in the spam bucket. Akismet should catch this kind of thing anyway (and usually does), so I should not get too many of those messages. Still, it’s an odd problem.

:: Comments (4)

« Previous entries Next Page » Next Page »