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

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."

Fair enough, I guess I am a bit accustomed to it.

"And other people have successfully written large, scalable, maintainable systems in Perl."

Yes. I certainly didn't say that it can't be done! For that matter, probably someone managed to build large, scalable, maintainable systems in Visual Basic.

"Thirdly, I'm not really talking about whether or not static typing is better than dynamic typing"

The issue I am talking about is strong dynamic typing (Ruby/Python) versus weak (mutable, as you call it) dynamic typing (Perl/PHP).

"have you ever tried using a dynamic language seriously, ie as your main language for a year or two? Think about it - you might be pleasantly surprised, and you might even learn something)."

Ruby is presumably not dynamic enough, as it doesn't have mutable typing?

"Now I'm going back to static typing and, of course, hating it"

Well, even after Ruby I quite like expressive static typing (as in Haskell/OCaml/Nemerle/F#/...) I don't think I could go back to Java or C#, though.

"I think that Haskell development is about pushing axioms you want your code to satisfy into the type system, and then using your compiler as an automated theorem-checker."

Yes. Unfortunately, dependent types (which are needed for many desirable axioms) are ugly to express in Haskell. And Epigram, Cayenne or Sage (now there's a really nice type system!) are not ready for prime-time (and may never be).

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. Still, I'm very interested by the automated-theorem-checker aspect, and some very smart friends of mine assure me that I'll come to like the type system eventually, so I'm persisting, with the occasional rant here to let off steam.

I'm aware of dependent typing, but haven't yet looked seriously into it. I hadn't heard of Sage - I'll check it out...

Reply

anonymous February 28 2007, 23:14:30 UTC
Here is the link to Sage: http://sage.soe.ucsc.edu/

All types are values of the type *, so Haskell's Maybe is simply a function of the type * -> *, and -- here is what you wanted -- you can have Vector of the type Int -> *. You also have Dynamic type which can be cast to and from anything, so you can be as dynamic as you want, or as static as you want.
You can also have "refinement types", for example the type of positive integers: {x:Int | x > 0}. Since I tend to think of static typing as expressing contracts, this makes a lot of sense to me.

Reply

pozorvlak March 1 2007, 12:51:49 UTC
That does sound good :-)

# (1 + 2) - 4;;
Type: (Refine Int (fn (z:Int) => (inteq z (sub (add 1 2) 4))))
Evaluation: -1
Hmmmm. Looks rather Lispy...

Reply


Leave a comment

Up