From: Austin Ziegler Date: 2003-11-20T10:06:31+09:00 Subject: Re: "stereotyping" (was: Re: Strong Typing (Re: Managing metadata about attribute types) ) On Thu, 20 Nov 2003 08:19:08 +0900, Sean O'Dell wrote: > On Wednesday 19 November 2003 03:00 pm, Austin Ziegler wrote: >> Likely not. Because if you're looking at choosing a scripting >> language based on its type-checking, you're excluding the vast >> majority of modern scripting languages including Perl, Python, >> JavaScript, and Ruby. > Exactly my point. People are sticking with C++ where they could > really benefit from moving to a script language like Ruby, or > they're learning Java and they're stuck being C++/Java > programmers. I somehow doubt it. [snip] >> Again: consider the words of Bruce Eckels. The man knows what >> he's talking about and is amazed by the power of not statically >> type checking. It's saved him loads of work. You want to add the >> work back *into* Ruby development. Optionally, I grant, but part >> of what a language designer like Matz must consider, is what >> changes like you're talking about would mean to the "culture" of >> the language. If people start using an "optional" method >> signature mechanism for type name enforcement, then that changes >> the assumed and actual dynamicity of Ruby. I suspect that the >> number of people thinking "ah screw it" are few and far between >> and instead are feeling liberated from having to specify types >> unnecessarily. > The programmers who jump into Ruby, yes. Their managers, no. There > are requirements in the real world that go beyond "what feels > good" and some of it has a basis in reality. Being able to ask > what interface an object implements does a lot to make up for bad > documentation and crazy error messages. On large, multi-developer > projects, and with poorly documented libraries, this gets proven > every single day. Type checking, in whatever form it takes, helps > a LOT. This is pointy-haired boss twaddle. Type checking does *not* help either the developer or the project -- it helps the compiler. I've worked on very large scale projects and type checking did nothing to help. In fact, it is my professional experience that type checking harms the project because it encourages the (improper) concept that "if it compiles, it must be okay." Again: read the Eckels article. Ruby is also in large scale production use in several places (including Amazon), and doesn't use static typing. Managers *don't* know the upsides or downsides to static typing. Most of them won't actually have a clue as to what the term means. There are legitimate reasons to use C, C++, and Java. Static typing isn't one of them, and I can't think of a single manager in my past who would argue that it would be. Some developers, perhaps, but they are also people who didn't have exposure to dynamically typed object systems and languages. >> Consider generics in Java (templates in C++). These effectively >> introduce the sort of dynamicity that is found in Perl, Python, >> and Ruby. Instead of having to do: >> int max(int x, int y) { return x > = y ? x : y } >> float max(float x, float y) { return x > = y ? x : y } >> double max(double x, double y) { return x > = y ? x : y } >> You can do: >> def max(x, y); x > = y ? x : y; end >> >> I know which I would prefer, and C++'s move toward generics is a >> halting step toward that step. > I loath templates. But I know what you mean. I don't like C++ templates, but they're better than the alternatives available to C++. > I am not an advocate for strong static typing. I only advocate a > reasonable assurance that an object implements a certain > interface. As Matz has said, there's no clean way to do this in Ruby at this point. Simply doing name checking (whether interfaces or inheritance) doesn't ensure compliance, so it actually buys us *absolutely* nothing more than assuming we have the right object to begin with. >> It's not that I don't want to listen: it's that type checking >> doesn't help in the real world. Ruby is used in a number of real >> world large-scale projects. > No, it is not. Perhaps one day. You don't know what you're talking about: http://www.rubygarden.org/ruby?RealWorldRuby One of the things not mentioned there is that Ruby is also used in the Amazon apparel store (see [ruby-talk:54605]). All of these have been done *without* type checking. [...] > I really think doing some form of intelligent, flexible interface > checking will put Ruby a notch up in a lot of C++/Java developer's > eyes. It won't be static type checking, but you can bill it as a > suitable replacement, and I'm sure that'd be good enough for most > water-cooler discussions. *shrug* I don't think that it's necessary. Most people I've talked to have been convinced that Ruby's worth looking at because of the deep object orientation. >> Useless runtime processing. > Listen. My thoughts on this were already written. I said it could > be shut off at runtime. A NOOP still costs performance. Further, since most things can be redefined at runtime (there are very few keywords in Ruby), it's not exactly something that can be turned off. >> I tend to open the code and look at it. > That's you. Don't make the assumption that performing such a task > is fine for everyone. That's not a language feature, that's a > personal habit. It seems to be the nature of many Ruby developers. >> Obviously, you're not speaking about that which you know. I >> recommend against it. I've done plenty of C, C++, Java, and >> Pascal programming -- as well as truly strongly typed languages >> (Ada, PL/SQL). Ada provides type checking that is *truly* useful >> (and exceedingly annoying because of its inflexibility), not the >> half-assed crap you get in C and C++. I've had to write two to >> twenty times the amount of code in C/C++, Java, or Pascal to do >> the same amount of work in Ruby. Not only that, my Ruby handles >> more types than my equivalent statically typed code. > You know what Ziegler? If you toss around insults, I'm simply > going to ignore you. Telling a man who's programmed for 20 years, > the last 12 of which were in C++ that he doesn't know about C++ is > extremely presumptuos and insulting. If you want to start talking > to air, keep insulting me. I'm not insulting you. You suggested that because I don't like static typing, I must not program in statically typed languages and therefore don't know what *I* am talking about. You demonstrably *don't* know what you're talking about when it comes to my knowledge and background. I may not have twenty years under my belt, but I'm not about to pretend that static typing is a boon for anyone when some very *bright* people (like Bruce Eckels) are coming to realize that dynamic typing is a very good thing. >> Still don't like it. I'd accept method signature publication that > Fact is, it doesn't seem like you like anything I say, so I think > my thread with you is at an impasse. No, I don't like what you've proposed. Propose something that is useful and I can see supporting it. So far, you've suggested something that does not add value or hasn't been done by others (namely Ryan Pavlik's metadata module). -austin -- austin ziegler * austin@halostatue.ca * Toronto, ON, Canada software designer * pragmatic programmer * 2003.11.19 * 19.26.11