Table of Contents
Put aside the application Talking about performance in scenarios is just a joke
Home Backend Development Golang Go's performance is not as good as Java's?

Go's performance is not as good as Java's?

Jul 24, 2023 pm 02:45 PM
java go

I saw a question on Zhihu today about the performance comparison between <span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">Go</span> and <span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;font-size: 14px;">Java</span>. This kind of question There is usually only one ending, and that is endless debate. Ten years from now, if these two languages ​​​​are still alive, this may still be a hot issue:

Go's performance is not as good as Java's?

Put aside the application Talking about performance in scenarios is just a joke

At present, I mainly use Java and Go, and the direction is big data. First, let me talk about my views:

  • Most languages ​​have areas in which they are good at, and their existence is reasonable:

    • <span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;font-size: 15px;">PHP</span> Good at Building low-cost WEB is also the best language in the world

    • <span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;font-size: 15px;">c</span> Good at operating systems and embedded

    • <span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;font-size: 15px;">Go</span> Naturally high concurrency attribute

    • ##R<span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;font-size: 15px;"></span>’s scientific calculations and statistics are unparalleled

    • <span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;font-size: 15px;">Python</span> is the leader in the field of AI

    • <span style="box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;font-size: 15px;"> Java</span> Industrial-grade application services and Android (the old gangster who has long dominated the TIOBE list)

  • ##Benchmarks<span style="color: rgb(74, 74, 74);box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;"></span> The test data can certainly explain some problems, but this test environment and method are still not grounded enough. It is rare to encounter similar cases, and it will not be mentioned in actual use. Because of the gap of a few milliseconds, I changed the language and refactored the project.

  • ## Hot Code<span style="color: rgb(74, 74, 74);font-size: 16px;box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;"> This concept is very important. Some code snippets will hit once a month, then it will not How much extreme optimization is needed. </span>

  • 28<span style="color: rgb(74, 74, 74);font-size: 16px;box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;"> Rule, spend 80% of your energy on the important 20% of the code, people My energy is limited, and there are still many beautiful things in the world, such as writing original articles to share with everyone (manual wink). </span>

  • ##Talkischeap.Showme the code. Based on my experience, the current programming level of most people , it’s not my turn to talk about the performance of the language itself. If you are not, then please add me on WeChat and let me fly. <span style="color: rgb(74, 74, 74);font-size: 16px;box-sizing: border-box;background-image: initial;background-position: initial;background-size: initial;background-repeat: initial;background-attachment: initial;background-origin: initial;background-clip: initial;display: inline-block;padding-right: 2px;padding-left: 2px;line-height: 22px;"></span>

    Summary of advantages and disadvantages
I think the content replied by a friend is very objective and typical. It was caught on Zhihu and deleted.

The current problem with JAVA is not performance, because the code automatically optimized by JIT is already comparable to C.

The problem with JAVA is that in real actual projects, there are too many third-party dependencies, a bloated architecture, and over-design. At this time, it is hard to say who will win.

I personally think that because go basically only needs the standard library, the performance in actual projects is better than JAVA (Go’s coroutine is essentially an asynchronous IO model, Go language: everything is asynchronous ), in addition, resource usage is also a part of performance. Obviously go has smaller memory usage and relatively low CPU consumption.

Go on the benchmark game runs faster than Java in most scenarios, and the memory consumption is 1/3 of Java;

Let’s list the shortcomings of Go:

  1. It’s a bit anti-programmer syntax

  2. No generics

  3. The data structures in the standard library are far less rich than Java

  4. Dependency management is useless

  5. If channel is used improperly, it is very easy to deadlock

  6. Loop import is not allowed during compilation

  7. Many package names will conflict with custom variable names during coding

  8. There are many libraries that we take for granted in Java, but we find that we have to reinvent the wheel in Go

  9. The go get command will clone the entire git Warehouse, including historical commit

  10. The standard library does not provide a routine pool

  11. There is no ready-made one Future mechanism, you have to implement it yourself through channel

Those are the things that come to mind for the time being; of course all of these can be solved

Disadvantages of Java:

  1. Lack of language expression skills (a down-to-earth term is "stinky and long")

  2. High memory and CPU consumption

  3. When the heap memory is large, the garbage collector needs in-depth tuning to obtain satisfactory recycling effects; however, in some cases In scenarios with high real-time requirements, gc may simply have no solution. Once full gc is triggered, it will be hell

  4. The program needs to be warmed up

  5. The JDK is huge, and the springboot jar package is huge (the problem is most prominent under the microservice architecture)

  6. ##Spring FamilyBucket is getting heavier and heavier (for Spring, it is enough for you to do IoC AOP), resulting in poor performance of applications using FamilyBucket (please refer to the position of spring in TechEmpower Round 14), but it is still sufficient

  7. Because there are too many mature frameworks and libraries, many people are biased when they get started, thinking that programming is just adjusting APIs and using frameworks, but they know little about the principles

Those are the things that come to mind for the time being; of course, the advantages of Java far outweigh these shortcomings, otherwise it would not be ranked first in the TIOBE programming language rankings all year round

The above is the detailed content of Go's performance is not as good as Java's?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Perfect Number in Java Perfect Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Perfect Number in Java. Here we discuss the Definition, How to check Perfect number in Java?, examples with code implementation.

Weka in Java Weka in Java Aug 30, 2024 pm 04:28 PM

Guide to Weka in Java. Here we discuss the Introduction, how to use weka java, the type of platform, and advantages with examples.

Smith Number in Java Smith Number in Java Aug 30, 2024 pm 04:28 PM

Guide to Smith Number in Java. Here we discuss the Definition, How to check smith number in Java? example with code implementation.

Java Spring Interview Questions Java Spring Interview Questions Aug 30, 2024 pm 04:29 PM

In this article, we have kept the most asked Java Spring Interview Questions with their detailed answers. So that you can crack the interview.

Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

TimeStamp to Date in Java TimeStamp to Date in Java Aug 30, 2024 pm 04:28 PM

Guide to TimeStamp to Date in Java. Here we also discuss the introduction and how to convert timestamp to date in java along with examples.

Java Program to Find the Volume of Capsule Java Program to Find the Volume of Capsule Feb 07, 2025 am 11:37 AM

Capsules are three-dimensional geometric figures, composed of a cylinder and a hemisphere at both ends. The volume of the capsule can be calculated by adding the volume of the cylinder and the volume of the hemisphere at both ends. This tutorial will discuss how to calculate the volume of a given capsule in Java using different methods. Capsule volume formula The formula for capsule volume is as follows: Capsule volume = Cylindrical volume Volume Two hemisphere volume in, r: The radius of the hemisphere. h: The height of the cylinder (excluding the hemisphere). Example 1 enter Radius = 5 units Height = 10 units Output Volume = 1570.8 cubic units explain Calculate volume using formula: Volume = π × r2 × h (4

Create the Future: Java Programming for Absolute Beginners Create the Future: Java Programming for Absolute Beginners Oct 13, 2024 pm 01:32 PM

Java is a popular programming language that can be learned by both beginners and experienced developers. This tutorial starts with basic concepts and progresses through advanced topics. After installing the Java Development Kit, you can practice programming by creating a simple "Hello, World!" program. After you understand the code, use the command prompt to compile and run the program, and "Hello, World!" will be output on the console. Learning Java starts your programming journey, and as your mastery deepens, you can create more complex applications.

See all articles