This is a creation in Article, where the information may have evolved or changed.
Disclaimer: This article is not to attract the mouth water fights. Just a few of my personal views on a limited level of record. Go dead-end powder or a love war enthusiast.
Go is a young, but fast-moving red language. When I first came out of the go, I began to pay attention to the cult of its creator. But the real use of these two years. Docker, the advent of kubernetes has greatly accelerated the speed of go popularity. Because a lot of people are concerned about it because go can be used to write such a complex program. On the contrary, I was in 13 because someone accidentally wrote Docker with go to start paying attention and eventually get into the pit of the container.
Let's talk about the pros.
The purpose of the advantage is to be more enjoyable with the haha of the groove,
- There's no good repl. Maybe the static language doesn't need it. But I was used to
- There's no good debugger. I don't really use debugger. But it's good to know that one is ready to use it. Delve? It's impossible to be successful with n times.
- no generic. this one's been said to be rotten. This thing is not necessary for dynamic language, but static language is ...
- Some gofmt of the brain. For example, automatic alignment equals. This is a bit contradictory. GOFMT forces the array, or the last element of the list, to be followed by a comma. This is good because the diff looks very clean. But the automatic alignment of the equals sign is completely opposite to this. When I was very young, I also like to make the code such a beautiful optimization, but the result is the architect gave a meal.
Others know why GOFMT must format the following two pieces of code in a different style time.Duration
?
- The mark of C is very heavy. Go has pointers! Although it is much safer than the C pointer. But I still have to understand. I still need to know this is the address. Error handling is basically the same as C. On the whole, go feels like an improved C language. Do not know the mandatory use of CamelCase to deliberately let themselves and C distinguish. Brain repair, if use C commonly used this_is_a_function to write go code is not and write C no difference.
- automatic recognition of interface implementations. when implementing a interface, there is no need to declare, just silently implement all of the methods. Generally speaking, explicit is always better than implicit. The go authors suggest that the interface be as small as possible, and this is a reliable one. Maybe that's why, as an elegant _ language, go doesn't want you to write a statement like this:
struct Foo implements Writer, Reader, Formatter, Transformer, Builder
. After all, I'm not java.
- Package Management. Why must I force an absolute import path? Suppose I clone
github/zhangsan/abc
, simply can't compile! have been unable to spit the groove ...
- the channel is not so tough. Robe Pike encouraged everyone to communicate by channel. Channel + Goroutine is really a good design. But just saying the channel, not mentioning sync, is a bit unkind. In fact, with the Goroutine, will soon find that the lock is still to lock. Still need to program ape know race condition and so on.
interface{}
It's like a C inside void *
. For static typing is an intrusion.
- the attitude of the creative staff is a bit ... Elitism. For example, the above-mentioned generic, such as the refusal of some grammatical sugar and disdain. Why I must write
list[len(list)-1]
Ah, why can't have cond? a: b
such conditional operator AH. At the same time, creating if a = foo(); a != nil {}
this almost the only function is to add a long line of syntax.
- It is almost encouraging to write extra long lines, or, to be exact, to encourage the writing of long function names. If you've seen Kubernetes's code, you'll see more than 80 characters of code lines everywhere, and I was surprised when I first saw them. The go language requires that the start of your function must be followed by the function name, and the
{
indentation must be 4, so if you have a very long function name, you can only write it on one line, or the following line will be mixed with the body itself. So, go is basically encouraging you to write extra-long lines. This is basically despised in all languages. I don't know what the go writer is thinking.
- name. unable to search, but also in conflict with another language, but also the English conflict with Weiqi ....
- CamelCase This article _find_it_is_much_easier_to_read_something_in_underscores_than_in_camel_case. Butthenagainthatmightjustbeme,youshouldallletmeknowwhatyouthink. But let's find an excuse for the creator of Go. CamelCase can play a few characters ...
Spit it out.
Undoubtedly, go is a very useful language. The purpose of its designers is clear: Create a language that is easy to learn, fast to use, and suitable for blue collar, for developing distributed programs. The strategy is based on the most successful language C in history, improving its dross (memory management, security, string), and adding elements of some modern language. The target audience is a large software team. From these perspectives, it is undoubtedly a success. But in terms of language, go has many failings.
The purpose of writing an article is not to contend for who is good or bad. It is: to organize and record some of their own ideas, and secondly to prove that NB people are also in his environment, experience, background, times and so on, the third is to continue to sing never do brain residue powder .
Finally, several links are attached:
-
Comprehensive evaluation of the Go language
- Wang Yin's comments. Although I do not recognize this person, but this article I still quite agree with.
-
Go-is-not-good
- GitHub above a collection similar to awesome xxx. It's just a negative connection set.