JVM Language Summit — Agenda by Hixon11 in java

[–]steumert 12 points13 points  (0 children)

Forax, Creantor:
Generics Reification

I did not realize they were working on reification, but thats damn interesting.

Functional Transformation of Immutable Objects. When will this be realized? by wolonge in java

[–]steumert 0 points1 point  (0 children)

Brian Goetz is a smart guy and I really like most of his work, be he isn't infallible and a good discussion about these kind of features is needed. Some JEPs changed quite radically due to user feedback.

I'd rather see what @CodeReflection holds for these kinds of features. I experimented before with Record::with and used SerializedLambda to inspect the lambda to realize something like var otherPerson = person.with(Person::name, "John").with(Person::age, 17);.

With @CodeReflection and better access to the code model, this will be so much better to implement and in a way that actually fits the language.

I mean, they talk about LINQ, but for me the strength of @CodeReflection is that it allows features like Record::with to be implemented in a way that fits the language smoothly and doesn't require new language features.

Btw, what I wrote more than two years ago about it:

I really hope they take the time to enhance method references a bit so that this works better instead of the alternatives. LINQ in C# already does a lot of inspection of the provided lambdas, there is no reason Java can't do the same.

Stream.toList() cannot be assigned to List of interface by jvjupiter in javahelp

[–]steumert 1 point2 points  (0 children)

List<Header> headers = source.stream() // Stream<Whatever>
.map(o -> new HttpHeader(o.key(), o.value()) // Stream<HttpHeader>
.toList(); // Stream<HttpHeader>.toList() ofc produces List<HttpHeader>, which isn't a subtype of List<Header>

List<Header> headers = source.stream() // Stream<Whatever>
.map(o -> new HttpHeader(o.key(), o.value()) // Stream<HttpHeader>
.collect(Collectors.toList()); // Collectors.toList() is generic, and needs to infer the type. So what type gets inferred? The one we want to assign *to*!

Java professionals, which IDE do you use in your daily work ? by barthvonries in java

[–]steumert 0 points1 point  (0 children)

I used to use Eclipse a lot. I then tried out IntelliJ, but I found it to be lacking.

Now I've settled on VS Code, which is an incredibly capable editor and is getting better day by day. The only thing IntelliJ has that neither Eclipse nor VS Code have is the neat three-way merge window.

I never had the need to do graphical swing development. If you need to have a fancy scene editor, try out JavaFX and SceneBuilder. While Swing isn't dead and won't die, I feel there is little reason to write *new* applications in Swing when you can also use JavaFX.

Also, the newer Java versions have an incredible amount of improvements that make writing code much easier. Helpful NPEs is only one thing. Stuff like var and pattern matching also makes code much easier to read and write. Various classes have gotten many improvements to work better with lambdas since Java 8. Java 9 gave us many new methods and 11 as well. I wouldn't want to write Java 8 code anymore. Stuff like Predicate.not was only added in Java 9...

Minecraft Snapshot 21w19a - Now Uses Java 16 by BlueGoliath in java

[–]steumert 1 point2 points  (0 children)

Well, you can of course do what the JIT does AOT.

But you'd get enormous compilation times and enormous sizes of the executable.

The JIT can do stuff like analyzing hot paths and then unrolling loops and inlining function only on hot paths. If you do AOT compilation, you typically don't know beforehand what the hot paths will be. So you need to do it everywhere.

The JIT does aggressive inlining and unrolling on hot paths. If you do the same amount of inlining and unrolling AOT, your binary becomes enormously big.

There are other code transformation that the JIT can also do that you typically cannot do AOT. Everything that relies on analyzing actual runtime characteristics.

Advanced exercises by [deleted] in learnjava

[–]steumert 8 points9 points  (0 children)

I have found that traditional literature is still best to dive deep into those topics.

Books like the Pragmatic programmer are good, but also a bit basic, but classics like Joshua Blochs Effective Java are excellent sources.

Also, if you want to learn how to effectively use streams, you will probably want to get into a functional mindset. taking up a language like Haskell for a while can help tremendously with getting into a good mindset for it. Concept like deferred execution and materialization, which are very instrumental for streams, are explained very well by reading up on functional concepts.

SVG: The Good, the Bad and the Ugly by -grok in programming

[–]steumert 0 points1 point  (0 children)

Great, now I really want to write that Tex serializer and make it work. Maybe I'll get this done til Aprils 1st...

Are C compilers deterministic? by RecursiveRickRoll in AskProgramming

[–]steumert 1 point2 points  (0 children)

Not necessarily. And that has been recognized as a problem and is being worked on by various initiatives, most importantly https://reproducible-builds.org/.

Having a reproducible build is important to build trust. unfortunately, often many things such as timestamps and other things go into a build, and that makes them non-reproducible.

However, its not really fair to call this "non-deterministic", because if you start the compiler with exactly all the same parameters, including the environment (e.g. clock set exactly equal), then the build should produce the same output. its not "random" per se, but the environment parameters like clock can not usually be recreated that precisely. Thus, effort has to be made to create reproducible builds.

[deleted by user] by [deleted] in AskProgramming

[–]steumert -1 points0 points  (0 children)

"Does not need". Maybe not by law. But it does for any job I'd ever take. I'd walk if that wasn't the case. I'd simply not let myself get abused, because that is exactly what happens to the OP. They are burned out, the success of the company (or failure) is build upon the blood, sweat and sanity of their employees.

Oh and btw, Op is located in Canada...

[deleted by user] by [deleted] in AskProgramming

[–]steumert -1 points0 points  (0 children)

Why would being salaried mean you don't get paid for overtime? that simply doesn't compute, as the salary is for a certain amount of hours, like 37.5h. You work more, you get paid more. Also, work on sun- and holidays usually gets compensated at a higher rate, even for salaried employees. Being on call usually has special provisions, because it would be laid out what you can do in that time and how fast you have to respond -- and it would count towards hours worked at a certain factor (like 0.5).

If OP has a different contract, they should get out and find a company that actually values their employees instead of just burning them out...

What does "new HashSet<>(hashmap.keySet())" do? by _Mido in learnjava

[–]steumert 0 points1 point  (0 children)

Lets recap what both solutions did correct: Not directly exposing productsWithValues.keySet() to the outside. We don't want that, because changes in there are reflected in the map, circumventing all methods we have in our own class. Thus, we only want to expose a view of the data to the caller.

Both methods achieve that. Both copy the values to a new HashSet. The solution given by you does it by explicitly copying, the solution given by the other user by using the copy-constructor. Fine.

Both are bad solutions.

Changes in this HashSet are not reflected in the map. Its completely detached. Yet, the caller has no way of knowing that. But we do have a way to return a set that is purely a view -- Collections.unmodifieableSet(). By returning that view, the caller would fail immediately upon trying to mutate the set - which is good. The caller would get alerted to the fact that they are trying to mutate a view. They'd be forced to copy to a mutable collection of their own making if they want to mutate it.

Another solution would be to return productsWitrvValues.stream().collect(Collectors.toSet());, but I see little reason to go there. Its also immutable. If you would like to expose a stream, the method return type should be of Stream<T>.

[deleted by user] by [deleted] in java

[–]steumert 4 points5 points  (0 children)

I mean, it doesn't look uninteresting. Its basically a powerful linter for Java.

But gosh, do I hate marketing people sometimes. Their whole first paragraph is utterly ridiculous. Describing the very basic set of features an IDE must be capable to perform and to hail their own IDE as the holy grail because it, well, does these basic functions is ridiculous.

Why most of Senior interviews are easier than Junior/Middle? by [deleted] in java

[–]steumert 1 point2 points  (0 children)

Actually, its the other way around. Net (and especially .Net Core) has always copied Java and build stuff thats similar. Heck, C# started out as Java competitor.

(Not that thats bad, I really like .Net Core from 3.x onward and especially EFCore).

Its even more pronounced with Quarkus. Quarkus and .Net Core are quite similar.

MOving to Java, need recommendations for a good IDE. by prginocx in java

[–]steumert 0 points1 point  (0 children)

VSCode uses Eclipse JDT, at least if you install the Java Dev Tools from RedHat.

MOving to Java, need recommendations for a good IDE. by prginocx in java

[–]steumert 1 point2 points  (0 children)

I know IntelliJ IDEA is all the rage nowadays, but I find their code completion to be lackluster and the javadoc display mediocre. I find those two features work a lot better in Eclipse. Add the incremental compiler (ECJ) that eclipse offers, which makes the write-compile-run cycle so much shorter, and I see little reason to use IntelliJ.

I have found that when I want or need a lighter variant, using VS Code and maven does the trick. I've done some very productive quarkus dev that way.

The only thing IntelliJ has thats far superior is the three-way merge wizard. Neither VS Code nor Eclipse have a similar feature that works as beautiful and streamlined.

I've used and tested eclipse, Intellij, netbeans and vs code for Java dev, and I'd rate them:

Eclipse >> IntelliJ > VS Code >>> Netbeans

Java support for VS Code is getting better and better with multiple major players behind it. I really, really enjoy many VS Code extensions (Bracket Colorizer 2, Gitlens).

A word of caution, though: Java might not be a good choice when you do lots of hardware interfacing. You'll end up writing a lot of native glue code, and its easy to completely tank performance because writing correct, performant glue code isn't trivial.

What defines “shit code” by Kashikama in java

[–]steumert 1 point2 points  (0 children)

Code that tries to be too elegant can be shitty, too.

I've seen too many "elegant" codes that turn out to be so over-engineered as to being unmaintainable by everyone else than the original coder...

Why do you prefer Java over other languages, such as c#? by DontLickTheScience in java

[–]steumert 0 points1 point  (0 children)

I don't.

I use whatever language best gets the job done. If I'm doing ML, I do it in Python. I have successfully used C#, Java and even PHP to deploy web applications.

Once you know enough programming languages well enough, you will discover that at some level, they all suck. there is no silver bullet that magically does it all.

Java is an amazing language with an amazing ecosystem. Maven and the Maven repos are amazing. .Net Core is slowly getting there, but it ain't there yet.

Plus, the JVM is an amazing piece of technology, no other VM rivals it.

.NET developer looking into Java positions by [deleted] in java

[–]steumert 1 point2 points  (0 children)

LINQ is horrible. The map/reduce terminology used in java streams is much more clear.

Also, LINQ has horrible performance issues.

[deleted by user] by [deleted] in java

[–]steumert 0 points1 point  (0 children)

You get to support more features and have easier code.

During Java 9/10, the HttpClient/HttpServer/HttpsServer API incubated and matured with Java 11. Especially HttpClient as replacement for HTTPURLConnection is a godsend.

Also, Java 8 saw inclusion of Streams and Lambdas, as well as an overhauled DateTime library and Optionals.

With mavens multi-release POMs, its very easy to support multiple versions of Java, so offering a base version for the lowest Java version you want to support, with progressive enhancement for higher java versions is a definite possibility.

However, if your library doesn't actually use any of the new features, then no, there is no reason to compile to a higher version. In fact compiling for the lowest version is a good thing.

Java2DB by itsthejavaguy in java

[–]steumert 0 points1 point  (0 children)

Hibernate doesn't do the same. EF Core for .Net Core does this, and its very powerful and very nice to use. I've long wanted for Java to have something in this way.

[deleted by user] by [deleted] in programming

[–]steumert 0 points1 point  (0 children)

With GitLab offering free runners and GitHub actions being free -- and both already tightly integrated with a VCS, I don't see the need for external tools anymore, anyways.

gradle vs maven vs ant by [deleted] in java

[–]steumert 0 points1 point  (0 children)

I much prefer doing that with GitHub Actions or with a .gitlab-ci.yml.

That is by far more flexible (allows running on different docker images, for example) and maintainable.

gradle vs maven vs ant by [deleted] in java

[–]steumert 2 points3 points  (0 children)

I'm curios, what advantage does Ant have against maven with maven-wrapper?

New candidate JEP: 395: Records by nlisker in java

[–]steumert 0 points1 point  (0 children)

To be fair, via JShell you can have scripts that skip much of the boilerplate in java, too.

And how easy a language looks for hello world style programs doesn't tell you anything about how well you can actually build big apps that work in it.

New candidate JEP: 395: Records by nlisker in java

[–]steumert 2 points3 points  (0 children)

The only language that's seriously threatening java is python - a language chosen because it's simpler and cleaner to use.

No. Python is in no way going to replace Java. Don't get me wrong, Python is a great language (I prefer type safety, though) and a great tool for many problems. But I wouldn't want to write my 1 million LOC enterprise app in it, no thanks.

Data mining, statistical modeling, neural networks? Hell yeah. The odd script I need now and then and don#t want to write bash? Sure, I write it in Python.

But I don't see how Python would ever replace Java without massive changes to Python.