New language Learning

Source: Internet
Author: User
Tags lua

Used languages are timed: C + +, LUA (Shallow script), Erlang, C # (Unity), LUA, go. The deepest impression is Erlang, because of the special disadvantage, uh.

That will not even multi-threaded, multi-process are not familiar with, although looked at Erlang process communication model, Mail_box, gen_server principle, but do not understand when to want them. There are recursion-based coding, but also not used.

......

The above is not to say the focus: technical things, time enough, more use of the familiar, and the project team to the new people also have enough latitude.

What's more important is what's on "security," especially for published projects.

Own past coding, put almost all the energy to grasp the "logical context", after switching to a new language even after several mistakes. have been thinking why, thought careful, rigorous aspects of the reason is not sufficient (of course, some master really is very meticulous, can take into account all aspects ~).

Nearly half a year later, a time to look at the project piece of code, we wrote so many, suddenly realize: The business logic is not difficult to write (write good), so many people wrote so many ... Business logic, after the clear in the code is a relatively careless. Can be counted everyone can write, efficiency difference, and this kind of logic errors, omissions are easier to find. According to the actual project experience, the loss of the external network is rarely caused by business logic omission. What's the most? Edge corner of things-critical value, NULL pointer, parameter test, subscript out of bounds, the destruction of the recovery is not sufficient ... These guys are more difficult to cover in the test, and they put it out a little bit.

Know to see a great God, Title: Chief Shovel excrement officer. Said a very wonderful comment, "the so-called apprenticeship is actually to make the mistakes are all committed again, someone apprenticeship fast actually he tried the wrong fast." If someone says he has not made a mistake, he can only say that he has not learned his home. (PS: He ranked refactoring as the programmer's first skill, then code design, style, 中文版)

Also met the client colleague, self-test a cooperative function old error, am single step to C + +, found in the constructor function pointer is not initialized. Call the partner developer, the communication is not very smooth, only to hear him burst a sentence: "You are questioning my professionalism?" ”

Domineering full, on the spot heartbeat!

I hope that I will be qualified to say such things in the future.

dispatch back to focus: each language has its own pit, understand the grammar after the first to die on them ( ̄" ̄) ~

For example, C + + null pointers, the effectiveness of the STL iterator, the container traversal it in a branch of the ++it,new/delete of the tree has a permanent match, memory operation of the cross-border protection, throw into the function to calculate a small standard and then access the array ...

For example, to see the concurrency of Erlang, it is necessary to think that the data in the ETS is shared, everyone can read and write, so when interacting with each other, we have to gen_server a layer; it provides a new form of the dead loop--the Tigger between branches of the same function (~ ̄▽ ̄~).

As a dynamic language, variables can match any type, and many functions return with an error code, but cannot be seen from the declaration. Often use a handy to forget to judge. In particular, the data interface, not like C + + with a pointer for the return value, no brain to judge the null pointer, the form of unity (leave a narrow-minded, all get, find methods are likely to fail, all this semantic function, all check the return value).

  Again, such as the LUA table reference pass, when the parameters are transmitted, the change of which, the original data changed, not good or configuration data. As with Erlang dynamic semantics, check for nil return problems ... The key is not convenient to determine which functions to check Wow ~

C #, variables are references, continuous use of closures, triggering callbacks, is likely to capture the same value, on the code

 for (int17; + +i)    {= = SelectOne (i));//The parameters passed into SelectOne at callback are all 7}

understand the lambda expression of c++11, knowing that it has the "[=], [&]" Two capturing methods to understand its principle. Patching is also targeted: the Loop body plus an "int idx = i", re-production of variables to the closure can be.

Recently used go, found a big pit, range loop, value transfer, much more dangerous than Lua's ipair. In particular, when the state changes (such as in the framework code), the changes in the loop body may be invalid, out of the bug hidden Deep ( ̄^ ̄), after consulting with colleagues decided to prohibit the use of it.

Finally: The pit points of each language function library are very different from each other and need extra attention, and the common interface writes code to try the boundary situation, no matter how simple it is.

New language Learning

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.