Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Lets just take your first example.

I read those exactly the same. There's no difference to me apart from taste, and potential for errors.

The potential for errors however, is far higher with the Moose and CLOS versions. Which is why I wouldn't like to use either of those syntax in a large project.

The java version, you can only really typo on the variable name. And even if you do that it likely won't compile unless your variables are similarly named. But with the moose example, you're starting to have silly things like '=>' which can easily be typoed and which can still compile, but completely change the meaning of the code.

Obviously at the extreme of this is regexp. Hugely compact, but a complete bitch if you typo anything. Personally I'd hate to write complete programs in regexp type syntax.

So you can keep your non-verbosity at the expense of sanity.

>> "In conclusion, Java is verbose, and verbosity is harmful."

I'd say Java has longer tokens than some other languages. By my definition that doesn't make it any more verbose. It makes it harder to go wrong with typos etc.

If you look at the underlying programming constructs in your first 3 examples, they're the same... thus for me, those code fragments are the same. No more or less verbose.

I think some of it just comes from having experience of reading code. Once you learn to read code in terms of programming concepts, rather than actual lines of code, you see no real difference.



The big issue is having to manually feed data from the constructor into the fields. There is no high-level concept of "attribute" in Java, which is what programmers actually want.

In Perl, you say "has foo => ( init_arg => 'foo', isa => Whatever, reader => 'get_foo', writer => 'set_foo' )" and the correct code is generated. In Java, there is no concept of "attribute", so you have to build it every time by manually declaring the field, manually writing the constructor, and manually writing the getters and setters. Anything you do manually more than once has the potential to introduce a subtle bug, and more importantly, is tedious and degrading.


It'd take you 2 minutes to write a java preprocessor to build your constructors if you really care about such things. (I don't particularly. I don't spend much time at all writing constructors, and often want to do nonstandard things, validation etc rather than just passing over variables as they are given).

With due respect, surely that's what being a good programmer is about? There's no law against preprocessing java if you really dislike the defaults.

How many constructors do you write? Sounds like perhaps too many.


But almost everything in Java is more verbose, and so you'd end up writing "preprocessors" for everything (and the strong, static, explicit typing means that a lot of this preprocessing would have to be rewritten for even slightly different cases).

So why not just cut-out the middle man and work in a higher level language directly?


>> "But almost everything in Java is more verbose"

Sure, that's the common misconception. You're correct. However, if you actually look at the language and write stuff in it, you'll find it's not actually true.

The issue is when people look at some existing insane Java code and cite it as proof Java is verbose.

I'd absolutely agree - most open source / freely available Java code is verbose. Several of the libraries (enterprise etc) are verbose and insane. But that's not Java.

Higher level languages are not always better. Use what is suited to the job at hand. I'm far more comfortable working at lower level than high level.

Which is better.... talking high level and relying on a compiler/runtime to figure out what you want? or just talking a bit lower level in the first place.


"Preprocessing Java" is called Clojure and Scala. But then it's not Java anymore, right, and the article is about Java.


Any programmer who just blindly accepts the default usage of a programming language, really has a lot to learn about programming.

all languages suck for some value of 'task'.


And yet half of this thread is people whining because 'use Moose' isn't part of their default usage of perl.


So the original argument is "java is verbose". How did we get to "all languages suck"?


idk. I could rant about how perl is error prone due to ease of typos and reliance on special characters, but I don't think it'd be news to anyone.


"ease of typos"? Give me some concrete examples.


> I'd say Java has longer tokens than some other languages. By my definition that doesn't make it any more verbose.

I don't know, that seems to be the very definition of "verbose" to me.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: