Senior architect talks about Java - the most powerful programming language

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

Java surpasses all the "dynamic languages" that curse it

Perhaps because of the rebellious psychology of young people, people don't take their entry language seriously. In the early days, computer science students used Scheme or Pascal to get started, and 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 grandpa's generation. Everyone can use Java, how can I look outstanding? So they said, "Java is old, big, complex, bloated. I'd much rather explore new languages..."

Some Python programmers explain the benefits of Python to beginners in forums. One of the reasons is: "Because Python is not Java!" ..." The gratuitous hatred and blind denial of Java leads them to lose sight of its important virtues and to lose their way. Although the momentum prevails, 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 types, it is difficult to find bugs in Python code, and it is not easy to debug when found, so 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 software of these companies is actually quite low quality. In mature companies, Python is at best used to write tool-like things, or small scripts that don't affect the reliability of the system.

The lack of static typing also makes it impossible for Python to have good IDE support, you can't "jump to definition" completely reliably, and you can't completely reliably refactor Python code. PyCharm is a great improvement for the early Python programming environment. However, theory determines that it is impossible to perform basic refactoring operations such as "variable renaming" completely and reliably. Even PySonar, which is much more powerful than PyCharm, can't do anything about it. Due to the overly "dynamic" design of Python, there is no type tagging, making fully accurate definition lookups an undecidable problem.

In terms of design, Python and Ruby are actually much more complicated than Java. A lot of important features are missing, and there are a lot more "powerful features" that are faulty. Due to the blind advocacy of the so-called "authentic object-oriented" method and the so-called "late binding", there are too many places in these languages ​​that can "overload" semantics, and no matter what can be redefined, this leads to the code with great inconsistency. Certainty and complexity, many bugs are hidden in these overloaded language constructs. As a result, Python and Ruby code is easy to abuse, easy to understand, easy to mess up, and easy to go wrong.

Many JavaScript programmers also blindly despise Java, when in fact JavaScript is worse than Python and Ruby. Not only do they have almost all their shortcomings, but they also lack some necessary facilities. Various "WEB frameworks" of JavaScript are emerging in an endless stream, and it seems that they have been introducing new ones. The JavaScript community is known for being naive and ignorant. You often find some very basic common sense that the JavaScript "experts" treat like a great discovery, preaching at conferences. I don't see the point of the JavaScript community having those meetings, as if they were just trying to get a job.

Python makes do where it doesn't matter, Ruby is garbage, and JavaScript is garbage in garbage. The reason is very simple, because the designers of Ruby and JavaScript are actually half-understood civilian subjects. However, the world is so strange that a completely garbage language can still claim to be the "programmer's best friend" and thus be loved by some people...

Java's "heir" fails to surpass it

In recent times, many people are keen on emerging languages ​​like Scala, Clojure, Go, etc. They think these are more modern and advanced languages ​​than Java, thinking that they will eventually replace Java. However, these fanatics gradually discovered that Scala, Clojure and Go did not solve the problems they claimed to solve, but brought their own problems, many of which Java did not. Then they realized that Java was far from the end of its life...

Go language

About Go, I have commented a lot, and those who are interested can read it here. In short, Go is the product of Minke plus megalomaniac, and it's amazing. I won't say much about it here, just Scala and Clojure.

Scala

I know some people who started out with Scala as a savior. I advise them to stop messing around and stick to Java. I didn't listen to me, and as a result, I was scolding Scala's various faults all day long. But there is no way, the project is on the thief ship, and I 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 background, consciousness, character and motivation of its designer. Many times my intuition 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 the designers of Scala and Clojure.

Martin Odersky, the designer of Scala, has made some achievements in the field of PL, published many academic papers (including the famous "The Call-by-Need Lambda Calculus"), and is also a disciple of the famous Niklaus Wirth, so I think he also relatively reliable. But not long after I started working with Scala, I was surprised to find that some very basic things were designed wrong in Scala. That's why I've tried to adopt Scala several times, but never got around to it. Because while I was looking, I found eye-popping design mistakes that Java doesn't have. After doing this a few times, I lost faith in Odersky and lost interest in Scala.

Looking back at the nature of Odersky's papers, I see that while they seem theoretically strong, many of them are actually cryptic (including the so-called "call-by-need lambda calculus"). Although he has a certain depth on some specific issues, his knowledge is not very broad, and his vision is relatively one-sided. For the overall design of the language, the grasp is not good enough. It feels like he forcibly pieced together the characteristics of various languages, without considering whether they can coexist in "harmonious", and rarely consider "usability".

Since Odersky is a university professor and has a good reputation, many people want to get a PhD from him, so they talk about it and like to add some unclear and potentially problematic "features" to Scala. The purpose is to publish papers and graduate. . This leads to Scala indiscriminately adding too many features and being overly complicated. Many of the added features turned out to be of little use and instead created problems. Students add the code implementation to the Scala compiler, and they leave after graduation. Therefore, in the Scala compiler, a pile of historical garbage and bugs are left behind. This may not be Odersky's fault alone, but at least it shows that he is not strict, or that there is indeed a problem with his taste.

The most famous company adopting Scala is Twitter. In fact, a system like Twitter can still be written in Java. What happened to Twitter after that? The CEOs are gone :P The new CEO took office and laid off more than 300 people, including engineers. I suspect one of the reasons for Twitter's layoffs is that there are too many Scala programmers, with all sorts of grand and impractical slogans like "functional programming", overengineering, and wasting company resources. Spending the company's money, holding various conferences, organizing various meetups and hackathons, and improving their prestige in the open source field, did not create a lot of value for the company...

Clojure

Let's talk about Clojure again. When Clojure first "came out", some people enthusiastically recommended it to me. So I watched a promotional lecture video by its designer, Rich Hickey. At that time, I was very impressed with his half-knowing ability to pat his chest. Rich Hickey is really a half-way monk and doesn't even have a CS degree. But his aura, as if other language designers didn't understand anything, only he saw the truth. But only such people can create "religion", right?

A mouthful of popular terms, such as lazy, pure, and STM, claiming to be able to solve the problem of "large-scale concurrency"... This is very easy to get hooked. In fact, these words of his are all hearsay from other languages, but he has not been able to deeply understand their essence. Some of the features of "functional languages" are inherently problematic, but they are copied for the sake of being correct and to appear tall. So in the end you found out that this language is selling dog meat with a sheep's head, and it's as eloquent as dog skin plasters, how can it be so lame to use.

The Clojure community has been busy copying ideas from Scheme and Racket projects, yet trying to advertise their own inventions. For example, Typed Clojure is a copy of Typed Racket intact. Some of the same basic concepts have been in Scheme for decades, so it is necessary to change the name to a different name, lest you find out that it existed in Scheme first. Some people even rewrote the code in SICP, The Little Schemer and other famous works with Clojure, and the result completely lost the simplicity and clarity of the original work. Finally, you find that the good things in Clojure are all what Scheme already has, and the new features in Clojure are almost all problematic. I have participated in some Clojure meetups, but later found out that there are all kinds of idiots shouting big slogans, all kinds of arrogant folks, and they are ignorant.

If you want to make a system now, you really would rather use Java than waste time messing around with Scala or Clojure. The wrong people have designed the wrong language, and it's a waste of everyone's time.

There's nothing particularly annoying about Java

I still do not understand, many people's hatred and contempt for Java, come from. It may lack some convenient features, but for a long time teaching in Java, working in Java, developing PySonar, RubySonar, Yin language in Java, ... I found that Java is not as bad as many people say. I find that more than 95% of the functions I want can be used directly in Java. For the remaining 5%, the problem can be solved in a slightly stupid way.

Many people who blindly admire Scala and Clojure have found that almost all the "new features" in these languages ​​are faulty. The most important and useful features 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 subconsciously determined that they had to use some of the latest and coolest language features to achieve their goals. Java doesn't have these features, they think they have to use another language. In fact, if you look at the problem from a different angle, don't go to the horns, focus on solving the problem, instead of pursuing the latest and coolest "writing method", you can solve it in Java, and solve it neatly.

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

Java is just a language. The language only provides you with the basic mechanism. As for the complexity or simplicity of the code, it depends on the person. It would be unwise to transfer the hatred of some Java programmers who abused Design Patterns to the Java language itself, thereby completely abandoning it.

in conclusion

I usually use Java for fun, and I don't bother to comment on other languages. But I can't bear to see some people being fooled by Scala and Clojure, so I will say a few words here. If there is no super high performance and resource requirements (may use a low-level language such as C), for now I suggest to use Java honestly. Although not as cool as some new languages, there is really nothing that Java can't write in the actual system. A few places may need to bypass some restrictions, or relax some requirements, but such cases are not many.

What tools you use to program is important, but tools are not as important as your own skills. A lot of people spend too much time messing around with new languages ​​hoping they will miraculously improve code quality, only to end up with nothing. The most important condition for choosing a language should be "enough to use", because the success of a project ultimately depends on people, not languages. Since Java doesn't have a particularly big problem, it won't make you unable to do a good project, why try some unreliable new language?

Programmer's Advanced Approach

The above are my views on Java, but here, I also want to give you a learning method, so that you can not only gain something in theory, but also gain more in work practice. I recommend this method.

  • No matter you are facing the current popular technology and don’t know where to start, those who need to break through the technical bottleneck can learn.

  • It doesn't matter if you've been at the company for a long time and have a good life, but the interview hits the wall when you change jobs. Those who need to study in a short period of time and change jobs to get high salaries can learn.

  • No matter you have no work experience, but the foundation is very solid, you can learn the working mechanism of java, common design ideas, and common java development framework. (Don't learn Xiaobai, learn the basics first)

  • No matter if you think you are very good, the general needs can be handled. However, the knowledge points learned are not systematic, and it is difficult to continue to make breakthroughs in the technical field.

Here I recommend an exchange and learning group to everyone: 697579751 (adding a group can learn advanced programmer methods) It will share some videos recorded by senior architects: there are Spring, MyBatis, Netty source code analysis, high concurrency, high performance, The principles of distributed and microservice architecture, and JVM performance optimization have become a must-have knowledge system for architects. You can also receive free learning resources, which are currently benefiting a lot

Here's an advanced approach for programmers:

1. Source code analysis

The analysis of Mysql index and the analysis of the underlying data structure by the former senior R&D expert of Dianping

2. Distributed Architecture

The analysis of Mysql index and the analysis of the underlying data structure by the former senior R&D expert of Dianping

3. Microservices

The analysis of Mysql index and the analysis of the underlying data structure by the former senior R&D expert of Dianping

Fourth, performance optimization

The analysis of Mysql index and the analysis of the underlying data structure by the former senior R&D expert of Dianping

5. Teamwork

The analysis of Mysql index and the analysis of the underlying data structure by the former senior R&D expert of Dianping

Six: E-commerce practice

The analysis of Mysql index and the analysis of the underlying data structure by the former senior R&D expert of Dianping

Seven: Concurrent programming

The analysis of Mysql index and the analysis of the underlying data structure by the former senior R&D expert of Dianping

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325336912&siteId=291194637