
When I saw this question, I was instantly in a trance. Where can Go do it? Net can't do it, but C#can't?
Then let's break it up and break it into pieces, and analyze it one by one from the places where Go may win:
1. Cross-compilation
When compiling programs for Linux and Mac platforms on the Windows platform, Go can, and C#should be able to do it, and you can do it through the publish mechanism!
2. Object-oriented
What should be discussed is "Can Go reach the level of Net?"
Although Go's interfaces and structs can be separated from "implementation and declaration", C#'s interfaces can be the same, but they are not as thorough as Go's separation. This should be a "weakness" of C#.
But at the same time, C#'s strict Interface/Implement mechanism also ensures the security of large-scale projects, so that interfaces are not flying everywhere in some Go programs!
On the other hand, I personally feel that the Class mechanism of C#is more in line with my programming thinking. Many older programmers actually follow the same programming trajectory, from c to C++, and then Java, which has always been the protection of Class.
Class has been written for so many years, even if you use go, it is still the soul of the class.
Not afraid of everyone laughing, I usually define a struct and then start to define methods, like this:
type Person {
Name string
Age int
}
//下面开始进入C++形态
func (p Person) CalSome(){
}
func (p *Person) IncSome(){
}
//开始调用
p := Person{
Name:"ttt",
age:45
}
p.IncSome()
Think about it carefully, how big is the difference between this and C#? Personally, I don't think it's much different!
From the perspective of the "beauty" of the program, C#is actually more beautiful!
3. Decompilation
If in the past, it was indeed possible to decompile Go's source code on the Windows platform after compiling it into an Exe file.
C#is very easy here. If you know this is a piece of Net code, there are many tools you can use if you want to decompile, including ILDASM, dotPeek, and ILSPY.
Of course, Java also has decompile tools such as jd.
Now that Net provides the AOT option, its decompilation function should be greatly improved. The code compiled by AOT is all native code, and it will be as difficult as Go to decompile it.
Differences must be combined over time, and differences must be separated over time. During the language period, various functions "learn from" each other.
4. Docker image size
This should be an area where Go wins.
Using Alpine as the Base Image, I made a mirror a few days ago, and docker images showed that its size was 13M.
If you use a "scratch" image as the Base, I believe it will be smaller.
Net's AspNetCore is obviously much larger, 30M +.
If you need a lot of Docker Images to run in k8s, the consumption of Go images will undoubtedly be much lower.
5、Father
In the end, we have to compare ourselves to our father. After all, the rich second generation was born in Rome, and the goal of ordinary people in life is Rome!
Go's father is Google.
Net's Father is Microsoft!
One is a bit old "overlord of the new era", and the other is a bit old "Old Meoney"!
In comparison, Google may be stronger.
From this point, Go wins slightly, Net loses slightly!
Of course, Father also has a great influence. Net has been unpopular since its inception and has received suppression from Java.
This seems to be particularly prominent in our Panda Country.
Nowadays, Tencent, a major company in Panda Country, has been fully shifting its main language from C/C++ to Go; ByteDance means that Go is the first choice for programming language by default. There are no special requirements. Generally, Go is used for development, and Rust is still ranked behind Go; Xu Zhiwei of Qiniu has always been a fanatical supporter of Go, and even developed a Go+ language, which is equivalent to an improved version of Go.
At present, it seems that in addition to Ali's insistence on Java, Go is already very popular among major companies in China. In comparison, Net's business is bleak, struggling to survive in industrial control, MES, Internet of Things, HIS and other fields, and its salary is not optimistic.
In Panda Country, Go undoubtedly beats Net in terms of popularity.
summary
From a grammatical and functional perspective, what Go can do, Net can do, or even better.
In terms of size, Go can be more lightweight. After all, Net has been accumulated for many years and is hard to recover!
In terms of popularity, especially in the Internet field, Go's usage rate is completely better than Net; in non-Internet fields such as factories, Net is more popular.
A new rich man, Lin Xiangru, and an old man, can they make peace with each other?
I am Mingyue,
An Internet storyteller!