Use go language to do product half a year some feeling

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

With Go language products just half a year, some feel with everyone said.

Before using go, I often imagined that the inability to use advanced debug tools would have a significant impact on the progress of the work. Even in Visual Studio's pampered view, cannot debug the basic can not write the code correctly.

Since I am on the Windows platform, gdb that can support go language debugging is always unable to work, so in this half year, I did not hit a breakpoint, and did not open a single step tracking. At first I had a very deep heart and had to honestly write the test code for each method and run all the tests after each development. This method is actually a household name, but it is strange that I do not consciously do this when writing C #. Part of the test code will be written only in some very special sections.

I thought about it afterwards, laziness is just one of the reasons, and another reason is "compile speed." It is well known that the speed of the go language is very fast. Usually see this message should not feel, once began to write a paragraph on the implementation of a "compilation-" test, the effect is immediately out. My project currently has about 30,000 lines of code, with an average compile speed of 2 seconds. Plus SublimeText3 inside the convenient gosublime plug-in, write the code CTRL +. Ctrol+r, a few seconds later I saw the result. Very convenient.

Of course, you might say that it's easy to do things like that in Visual Studio, ha, you're right, but you stick with it and try it once, and there's a feeling of being interrupted. (I may have editor obsessive-compulsive disorder, I used to like Vim, now I love sublimetext, I always feel that the various panels of graphical IDE can easily distract me, let's not be serious,:P)

Before each encounter bug, must use a single pace to follow, now martial arts have been abolished, I can only bite the naked eye to see the code, from time to times with print the value of the variable out to see. After a while I found that the number of bugs encountered was decreasing. The increase in language proficiency is on the one hand, but I consider myself a careless person, and in the past 10 years, C # has not felt that way.

Thinking about it, I think it is the simplicity of the go language itself that brings benefits. The grammar and features of the go language are so little, so clear, there's no weird tricks, and there aren't too many fancy ideas. Do not need to see "Go language Notes 100" or something. Plus the compiler's strict hints (such as declaring that a variable is not assigned can cause compilation to fail), to a large extent, to ensure that the "magic" code is not inadvertently written.

Here you have to mention the go language at the beginning of the stubborn band on a small tool "gofmt", its role is very simple, formatted go code. At first I was quite puzzled, this thing dispensable, early have this time to do something else bad?

Now it's clear that the readability of the code is more important to the programmer. This makes it much more comfortable for the naked eye to find problems.

So a combination of boxing down, concise grammar design + excellent code readability + strict compiler + built-in test support = very comfortable writing experience + high-quality code.

Everyone should love and hate the word "best practice", which should have been the scene: to achieve a function, but there are two or three ways of realization in the brain, so it took a long time to make a choice. Of course, the system-level design, this is understandable. But if it is a very simple function, such as "should we use pointers here?" Or a pointer pointer? or the array? Or a linked list? "The pain of this choice is a little meaningless.

I'm rarely blocked by this problem when I write go, and I don't have to think about whether to pass a reference or pass a value, whether it's a deep copy or a shallow copy. Unknowingly writing process is very smooth, really focused on the business logic. You can also scold me for a loser, this basic problem will be tangled? The level is too bad! However, the logic that can be expressed in three lines of code, why use 10 lines? We all know this truth, hey, the use of language design should be the same bar.

The other thing is the comfort of the deployment. Anyway the Go Language program to the final compilation is an executable file, run up on the line. That doesn't make any sense, does it? All right, let's talk first. How to deploy a website, install Apache, install Xxxmod (such as Python and Ruby), configure XXX (omitted 200 words here), in the middle also pay attention to the version of each module Oh, or encountered a variety of errors also have to catch the countless hair.

What about the Go language? Compile, run. What the? Well, that's so simple. Not Apache or any other HTTP server? No. Isn't that very unscientific? Well, it's kind of magical.

I have always felt that IIS and Apache are very black a big piece of things, inside all is ultra-technology, configuration file is also very advanced, high man came here to change to change the performance of silently improved n times.

At first, I also felt that an executable file ran very thin, and so more understanding of the fact that the core concept of HTTP server is so few, go language built-in support, so light can run.

Don't you feel bad? Well, think about the scenario of updating the code? Close the instance, update the code, compile, run (the update time how to let the service uninterrupted I first not discussed, this requires the other server mates). Very worry.

Especially like me this kind of Windows programmer, originally faced with Linux when the various stricken, all kinds of unfamiliar, if let me again to modify the Change folder permission what I blew up.

All right, just a little bit of a nagging talk. I have become a loyal fan of the Go language (so you don't have to talk to me about it haha), see go language happy, write comfortable, with the liking.

If you see this, then incidentally, we are going to call a Go language server-side engineer in January, if you happen to like the go language, love to read Internet fiction, the algorithm is full of love, but also in Shanghai, that may wish to talk to me, I may be able to open a happy heart to do a good thing out.

Reprinted from: http://www.cnblogs.com/AllenDang/p/3489576.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.