I'm not all that religious about any language, but let's spread the lack
of love around - Java can be awesomely ugly when it hits a problem it's
not suited for. And it often doesn't compete nearly as well as, say,
Perl or Python, if it's in a problem realm where it results in 3x or
more code to solve a given problem.
same here, mostly not very language religious (and use several
languages, although admittedly the bulk of it is written in C and some
C++, 1).
1: C (and to a lesser extent C++) is fairly good for infrastructural
code, but sadly, using it itself seemingly creates a need for large
amounts of infrastructural code (and, as well, the "libraries" space is
often very fragmentary, and 3rd party libraries are very much often "use
at your own risk"). (a multi platform project also ends up with a lot of
"portability boilerplate" as well).
in contrast, Java is much better for tasks which involve "using things
provided by the class library" (or, at least, this has been my
experience). a big comprehensive library at some cost that writing code
for things not provided by the library is a bit more painful (partly due
to the languages' relatively minimalist semantics, vs, say, C or C++).
C# is a little more of a compromise, but has a big drawback of being
tied mostly to Windows and .NET (portability in C# is not entirely
non-existent, after all there is Mono, .GNU, ..., but is not exactly a
strong area for the language either...).
me remembering a recent example, looking where a person tried writing an
H.264 codec in Java, and apparently gave up partly through (though, as
an external observer, one can't be sure if this was more due to the
general pain of writing an H.264 codec, or the specifics of writing an
implementation in Java).
(admittedly, it is bad enough writing these sorts of things in C#, and
Java would pose some additional issues, as in many ways they run at-odds
with the language-design choices).
sadly, a lot is a case where choices made which may offer benefits in
one area come at costs in another area.
not sure if anyone will try to argue all this.
I just now close-of-business yesterday finished a chunk of code that
despite some 15 years of working with Java isn't anything but ugly...and
I stipulate that it's not an uncommon ugly as far as Java and certain
types of problems go. Very complex SQL so a native JPA query that needs
to be assembled, trees using the Swing implementations, enumerations,
iterators, *lots* of list operations, *lots* of conditional intermediate
getter and setter operations to build the list of final result objects
to pass back to XStream for the REST call response...it's not pretty.
In a problem like this Java becomes kludgy because of death by a
thousand cuts. You do everything best practise (or decent practise) and
you still end up with hard-to-read clumsy code: no type inference so too
much verbiage, no C#-style properties so dozens of getter/setter usages
start looking pretty opaque...a Perl or Python equivalent _would_ look
considerably better. Ironically even the use of longer, descriptive
variable and method names can be self-defeating in this scenario - it's
just more bloat.
pretty much...
descriptive variable-names can be a double-edged sword.
in some cases, they can make the code "more obvious", especially if the
variable has "some well-defined meaning readily expressible in words".
in many cases, there are no words to express just what exactly this
variable is being used for, or it is being used as part of a big/hairy
set of mathematical expressions, making the use of a longer variable
name considerably more painful (like a single calculation spread over 4
or 5 lines).
there are still cases where multiple lines are needed for some
calculations, even with single-letter variables.
usually, using longer method names is not as big of an issue, since IME
method calls tend to be used at a lower density than that of variables,
and also because the choice of method names often has a lot more effect
on code outside the class, whereas variable names are typically much
more local to a given class or method.
my policy in general though is more often to not rigidly adhere to any
particular conventions, but rather to adjust conventions more "as they
make sense for a particular piece of code" (though sometimes this can
get at-odds with an IDE which does auto-formatting...).
And it's telling that you have libraries like StringUtils or Google
Guava that supply a list "join" method if you don't care to write your
own loop to handle it. Another one of those thousand cuts that adds to
the bloat.
I'll probably end up refactoring some of the code - but in another
language like Perl or Python or Scala or Ruby or C# I'd not have to
refactor in the first place.
yep, could be.