search
HomeBackend DevelopmentGolangGo's performance is not as good as Java's?

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
This article is reproduced at:Go语言进阶学习. If there is any infringement, please contact admin@php.cn delete
Golang vs. C  : Code Examples and Performance AnalysisGolang vs. C : Code Examples and Performance AnalysisApr 15, 2025 am 12:03 AM

Golang is suitable for rapid development and concurrent programming, while C is more suitable for projects that require extreme performance and underlying control. 1) Golang's concurrency model simplifies concurrency programming through goroutine and channel. 2) C's template programming provides generic code and performance optimization. 3) Golang's garbage collection is convenient but may affect performance. C's memory management is complex but the control is fine.

Golang's Impact: Speed, Efficiency, and SimplicityGolang's Impact: Speed, Efficiency, and SimplicityApr 14, 2025 am 12:11 AM

Goimpactsdevelopmentpositivelythroughspeed,efficiency,andsimplicity.1)Speed:Gocompilesquicklyandrunsefficiently,idealforlargeprojects.2)Efficiency:Itscomprehensivestandardlibraryreducesexternaldependencies,enhancingdevelopmentefficiency.3)Simplicity:

C   and Golang: When Performance is CrucialC and Golang: When Performance is CrucialApr 13, 2025 am 12:11 AM

C is more suitable for scenarios where direct control of hardware resources and high performance optimization is required, while Golang is more suitable for scenarios where rapid development and high concurrency processing are required. 1.C's advantage lies in its close to hardware characteristics and high optimization capabilities, which are suitable for high-performance needs such as game development. 2.Golang's advantage lies in its concise syntax and natural concurrency support, which is suitable for high concurrency service development.

Golang in Action: Real-World Examples and ApplicationsGolang in Action: Real-World Examples and ApplicationsApr 12, 2025 am 12:11 AM

Golang excels in practical applications and is known for its simplicity, efficiency and concurrency. 1) Concurrent programming is implemented through Goroutines and Channels, 2) Flexible code is written using interfaces and polymorphisms, 3) Simplify network programming with net/http packages, 4) Build efficient concurrent crawlers, 5) Debugging and optimizing through tools and best practices.

Golang: The Go Programming Language ExplainedGolang: The Go Programming Language ExplainedApr 10, 2025 am 11:18 AM

The core features of Go include garbage collection, static linking and concurrency support. 1. The concurrency model of Go language realizes efficient concurrent programming through goroutine and channel. 2. Interfaces and polymorphisms are implemented through interface methods, so that different types can be processed in a unified manner. 3. The basic usage demonstrates the efficiency of function definition and call. 4. In advanced usage, slices provide powerful functions of dynamic resizing. 5. Common errors such as race conditions can be detected and resolved through getest-race. 6. Performance optimization Reuse objects through sync.Pool to reduce garbage collection pressure.

Golang's Purpose: Building Efficient and Scalable SystemsGolang's Purpose: Building Efficient and Scalable SystemsApr 09, 2025 pm 05:17 PM

Go language performs well in building efficient and scalable systems. Its advantages include: 1. High performance: compiled into machine code, fast running speed; 2. Concurrent programming: simplify multitasking through goroutines and channels; 3. Simplicity: concise syntax, reducing learning and maintenance costs; 4. Cross-platform: supports cross-platform compilation, easy deployment.

Why do the results of ORDER BY statements in SQL sorting sometimes seem random?Why do the results of ORDER BY statements in SQL sorting sometimes seem random?Apr 02, 2025 pm 05:24 PM

Confused about the sorting of SQL query results. In the process of learning SQL, you often encounter some confusing problems. Recently, the author is reading "MICK-SQL Basics"...

Is technology stack convergence just a process of technology stack selection?Is technology stack convergence just a process of technology stack selection?Apr 02, 2025 pm 05:21 PM

The relationship between technology stack convergence and technology selection In software development, the selection and management of technology stacks are a very critical issue. Recently, some readers have proposed...

See all articles

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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment