Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What's bothering you in Java programming?
What's bothering you in Java programming?
Aha Reddit (a well-known online Q&A community abroad), without you, where can you extract the real essence from the fishy network? In this chaotic forum, there are really some incisive discussions.

For example, a brother named Shambloroni initiated a topic that caused widespread condemnation (received 150 reply and voted). At the beginning of the topic, he talked about several aspects of Java that bored him most, and collected some painful (sad) stories of other programs writing Java.

Below I have listed some of the most interesting answers-do you agree?

The sadness of Try-catch statement

Although I just started writing Java programs, I was shocked by the complexity of stopping the program for a while and then continuing to run in Java. In addition to writing down the basic instructions to complete the pause, I must also use try-catch to wrap these operations. Maybe it's nothing to Daniel, but it's too sad for me.

There are also exceptions related to all IO, which complicate many simple things. For example, I just want to do one thing succinctly, but I always screw it up in the end. Then I had to add "throwsException" to all the methods.

No, no, still no.

No unsigned shaping.

There is no operator overload.

There are no object properties.

There is no proxy (although I heard that a proxy or similar mechanism may be introduced in Java8, I didn't read it carefully).

I also hate the way many Java libraries introduce modules (such as loading modules by name). Relatively speaking, I prefer to check whether the dependency library I need has been loaded at compile time.

Can't find love?

I hate Java, just plain hate it. To be responsible, the biggest reason why I never write programs in Java is because I hate it. Another point is the poor modularity of JRE. Even if you use some loading tools, such as Launch4j, you still need to let users install a framework of more than 200MB to run the program.

There is no getter or setter.

Java also lacks getter and setter comments. This makes it easier to add and delete template code.

Lack of bright spots

Java is missing some killer modules. Although I heard that Java9.x will add some good modules, this is my biggest slot so far.

Non-violent cooperation

The biggest trouble I have encountered is how to use basic elements and objects together. For example, it is not difficult to convert a variable of type char[] into a list. I think this operation is completely unnecessary.

Wish list

What I want most is context-sensitive functions like those in Perl, and the role these functions can play in the language when dealing with real exceptions.

I also hope that Java can support intelligent packaging of return values, so that we can return a list containing multiple values like Perl.

Standard libraries that want to use exceptions can also be used in scenarios that are not suitable for throwing exceptions and can handle failures.

Also, another annoying thing is that I have to handle IO exceptions when using StringWriter.

What else is missing?

The lack of macros makes Java a lot worse for me (I'm not talking about preprocessing macros used in C/C++, but macros used in Lisp/Scheme).

No matter what you do, you need to define a class, although you may not need a class at all. For example, I want to extract a frequently used code and use it where necessary-in order to achieve this goal, I must encapsulate this code in a finalstatic method and put it in a class. So I will try to give the class an easy-to-understand name, which could have been very simple (this is really simple, especially when you can define macros).

Are you kidding?

Lack of support for generics. Templates in C++ are much stronger.

In fact, in Java, you can't instantiate a class in a generic at all unless you declare a generic with this class as a parameter.

It's hard to add a constructor to a class and let it destroy it. RAII (a resource management model, see C++) has always been very useful.

There is no operator overload. C++ allows the = = operator to compare strings. Similarly, for the same reason, large integer operations become difficult to use.

All right.

There is no unsigned base type. What the fuck is this?

Or getter, setter

1, empty (maximum slot point).

2. No getter and setter comments (for example, no attributes).

3.Java only supports location parameters. I like Python3 to support multiple parameter forms, such as Smalltalk, or to force keyword parameters.

For example, if you call a function with two parameters in Samlltalk, you can do this:

myInstancemyMethodWithFoo:arg 1 bar:arg 2

In Python, you can use the following syntax to call functions and assign values to function parameters:

my _ inst . my _ method(foo = arg 1,bar=arg2)

4. Multiple assignments are not supported?

These are my initial thoughts, but I think there should be more. Seriously, using callback functions has always been a big problem because it is too troublesome. However, I am glad that this problem has been solved in Java8 =)

Stupid default value

Default visibility. If you don't give a modifier to a variable or method, then the method should be private and invisible in the package.

Default modification ability. The final type (in all cases) should be the default type, with "var" as the modifier. At present, programmers rarely set the parameters of methods to the final type, because that will make variables unreadable quickly. At the same time, parameters are rarely rewritten in methods.

Assembly interface. Java should provide a writable collection interface, and now the collection inherits this writable interface, only shielding all methods that change the contents of the collection. This will reduce the confusing historical methods you will see in collections. un modified () and some third-party APIs. With a writable collection interface, Java will become more type-safe.

Lack of expressive ability. After using Scala (or the latest PL), you will find that Java is very cumbersome. This is the most common statement about Java, but it is true.

Talk about anomalies

Forced to handle exceptions.-God bless you. Who can tell me why we wrap each Thread.sleep () with try-catch? I have never really seen the interrupt exception I was asked to handle.

I know what I'm going to say may not be a widely recognized problem, but I really agree that checkedexception is annoying. These exceptions make the code unrecognizable and refactoring impossible. I understand why they exist (which makes sense in theory), but they have not brought any substantial benefits to developers. Whatever you do, don't leave an empty catch block, even if you think this exception will never happen. You can repackage this checkedexception with runtime exception and throw it.