News for hackers. Stuff that matters.
Re:Java 12 by ellard on Tuesday March 19, 2019 @05:44PM (#19436294)
Serious question: Isn't Java still one of the default languages if you are choosing a "safe" language to build and maintain a large piece of software? Considering how long it's been around and how many libraries exist for it now, i've generally viewed it as a language that's:

- fast enough for most things without a lot of pitfalls/gotchas

- easy enough to read for most developers

- easy enough for most developers to pick up if they've never used it, even if they aren't exactly enthused by the idea of doing so

- supported enough that you'll never be the only person who is debugging something

- widely used enough to never be alone when you are trying to use it in unsupported ways

- has commercial support from multiple companies

Basically all the things that a lot of "enterprise" companies love.

Edit: formatting

Re:Java 12 by yazr on Tuesday March 19, 2019 @06:15PM (#19436632)
> Isn't Java still one of the default languages ?

Yes.

There is no need to engage the GP - let him rant about Go and JS. Java is still huge, for both legacy and new projects.

For context - I started as a C/Kernel dev. I also spent 2 years with Java on mission critical backend code. Both have their uses.

[dead]
Re:Java 12 by dang on Tuesday March 19, 2019 @10:55PM (#19438487)
Personal attacks aren't allowed here and we ban accounts that do that. If you'd please review https://news.ycombinator.com/newsguidelines.html and follow the rules when posting in the future, we'd be grateful.
Re:Java 12 by kickopotomus on Tuesday March 19, 2019 @07:22PM (#19437212)
Are you familiar with the term "Magpie Developer"[0]? Your claim of "better choices" is highly subjective. To me, every point that ellard brought up makes Java "better" than JS or Go.

[0]: https://blog.codinghorror.com/the-magpie-developer/

Re:Java 12 by wongarsu on Tuesday March 19, 2019 @06:09PM (#19436574)
All of those points are also true for C#, which imho fixes a lot of Java's problems and is a much nicer language. With .Net Core maturing you even get the "runs everywhere" factor (at least everywhere you care about, i.e. Win+Linux+Mac), and Microsoft is a much better vendor than Oracle.
Re:Java 12 by pjmlp on Tuesday March 19, 2019 @06:47PM (#19436914)
As someone that works with both stacks since their inception, there are tons of platforms with Java compilers, where .NET Core isn't even a thing today, and there are tons of .NET libraries that will never leave .NET Framework.

So it isn't like just exchanging one for the other like that.

Re:Java 12 by james_s_tayler on Wednesday March 20, 2019 @01:56AM (#19439416)
I'm finding library support quite good for .NET Core tbh. Not perfect, but it's not at all a barrier to adoption.
Re:Java 12 by pjmlp on Wednesday March 20, 2019 @03:33AM (#19439799)
Try to port any commercial component library to it like Telerik and friends, ODP.NET, WCF, EF 6, Forms, WPF.

.NET Core 3.0 will fix some of the compatibility issues but not all of them, for example EF 6 will only be partially supported (VS DB tooling is not being updated for Core).

Re:Java 12 by james_s_tayler on Wednesday March 20, 2019 @04:52AM (#19440174)
Yeah .NET Core 3.0 will address some of that, not all. I suppose for any brownfield development looking at switching across those things are the potential blockers at the moment. Especially things running EF where EF Core doesn't have a particular feature just yet. But EF Core development is cracking on at a good pace.

Telerik and the likes I'm not so fussed about personally. I suppose DevExpress is another one on that list. I think front end component libraries like Prime-ng/PrimeReact are probably the way to go for the future of UI development for Line of Business applications.

Overall I reckon in a couple of years there won't be much of those blockers left at all.

Re:Java 12 by evil-olive on Tuesday March 19, 2019 @06:18PM (#19436651)
I'm very happy to see .NET Core getting more stable and mainstream (I miss my days of working in C# even though I don't miss Windows) but I think running it on Linux for backend microservices still counts as fairly off-the-beaten-path compared to the safe, "no one ever got fired for doing X" choice of using plain ol' Java.
Re:Java 12 by meddlepal on Tuesday March 19, 2019 @08:11PM (#19437541)
The problem with C#, which I think is a fine language, is the small(ish) size of the ecosystem and the refusal of the ecosystem to deviate away from non-MS endorsed libraries and frameworks.

It's the ridiculously large JVM ecosystem that makes Java awesome, not the language.

Re:Java 12 by james_s_tayler on Wednesday March 20, 2019 @02:03AM (#19439447)
Yeah, I definitely feel this some days. I've just moved over to C# from Java because I'm bearish on Oracle as a vendor in general, I find C# great and impressed with Microsoft's efforts as a vendor with what they've done with .NET Core.

I have love for Java, but I gotta say it mostly is because the ecosystem is pretty fantastic. So much open source stuff for so long means it's all just there and it all just works. There are some gaps though.

.NET ecosystem isn't bad. It's pretty good. There are some phenomenal libraries. But sometimes the gaps are painful. The lack of an open source (read FREE) integration framework is a big one for me. There is BizTalk but that's commercial and probably expensive. Same with scheduling libraries. HangFire looks great but it's paid. A lot of the really high quality stuff you have to shell out for which when you're just hacking in your own time is not feasible. That being said there are open source libraries and some of them aren't bad. Lots of great stuff in general.

Re:Java 12 by threeseed on Tuesday March 19, 2019 @06:29PM (#19436742)
You can still have a more modern language i.e. Scala, Kotlin on the JVM whilst not abandoning the unparalleled array of libraries that the Java ecosystem offers.
Re:Java 12 by spricket on Tuesday March 19, 2019 @10:29PM (#19438350)
Completely agree, except that MS was so crazy hostile to OSS that they scared off all the serious guys a decade ago. I wish them the best. The CLR has some compelling features that make it objectively better than JVM on so many levels.

But the lack of ecosystem is killing them. And has been forever. The new MS CEO is great in my mind but it will take many years to turn the ship around. Devs don't forget.

Best example I can think of (was a C# guy for years). Resharper has been around forever. But it costs a lot. This is par the course for C#. I can get the same thing in Java by pulling in a few linters with Maven, and it's all free. Because MS scared away everyone that was afraid of licensing fees (ie most academics, the sharpest devs out there), there's nothing comparable.

Same with C# port of Quartz and so many others. They killed off the real rockstars among us that create the majority of libraries that everyone else uses.

Can it be fixed? I hope so. The CLR is great and Oracle sucks. But for now there's a good reason Java is dominant

Re:Java 12 by scarface74 on Wednesday March 20, 2019 @07:12AM (#19440911)
Resharper is $139 a year for a personal license and the price goes down 20% after the first year and 40% year after that. You can also pay monthly.

They also have a perpetual license. If you cancel after the first year, you can keep using the version that was current 12 months ago.

But the one thing missing in Java is anything like LINQ. I don’t mean the syntax I am referring to the idea of LINQ -> expression trees -> third party providers that translate LINQ to another language (sql, Mongo Query, etc.).

Re:Java 12 by spricket on Wednesday March 20, 2019 @11:15AM (#19443000)
It's not built in to the language, but JOOQ and QueryDSL come fairly close.

I do miss LINQ though. The Java options are all clunkier because the type system isn't nearly as flexible

Re:Java 12 by scarface74 on Wednesday March 20, 2019 @11:25AM (#19443102)
I can't tell from looking at the examples, but can I do things like pass around arbitrary expressions:

  Person.Get(p => (p.Age > 65 && p.Sex == "M") || (p.Age > 63 && p.Sex == "F"))
and have a method

  public List<Person> Get(Expression<Func<Person,bool>> expression)
and have that expression interpreted correctly at run time by separate providers?

You get full compile time checking and IDE supported autocomplete.

Re:Java 12 by spricket on Wednesday March 20, 2019 @12:41PM (#19443950)
Yes. But it's done in a different way than C#. C# supports fields and field references so you can pass them directly to a function.

The Java code "looks" like they do the same because they generate code to simulate method references instead. It's pretty clever and Javas code generation support for Annotation Processors is excellent and makes it possible to do this in a cross-ide cross-build-system way

LINQ and JOOQ/QueryDSL all work on plain data objects with fields. But with Java you do it on a pseudo object generated from your existing classes

Re:Java 12 by scarface74 on Wednesday March 20, 2019 @12:55PM (#19444105)
That's really interesting.

All of these years I've been beating up on Java for lack of something akin to LINQ. I guess I'll have to find something else to complain about.....

Re:Java 12 by spricket on Wednesday March 20, 2019 @03:56PM (#19446196)
IMO LINQ is still better because of how integrated into the language it is. JOOQ and QueryDSL were basically designed to replicate it as much as possible but not nearly to convenience levels of LINQ + Entity Framework
Re:Java 12 by cafebabbe on Tuesday March 19, 2019 @06:21PM (#19436665)
Yes, albeit with noticeably weaker libraries/ecosystem.
Re:Java 12 by iGoog on Tuesday March 19, 2019 @07:48PM (#19437405)
I gotta ask what in particular "problems" C# solves over Java, and I'm not talking about J2SE 1.4. Having dipped into C#, it feels like the designers resented OOP and reusable code. C# is not the new kid on the block and is almost 20 years old now.
Re:Java 12 by throwawayEntDev on Tuesday March 19, 2019 @09:21PM (#19437984)
Over that 20 years, C# has been continuously improved with language features added at a faster rate than Java. Some examples: * properties * LINQ * async/await * dynamic types * better generics * inferred typing - `var` * null conditional operators * custom iterators - `yield` * pattern matching

Also, .net is more of a “pit of success” language — Java with all its legacy baggage requires a lot more knowledge to avoid mistakes.

Re:Java 12 by iGoog on Wednesday March 20, 2019 @03:16AM (#19439745)
so... properties that require a steeper learning curve, a system that's worse far worse than JPA+Spring Data (or you could use the hibernate in both languages - a java development), another word for var/let, I'd disagree about generics, var/let again, I wonder what rust devs would say about these null inline conditionals that require more knowledge, and... yield is actually neat if also not another non-traditional baggage thing to learn. Anyhow, I guess my take is that Rust is a better language than C# in all the ways that C# might be better than Java and more... Except that C# is a lot like Java and is the language of choice if you use Unity - so it does have a big awesome ugly library that Java does not have. Really we should feel sorry about all the Unity baggage C# devs get to deal with. Then there's Microsoft land, which has not inspired me of code quality and can't get out of VB think.
Re:Java 12 by scarface74 on Wednesday March 20, 2019 @07:16AM (#19440931)
Hibernate is an ORM. LINQ is just what the name says it is language integrated query. Linq is understood by the compiler, translated into expression trees at run time and then any third party provider can translate it to the destination language. You can pass Hibernate expressions around and depending on context, they can get translated to regular IL when working with Lists, Sql when working with RDMSs or MongoQuery when working with Mongo, etc.
Re:Java 12 by int_19h on Wednesday March 20, 2019 @12:07AM (#19438880)
> it feels like the designers resented OOP and reusable code

Can you give some examples, that wouldn't be equally applicable to Java?

Re:Java 12 by iGoog on Wednesday March 20, 2019 @02:13AM (#19439492)
Maybe it's less of a C# thing, and more of a Unity thing - but I'd say that Unity has some major architectural anti-patterns - which may just be to appease the ease of a the awesomeness of a wysiwyg type game engine.
Re:Java 12 by iGoog on Wednesday March 20, 2019 @02:10AM (#19439476)
Polymorphism and inheritance by default?
Re:Java 12 by int_19h on Wednesday March 20, 2019 @02:37PM (#19445359)
You mean the fact that methods aren't virtual by default?

As Hejlsberg explained, the problem with virtual-by-default is that every time one of your public methods calls another public method on the same object, it makes it that much more complicated to reason about your invariants. If the called method is non-virtual, then you're in full control, and you know exactly what happens. But if it can be overridden, then you need to define a contract for overriders to follow, and you can't assume that it does anything other than what's expressed in that contract (in particular, you can no longer call that method without ensuring that all class invariants hold, even if it's expensive). Furthermore, the overriders often also need to know which other methods on the class do or do not call this method.

In practice, this is so much hassle that not even the Java standard library does that. For example, given ArrayList, if you override add(), does that affect addAll()? The docs don't say. So in practice, the only things that are safe to override is what the docs say are safe to override... which is to say, exactly like "virtual", except it's not enforced by compiler. Overriding random methods often works, but is a hack not dissimilar to using Reflection to access non-public members - even if it works, you're relying on implementation details of the class.