Tightrope walking

Feb 26, 2007 23:24

[Non-coders: it shouldn't matter if you don't know about the specific technical issue that I'm discussing here. Hopefully, I've managed to convey something of what it feels like to code in different languages, which is the important thing ( Read more... )

computers, programming, type systems, beware the geek, perl, haskell

Leave a comment

Comments 16

elvum February 27 2007, 00:40:10 UTC
I took a similar path to you, but when I got to Perl, I hated it. Perhaps the fact that I learned Java instead of Delphi was significant. Also, I had tried (and found impossible to debug) Javascript and PHP. I've heard that the existence of unit testing frameworks for Perl makes debugging more bearable though. I've yet to try Haskell, but I'm a huge fan of static typing. Except on the occasions where I say things like "if only Java had duck typing, $vital_thing would be possible..."

Reply

pozorvlak February 27 2007, 12:42:32 UTC
Perl took a long time to get, certainly (and thanks must go to the incredibly helpful and friendly members of London.pm for a lot of that). I remember with a shudder the first time I tried to use references (and I still find Perl's reference syntax pretty unmemorable). Perl's unit testing frameworks are, indeed, brilliant, as are things like Data::Dumper (or Data::Dump::Streamer for code that uses closures).

What are your main languages? Java and Python?

Reply

elvum February 27 2007, 12:45:32 UTC
Pretty much Java atm. Python, Ruby and Haskell have all been on my to-learn list for about a year now, but stuff like the Goolge Web Toolkit keeps distracting me...

Reply

pozorvlak February 27 2007, 13:00:38 UTC
Python's nice, and tends to be liked by people who react badly to Perl :-) Ruby's on my to-learn list too, but I'd like to get my head round Haskell first...

Reply


michiexile February 27 2007, 08:30:37 UTC
I must admit I do not even know how to use the optative in english, given that I cannot seem to find any kind of subjunctive forms in my latent grammar storage.

However, in swedish, latin and german, I would most probably be capable of using the optative correctly. AND I always tuck my shirt. :P

Reply

pozorvlak February 27 2007, 12:45:37 UTC
I'm not sure English even has an optative mood. It has a subjunctive, but it's not used much these days. My dim memory of the optative is as a particularly recondite and hairy part of Ancient Greek, a language with enough grammar for any two normal languages :-)

Reply


(The comment has been removed)

pozorvlak February 27 2007, 12:57:12 UTC
Sounds like it's weakly (== dynamically + mutably) typed, and Wikipedia agrees, but see the caveats. As for integer division, it sounds like the kind of thing you ought to know, and it would take five minutes to find out! :-)

Reply


anonymous February 27 2007, 22:47:57 UTC
If the difference between 3 and "3" is trivial, then so is the difference between 3 + 3 and "3" + "3". Right?

Reply

pozorvlak February 28 2007, 10:34:25 UTC
Only if you use the same operator for addition and string concatenation. Which is a bad idea anyway, as string concatenation doesn't behave much like addition: it's not commutative, and it's only associative if you ignore performance issues.
pozorvlak@delirium:~>perl -le '$x = 3; print $x . $x; print $x + $x'
33
6
:-)
[You'll note that Haskell doesn't use "+" for string concatenation either.]

Secondly, the dynamic philosophy is that errors caused by this kind of thing are a) mostly trivial, b) easily detected by testing running code, which you need to do anyway to find the real bugs. I've found that this accords pretty well with my experience, tbh. But hey, I've never tried to write climate-modelling systems or real-time control software for nuclear missiles, so maybe that's just a reflection of the limited scope and relatively small scale of the code I write. But, you know, there are a hell of a lot of things you can do in ten lines of Perl, so features that only make sense for small programs should not be dismissed. And other ( ... )

Reply

anonymous February 28 2007, 19:17:28 UTC
"Only if you use the same operator for addition and string concatenation. Which is a bad idea anyway, as string concatenation doesn't behave much like addition: it's not commutative, and it's only associative if you ignore performance issues ( ... )

Reply

pozorvlak February 28 2007, 22:35:13 UTC
Yes, I was (to some extent deliberately) fudging the weak/dynamic distinction - and I must say, I prefer the term "mutable typing" because it doesn't sound like an insult! Dynamic strong typing is a combination that's never made much sense to me, but other people seem to like it.

So, you're a Ruby hacker? Interesting. I have no idea who you are, you see, so can't infer much about your choice of languages - but I've heard your comments about string concatenation versus addition a dozen times and don't find them in the least convincing, for reasons I've hopefully explained :-)

My problems with Haskell's type system are that 1) it causes me lots of grief and frustration (and will do until I rewire my brain to do stuff that a Perl interpreter would do for me >:( ), 2) I find it's often insufficiently expressive for my needs (and many of its more recondite aspects seem rather ad-hoc). As in, I can't do things in Haskell (or can't do them without going to ridiculous lengths) that are straightforward and standard practice in C++ or Ada. ( ... )

Reply


johnckirk March 10 2007, 21:51:12 UTC
A delayed response on this one ( ... )

Reply

pozorvlak March 11 2007, 11:58:20 UTC
No need to apologise :-)

As far as I can remember, I've only had a tiny number of problems caused by type coercion in Perl. Mostly it just does the Right Thing. A lot of this, of course, is sensible choices of operators: for instance, string concatenation in Perl is always ".", so "3" + 3 has the unambiguous meaning of 'coerce the "3" to 3, then add' - see my response to Anonymous, above. Note that this is not simple or consistent1 - this requires hundreds of delicate balancing acts all over the language to get the magic right. See here for an excellent blog post on this kind of thing.

The way I see it, computers should know their place, and that place is to obey my commands. If they don't know what I mean, they can ask for clarification, and that's fine, but I don't want them to start guessing.And again, I used to think like that. But it turns out that it is possible to guess with a (perhaps surprisingly) high degree of reliability, and besides, do you trust any code that you haven't tested properly? Having experienced this, I know ( ... )

Reply


Leave a comment

Up