From: David Vallner Date: 2006-10-25T10:58:39+09:00 Subject: Re: Some help against the raging hordes of 'J' fanatics --------------enig62FA7666DA60164D0F48147A Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Peter Szinek wrote: > Hello, >=20 > Maybe some of you already came across my latest blog entry - it's about= > the comparison of a few Ruby vs Java idioms. Basically I wrote it > because I just learning Ruby and I was astonished by it's power, and > well, I just blogged about a few tasks I solved recently. It can be > found here: >=20 > http://www.rubyrailways.com/sometimes-less-is-more/ >=20 The post is such blatant trollbait I won't even bother. Anecdote * 10 !=3D= evidence. Then again, I have a reputation of a troll to keep, so here goes. (For my defense, I only troll back.) I'll try to touch on some points your commenters missed. Ruby lets you write less code because the language is much, much, much larger. The Java policy is to defer non-basic things to tools so you can mix and match approaches. With some notable exceptions around singleton classes which aren't possible with Java's object model, but I find those somewhat of a hack, basically they seem to classes like lambdas are to named functions. Fun for one-off throwaway code, annoying to find bugs in if non-trivial, and you could as well make a generic object parameterised by a lambda or two to replace them without too much of a kludge (this pattern can also be implemented in Java-like object models with varying larger amounts of kludge). There's also the varying design principles where on one side, you try and keep a clean (-ish) separation between the language and its artifacts (the libraries), and on the other you blur the boundaries of those. Understanding the latter completely is a much larger learning curve, even if the early "oh, wow, neato-whiz shorthand" shiny objects dangled in front of your nose hide that fact. A lot of the examples you show are using dynamic code generation of sorts, which would require either XDoclet or load-time bytecode enhancement in Java to implement. Believe or not, that extra step is a virtue in circumstances. Dynamic code generation is basically Dark Magic (to wit: the umptillion metaprogramming threads that have people groaning over one gotcha or another), it requires more skill from a programmer to both write and read again. And while you might yet blissfully ignore the fact that the real world needs programs that are a) maintainable, and that b) by muppets, I find it a very hard fact. No matter how god damn smug you are, if your code will have to be understood by a student coder, there is no place for metaprogramming unless it's damn well contained, tagged with big red neon signs saying "This works, do not touch". Summarising: just because you can't see a point to verbosity doesn't mean there is never none. Well, except for declaring types of locals, inference of those is on my personal Java 7 wishlist. (As optional syntactic-sugar for type checks / DbC and a standard library that plays along nicely with that is on the Ruby 2 one). PS: Noone gives a flying *bleep* about attr_accessor or public static void main, that's what IDEs or editor templates are for. I can IDE-generate default member accessors in (four) less keystrokes than typing "attr_accessor" takes. (Alt+Ins Down Down Down Enter Shift-End Enter. From memory.) Which is a non-argument too, but I'll leave it as an exercise to the reader to spot it. If you're too cheap for IDEA and hardware to run it, sux2bu. PPS: The comparing Java arrays to Ruby arrays because you can't initialize lists in one statement is braindead beyond all belief. Redo from scratch. HINT: List strings =3D Arrays.asList(new String[] {"bing", "cabbage", "womble"}); By the way, a Stack is a List, and a List is an array for any purpose you might need (the List contract is an extension of the array one). Now, can I PLEASE have the constructive Ruby community that didn't give a damn about any other programming languages either from a year ago or so back? I feel faintly disturbed by how much noise various programming language expatriate whiners are able to generate. I also object to the overgeneralising blanket fanatic descriptor. You start with a shallow troll and then call people that defend against it fanatics? Sad. David Vallner Your Unfriendly Neighborhood 'J'ava Fanatic --------------enig62FA7666DA60164D0F48147A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) iD8DBQFFPsTKy6MhrS8astoRAiuUAJ46BPU77UV8n01+szqdaDBGyPcekwCdFA0c rxxxeCJHWeuOqKampOYoN6Y= =YzkR -----END PGP SIGNATURE----- --------------enig62FA7666DA60164D0F48147A--