Can some one explain the architecture of GO lang, Is it faster compared to Nodejs & if so what makes it faster

huangapple go评论91阅读模式
英文:

Can some one explain the architecture of GO lang, Is it faster compared to Nodejs & if so what makes it faster

问题

有人可以解释一下Go语言的架构吗?相比Node.js,它是否更快?如果是的话,是什么使它更快?Go是使用C/C++开发的,那么与C/C++相比,Go在性能上是否更胜一筹?C/C++和Go之间唯一的区别是更多的函数使得开发者在使用Go编码时更容易吗?

英文:

Can some one explain the architecture of GO lang, Is it faster compared to Nodejs & if so what makes it faster and Go is developed using C/C++, So, does GO beats out in performance when compared to C/C++ and is the only difference between C/C++ & Go is all about more functions which makes developer easy to code using GO?

答案1

得分: 1

请注意,Go 1.5将完全使用Go编写其编译器、汇编器、链接器和运行时。

目标是完全使用Go编写Go,并消除代码库中的任何C代码。唯一的例外是Cgo的C代码

(参见Go 1.5引导计划

速度更多地与生成的本机代码以及语言的简单性有关(没有泛型意味着要跟踪的动态数据较少)。

Go并不总是很快:“为什么Go语言如此慢?”。它逐步改进,尤其是在垃圾回收方面和堆栈管理方面


Uvelichitel在下面提到了x64 Ubuntu:Intel® Q6600®单核--计算机语言基准游戏


至于“Golang架构”,这在这里并不适用(详见此答案):

Go没有像Java JVM那样的虚拟机。它直接编译成类似于C/C++的机器码。

Go 1.3链接器改进中提到:

当前的链接器执行两个可分离的任务。

  • 首先,它将伪指令的输入流转换为可执行代码和数据块,以及一系列重定位信息。
  • 其次,它删除死代码,将剩余的代码合并为一个单独的映像,解析重定位信息,并生成一些整个程序的数据结构,例如运行时符号表

英文:

Note that Go 1.5 will feature its compiler, assembler, linker, and runtime written entirely in Go.

> The goal is to have Go written entirely in Go and to rid the codebase of any C code. The only exception to the C code is for Cgo.

(See Go 1.5 Bootstrap plan)

The speed is more about about the native code generated, and the simplicity of the language (no genericity means less dynamic data to keep track of)

Go hasn't been always fast: "Why is go language so slow?".
It improves incrementally, notably on the garbage collection side, and stack management side.


Uvelichitel mentions below x64 Ubuntu : Intel® Q6600® one core -- Computer Language Benchmarks Game


As for "Golang Architecture", this doesn't really apply here (as detailed in this answer):

> Go has no VM like the Java JVM. It compiles straight to metal like c/c++.

The Go 1.3 Linker overhaul mentions:

> The current linker performs two separable tasks.

> - First, it translates an input stream of pseudo-instructions into executable code and data blocks, along with a list of relocations.

  • Second, it deletes dead code, merges what’s left into a single image, resolves relocations, and generates a few whole-program data structures such as the runtime symbol table.

huangapple
  • 本文由 发表于 2015年2月2日 16:11:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/28273432.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定