From: Chad Perrin Date: 2006-07-31T03:36:08+09:00 Subject: Re: Miscellanous Language Ranting (was Re: For performance, write it in C - Part 2, comparing C, Ruby and Java) On Mon, Jul 31, 2006 at 01:44:48AM +0900, Charles Hoffman wrote: > On Sun, 2006-07-30 at 03:47 +0900, M. Edward (Ed) Borasky wrote: > > I don't think I've ever needed lexical closures. > > Oh no ohh no... I think Chad hit it pretty well on the head with "well > you don't *need* switch statements." There are plenty of things in > programming languages you don't *need*, but once you've gotten into > them, you find yourself missing them when you have to do without them. > The programming I get paid to do is largely in PHP and ActionScript 2.0 > for Flash; once I got the hang of using anonymous functions in > ActionScript, which are (or at least try to be) lexical closures, I > found my life getting a lot easier. For writing very event-driven code, > such as responding to a GUI and responding to callbacks generated by > remoting, anonymous functions, (despite a strong orthodoxy in much of > the Flash community against their use) can be a great way to write > smaller, clearer code. 1. Sorry to hear you have to make your money primarily by writing PHP and ActionScript. 2. That's a pretty silly orthodoxy. 3. I didn't know you could do anything like a closure in ActionScript. Good to know. Thanks. > > I submit to you that you use lexical closures all the time and don't > even know it. You mention below that you've written Java, and I presume > you've written other object-oriented stuff. Guess what? Objects are > full of closures. The methods of an object are closures on the object > itself. If they weren't, you wouldn't be able to access instance > variables from them. Unless they started making everything global, and > then you may as well write in Fortran IV. I tend to subscribe to the Schemers' view, rather than the Java programmers' view: objects are like big, fat, complex, inelegant closures. This is one of the reasons that I tend to be put off slightly by languages that don't support lexical closures -- I like having the ability to write my code with closures rather than objects sometimes. > > > In this sense, Ruby is on the edge of becoming a special-purpose > > language as the engine underneath Rails. > > So? C has already become something quite like a special-purpose > language as the engine underneath *nix. And why not? Writing Unix is > what C was pretty much invented for. This doesn't imply that you can't > do plenty of other things with it, nor that no one doesn't do other > things with it, but a large amount of C's usage today falls in a certain > niche. Probably the biggest part of C's importance is the influence it > has had on other languages and on programming in general. I think it > would be just fine if Ruby followed a similar trajectory. . . . except that I think it would be a shame if Ruby's niche were so narrow as to be focused entirely on Rails. If C is for Unix, Perl is for system administration, and PHP is for lightweight server-side web programming, while Ruby is for Rails, it sounds to me like Ruby's going to go the way of the dinosaurs pretty quickly while the other three will be around for some time to come. Luckily, I don't believe that Ruby's major niche will be any more tied to Rails than Perl's was to CGI programming: CGI was Perl's gateway drug, and Rails is Ruby's. In neither case is that likely to be the thing for which the language is used most in the long run, I think. Ruby, I predict, will have a rich and varied life ahead of it, and Rails will only be a small (if interesting) part of that. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "The measure on a man's real character is what he would do if he knew he would never be found out." - Thomas McCauley