C++,python,golang Control Study-01

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed. Well actually learn go just for fun, just for fun, learning process will inevitably be other I understand the language of thinking stereotypes and habits brought in, thus have this control study record, it is left to learn the footprints it.
The language features mentioned here refer to the latest C++11 standard in C + +, Python refers to python3.x (2.x didn't learn), go is the latest 1.1


Variable declaration
Go variables are declared in the order of variable name and variable type, and can ignore the variable type and the result is inferred such as a: = 5 at this time a is an int type
The order of variable declarations in C + + is variable type, variable name. Variable types such as auto a = 5 can be inferred from the Auto keyword; This time a is int
The declaration of all variables in Python is not required to specify the variable type with the keyword

Defer
The defer keyword in Go is used to delay the execution of a function or method, and it returns its value (if any) before the peripheral function or method returns. I want to say that the first time I used it, it felt like a shared_ptr, and lighter than shared_ptr.
shared_ptr can specify a destructor at the time of destruction, which can be used in the removal of resources to ensure that the resources can be released correctly regardless of the way they leave the scope (normal departure, exception occurs).
Python... Well, you don't even know when the resources will be released.


Range
In go, range is a keyword, it always returns two values, one is the subscript one is the specific value
Func main () {list: = []int{10, one, a, a, a, 15}for key, Value: = Range list {fmt. Println ("Key:", Key, "Value:", Value)}}


Output:
key:0 value:10
Key:1 value:11
Key:2 Value:12
Key:3 value:13
Key:4 value:14
Key:5 value:15

A range in Python is a function that returns a sequence of consecutive integers of a specified length starting at 0, which sounds a bit awkward and a few examples are clear.
A = range (0,10) for value in A:print (value)


The result is 0,1,2,3,4,5,6,7,8,9.
C + + Wood has this item, but C + + provides a range of similar functionality iterations
int a[] = {0,1,2,3,4,5,6,7,8,9};for (auto i:a) {    cout << i << "";}


0 1 2 3 4 5 6 7 8 9


Slices
Well, the slices in go and the big categories of Python. There's a Python foundation that's easy to get started with.


Concurrent
Go is the language itself that supports concurrency, and both Python and C + + implement concurrency in the form of libraries. Concurrency in Go is really fucking simple ....

These are just a few of them, and others will have time to continue writing.

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.