18 ms·
You know, I've been messing around with Java little lately. Nothing too fancy. It's actually not a bad language -- with a modern IDE it's actually pretty quick
by bane 13y ago
You know, I've been messing around with Java little lately. Nothing too fancy. It's actually not a bad language -- with a modern IDE it's actually pretty quick and breezy to work with.
If the standard library was cleaned up and the warts were all removed and filled in, even if it broke compatibility (call it Java X or the Latte language or something) I'd be okay with that. There's too much old 90's cruft hanging around making usage of different pieces non-standard and lots of over-objectizing everything so you end up having to assemble lots of things out of little pieces, boilerplate-like, that should just be a single import and instantiation.
The modern JVM is surprisingly quick and robust technology and I've been pretty happy with it in my limited tests. I ported some old Perl algorithms to it and got some really good speed out of it once I benchmarked some of the collections a little.
Some things should just be outright fixed, like a proper regex literal so I don\\'t have to \\e\\s\\ca\\\p\\\\e everything so much\\\\\//\/\\.
It's "got good bones" and a refurb of the entire thing to bring it focus could breath a lot of long-term life into it.
edit
I guess what I'm trying to say is it would be great if the language was informed a bit more with what's going on in the dynamic languages space like Go has been. I like how Python is about as clear as Java code is, but it's always seemed a little more quick and breezy to work with. This is something I think Go got right and it'd be great if Java sort of caught onto this.
- netcraft 13y ago>If the standard library was cleaned up and the warts were all removed and filled in, even if it broke compatibility (call it Java X or the Latte language or something) I'd be okay with that this is what groovy and kotlin attempt to do. groovy is backwards compatible with java as well, in most cases java code is valid groovy code.
- bane 13y agoI've always been reticent to learn these offshoot dialects of languages unless I really needed to. I'd much prefer it if they were treated as syntax experiments, and good ideas from them filtered back into the main language.
- emp 13y agoThe problem is the rate things get filtered back to Java. I started using Groovy when I kept waiting and waiting for new language features. In 2003.
- vorg 13y agoGroovy wasn't production-ready in any way, shape, or form until 2005 when the parser was rewritten in Antlr 2, and even then it took years to clean up bugs particularly those related to the MOP which was added in 2006. The Java 5 features weren't even begun to be added to Groovy until early 2006, and they're still buggy. The only significant addition to Groovy since then has been a @CompileStatic tag in Groovy 2.0 in June 2012, which its main user Grails 2.2 didn't dare bundle until 6 months later, but didn't actually use the static compilation. Grails 2.4, still in development, is the first to actually use any of the static features of Groovy, but with a strong caution in the doco: "Care must be taken when deciding to statically compile [Grails] code." http://grails.org/doc/2.4.0.M1/guide/introduction.html#whatsNew24 http://grails.org/doc/2.4.0.M1/guide/introduction.html#whats...
- radiantsand 13y agoIt's a mistake to think of one "main" language. There's a limit to what can be fed back into the Java language. Other languages like Clojure and Scala have more than enough going for them and stand on their own merits. I'm seeing increasing numbers of teams relegate Java code to legacy status in favor of newer JVM languages.
- eropple 13y agoGroovy isn't attempting to fix Java, it's entirely different. (And it sacrifices type safety--even what of it you get with Java--and performance to do so.)
- mbell 13y ago> And it sacrifices type safety Groovy is optionally typed, you can have as much safety as you wish. > and performance to do so If you use static types, you can use @CompileStatic to get most of the performance back.
- eropple 13y agoOptional typing adds a ton of sand to the gears when you actually are writing code. @CompileStatic requires you to spend entirely too long thinking about what's actually legal to annotate and generally sucks rocks to read and write. So, okay, you're technically correct, which is every nerd's favorite kind of correct, but writing it that way sucks. Groovy isn't a bad scripting language (or wouldn't be if discobot ever got done), but it's unserious as a Java competitor where Java is good.
- vorg 13y agoGroovy's main user Grails 2.2 didn't dare bundle Groovy 2's @CompileStatic until 6 months after its release in June 2012, but didn't actually use the static compilation. Grails 2.4, still in development, is the first to actually use any of the static features of Groovy, but has this strong caution in the doco: "Care must be taken when deciding to statically compile code." http://grails.org/doc/2.4.0.M1/guide/introduction.html#whatsNew24 http://grails.org/doc/2.4.0.M1/guide/introduction.html#whats...
- lmm 13y agoI'd say Ceylon is the interesting project here - it keeps the JVM but drops the standard library. (I'm a big fan of Scala - its sheer power is second to none - but it definitely has its ugly parts and many of them can't be fixed as long as it's to remain compatible with the Java standard library)
- vorg 13y ago> groovy is backwards compatible with java as well, in most cases java code is valid groovy code. Whenever I read that meme I get damn suspicious about why java code isn't valid groovy code in all cases. Why only most cases? It all sounds like a recipe for spending half a day debugging simple scenarios where things don't run as intended. To be taken seriously (or as seriously as a language called Groovy can be taken), embrace and extend Java fully, don't embrace only 99% of it before extending. That's what Microsoft tried with J++ and lost a lot of trust with developers that took them a decade to win back.
- netcraft 13y agoIts mostly things where the java code contains groovy identifiers, but here is a pretty good list: http://stackoverflow.com/questions/687601/valid-java-code-that-is-not-valid-groovy-code http://stackoverflow.com/questions/687601/valid-java-code-th...
- jpitz 13y agoThere are warts in the standard library to be sure, but many of them have already been filled in by third parties like Apache Commons, Google Guava, and Joda-time. I'm sure there are others I'm not thinking of.
- latchkey 13y agoAgreed ...and jdk8 includes what was effectively joda-time (jsr-310) now. projectlombok.org also makes a lot of the language syntax ugliness quite bearable.
- kevinpet 13y agojdk8 completely breaks the entire value we get out of using joda-time, namely, that instants are unambiguous. It actually recommends using time and date without time zone.
- portmanteaufu 13y agoCould you elaborate on this? I thought that JSR-310 and Jodatime were supposed to be nearly identical. Why would they introduce such a regression?
- grimlck 13y agoIt doesnt recommends using time and date without time zone, it recommends using the right class for the right job. And sometimes the right class doesnt include a timezone Suppose you have a webpage asking users for their birth date. What data type do you store that value in? Hint: You aren't going to prompt the user for the time zone they were born in.
- puppetmaster3 13y agoThe problem is not java the lang. It's the java developers. Looks like they moved on to do angular now.
- edwinnathaniel 13y agoThat's a good sign. Y'all JS devs need to learn something from Java community (especially the engineering/quality side) even if you guys have to go through the pain of Java growth (small => medium => bloated => denial => acceptance => cleaning up => shaping up for the future).
- puppetmaster3 13y agoIt's a bad sign for .js devs: trouble ahead.
- edwinnathaniel 13y agoJS ecosystems in terms of quality, tooling, and engineering is already bad, can't be worse than that really... PS: No, yet-another-js-library-to-replace-jquery is not considered tooling. No, yet-another-replacement-for-grunt/bower/yeoman is not a good sign of the ecosystems. Java has Maven since 2004.
- puppetmaster3 13y agoMaven is horible. Hth
- edwinnathaniel 13y agoIt's awesome and other tools (bundler) are copying it or build on top of it (gradle, buildr, Ivy repo). XML is horrible, not Maven. Python tools don't even come close. Ditto with .NET NuGet. Find me a tool that can compare feature by feature with Maven and still relevant for a long time.
- edwinnathaniel 13y agoThose warts have been addressed by 3rd-party libraries. The ecosystem is much better (more stable, higher quality, higher "engineering" effort) than Ruby or Python. Might not suit to one's taste but we all have different taste buds.
- kovacs 13y agoYou know I'm not sure I completely agree on this point. As someone that's lived in both the Java and Ruby worlds for a long time I'd say that in a many number of cases you're right. The "shiny object" syndrome is much less of a factor in the Java world and things like backward compatibility are engrained in the culture which manifests itself in the various open source projects. In the ruby world things are simpler to get started with and the surface area of a project is usually smaller and fairly easy to get integrated compared to Java. But ruby projects tend to "rot" much more quickly and aren't nearly as strict about compatibility. That's probably because Rails, the biggest reason for ruby's popularity, is very much about breaking compatibility without a second thought if it means improving the framework. But I've also seen some really well written and tested ruby gems in my time, compared to some java projects... and visa versa.
- praetorian84 13y agoDefinitely a promising little language. Might make it big in the enterprise.
- mariusmg 13y agoC# is a nice languae. Java...not so much. Properties, delegates, proper generics, LINQ and so on.
- sremani 13y agoI agree C# from pure language point of view had a better road map and unlike Java which was sort of kind of run by committee did not need colossal consensus from disparate groups for new language features. JVM vs CLR its a different story - I am hearing Microsoft in negotiation with Xamarin to buy/invest, that may make Mono get feature/implementation parity with CLR. Till then JVM is the only thing close to platform agnostic environment in town.
- benjiweber 13y agoA lot of the things you can do with LINQ you can do in Java now there are lambdas and method references. e.g. http://benjiweber.co.uk/blog/2013/12/28/typesafe-database-interaction-with-java-8/ http://benjiweber.co.uk/blog/2013/12/28/typesafe-database-in... Properties you could simulate with lambdas now. something like Property<String> name = get(() -> name).set(name -> this.name = name); You would lose all the existing framework support that assumes getters and setters doing that though. Some of the generics failure will likely be fixed in 9 (Primitive specialisation). Other things are not as bad as some people think (At least generic supertype params are available at runtime)
- benjiweber 13y agoHere's that example of Property implementation https://github.com/benjiman/expressions/blob/master/src/test/java/uk/co/benjiweber/expressions/PropertyTest.java https://github.com/benjiman/expressions/blob/master/src/test... https://github.com/benjiman/expressions/blob/master/src/main/java/uk/co/benjiweber/expressions/Property.java https://github.com/benjiman/expressions/blob/master/src/main...
- kvb 13y agoThat's an impressive proof of concept, but without expression trees it can't quite measure up (e.g. you need to remember to use `.and` instead of being able to use `&&`).
- pron 13y agoA major cleanup of the Java libraries is scheduled for Java 9. The JVM actually does not surprise anyone who's been working with it for a while: it is downright the most performant, flexible and awesome runtime environment ever developed. I've been playing around with lots of languages and environments in my pretty long career and, in the past decade, have always come back to Java (or the JVM). It feels like driving a Ferrari where everything else is at best a Toyota - might be easier to handle at first, but it's not your dream car. This pattern, by the way, has been going on in lots of tech companies. They always end up going back to the JVM. Aside from terrific performance, the JVM gives you the best concurrency platform out there (though not the easiest to use), cool and extremely useful capabilities like dynamic linking and bytecode instrumentation, and unparalleled monitoring and profiling tools. It's the most professional platform you can choose (unless you're limited to Windows, in which case .Net is also an option). It's so far ahead than anything else out there, that the competition can only beat it in very specific use cases (e.g. Go is much better at startup time as well as standalone packaging, and C has better performance, though mostly in single-threaded programs). But nothing else gives you the whole package of performance, flexibility, maturity and monitoring.
- chaostheory 13y ago> Aside from terrific performance, the JVM gives you the best concurrency platform out there (though not the easiest to use) It's getting easier http://akka.io/ http://akka.io/ http://gpars.codehaus.org/ http://gpars.codehaus.org/ I think clojure is also actor based.
- ape4 13y agoLots of things in the library have multiple ways of doing things. Eg File, NIO. Generally if you use the new class you're in for a nicer time. I agree about the regex literals. JavaScript does it right.
- Pxtl 13y agoBreaking backwards compatibility isn't really an option, but if the compiler and IDE would discourage the use of legacy features that would be best. Just remove the legacy/ugly methods and packages from the autocomplete process, and warn with recommendations/flag as deprecated. You don't actually have to break anything.
- iSnow 13y agoActually, every IDE warns you if you try to use a deprecated method. They show as strikethrough in your source too. There are things like http://docs.oracle.com/javase/7/docs/api/deprecated-list.html#class http://docs.oracle.com/javase/7/docs/api/deprecated-list.htm... and IDE's know about this.
- bradleyjg 13y agoProblem is Sun^W Oracle hardly ever depreciates anything. There are 21 classes in that list (7 in java.*), out of a total of almost 4000 as of java 7.
- elwell 13y ago> lots of over-objectizing everything This. This is what I think of when I think of Java.
- tormeh 13y agoObject orientation isn't a bad thing per se, but everything should be done in moderation and, well, the argument can certainly be made that Java has gone a bit or two too far.
- piokuc 13y agoJVM is fast these days, indeed. I was playing with Solr lately and was shocked with its speed... Also saw a comparison of HTTP servers lately and the fastest one was written in Java, I think.
- mbillie1 13y agoThis sort of reaction is surprising to me. Java has been a useable, performant language for some time now. The tooling is excellent, the JVM is astonishingly good, and it will run circles around Python, no less Perl. I don't think many of the arguments against Java are based on how it works once you've written it, but rather to the horrendous verbosity, class-explosion-as-a-design-pattern, painfulness to read (not debug with an IDE, which is easy, but to actually read Java code), and so on. I'm not a Java developer by trade, but I'm surprised that other people are surprised by Java being high-performing, and the JVM being a good platform. I mean, Clojure Scala and Groovy all run on the JVM, and we talk about them all the time!
- ephemeralgomi 13y ago> painfulness to read (not debug with an IDE, which is easy, but to actually read Java code) This is incredibly important and I never see any Java advocate addressing it. I _do_ see tons of people pointing out how easy it is to automate refactoring, and then they leave dozens of ugly, poorly-thought-out methods lying around...
- Terr_ 13y agoThe problem is that there are two major kinds of "reading code". There's (A) the brief pass you do to get the gist of what a class/method does, and (B) the deeper pass when you try to build a mental model and step through bits of code in your head. While Java's verbosity does harm skimming, it also aids targeted comprehension, since it is easier to see the "one right behavior" that code has. Fewer sneaky surprises, leaky abstractions, weird type coercions, inferring which class-interface the designer intended to target, etc. As mentioned already, the other big advantage to explicit-ness is all the static analysis the IDE can do for you.
- Dewie 13y agoVerbosity adds noise (redundant information), or information that is usually redundant, so you get used to it, so when you see the ~same pattern again, you skim over the things that you think are the same. But then sometimes it isn't quite the same, because of a bug or because the for loop does a decrement rather than an increment, which is lost on you. Finding the balance between terseness and having a little bit of redundant information is of course very hard.
- dragonwriter 13y ago> I guess what I'm trying to say is it would be great if the language was informed a bit more with what's going on in the dynamic languages space like Go has been. I like how Python is about as clear as Java code is, but it's always seemed a little more quick and breezy to work with. This is something I think Go got right and it'd be great if Java sort of caught onto this. Java has caught on to this, and a number of the new JDK 8 features reflect this (lambdas and everything related to them, default methods for interfaces, etc.) But Java isn't as unconstrained as a new language like Go is, because its got to support a huge stack of established code as well as making things more streamlined for new code.
- suyash 13y agoJava is the #1 language in the world. It's the best out there, period. http://jaxenter.com/java-is-the-world-s-1-programming-language-again-47932.html http://jaxenter.com/java-is-the-world-s-1-programming-langua...
- radiantsand 13y agoBest at what? You've link to a notoriously unscientific index which counts search engine results. How does that make one language universally better than all others "period". I've coded in Java for most of my career, but the blind blinkered faith in the language within the Java community never ceases to amaze me. It's one tool available among many, look a little further than that single hammer which you worship in your toolbox.
- gamegoblin 13y agoPopularity != Quality
- peterashford 13y agoI don't think you can become a popular cross platform systems programming language without being pretty decent.
- gamegoblin 13y agoThere is a lose correlation between quality and popularity, but being the most popular language is in no way indicative of being the best language (as the person I responded to was saying).
- Buttons840 13y agoI agree. I've ran across a few obscure languages I thought would be barren, but found they had exciting new developments happening. It made me realized there's a big difference between the number of language contributors and the number of language users. Most are language users, like myself, who glue a few libraries together and write a little business logic and call myself a programmer. Whereas a language contributor (as I call them) create libraries, development tools, etc. I've wondered if the number of language contributors is roughly equal, within an order of magnitude, across most languages, even the obscure ones. Language contributors add quality to the language, language users (again, myself) don't.
- cia_plant 13y agoNo, actually, Java is a really bad language. It has a very complicated type system, but doesn't even allow you to express things like function composition or generic sums at the language level. Its syntax is stunningly verbose (e.g., no map literals; only now adding lambda literals; no type synonyms; no operator overloading). There is no macro system or method_missing or any other way of really extending the language, except the ugly, unsafe reflection system ... so now all the libraries (Spring, Hibernate, etc.), use annotations and reflection to modify object behavior at runtime.
- stusmall 13y agoWhat is complex about the type system?
- bronxbomber92 13y agoI'm guessing he's referring to wildcards (http://cseweb.ucsd.edu/~atl017/papers/pldi11.pdf http://cseweb.ucsd.edu/~atl017/papers/pldi11.pdf) and the fact that the type system allows this (which isn't really a complexity, but rather a deficiency): Object[] foo = new String[1]; foo[0] = new Integer(4); // exception thrown here instead of a compile error.
- mercurial 13y ago> It has a very complicated type system, but doesn't even allow you to express things like function composition or generic sums at the language level. Yeah, sure, it doesn't have Haskell's . or algebraic datatypes, just like lots of other languages. I'm not sure what's complicated about the Java type system, but I suspect you're trying to say you don't like subtyping. Moving on... > Its syntax is stunningly verbose (e.g., no map literals; only now adding lambda literals; no type synonyms; no operator overloading). No map literals, but Guava has leveraged generics in a brilliant way to reduce the duplicate declaration of types. Also, it brings a little bit of functional-style goodness with transform/filter. It turns even JDK 6 into something you can be productive with. I'm not sure the lack of type synonyms is really an issue, the type signatures are rarely complex enough that you need to obfuscate them. On the other hand, I'd give somebody else's right arm for an equivalent to newtype and deriving. > There is no macro system or method_missing or any other way of really extending the language, except the ugly, unsafe reflection system ... so now all the libraries (Spring, Hibernate, etc.), use annotations and reflection to modify object behavior at runtime. Not to forget proxy objects and interceptors. But yes, Java could definitely use a macro system. But you're missing the elephant in the room, the existence of null. The bane of every Java programmer, dreading NPEs at each function call.
- gamegoblin 13y ago@regex I think a simple enough solution would be to introduce raw strings which is how regex is usually done in python.
- why-el 13y agoWell you are basically quoting Joshua Bloch of Effective Java fame when he says "please don't abandon the JVM, a lot of work went into it"(My paraphrasing).
- jonalmeida 13y agoI've gained an affection towards IntelliJ after having to use Android Studio for some development. Much more flexible nicer and customizable (from a UI pov) than Eclipse-based IDEs.
- rurounijones 13y agoOne reason I love JRuby. The ruby language syntax with the power of the JVM and Java library interop. As far as I am concerned that is a match made in heaven.
- NerdfaceKillah 13y agoWhat IDE do you use?
- keypusher 13y agoYou might want to check out Groovy. It's built on the JVM, you can use all the standard library and third party Java packages including stuff off Maven, and you can even just run straight Java code through it. However, at any time you can also drop into Groovy land, and write in a much more concise and functional style. Closures are very common (just look at anything in Gradle), it was clearly influenced by Python/Ruby as far as syntax and type optionality, there's a REPL (groovysh), there's a modern web framework (Grails), all in all it's pretty nice.
- virtualwhys 13y agoMeh, used Groovy for 2 years followed by a year of Grails 1.3.x hell. Both the language and the framework have likely improved since then, but after switching to Scala + Play there's simply no going back ;-) p.s. Haskell + Yesod (or Snap) look interesting as an alternative web stack to explore, but otherwise not seeing much out there that would draw me away from Scala land.
- keypusher 13y agoInteresting. Scala always put me off, the sytax just seems so nasty. Does that just get better after working with it for a while?
- virtualwhys 13y agoSo much better ;-) There's a learning curve, can't hit the ground running as you can with Groovy, but with Groovy there's a ceiling; with Scala the only ceiling is (perhaps) Haskell and for that you have to leave the JVM.
- vorg 13y agoLanguages where you can "hit the ground running" always have a ceiling. If you churn out working code quickly, you're offloading the real work onto someone else in the future. Real world programming, like business, is all about borrowing from the future, intending to default on the debt.