News for hackers. Stuff that matters.
Re:Modern Java – A Guide to Java 8 by kriro on Monday November 16, 2015 @07:32AM (#10574018)
I've always had some sort of mistrust of Java (neo-Cobol ohnoes!) but I'm liking it more and more. Mostly I've come around to the fact that static typing isn't as bad as my young self thought (and can in fact be quite cool). The verbosity and "enterprisy" and committee oriented feel are still a bit off putting but I've made a commitment to try some Java on a couple of weekends. Did a bit of research and there's actually nice looking lean web-stuff, too (Spark Framework, Ratpack). Played with the J8 features back when it was released and they are pretty cool.

Cliffnotes: I think I have discriminated against Java mostly on a "religious" basis. I think it's a great time for people like me to give it another shot (especially if you have grown accustomed to functional ideas form other languages in the meantime).

The repo is an excellent resource, bookmarked.

Re:Modern Java – A Guide to Java 8 by pjmlp on Monday November 16, 2015 @08:49AM (#10574360)
Good luck with your experiments.

Many of us in the 90's jumped into Java, in spite of its issues, because it made it more pleasing to write cross platform code, than using C or C++ with CORBA/COM across OSes with compilers that were still playing catchup with the standards.

Re:Modern Java – A Guide to Java 8 by haxeny1 on Monday November 16, 2015 @11:44AM (#10575420)
I never understood the following : Eiffel had a better syntax, better support for core issues, Void type, design by contract, multiple-inheritance and an intermediate virtual machine for portability although the most common target was C code. To name a few. I was using Eiffel in a small side project just about when Java released their 1.1.4 (a version before the object serialization library, iirc). It was a sticking point for me. Add to that, to program in java before IBM Visual Age was released was to using vi/notepad(++?) editors. Coming from Smalltalk env that was a bit of a shock. Eiffel commercial IDE from ISE was way better and its clever use of pick event on the mouse's right click to drop to compile/run targets was actually easier on my fingers, which is a side show, but good quality products demonstrate quality at unexpected places.

I am still programming in java in my day job, knowing fully well that Java was not my top five language choices. Eiffel's type system was a bit more advanced than Java even way back in those days, so not only was I stuck without an ide till VA for Java showed up or VisuallJ++ I also had to accept weak inheritance and design by contract models. Performance of course was not even close to an Eiffel compiled C code, which was probably addressed in later versions of java.

My point being, that just as Eiffel was something that was better and set aside by a few leading development shops, there must have been other languages that could/should have received a fair share in language evaluation by programmers, I dont necessarily mean limiting to Ruby, Python for example, despite them being excellent tools, they may fall short in an enterprise ecosystem. What happened at least I seem to think instead is a sort of groupthink to start coding in Java because of rubbernecking. All in all, I think that things could have been better if people paused to understand the Java language model and fixed in java 1.2/3, or some earlier version so we didnt have to wait till Java 1.8 to get these features. /rant.

Re:Modern Java – A Guide to Java 8 by rcurry on Monday November 16, 2015 @12:19PM (#10575638)
I developed a great interest in Eiffel after I read Bertrand Meyer's book "Object Oriented Software Construction" (which I still think is one of the all time great books on object-oriented programming), but I never found anyone else that was using it and the IDE was way too expensive for me at the time. It just seemed to me like one of those technologies you'd probably get to have fun with on some niche project at a defense contractor, but that you'd probably never see out in the more general software development world.
Re:Modern Java – A Guide to Java 8 by haxeny1 on Monday November 16, 2015 @12:59PM (#10575885)
I was one of those folks who actually bought the personal license. Over years, SmallEiffel came along and improved the ecosystem. Of course, now Eiffel has a community/enterprise model. In any event, I do think that they were pricing them out of the market. Defense contractors, seem to like ada more. The feature that I miss from Eiffel is the Expanded (allocated on stack feature). Even haskell has some #untyped to deal with boxing primitives. I thought that Expanded was a stroke of genius: bringing specification to implementation without the middleman(aka heap).
Re:Modern Java – A Guide to Java 8 by pjmlp on Monday November 16, 2015 @12:22PM (#10575666)
I agree with you.

Before Java was known to the world, I already knew plenty of languages with closures, value types, GC,AOT compilation to native code, ...

But they all suffered from two problems, not being from known companies with geek credit and being commercial.

Java was from Sun (geek credit) and was free (as in beer), hence why it got adopted.

I think it would been great if Eiffel had got a decent market share,instead of just the DBC ideas.

But if I remember correctly they went after the enterprise, so the language was out of reach to many developers given what they used to charge for.

Re:Modern Java – A Guide to Java 8 by snambi on Monday November 16, 2015 @03:25PM (#10576906)
Syntax is not a big deal. Ideally it should be small. If you don't like java, please don't use it. move on. Why create ugliness in java?
Re:Modern Java – A Guide to Java 8 by haxeny1 on Monday November 16, 2015 @05:12PM (#10577624)
Typesystem is not the same as syntax? I dont believe raising ugliness in syntax as an issue. Of course, I do mention the ugliness in Haskell and that is in special cases where the overhead of boxing is significant. So, yeah, we could move on, but I think that is a specious argument. I guess one could really move on, till we start seeing Scala embrace Uniform Access Principle or Java embrace lambdas (implicitly or explicitly) to support generics. So, what it seems to me is that you are ok with a bad language design and accept the weakness of the language because it was delivered and also accept that like any working document there could be amendments and that is part of working in a programming language. Moreover, the principles of language design that I list were available as prior art, so it is not clear as to why Java language designers decided to at least not refer to it during design. Anyway, my intention was not to start a flame war? Note: Regarding : "why create ugliness in Java?" Any reason for an ad homenim attack? or was it a general rant? Since we are on hacker news I would like to give you the benefit of doubt :).
Re:Modern Java – A Guide to Java 8 by ww520 on Monday November 16, 2015 @01:49PM (#10576236)
I don't remember the detail at the time but I think the lack of free tools hurt Eiffel's wider adoption.
Re:Modern Java – A Guide to Java 8 by MrBra on Monday November 23, 2015 @08:44AM (#10614496)
I had some little experiences with Java and now I'm approaching C# so I have a genuine newbie question regarding cross platform development: was Mono (or .NET core) a thing in the 90's, would you have chosen C# over Java?
Re:Modern Java – A Guide to Java 8 by masklinn on Monday November 16, 2015 @07:43AM (#10574065)
> Mostly I've come around to the fact that static typing isn't as bad as my young self thought

That's not exactly a point for Java though, considering it doesn't really have a good static type system.

Re:Modern Java – A Guide to Java 8 by cfontes on Monday November 16, 2015 @07:53AM (#10574100)
Could you define good?
Re:Modern Java – A Guide to Java 8 by lmm on Monday November 16, 2015 @08:55AM (#10574388)
Java's way of expressing variance is really awkward (even quite popular libraries get their types wrong as a result), arrays are special-cased into unsoundness, Serializable is a total mess where it could be a perfect example of how to use a type system, there are no higher kinds, the exception system is like a second parallel type system (it even has union types, which would be incredibly useful if you could use them in the rest of the language). More than that, the standard library doesn't really use the type system to its full effect, e.g. errors in JDBC are C-style numeric codes, Comparable returns an int for what should be a 3-value enum.

(To answer your question, a type system should be sound unless and until the user explicitly requests otherwise, easy to use, but above all consistent)

Re:Modern Java – A Guide to Java 8 by meddlepal on Monday November 16, 2015 @09:15AM (#10574499)
Besides null being a potential type for any reference and causing a ton of issues I do not think most Java programmers regularly care about the lack of abstractions like higher-kinded or union types. Would be nice to have, but never have I felt like I needed them.

Enum types didn't exist in Java when the Comparable interface was implemented. That's why some API's look old-school by comparison because newer language features didn't exist yet.

Re:Modern Java – A Guide to Java 8 by masklinn on Monday November 16, 2015 @09:36AM (#10574621)
> I do not think most Java programmers regularly care about the lack of abstractions like higher-kinded or union types. Would be nice to have, but never have I felt like I needed them.

That could be stated about pretty much every feature added since Java 1 really, it's not like the blub paradox has disappeared from our reality. How do you know that you wanted union types when you've never used a language which had them (and had features hindering such a conceptualisation, C-style enums are not really helpful there, even less so when extended the way Java did)

Re:Modern Java – A Guide to Java 8 by lmm on Monday November 16, 2015 @10:21AM (#10574887)
> I do not think most Java programmers regularly care about the lack of abstractions like higher-kinded or union types. Would be nice to have, but never have I felt like I needed them.

My counterargument would be the popularity of annotation-based libraries in Java. An annotation is basically a place where the official type system has proven inadequate.

Re:Modern Java – A Guide to Java 8 by masklinn on Monday November 16, 2015 @11:12AM (#10575203)
That's not entirely true, part of annotation's use case is metasyntactic: codegen, code analysis and just plain structured/extractable comments.
Re:Modern Java – A Guide to Java 8 by stickfigure on Monday November 16, 2015 @06:27PM (#10578105)
For an eye-opening experience, walk through the tour of Ceylon sometime. It has the most sophisticated implementation union & intersection types I've yet seen:

http://ceylon-lang.org/documentation/1.1/tour/types/

Compared to union/intersection types, I find myself craving higher kinded types less frequently. I do feel the absence strongly, however, when I'm writing tools. I think the lack of higher kinded types manifests in the Java community as inferior libraries (eg ORMs) that require more manual-feeding of information via annotations or extra parameters to methods.

Re:Modern Java – A Guide to Java 8 by rbanffy on Monday November 16, 2015 @08:34PM (#10578641)
> I do not think most Java programmers regularly care about the lack of abstractions like higher-kinded or union types.

When you become used to a given language, you start to reason in its terms. A programmer who is used to Java is used to its shortcomings and will not miss Lisp macros or dynamic types.

Re:Modern Java – A Guide to Java 8 by mercurial on Monday November 16, 2015 @02:09PM (#10576382)
> Comparable returns an int for what should be a 3-value enum.

To be fair, I can think of another functional language starting with "O" guilty of exactly the same thing...

Re:Modern Java – A Guide to Java 8 by haxeny1 on Monday November 16, 2015 @05:28PM (#10577733)
I was about to refute your argument by proposing creating a union type. Here is a relevant reference: https://realworldocaml.org/v1/en/html/functors.html

(This idiom is a bit of a historical error. It would be better if compare returned a variant with three cases for less than, greater than, and equal. But it's a well-established idiom at this point, and unlikely to change.)

Eiffel is similar to ocaml : http://www.infor.uva.es/~felix/referencia_smart_eiffel/libra...

Does anyone know the advantages of the above signature over the Haskell alternative? Because this seems to be more obvious and easier to read. So there are more than one language guilty of using a ternary operator for compare.

Haskell does define the appropriate constructors, rightly so: https://hackage.haskell.org/package/base-4.8.1.0/docs/Data-O...

data Ordering :: *

Constructors LT EQ GT

Re:Modern Java – A Guide to Java 8 by mercurial on Tuesday November 17, 2015 @12:30AM (#10579334)
> Does anyone know the advantages of the above signature over the Haskell alternative?

Historical reasons, mostly. The only practical advantage I can imagine is that it's a bit shorter to implement a reverse comparison, since you just multiply by -1.