Ten Things Every Java Programmer Should Know About Ruby

P

PA

* If a Ruby core method isn't behaving quite like you need it to, just
edit it to fit your task.

This sounds very much like the ultimate "nuclear" option in
Objective-C... after indiscriminately applying +poseAsClass: left and
right add some random "method swizzlings" for good measure...

http://www.cocoadev.com/index.pl?MethodSwizzling

Not recommended. Even when you think you know what you are doing in the
first place.

Newbies especially should stick to the principle of "least magic"...

Just my 2 ¥…

Cheers
 
P

PA

There has been a progression in writing systems that could possibly be
said to
parallel the progression in programming systems:

I like that... nice analogy... there is one obvious flaw with it
though... the lack of a, er, "historical" perspective... after all...
there are thousands of years separating Hyeroglyphics and
Wordprocessors...

In contrast... and to keep the "historical" perspective going...
"programming languages" have been "invented" in the last few seconds...

http://www.levenez.com/lang/history.html

Cheers
 
J

Joao Pedrosa

Hi,
The only thing I wanted to "subtly" hint at is that implementation
languages are the least important factor in the ultimate success and/or
failure of a project.

In other words, an implementation language of any sort is not a silver
bullet of any sort.

After all, blaming or praising a language for your own success or
failure would be equivalent to a writer blaming its pen for "writer's
block".

Ok. What about the Domain Specific Languages? If they are any
important in getting work done, then we may distinguish languages on
appropriateness. All the Ruby features make it a DSL for certain kinds
of programs and libraries. What's more, the Ruby features allow you to
add to the language, making it even more Specific for certain Domains.
Closures, for example, are considered very useful when addind new
"language" constructs. As is the set of features of Ruby, because the
whole is comprised of every single part, for the whole without a part,
would not be the whole.

Keep the fun in programming. Keep using Ruby. :)

Cheers,
Joao
 
J

James G. Britt

Ballpoints and pencils facilitate making notes anywhere.
The typewriter sped up writing legibly considerably.


This last point is interesting: being able to churn out fiction can,
it is sometimes argued, allow people to produce lots of lower
quality work than if they have to rework parts. I'm not sure how one
applies that point to programming though, but maybe we are still at
the typewriter stage. Is there any evidence that refactoring
browsers allow people to "leave quality till later" and never get
back to fix it? There are other factors at work though, not just
the tools: time pressure for one.

The 700-lb pen is a flawed analogy, though it offers something of a
good, quick visual. I tend to think that the ease with which people
can now write and self-publish has led to a flood of crap, though it
has also made possible numerous gems that might not otherwise have
been available.

I wonder if there are reasonable analogies between programing tools
and writing tools; I'm inclined to see the Excel macro language as the
equal to the ballpoint pen.

I also wonder about the efficacy of refactoring tools, especially if
one has to think of refactoring as a separate task. If something
isn't easy to do, so easy that it just because part of your unthinking
process, then it will often be pushed off forever. Or else you may
have to alter (stifle?) your normal creative process.

There was a post on some blog someplace (how's that for precision? It
was either a java.net or artima blog, I think) positing that TDD might
stifle creative flow. And I can readily see that.

Like at least a few people here, I tend to first bang out short
scripts to sketch out some possible approaches to a task, refactoring
as I go. Ruby make this very easy, both to try something out and to
move things around; a tool might be a good thing for large
applications, but for most things all I need is gvim.

At some point I may go back and rewrite the application, once I've
discovered it's true purpose, and that's when I am more likely to
write the unit tests first. But since adding unit tests in Ruby is
snake simple I also find myself dropping them in during that first
stage, if code starts appearing less than obvious, so that I don't get
side-tracked looking for goofy bugs.

I may be unfamiliar with available tools (aside from Eclipse, which
makes Java bearable), but I think this style of exploration,
refactoring, and testing is less fluid in Java, and it effects your
thinking. You are more inclined to want to do a bunch of up-front
design, much as when people had to write with quill pens they were
likely more inclined to think a whole bunch about what they wanted to
write. But, in both coding and writing, the physical process itself
changes how you think. You often don't really know what you're
thinking until you write it down.

James
 
J

James Edward Gray II

This sounds very much like the ultimate "nuclear" option in
Objective-C... after indiscriminately applying +poseAsClass: left and
right add some random "method swizzlings" for good measure...

http://www.cocoadev.com/index.pl?MethodSwizzling

Not recommended. Even when you think you know what you are doing in
the first place.

Hmm, I would say it's a fairly common Ruby practice. Adding method to
the classes is even more so.

Doesn't Rubygems replace require(), just to give an example?

The require() hack earlier in this thread looked quite handy to me.

James Edward Gray II
 
N

Nicholas Van Weerdenburg

The 700-lb pen is a flawed analogy, though it offers something of a
good, quick visual. I tend to think that the ease with which people
can now write and self-publish has led to a flood of crap, though it
has also made possible numerous gems that might not otherwise have
been available.

I wonder if there are reasonable analogies between programing tools
and writing tools; I'm inclined to see the Excel macro language as the
equal to the ballpoint pen.

I also wonder about the efficacy of refactoring tools, especially if
one has to think of refactoring as a separate task. If something
isn't easy to do, so easy that it just because part of your unthinking
process, then it will often be pushed off forever. Or else you may
have to alter (stifle?) your normal creative process.

There was a post on some blog someplace (how's that for precision? It
was either a java.net or artima blog, I think) positing that TDD might
stifle creative flow. And I can readily see that.

Like at least a few people here, I tend to first bang out short
scripts to sketch out some possible approaches to a task, refactoring
as I go. Ruby make this very easy, both to try something out and to
move things around; a tool might be a good thing for large
applications, but for most things all I need is gvim.

At some point I may go back and rewrite the application, once I've
discovered it's true purpose, and that's when I am more likely to
write the unit tests first. But since adding unit tests in Ruby is
snake simple I also find myself dropping them in during that first
stage, if code starts appearing less than obvious, so that I don't get
side-tracked looking for goofy bugs.

I may be unfamiliar with available tools (aside from Eclipse, which
makes Java bearable), but I think this style of exploration,
refactoring, and testing is less fluid in Java, and it effects your
thinking. You are more inclined to want to do a bunch of up-front
design, much as when people had to write with quill pens they were
likely more inclined to think a whole bunch about what they wanted to
write. But, in both coding and writing, the physical process itself
changes how you think. You often don't really know what you're
thinking until you write it down.

James

I'd say that using a good IDE with refactoring in Java is pretty
creative. It's amazing how many code changes you can make in IntelliJ
IDEA in a short period of time.

1. create factory method
2. extract interface
3. change factory method to return interface

What would take several days without a good refactoring tool can be
done in an hour. It's like being on crack (or so I'm told).

The static nature of Java code makes the refactoring browser really
smart. It's quite incredibile. And, you develop a relationship of
trust with it. I stopped reviewing the IntelliJ refactor change list
after a while.

Nick
 
C

Charles Miller

If you want to convince java folks of the merits of ruby introduce
them to rails.
Depends. Rails would really impress a Struts audience, but less so a
Webwork audience.

Charles Miller

-- Contributing to the heat death of the Universe since 1975
(e-mail address removed) http://fishbowl.pastiche.org
 
G

gabriele renzi

Jim Weirich ha scritto:
Edgardo Hames said:



I'm going to collect responses in a public Ta-Da list at
http://jimweirich.tadalist.com/lists/public/14055 (which is already way
over 10 items!). Later (possibly this weekend) I'll sort through the
collected suggestions, edit them down to my top ten and publish the
result.

just a note: I'd present mixin as "interface withouth the need to
rewrite everything" more than "multiple inheritance replacement".
Anyway, great list, bookmarked ;)
 
J

James Britt

Nicholas said:
I'd say that using a good IDE with refactoring in Java is pretty
creative. It's amazing how many code changes you can make in IntelliJ
IDEA in a short period of time.

1. create factory method
2. extract interface
3. change factory method to return interface

What would take several days without a good refactoring tool can be
done in an hour. It's like being on crack (or so I'm told).

The static nature of Java code makes the refactoring browser really
smart. It's quite incredibile. And, you develop a relationship of
trust with it. I stopped reviewing the IntelliJ refactor change list
after a while.

Interesting. Yet I get the feeling that such tools solve problems
largely brought on by the programming language in the first place, so
it's hard to see just what real gain such ease of use brings.




James
 
K

Keith P. Boruff

James said:
Interesting. Yet I get the feeling that such tools solve problems
largely brought on by the programming language in the first place, so
it's hard to see just what real gain such ease of use brings.

Nope. A refactoring tool has nothing to do with solving the shortcomings of
a programming language but rather the shortcomings of the programmer. Among
many things, it's primarily a tool used to keep a software project from
decaying.

A good read on the subject is Martin Fowler's book on Refactoring. It's a
neat subject.

KPB
 
J

James Britt

Keith said:
Nope. A refactoring tool has nothing to do with solving the shortcomings of
a programming language but rather the shortcomings of the programmer. Among
many things, it's primarily a tool used to keep a software project from
decaying.

Ah. Does it matter if a language is intrinsically amenable to constant
refactoring, such that one rarely needs anything more than s// to
refactor, as apposed to a language that may encourage the creation of
complex, brittle code?

Shoes were created to solve the shortcomings of feet, but you're going
to need them a lot more when you're walking on glass than when running
on grass.

My point was that people who swear by some Java IDE because of the neat
tools it offers rarely seem to consider that maybe if they weren't using
Java them they wouldn't need the industrial-strength IDE.

Java + [IntelliJ|Eclipse] < Ruby + [vim|emacs]



James
 
L

Lothar Scholz

Hello Keith,

KPB> Nope. A refactoring tool has nothing to do with solving the shortcomings of
KPB> a programming language but rather the shortcomings of the programmer. Among
KPB> many things, it's primarily a tool used to keep a software project from
KPB> decaying.

But the more verbose your language is (C++ is an extreme example where
class names etc. are spread all over the source code, duplicated a
hundert times) the more usefull a refactoring tool becomes.

KPB> A good read on the subject is Martin Fowler's book on Refactoring. It's a
KPB> neat subject.

He is talking about refactoring in this book not about a tool to support this.
 
K

Keith P. Boruff

Lothar said:
Hello Keith,

KPB> Nope. A refactoring tool has nothing to do with solving the
shortcomings of KPB> a programming language but rather the shortcomings of
the programmer. Among KPB> many things, it's primarily a tool used to keep
a software project from KPB> decaying.

But the more verbose your language is (C++ is an extreme example where
class names etc. are spread all over the source code, duplicated a
hundert times) the more usefull a refactoring tool becomes.

If code is duplicated hundreds of times in a project, it's hardly the fault
of the programming language.
KPB> A good read on the subject is Martin Fowler's book on Refactoring.
It's a KPB> neat subject.

He is talking about refactoring in this book not about a tool to support
this.

Yes I know but you really should check it out as I think you're confused
about the subject of refactoring.
 
L

Lothar Scholz

Hello Keith,

KPB> Lothar Scholz wrote:

KPB> If code is duplicated hundreds of times in a project, it's hardly the fault
KPB> of the programming language.

If you have a class with 100 subclasses then each subclass calls the
constructor by using the typename, typecasts and repeating the classname
for each method definition are other places where you must use the
name. It is C++ fault

In Eiffel i often simply rename the class name and the file, thats it.
 
C

Curt Hibbs

Keith said:
If code is duplicated hundreds of times in a project, it's hardly
the fault
of the programming language.

In the case of C++, it *is* the fault of the language. A class name (and its
superclass name) is *required* by the language to be duplicated. In the case
of the class name, its duplicated once for every method defined in the
class!

Curt
 
K

Keith P. Boruff

Curt said:
In the case of C++, it *is* the fault of the language. A class name (and
its superclass name) is *required* by the language to be duplicated. In
the case of the class name, its duplicated once for every method defined
in the class!

Curt

Well, in the case of C++, I'll agree. I have to deal with this crap language
(sometimes I like it)for a living and understand its frustrations. Just the
dependency issues along.... sigh. I think I see where you're coming from.

But.... if you think Ruby is impervious to needing any refactoring because
it's less "verbose" than other languages, I would not agree.

KPB
 
M

Mark Sparshatt

--- "Keith P. Boruff said:
But.... if you think Ruby is impervious to needing
any refactoring because
it's less "verbose" than other languages, I would
not agree.

I don't think people are claiming that Ruby programs
never need to be refactored but rather that since
they're less verbose refactoring is easier, so that
you don't need the same heavyweight refactoring tools
that languages like C++ and Java require

--
Mark Sparshatt






___________________________________________________________
ALL-NEW Yahoo! Messenger - all new features - even more fun! http://uk.messenger.yahoo.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,166
Messages
2,570,903
Members
47,444
Latest member
Michaeltoyler01

Latest Threads

Top