Home  >  Article  >  Java  >  Say a word for Java

Say a word for Java

伊谢尔伦
伊谢尔伦Original
2016-12-03 09:15:381023browse

Some people asked me, what are the good recommendations among the existing languages? I said: "Java." They were surprised: "What? Java!" So I'll explain it now.

Java has surpassed all the "dynamic languages" that cursed it

Perhaps because of the rebellious psychology of young people, people don't take their introductory languages ​​seriously. Very early on, computer science students used Scheme or Pascal to get started. Now most schools use Java. This may be why many people hate Java and look down on people who use Java. When it comes to Java, it feels like something used by my grandfather’s generation. They say that Java is old-fashioned, large, complex, and bloated.

  Some Python programmers explain to beginners in forums what is good about Python. One of the reasons is: "Because Python is not Java!" They like to promote like this: "Look at how simple and clear Python is. You don't even need to write Type..." Their unreasonable hatred and blind denial of Java have caused them to fail to see the important advantages of Java, and have lost their way. Although it has the upper hand in terms of momentum, in fact, as a programming language, Python is completely unable to compete with Java.

 In terms of performance, Python is dozens of times slower than Java. Due to the lack of important facilities such as static typing, it is difficult to detect bugs in Python code and difficult to debug once detected. Therefore, Python cannot be used to construct large-scale and complex systems. You may find that the main code of some startup companies is written in Python, but the quality of the software of these companies is actually quite low. In mature companies, Python is only used at most to write tool-like things, or small scripts that will not affect system reliability.

 The lack of static types also makes it impossible for Python to have good IDE support, and you cannot refactor Python code completely reliably. PyCharm is a great improvement over the early Python programming environment. However, theory determines that it cannot completely reliably achieve basic refactor operations such as "variable name renaming".

In terms of design, Python and Ruby are actually much more complex than Java. Many important features are missing, and there are a lot more buggy "powerful features". Due to the blind admiration of the so-called "authentic object-oriented" approach, the so-called "late-binding", there are too many places in these languages ​​​​that can be "overloaded" with semantics, and everything can be redefined, which results in the code having a lot of complexity. Uncertainty and complexity. Python and Ruby code is easily misused, hard to understand, messy, and prone to problems.

Many JavaScript programmers also blindly despise Java, but in fact JavaScript is worse than Python and Ruby. Not only do they have all their shortcomings, but they also lack many necessary and convenient features, such as basic class definitions. Various "WEB frameworks" of JavaScript are emerging one after another, and they seem to be constantly introducing new ones, but in fact, they are all messing around in the dark. The JavaScript community is notoriously naive. You often find some very basic common sense being preached at conferences by JavaScript "experts" as if it were a great discovery. I don't see the point of holding those meetings in the JavaScript community, as they are just for building connections and finding jobs.

Java’s “successors” failed to surpass it

Recently, many people are keen on emerging languages ​​​​such as Scala, Clojure, Go, etc. They think that these are more modern and advanced languages ​​​​than Java, thinking that they will eventually replace Java. However, these enthusiasts gradually discovered that Scala, Clojure and Go did not actually solve the problems they claimed to solve, but brought their own problems. Many of these problems are not found in Java.

I have commented a lot about Go. Those who are interested can read here. In short, Go is the product of civilian science and arrogance, so I won’t say much about it here.

I know some people who initially admired Scala as if they were some savior. I suggest that they stop fussing and just use Java. He didn't listen to me, and ended up scolding Scala for all kinds of problems all day long. But there is no way, the project has been pirated, and we have to continue to use it. I don't like to make personal attacks, but I find that the quality of a language often depends on the level, character, and motivation of its designer. Many times, my intuition about people is so accurate that I can predict how the language will develop in the future based on my first impression of the language designer. Here, I would like to talk about my views on the designers of Scala and Clojure.

 Martin Odersky, the designer of Scala, has made great achievements in the field of programming languages ​​and published many seemingly advanced academic papers (in fact, many of them are nonsense). However, he is not particularly good at the "design" of the language. . So I was surprised to find that Scala got some very basic things wrong. Because Odersky is a university professor with a good reputation, many people want to get a PhD from him, so he talks about it and likes to add some unclear and potentially problematic "features" to Scala. The purpose is to publish papers and mix them up. graduate. This resulted in Scala being overly complex and adding many features that later proved to be of little use and instead caused problems. Students add code implementation to the Scala compiler and leave it alone after graduation, so piles of historical garbage and bugs are left in the Scala compiler.

 Let’s talk about Clojure. When Clojure first came out, some people enthusiastically recommended it to me. So I watched the video of a promotional lecture given by its designer, Rich Hickey. At that time, I had only a vague idea of ​​his chest-beating skills, and I was very impressed. Rich Hickey really became a monk halfway, without even a CS degree. But his momentum was as if other language designers didn't understand anything and he was the only one who saw the truth. But only such people can create "religion", right? The "features" that Clojure vigorously promotes (such as lazy, pure, transactional memory) are all copied from hearsay in other languages, but they fail to deeply understand their essence. Some features of "functional languages" are inherently problematic, but they were copied over indiscriminately for the sake of "doctrine correctness." So in the end, you find that this language is selling dog meat with sheep's head. It is said clearly and logically, but it is so lame when used.

 The Clojure community has been busy copying ideas from the Scheme and Racket communities, but they also want to claim it as their own invention. For example, Typed Clojure plagiarizes Typed Racket unchanged. Some of the same basic concepts have been in Scheme for decades, so we need to change them to different names, lest you find out that they were introduced in Scheme first. Some people have even rewritten all the codes in famous books such as SICP and The Little Schemer using Clojure. As a result, the simplicity and essence of the original works have been completely lost. In the end, you find that all the good things in Clojure are already available in Scheme, and almost all the new features in Clojure have problems. I have participated in some Clojure meetups, but later I discovered that there were all kinds of beginners shouting big slogans, all kinds of arrogant civil sciences, and they were extremely ignorant.

Many people who blindly admire Scala and Clojure eventually discovered that almost all the "new features" in these languages ​​have flaws. The most important and useful features among them are actually already in Java. Some people said to me: "Look, Java can't do this!" Later, after my analysis, I found that they had already rigidly determined subconsciously that they had to use some of the latest and coolest language features to achieve their goals. Java doesn't have these features, so they think Java can't do it and they have to use another language. In fact, if you look at the problem from a different angle, don't get too carried away, and focus on solving the problem instead of pursuing the latest and coolest "writing method", you can solve it with Java, and solve it neatly.

If you want to build a system now, you would really rather use Java than waste time on Scala or Clojure. The wrong people designed the wrong language and wasted everyone's time by using it.

 There is nothing particularly annoying about Java

 Java may lack some convenient features, but for a long time, Java has been used for teaching, working in Java, and developing PySonar, RubySonar, Yin language,... I found that Java is not actually like many It's so hateful as people say. I found that more than 95% of the functions I want can be used in Java in relatively straightforward ways. The remaining 5% can still solve the problem with a slightly dumber approach.

Many people hate Java, actually because the early GoF Design Patterns tried to come up with cookie-cutter templates, which brought unnecessary complexity to the program. However, the Java language itself is not actually equivalent to Design Patterns. The designers of Java and the designers of Design Pattern are completely different people. You can write very simple code in Java without using Design Patterns.

 Java has excellent IDE support

 I usually use IntelliJ to write Java code. I found that there are some very good design ideas in IntelliJ. Many of these functions actually surpass all text editors (Emacs, VIM...). IntelliJ makes Java even more powerful, and development feels like flying.

When using IntelliJ, you don’t need to worry about things like “naming variables”. Because IntelliJ has a very powerful and friendly refactor function, you can replace variable names very quickly. So when you first create a variable, you don't need to worry about coming up with a perfect name. Use a decent name, write the code quickly, and the experiment is successful. Then go back and look at the code and change the name to a more appropriate one.

 IntelliJ can also perform very fast structural transformations, which makes you feel like an artist constructing a sculpture. I can be bold at the beginning and chop the code into a rough shape, and then carefully refine it and knead it into a better, easier to understand, and more attractive shape.

 Conclusion

What tools you use for programming is important, but the tools are not as important as your own technology after all. Many people spend too much time tossing around with various new languages, hoping that they will miraculously improve code quality, and end up with nothing. The most important condition for choosing a language should be "easy enough to use", because the success of the project ultimately depends on people, not language.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn