What is golang similar to?

青灯夜游
Release: 2022-12-28 11:07:16
Original
4221 people have browsed it

Golang is similar to c language. The Go language is described as a "C-like language", or "the C language of the 21st century", and its syntax is similar to C; Go inherits similar expression syntax, control flow structure, basic data types, and call parameter transfer from the C language. There are many ideas such as values ​​​​and pointers, as well as the running efficiency of compiled machine code and the seamless adaptation to existing operating systems that C language has always valued.

What is golang similar to?

The operating environment of this tutorial: Windows 7 system, GO version 1.18, Dell G3 computer.

golang is similar to the c language

Go (also known as Golang) is a language developed by Google's Robert Griesemer, Rob Pike and Ken Thompson Static strongly typed, compiled language.

The Go language has been described as a "C-like language", or "the C language of the 21st century". Go inherits similar expression syntax, control flow structure, basic data types, call parameter value transfer, pointers and many other ideas from C language. It also has the running efficiency of compiled machine code that C language has always valued and is consistent with existing Seamless adaptation to the operating system.

Go language syntax is similar to C, and its functions include: memory safety, GC (garbage collection), structural form and CSP-style concurrent computing.

Go supports garbage collection. Go's parallel model is based on Tony Hall's Communicating Sequential Process (CSP). Other languages ​​that adopt a similar model include Occam and Limbo, but it also has features of Pi operations, such as channel transmission. Plugin support is opened in version 1.8, which means that some functions can now be dynamically loaded from Go.

Go language is the C language in the cloud computing era. The Go language was born to allow programmers to have higher productivity. The Go language is specially optimized for the programming of multi-processor system applications. Programs compiled using Go can be comparable to the speed of C or C code, and are more secure and Supports parallel processes.

When developers choose a language for their projects, they have to choose between rapid development and performance. Languages ​​like C and C offer fast execution speed, while languages ​​like Ruby and Python excel at rapid development. Go language builds a bridge between the two, not only providing a high-performance language, but also making development faster.

Comparison between golang and c language

1. Comparison of code management

In C language, code is managed through files

  • When you want to use a certain function, you only need to include the corresponding .h file

Code is managed through packages in Go language

  • Go language does not have the concept of .h files. When you want to use a certain function in Go, you only need to import the corresponding package

Public and private management of functions and variables in C language

  • Whether functions and variables are exposed through extern and static

Public and private management of functions and variables in Go language

  • Use the first letter of the function name to realize whether to expose the function

  • Use the variable name Is the first letter case to implement public variables?

2. Keyword comparison

There are a total of 32 keywords in C language

##dowhileforcontinuestructunionshortunsigned
1 2 3 4 5 6 7 8
##if else switch case default break return ##goto
typedef enum ##char
int long float double void sizeof signed
const autoregister static extern volatile

There are a total of 25 keywords in the Go language

##defaultbreakreturnstructrangeC language data type
1 2 3 4 5 6 7 8
# #if else ##switch case ##goto fallthrough
for ##continue type var##const mapfunc interface
import package defer go select chan






3. Data type comparison

Go language data type

What is golang similar to?Each data type in C language occupies memory space

What is golang similar to?Type

32-bit compiler

64 Bit compilerchar11int44float44double88##short22long48long long88void*48Type
Each data type in Go language occupies memory space

32-bit compiler

64-bit compilerEssenceint8/uint811signed char/unsigned charint16/uint1622signed short/unsigned shortint32/uint32 44signed int/unsigned intsigned long long int/unsigned long long intuint8/unsigned char int32/signed intThe length is determined based on the number of machine digitsDetermine the length uint32/uint64 based on the number of machine digitsfloatdoubleChar type integerChar type integerC language definition of constants and variables Format
数据类型 变量名称 = 值;
const 数据类型 常量名称 = 值;
Copy after login
Go language definition constant and variable format
##int64/uint64 8 8
byte 1 1
rune 4 4
int 4 8
uintptr 4 8
float32 4 4
float64 8 8
true 1 1
false 1 1
4. Comparison of constant variables

In addition to the following standard formats, Go language also provides several simple syntax sugar

var 变量名称 数据类型 = 值;
const 变量名称 数据类型 = 值;
Copy after login
[Related recommendations: Go video tutorial

Programming teaching

The above is the detailed content of What is golang similar to?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!