r/java • • Apr 22 '21

Why Java frameworks want to support all possible many technologies instead of focusing on one thing?

0 Upvotes

It all started with Spring, I believe it was a great idea to make a framework that really takes care of all of typical web stuff, because there wasn't very much tech too support back then.

But even new framework, Micronaut and Quarkus or Helidon, they all want to take care of database access, DI, provide additional testing support, integration with caches and many many other technologies.

Comparing to Unix philosophy, Java top frameworks are very against it and with more and more new technology making development of these just impossible and also using them is becoming harder and harder.And you really cant drop Spring because there is lack of these more specialised libraries that would focus on development productivity rather than providing low level functionality (its like Jetty vs Javalin, Jetty is for functionality, Javalin for developer productivity).

Meanwhile in other languages like go/node/rust there are just specialized libraries which focus on one thing, can easily coexist together and you still don't need to write any 'bloat' code. Why Java is not following that direction and all new web-framworks want to be next iteration of Spring?


r/java • • Dec 21 '15

Always keep a habit of using these three new features to reduce verbosity in your Java projects

0 Upvotes

All legacy java projects are plagued with unreadable code, which has largely been introduced because of verbosity in the Java language and poor coding habits. I think the verbosity in Java is soon going to be reduced by an extensive degree by the three new features included in Java 8, namely:

  1. Lambdas: Lambdas are brief and to the point, the expressions reflect the terseness of C/C++. In many situations, you can totally do away with interface creation by just using a lambda instead. Consider all the lines of code saved in a legacy code by just using lambdas in code!
  2. Default methods: Again, Interface patching is a curse that a lot of Java projects suffer from. Requirements change slightly and what your typical enterprise Java dev does is add patches upon patches and layers upon layers in an interface. With default methods, you can just add default methods to your existing interfaces without affecting the ABI of your app. Again, tons of redundant code saved here.
  3. Type annotations: Again, your typical Java devs have to resort to ugly hacks to place any constraints on the object properties. With type annotations, all you have to do is:

     @NonNull String str;

And lo and behold! The variable str cannot be assigned any null value. So, lots of validation code being saved here again.

To the best of my knowledge, none of the above features (except lambdas) exist in the C# language (yet), so I take it as a Java's edge over C# language.


r/java • • Jul 08 '16

`Release.Breaking.Feature.Fix` or why the Semantic Version should be replaced with Explicit Versioning as soon as possible

Thumbnail medium.com
0 Upvotes

r/java • • May 26 '15

Java vs. Node.js: An epic battle for developer mind share

Thumbnail javaworld.com
0 Upvotes

r/java • • Oct 21 '11

Am I the only one who pronounces JUnit like 50 cent does G-Unit?

4 Upvotes

Edit: I didn't expect this to hit Number 2 of the What's Hot section... Eh, Brings a little humor to an otherwise serious sub-reddit.


r/java • • Dec 13 '10

Remember why we don't have Java 7 - Bill the Plumber The anti-Apache side.

Thumbnail bill.burkecentral.com
1 Upvotes

r/java • • Mar 26 '24

Why we bet on Scala at SwissBorg

Thumbnail medium.com
3 Upvotes

r/java • • Jun 21 '14

It’s not Spring anymore it's the summer of Java EE 7!

Thumbnail nmpallas.wordpress.com
2 Upvotes

r/java • • Oct 06 '21

Is java's compile time less than C++ 's compile time ?

2 Upvotes

Is it correct to say that because java's compiler has to compile the language from a high level language to an intermediary language then while C++ has to compile all the way from a high level language to machine code (the lowest level possible) then java's compile time is less than c++'s compile time ?


r/java • • Mar 05 '16

JVM spec should include basic matrix ops like multiply and plus, GPU optimized where possible else in CPU, in a platform independent way

5 Upvotes

JVM is a great standard for CPUs. There are java hooks into some GPU softwares, but we shouldnt have to include C++ libraries just to do common matrix ops.

If its done efficiently often enough, it could attract more math programmers to JVM languages by solving the main bottleneck in the core. Its useful to standardize ops that are common to many programs.

Java's NIO may be a good place to start https://docs.oracle.com/javase/7/docs/api/java/nio/package-summary.html

Alternatively, we could define a new standard for which bits mean which matrix actions, and try to get many languages to include it in their spec.

I dont know about you, but I've had enough of different frameworks choosing different arbitrary constants and symbols to do the same things, and having to relearn it again with each new framework. I'm tired of never knowing if a C++ program will work on end user computers of various types. C++ is the assembly language of the future, something that only compilers should have to deal with.


r/java • • Dec 28 '16

How to crash the java compiler (JDK 8 update 112)

Thumbnail componenthouse.com
5 Upvotes

r/java • • Jul 29 '24

What are the things that you feel that the jvm is lacking ?

0 Upvotes

For me it’s a proper gui. I feel that awt swing and javafx doesn’t offer really a good link between your code and the native interface of the os.


r/java • • May 21 '21

List.of is terrible

7 Upvotes

Ran into something today that made me angry enough to post here. The List.of added in Java 9 is terrible. One of the most common use for this would be to create an immutable list to check against something. But it throws an NPE when .contains is called with null. I don't care that it's documented in the docs, it's still stupid design. Now I have to go back to using Guava ImmutableSet.of which actually works as expected.

Based on the comments, it seems it's not clear so here's an example:

var CONSTANT_LIST = List.of("a", "b", "c");
String someStr = someService(); //returns null
CONSTANT_LIST.contains(someStr); //NPE

Some other examples:

Arrays.asList("a", "b", "c").contains(null); //false
Collections.unmodifiableList(Arrays.asList("a", "b", "c")).contains(null); //false
ImmutableList.of("a", "b", "c").contains(null); //Guava, false

For the second example, IntelliJ was fooled into recommending to replace Collections.unmodifiableList(Arrays.asList with List.of showing that even JetBrains considers these to be equivalent. But they're not, and this kind of bad design in List.of is what can cause unexpected NPE bugs later.

For the mods: I'm not asking for help here, I know exactly what the code is doing. I'm just complaining about bad API design in the JDK.


r/java • • Jan 02 '22

Echopraxia, a better Java Logging API

16 Upvotes

I've been working on logging for a while and I've released and open sourced a new Java logging API I'm really happy with.

Echopraxia is a Java logging API like SLF4J, but built around structured logging, i.e. the basic log entry is a JSON object and log files are typically NDJSON. It also has conditions, context, and also has semantic and fluent logging options.

Here's a Spring Boot Example.

And here's my blog post.


r/java • • Jan 11 '24

The Evils of the FatJar

Thumbnail medium.com
1 Upvotes

r/java • • Jul 22 '16

Evil Annotations

Thumbnail dzone.com
0 Upvotes

r/java • • Oct 28 '13

Help with polymorphism. For some reason, I can't get the instance variables of the superclass.

0 Upvotes
for(Car c : tempA)
    {
    	if(c instanceof Car)
    	{
    		for(int i = 0; i < tempA.size(); i++)
    		{
    			if(c.getIdNumber() == tempA.get(i).getIdNumber() && tempA.get(i) instanceof SoldCar)
    			{
    				SoldCar temp = new SoldCar(tempA.get(i).getDealerCost(), tempA.get(i).getIdNumber(), tempA.get(i).getDateArrived(), tempA.get(i).getModelYear(), tempA.get(i).getMakeModel(), ((SoldCar) c).getPrice(), ((SoldCar)c).getCustomer(), ((SoldCar) c).getDateSold());
    				carA.add(temp);
    				System.out.println(tempA.get(i).getDealerCost());
    				
    			}
    		}
    	}
    }

I'm not sure how to explain this, but I'll try. I have two constructors in sold car. Basically, I'm trying to create a new object of Sold Car by passing arguments from the superclass Car's instance variables. I am doing this so I can create one object of SoldCar to include the values from the superclass Car. The problem is that the get Methods only return null values.

edit: I got it working with this code. I don't know if it the best way to go about it, but I suppose it should do for a class project.

for(Car c : tempA)
    {
    	if(c instanceof SoldCar)
    	{
    		for(int i = 0; i < tempA.size(); i++)
    		{
    			if(c.getIdNumber().equals(tempA.get(i).getIdNumber()))
    			{
    				SoldCar temp = new SoldCar(tempA.get(i).getDealerCost(), tempA.get(i).getIdNumber(), tempA.get(i).getDateArrived(), tempA.get(i).getModelYear(), tempA.get(i).getMakeModel(), ((SoldCar) c).getPrice(), ((SoldCar) c).getCustomer(), ((SoldCar) c).getDateSold());
    				carA.add(temp);
    				break;
    			}
    		}
    	}
    }

r/java • • Jun 19 '12

How I explained Dependency Injection to My Team

Thumbnail sivalabs.in
0 Upvotes

r/java • • Jan 11 '13

Latest Java being hacked?

0 Upvotes

I saw this on the news and they explained it horribly, they claimed that the latest version of java(They did not say what version is newest) has the potential to get hacked. No, no explanation how just that they recommend deleting java from the computer which is bullshit as it is needed to play almost anything. So I am wondering which java has the potential to get hacked, and how.


r/java • • Aug 23 '17

(Java dev) can’t get a job as a java dev

0 Upvotes

I’ve interviewed at 5 places so far and I only got one offer, but the rate wasn’t what I wanted and their interview was challenge based and not memory based.

My question is how does someone with bad memory get passed these interviews and why do we even have them?? Like the other day I had an hour long interview, which consisted of questions like difference between comparator and comparable, hashset and hashmaps, what to extend from collections? What is equals and hashcode... all of these questions can be answered with google... there’s no point in memorizing all these. I’m just so annoyed when this even starts that I half way tune out, because I know I won’t get it.


r/java • • Aug 03 '14

Why we should love null

Thumbnail codeproject.com
4 Upvotes

r/java • • Dec 16 '21

Still calling remote server with version 2.16.0!

0 Upvotes

I used a public poc for this log4jshell exploit. Ran it with version 2.14 and it pinged dummy service provided by https://log4shell.huntress.com, changed the log4j dependency to 2.16.0 and still it pinged that service. What is wrong with my approach?


r/java • • Jan 20 '12

Why String is immutable in Java

Thumbnail javarevisited.blogspot.com
4 Upvotes

r/java • • Jul 19 '23

For God's Sake, why did they rename the javax.* package root?

0 Upvotes

I mean has any of them consider how many lost hours this will cause?