Forgot your password?
typodupeerror
User Journal

Journal: Rant of the Day (static typing) 1

Journal by sleepingsquirrel
I think I'm most persuaded that static typing is the Right Thing (TM) by those who advocate for dynamic typing the most. They almost never have any theoretical foundations and argue mostly from anecdote. So in this fine tradition, I'll offer my own limited attempt at talking past the opposition...

Case in point: Peter William Lount has a rant about the subject of typing. He starts off critiquing a paper by Meijer/Drayton and tells us he likes Smalltalk. (the same paper gets a good roasting over at Lambda the Ultimate) So far so good. Then he starts to tell us why he's qualified to pontificate on statically typed languages...

[I've] learned C, Objective-C, Java, and other "typed" languages since then. Actually, like many professionals I speak - or is that write - many computer languages fluently and can read many more. I'm no stranger to typed languages, they work and get can usually be made to get a job done.

Well, of course that starts the eyes rolling into the back of my head. Note the scare quotes around "typed" and note anything other than an Algol derived language is lumped in the other category. Hmm, no note of Eiffel, or Ada, let alone a language with a modern type system (you know, something straight out of the 1970's) like ML or Haskell.

If you're arguing that C's type system isn't the end of type system evolution, you might as well skip the blog entry and point to (perl maven) Mark Jason Dominus' thoughts on the subject.

Mr Lount goes on...

Dynamicly [sic] untyped-languages work very well without types. Indesputable [sic] fact.

I don't know why I'm supposed to accept this statement as "indisputable". In fact, I'd argue that types are the meta-system which gives programs meaning. When you send bits to your video card, it has to take into account what "type" the bits are to properly display them. Some bytes are characters (when the display is in text mode). Other bytes represent red, or green, or blue pixel intensities. The same physical representation leads to a whole different meaning depending on what type the representation has. Other examples from the real world are abundant. If I gave you the word "tea" you need to know what language its in (i.e. its type) before you know its meaning. The bit pattern 01110010 could be a number or a character or a pointer, but it probably only makes sense to make it uppercase in one of those instances. Whether you like it or not, your programs are loaded with types, even if they're not expliticly specified in the source code or the language semantics.

For the life of me, I can't figure out a good interpretation for taking the square root of a string, so I generally want to catch these types of error sooner, rather than later. So I prefer the static solution. And I don't want to roll my own abstraction violation preventer, so I'll settle for the one that comes with the compiler. Hey, lookie there, code reuse. Hot damn!

And for those people who make the claims that they rarely ever make type error is there program, I'd tend to agree, you probably don't. But you probably don't have very sophisticated algorithms or data structures either. It's like if someone told me they had never run into a bug in their programs caused by floating point round-off. That either means you've never written a numerical program, or you've never tested it properly.

But let's continue...

Some very large applications have been written in Smalltalk, the most well known of the dynamicly untyped-languages. In fact, Das Kapital, in use by JPMorgan is a huge application that is used by the company to manage vast sums of money.

<snip>

The Java effort to replace Das Kapital failed, in part because the users had become accustomed to the power and leverage that Smalltalk enabled us to build into it.

The astute reader will note that he never actually mention why "types" caused this failure. In fact, maybe Smalltalk is just better than Java, and maybe types have nothing to do with it. Nah, that wouldn't fit in with our preconceived notions. Also, I guess we're supposed to believe that we can reliably extrapolate from this one data point. Oh, and that the relative failure of Smalltalk compared to Java is a market failure of almost unspeakable proportions. And while we're at it, it seems like he's conflating typing with dynamicism. I wonder if he considers Scheme typed or un-typed.

While many in the "typed" and "functional" world have for some non-rational reason rejected "runtime type inferencing" as not being valid "type inferencing" their argument is mute and without basis.

Here's one ("non-rational"?) reason. "Runtime type inferencing" with unit tests is an ad-hoc error-prone way to do it. With compile time type inference you get a whole bunch of unit tests, which have guaranteed 100% coverage (e.g. both branches of a conditional are checked, etc.), they cover a potentially infinite amount of cases (e.g. Integers), and they come for a very minimal price. That price is minimal, because you're going to have to fix any type error whether or not you get them at run-time or compile-time. And why build your own unit test suite to catch type errors, when (again) you can leverage the one which came with your compiler?

While compile time distinctions are useful for certain aspects they are a tiny corner of the full potential of the computing space whose majority of solution space exists at runtime. The proof? You can't use a computer, other than as a boat anchor, without "running it", thus by it's very definition, it's all about runtime.

Well don't try too hard to be rigorous. One thing I'd actually like to see from one of these Smalltalk advocates is an article explaining the theoretical and practical difference they see between types and classes.

Science

Journal: Beyond irrational numbers (continued fractions)

Journal by sleepingsquirrel
Lately, I've been casually trying my hand at learning some mathematics, especially number theory (my background is in electrical engineering). While doing some reading, I came across continued fractions, which are of the following form...

a/(b+1/(c+1/(d+1/...

...or in ASCII art...

Arrrgh. My ASCII-ART-fu isn't strong enought to defeat slashdot's lameness filter, see the link above to get a better idea of what a continued fraction looks like

So what I found interesting was that you can express any rational number as a continued fraction with a finite number number of terms (a,b,c,d,...) and any irrational number as a continued fraction with an infinite number of terms that repeat peroidically. For example...

sqrt(2) = 1+(1/(2+1/(2+1/(2+1/(2+...

Well it seems like the next question to ask is, "are there numbers that can't be expressed irrationally?" Or put in another sense, in the sequence: integers, rational numbers, irrational number, is there anything after irrational numbers? Let's make the terms of the continued fraction be the digits of pi...

3+1/(1+1/(4+1/(1+1/(5+1/(9+...

Can this number (is it a number?) be expressed as another continued fraction, but with terms that repeat periodiocally? Or is it a new kind of beast altogether? My quest continues...

The Matrix

Journal: Matrix Reloaded Sucks

Journal by sleepingsquirrel

Arrrgh. It sucks. There I've said it. I was an unabashed fan-boy of the first Matrix. That's why it pained me so much to see the second. If I'd had no previous expectations, I still would have walked away disappointed. And $16 poorer. But not betrayed. The sad part is, I should have seen it coming, the signs were definitely there. Sequels, it seems, are never as good as the original. Especially when the first movie does a good job of coming to a final conclusion. After the first movie, I distinctly remember thinking, "how are they going to continue this?". Everything was wrapped up so nicely for us. In retrospect, this was Hint #1.

And we all know that great works of art are solitary achievements, right? DaVinci doesn't say to himself, "Hey, that first Mona Lisa didn't turn out too bad, maybe I'll crank out a couple more". I guess the sign of a true master is knowing when to leave it alone. Hint #2.

Of course I shouldn't discount the fact that I had high expectations going into the movie. Now it might be just me, but it seems like the best films I've seen are the ones I've had no preconceived notions about. Like where a friend says, "Hey let's go see if something good is on." That was my experience for _The Matrix_. This is in contrast to _Reloaded_, where I bought the tickets on-line, so I knew I would get a ticket on opening day. I think the reason for this is because I've become accustomed to being disapointed at the theater so often. I think psychiatrists call it the "defense mechanism". If any particular film I go to is a stinker, I shrug it off and swear I'm going to abstain from movies for a while. Just like most of the previous movies I'd been to. No sense in getting all worked up over it, after all, it's only a movie. So then, when a genuinely good motion picture comes along, I'm psychologically unprepared, and I'm blown away. How could I not have picked up on #3?

And then there's that commercial crassness swirling around this flick that should have tipped me off. TV advertisements in which the cast is endorsing crap *before* the actual release of the movie should have been a giant neon sign pointing out that we were well on our way to sucksville. So I really don't know why I was surprised that the creators sold out to Cadillac.

So that's why I should have know _Reloaded_ was going to be bad. Here's why it actually is. I don't know if I can explain exactly why the first one was so good. I think it had something to do with actually having to think during the film. Everything was new and exciting. There was the meta-physical aspect (i.e. "hey, how would we know if were not in the Matrix right now?!?"). Then there was the cool camera work, and the cool music, and the cool way the agents talked. You're mind was always occupied, always immersed in the film. I wouldn't call it a formula in any sense of the word. Of course I wouldn't have written all of that if I didn't think part II was the exact opposite. The movie just felt wrong. Like they were trying to hard. Or not hard enough. Or something. Maybe it just felt forced. As Yoda might say, "Immersed, not I". Like the first fight scene where Neo takes on all of the Agent Smiths, was it just me, or did that computer generated crap look like it was rendered on a Sony PlayStation? And for that matter, who cares what the inside of the Zion ship hanger looks like. Why are we devoting 5 minutes to watching the ship land in the hanger? How does that advance the story. It felt like I was watching the guys who run the computer graphics machines masturbate. Of course, we are also treated to the engineering level of Zion. A place so boring, that no one who lives there, goes there. So why am I there? Oh yeah, so the old man can say that we are all here for a reason. Like that wasn't repeated 5,000 times elsewhere.

And I guess it's comforting to know that some things stay the same no matter what circumstances humanity has to endure. The city council meetings in Zion are precisely as dull as the city council meetings in my home town. I almost expected them to vote on a zoning ordinance. The story just didn't seem as compelling this time around. It could have been. Why didn't we see Neo spend more time philosophizing with the architect, instead of flying around in the corn-ball Superman schtick? Oh, and am I wrong or did they lift part of the sound-track from a '70s Batman episode? We may never know the answers to those questions, but one thing we do know for certain is that the albino agents are designed by the architect to be superior to the ordinary agents in every way. Including how they shill for Detroit. And I think we can also determine that the original _Matrix_ wasn't a financial success for the Wachowski brothers, because I would have thought if they were millionaires, they wouldn't need to grub for money from Cadillac. This isn't your father's Matrix. And here's a piece of advice for all of the future film-makers out there, leaving a movie unresolved at the end doesn't make me want to see the next one more, it just make me respect the current one less.

But I digress. I'm probably being too harsh. The film was a piece of art in the twentieth-century-post-modern sense of the word. You know what I mean. Like how someone can make a video tape of themselves taking a dump in your front yard, and it gets lauded by the New Yorker *and* the rubes are lined up willing to pay to be insulted. But I can't say I'm above the fray. I'll probably even see part III. When its on the 99 cent rack.

The Courts

Journal: Lawsuit Insurance

Journal by sleepingsquirrel
Hardly a day goes by without Slashdot posting a story about some coporation using the court system as a form of legal extortion. I was wondering what experience other /.'ers had concerning lawsuit insurance. Is it afforadable? Can you get a plan that just covers your attorney's costs? I'm assuming that would be cheaper than having a plan that covers any damages if you lose. Companies might think twice about filing some of these lawsuits if they knew they were up against a million dollar team of attorneys.

Loose bits sink chips.

Working...