A lot of people argue that Java's verbosity improves clarity.
Thank goodness for those casts, semicolons, generics, ... ;-)
I'm not arguing that ever part of Java improves clarity. But there is a key difference that does...
I know that when I go back and look at old Python code, it takes a little while to figure out what types are being dealt with at any given point. It's not very self-documenting like good Java code, IMO.Do you think that is inherit in Python or was the code written more obtusely than needed?
I'm probably a pretty crappy Python coder at this point but I'm talking about something inherent here. There are no type declarations in Python. On one hand this is a great stregnth. However, for code maintenance, it seems problematic. If I need to modify a method, it's can be difficult to know what types are being passed in and what operations I can safely use.
I know many criticize Perl for being obtuse with its tightly compacted syntax. But isn't a language like Ruby touted as having a clean syntax without a lot of junk to add to the line noise? To me a clean script is easy to read and closer to English than Java.
I had a cat that was pretty good Perl programmer. He liked it because he couldn't type very fast.
I agree with you to a point. Python code reads like psuedo code and is a lot faster to write. For tools, 'throw away' business logic, and testing, I highly prefer it to Java.
I'm not talking about replacing Java - just a critique of when it kind of breaks down.
I got that. We are pretty much on the same page here. I would actually go a step further to say Java vs. Python or Java vs. Ruby is a false dichotomy. The languages are really quite complimentary. More on this...
Also, you've set up a straw-man with your example. BigDecimal is one of the worst APIs in the JDK. It's clearly not representative of most Java libraries. It's also a poor choice for working with money. Good Java code would use a Money type.Agreed that my sample stinks - but even with Money I don't think the code would change much. You still have to do silly things like use .add() .multiply() .compareTo(), and convert from primitive to Object right?
Well, it's really nether here nor there because I got your point but:
curr_amt = my_bo.amount
my_bo.amount = DISCOUNT * curr_amt if (curr_amt > MAX_AMOUNT)
Money current = myBo.getAmount();
if (MAX_AMOUNT.compareTo(current > 0) myBo.setAmount(current.multiply(DISCOUNT));
Is the Java version harder to read? Sure. But there are much better examples that highlight where Java's verbosity becomes very cumbersome.
That was my point. All that stuff is overhead to make Java work - it takes away from the clarity of what is being programmed.
I'm wondering if this is only true for people like you and me who do the vast majority of their work in Java (I'm assuming for you since you are posting on this site). I can crank out code in Java like nobody's business compared to Ruby but that doesn't mean that Ruby may not be a better language in certain situations. I'm just guilty of knowing how to use my Java hammer better than my Ruby (or other language) hammer. I'm wonder if we'd feel different after spending a few hundred hours of development time in a scripting language. Maybe we'd see Java in a whole different light?
I think languages like Python are good for prototyping and for logic that changes often. But for more structural code, it seems less appealing.
Yes, I've only recently started using Python after reading and getting involved in agruments about static-typing vs. dynamic-typing and realizing that deep inside, I was favoring what I knew mainly becauase I knew it.
Anyway what I found is that Python (Jython) and Java work great together. I love Python for testing and writing small pieces of glue code. However, for things that don't change much (big heavy structural elements), Java's verbosity becomes a benefit. And I also discovered something really cool (IMO). Nether Java nor Python support multiple-dispatch: Java because it's compile-time bound and Python because you can't overload by parameter types (no types!). But when you put them together: viola! double-dispatch on Java method calls from Jython.
Actually, I just realized that I need to use Jython in a side project to really improve a piece of functionality.