News for hackers. Stuff that matters.
Re:Pointer Free Programming and the Future of Nim by Arcsech on Thursday October 19, 2017 @10:31PM (#15513167)
While I love option types, retrofitting them into languages which already have nulls has problems.

Ask me about using a Java library that could return an option type, which could be null, so you have to check for both the None return value AS WELL AS null.

Re:Pointer Free Programming and the Future of Nim by cytzol on Friday October 20, 2017 @07:03AM (#15514828)
> Ask me about using a Java library that could return an option type, which could be null, so you have to check for both the None return value AS WELL AS null.

No, you don't -- because those are two different kinds of null!

If your library's function returns Optional.empty(), then it's because it successfully returned no value. If it returns null, though, then the library has a bug and you should crash instead of trying to continue in a known invalid state.

Without the Optional type signature, the function would return null for both of these, and your program will appear to work even though it's just suffered a bug.

Re:Pointer Free Programming and the Future of Nim by Const-me on Friday October 20, 2017 @07:45AM (#15514976)
> retrofitting them into languages which already have nulls has problems

I'm not sure I agree with that. See how MS did that in C# 7:

https://www.kenneth-truyers.net/2016/01/25/new-features-in-c...

Re:Pointer Free Programming and the Future of Nim by jacobparker on Friday October 20, 2017 @08:29AM (#15515206)
FYI that didn't ship in C# 7

More info: https://github.com/dotnet/csharplang/issues/36

Re:Pointer Free Programming and the Future of Nim by pjmlp on Friday October 20, 2017 @01:58AM (#15513780)
The situation is known and will be fixed when the JVM gets value types, with minimal value types already on the horizon.

https://wiki.openjdk.java.net/display/valhalla/Minimal+Value...

Until then it is an issue that we have to live with.

Re:Pointer Free Programming and the Future of Nim by qznc on Friday October 20, 2017 @03:52AM (#15514186)
When or if? I heard one talk about Valhalla some time ago. If this project succeeds it will either be a miracle of engineering or a nightmare to use.

Just one example: Java's type erasure trick does not work anymore when value types are type parameters, so it affects the build process. The current approach seems to be to construct specific instances at run time (or rather at class loader time). That is very late though, because some information (like return types) are lost after compilation.

Re:Pointer Free Programming and the Future of Nim by pjmlp on Friday October 20, 2017 @04:58AM (#15514421)
When.

The ongoing changes related to value types, AOT compilation, and overall mechanical sympathy are driven from pressure in the Fintech industry. Which has been moving into Java during the last decade, and currently is eyeing other stacks that could given them the benefits of Java alongside those features, like e.g. Pony.

So of course Oracle wants Java to stay relevant in those domains.

You are required to annotate type parameters for the old reference behavior, currently that would be with the any modifier.

Something like

    class Data<any T> {
    }
Re:Pointer Free Programming and the Future of Nim by catnaroek on Thursday October 19, 2017 @10:49PM (#15513236)
Retrofitting anything into anything always results in warts. Moral of the story: design things right, right from the beginning.
Re:Pointer Free Programming and the Future of Nim by tomsmeding on Friday October 20, 2017 @02:42AM (#15513924)
... which is practically impossible with larger projects that you can't oversee in a glance.
Re:Pointer Free Programming and the Future of Nim by catnaroek on Friday October 20, 2017 @08:50AM (#15515323)
So don't bite more than you can chew?
Re:Pointer Free Programming and the Future of Nim by lmm on Friday October 20, 2017 @05:27AM (#15514536)
That's a problem you already have in Java with any other type though. If you have a List or a String or whatever it could always be null.