📜 ⬆️ ⬇️

Go programming language - seven years


Seven years is an important age in the lives of many people, a symbolic milestone in the new stage of maturation, when we start going to school. It seems that seven years is not so much, but still not a little. So if programming languages ​​are presented in the form of people, today we are celebrating the birthday of the first grader Go - he turned seven!

What is Go and what it is good, we will not describe: who is in the subject, they know and so, and the rest can read in Wikipedia . Yesterday we shared with you a useful translation of 50 shades of Go: traps, pitfalls and common mistakes of newbies , and today we are giving the floor to our developers writing on Go. In honor of the anniversary, we asked each of them three questions:

  1. Why did you choose Go (pros / cons)?
  2. What have you already written on Go?
  3. How best to learn Go, what do you advise to beginners?

That's what they answered.

Victor, Mail.Ru programmer
')
It began with the fact that I did several tasks in a project written in Go. I liked being involved. Go is well suited for new tasks in terms of performance and ease of writing / maintaining code. Pros: code readability, predictability, application performance on Go. Cons: non-ideal integration with C-shny code.

To date, I have written a blobs repository for Mail.Ru Mail: it stores almost (but not quite) the body of letters. Also helped rewrite Mail on Go.

To get started in Go, it’s quite enough to explore tour.golang.org . The standard library has almost everything to write a not too complicated web service. From the third party, you just need the connectors to the databases. Go is quite simple, there is no complex theory and cunning logical concepts, there are few "thin" places in the specification. It seems to me that it is best to learn a language in the process of writing code.

Tips:


Michael, leading programmer myTarget

"I'm bored with knowing what I used to know." One day, the Internet convinced me that it was good to know new programming languages. Not just others, besides the usual C ++ and Python, but new ones: the future is with them. I looked towards Rust, Go and Scala. But at the same time I really wanted the language to be learned to be useful to me. About three years ago I became fascinated with Erlang (and the FI as a whole), but I realized that I could not make money on it - and even as much as in C ++ - (right away, not in five years). For the same reason, Scala has disappeared (sorry, it seemed to me very interesting), this language implies a serious Java background. Rust just did not like right away. Go, by the way, didn’t like either: after C ++, I don’t have much in it, first of all flexibility.

But Go has a rich standard library, gorutiny, it develops, serious things are written on it (Docker, Dropbox). And the reverse side of what I didn’t like, Go requires a slightly different way of thinking. Not OOP, as in C ++ or Python. This prospect of mastering “a slightly different mindset” attracts me.

Go is also good with the pragmatic-financial component. Its scope is my favorite backend. That is, C ++ remains my main language, but little by little, some tasks are solved on Go — on the same workplace, without loss of salary. On Go, I have so far written only a utility for recognizing and adding tags to my music collection. That was when I first became acquainted with the language. Then I realized that Go is not intended for such tasks.

And I do not write the production code, I review it. I master Go together with the authors of the code. I myself am a beginner, so I can only share my plans for learning:


Ilya, Mail.Ru programmer

I managed to program a lot on what (C ++, PHP, Java, Objective C). Before coming to Mail.Ru Group, wrote on Perl. It is possible to write on it, but sadly in some places, since there are a lot of “historically established” terrible code. At some point I heard about Go and Rust, at about the same time, and decided to try. I liked Go. Over time, I even figured out how to use it at work. Pros - simplicity, compiled language, strong typing, static compilation.

On Go, I wrote for two Mail.Ru Group projects: for Cars, Mail.Ru wrote an asynchronous “spider” for downloading images from external sources with the ability to stop downloading early; Mail.Ru Mail - parser / parser / sender logs. The rest is home projects, rather experimental character.

Those who want to learn Go, you need to start writing code and google. Maybe like it and maybe not. There are lots of video tutorials, articles in bulk. Go has its own tricks that many people might not like. :) The language is pretty simple, with a bit of magic. Although compared to Perl, it is almost none. Good books have been published (Alan A. A. Donovan, Brian W. Kernighan. “Go Programming Language”; Mark Summerfield. “Go Programming. Developing Applications for the 21st Century”), they will help you use more correct approaches to Go development and understand well in tools.

Maxim, intern in Mail.Ru Mail

When I came for an interview, I applied for the post of C-developer of Mail.Ru backend Mail. And Victor interviewed me. The dialogue was like this.

- Do you want to write in C? - asked Vitya.
“Not very,” I answered honestly.
- And why?
- It has a lot of bukaff.
- I agree, we go then to me, we will write on Go - and no C, - suggested Vitya, slyly squinting his eyes.
“It’s scary, the hipsters write Go, but we have to do serious things,” I replied, almost agreeing to everything.
- Yes, everything will be fine, I give a tooth! - said Victor ...

So I became a go-developer. But, of course, it didn’t work without C. If you already know how to write in any programming language, but suddenly decided to step on the right path and chose Go, then you need to get used to the strict type system. Use more interfaces, less inheritance.

If Go is your first programming experience, rejoice. There are much fewer syntaxes compared to Python, Ruby, Java, which should make learning a bit easier. Go is not the most elegant language, but at the same time it is very expressive. A huge number of auxiliary tools (gofmt, goimports, govet ...) will help to forget about many annoying problems.

For starters, I recommend reading the post effective go . Relax, re-read effective go , after some time look again at effective go . Effective go does not happen much, it is worth re-reading from time to time. It is important for everyone to understand (and for some - forgive) the memory model of the language and remember: “Do not communicate by sharing memory; instead, share memory by communicating . ”

Alexander, Junior Programmer at Mail.Ru Mail

In January, I became an intern at the position of C-developer. On the first day a colleague asked: do you want to write on Go? I agreed. So it all started to happen. I rewrote mail threads from Perl to Go, also on the approach of Sishny messages / status. Now I rewrite the mail API with Perl / C. On open source projects, there is not enough desire. :(

Beginners should first go tour.golang.org :). Then you can try to write your own API service to cover as many features of the standard library as possible using http.HandleFunc . And then write your own http.HandleFunc :)

Roman, programmer in the video services development team

When I came to Mail.Ru Group, our main backend corresponded with NodeJS on Go. So this Go chose me, but I am pleased. Go has three main advantages over NodeJS:


Go is very focused on simplicity, and that is how I like it. However, for the simplicity you have to pay. For example, the lack of generics. Also, not all problems are solved with vendoring. However, it should be remembered that Go did not reflect as a language with the widest scope, therefore its minimalism is largely justified.

My development experience on Go so far is limited to microservices and console utilities. To begin to get acquainted with Go, I recommend to open the specification and read 20 minutes before bedtime, until you learn to scratch (just kidding). Of course, to learn a language, you need to write on it. And for learning idioms, it would be good to look through the code of standard Go libraries. I also recommend an effective go .

Dmitry, programmer in the studio Allods Team

I chose Go mainly because I don’t know other languages ​​in which asynchronous IO could be written as easily as synchronous (except async-await in C #, but on * nix-systems it is not very popular). In addition, the language is simple to learn, the standard library has almost everything that is needed (and there is a developed ecosystem of third-party libraries); toolkit easy, no frills, good documentation. Among the shortcomings: I do not have enough generics.

At the moment I have written several utilities on Go for internal use. To start it will be enough to study the information from the official site. There is a brief overview and a more complete specification, plus speeches from conferences.

That's all. How did you study go? Share stories in the comments.

Source: https://habr.com/ru/post/314834/


All Articles