kickaha: (Default)
[personal profile] kickaha
A comment in another thread regarding the lack of true class-methods in Java (and the inevitable "C# is bettah!" content-free rejoinder) got me thinking on something I read earlier on the bus, regarding Java Generics, and how they're a small step above macros in their type safety. (Hint: it's called 'type erasing', if that gives you an idea on which direction it goes...)

Why is that some languages seem like such a mish-mash of warring styles (C++, I'm looking at you...) and others seem so simple it's a wonder anything is ever accomplished with them (Objective-C anyone?), yet they can do just about everything that one can think of?

Object model. A clean object model, with introspection, reflection, genericity, dynamic binding, and late binding will let you do basically anything allowed by the theoretical foundations of object-oriented languages. (Abadi and Cardelli's _A Theory of Objects_ is a good start for this.)

Languages that lack some features of this model try and glue them on ad hoc via 'new features'. Templates come to mind. No one who has ever used Smalltalk or Obj-C to any measure can figure out what the big deal is about templates... they just aren't needed in the dynamic languages. Ditto for things like C#'s 'delegate' keyword. Or C++ RTTI. Etc.

OTOH, having clean and clear code is a big win. (Wait, did I just compare C++'s templates to clean and clear code? Shoot me.) Actually, that exemplifies my point beautifully. *CLEAN* code is good. *KITCHEN SINK* code to get around holes in the basic model of a language is not.

And in that respect, C#'s delegate is kinda nifty - it provides a single point of reference to say "Aha! So they're using a delegate object, and here it is..." No idioms to have to search for this particular implementation of, etc. It's obvious. And it's even useful. My only concern with it is, and perhaps someone can answer this for me, is it *necessary*? Is C#'s object model such that one could not do this otherwise, and do it easily?

All too often I see keywords, as tacked on 'features', being used to shore up fundamental holes in a basic language theory. The language designers biffed it up front, so they have to keep adding new thingamabobs to satisfy critics... and all those thingamabobs inevitably lead to a kitchen sink approach that pleases no one trying to get real work done... too many poorly interacting or downright conflicting language 'features' need to be used, worked around, cussed at, and eventually abandoned. But man, it sure looks good on a bulleted list.

Sounds like Word, now that I think of it - just keep tacking on 'features' that get around problems in the basic underlying design, and hope people swallow that it's 'innovation'. Uh, no.

Which leads me to today's Church of Geek Homily: "The cleanliness of a language's object model is inversely proportional to the size of its keyword list (including operators)."

Anytime you look at a language, and see a nifty new keyword or construct that looks to provide a wealth of usability, stop, and think to yourself "What hole in the object model was this designed to cover up?" If you can't find one, chances are that the designers may have stumbled onto something of worth, and one to consider as adopting as canon for language design. But I'm willing to bet that 99% of the time, you'll find that hole.

(no subject)

Date: 2004-06-14 07:54 pm (UTC)
From: [identity profile] jason0x21.livejournal.com
Does this mean that Forth is the ultimate language?

(no subject)

Date: 2004-06-14 08:00 pm (UTC)
From: [identity profile] kickaha.livejournal.com
Well, there are object models with holes, and there are languages without an object model at all... ;)

If you want an OO example, take a gander at Galaxy sometime. Forth like in that the program can modify the compiler on the fly, and recompile itself... quite funky. Downside? No two programmers can read each others' code, because they've both made custom additions on the fly. :P

Kind of like Perl. ;)

(no subject)

Date: 2004-06-14 08:17 pm (UTC)
From: [identity profile] jason0x21.livejournal.com
Yeah, but Perl's like that for different reasons. "There's More Than One Way To Do It", after all. You just don't like it because he explicity singles out "Computer Science Types" for abuse. ;-)

(no subject)

Date: 2004-06-14 08:19 pm (UTC)
From: [identity profile] jason0x21.livejournal.com
I should mention "The completely incomprehensable and unmaintainable way" as a legal and valid (if not very nice) way to do it.

(no subject)

Date: 2004-06-14 08:28 pm (UTC)
From: [identity profile] kickaha.livejournal.com
Nope, I don't like it because it's C++ like in its kitchen sink approach to programming. Instead of thinking through a nice solid, elegant underlying model, it seems to have been designed strictly ad hoc, with every Latest Greatest Thing(tm) tacked on as an afterthought. The added apparent *attempt* at obfuscation through extreme syntax compression (can anyone explain to me why this is considered a good thing, *other* than for geek ego fluffing?) just makes it worse. And *then* you get to the 'more than one way to do it', which I can only attribute to clash of the geek egos, and no one wanting to a) step on someone else's toes, or b) an extreme libertarian approach to programming.

For writing quick off the cuff one-liners, Perl is fine. For writing production code more than about 100 lines in length that more than one person needs to read (and that constitutes the vast majority of code written out there), it's horrid. It's like writing a large system in shell script syntax. Why be such a masochist? :)

As for his desire to abuse CS folks, I chalk it up to jealousy. ;)

Profile

kickaha: (Default)
kickaha

January 2020

S M T W T F S
   1234
5678 91011
12131415161718
19202122232425
262728293031 

Style Credit

Expand Cut Tags

No cut tags