Many articles comparing programming languages always like to compare the performance, syntax and IO models of various programming languages. This article will compare different programming languages and technologies from the perspective of mental burden. Because I am good at programming language is limited, if there is anything wrong, please correct me.
Memory out of bounds
For example: c language, C++(C with class)
C/C++Can directly operate the memory, but programming must face memory out of bounds. After memory violation occurs, the program will directly
core dump, developers need to use
gdbThe tool analyzes the cause of memory errors. If memory out-of-bounds is accidental, for example, due to data synchronization problems, it will occur once in hundreds of millions of times, which is very difficult to solve and even requires top experts to find the cause of the problem.
Mental Burden: 10
STLThe library contains a large number of containers, and in addition
C++Support reference syntax, no longer need to directly operate pointer, reduce the risk of memory error reading and writing. Use modern
C++The programming style of can avoid this problem. But because
C++The pointer has not been completely removed from the grammar level, which is not thorough enough.
C/C++Predefined macros are often used in programs to implement some logic, resulting in poor readability. In some cases, macros will be nested multiple times and become extremely difficult to read when expanded.Mental Burden: 6
static inlineFunction instead of macro.
For example: C language, C++
C/C++Language requires manual memory management.
malloc/newThe memory requested should be the same as
free/deleteUse in pairs. If the requested memory is forgotten to be released, a memory leak will occur.Mental Burden: 8
GCThe programming language, does not need to manually manage memory, will not cause memory leaks due to code errors.Mental burden: 0
C/C++/GOSuch as programming languages, provide signed, unsigned integer and floating-point types,
8/16/32/64Integers of different sizes. Additional processing is required during programming to avoid numerical overflow.Mental Burden: 6
PHP/JavaSuch as programming languages, the default integer is signed
int64, reduce the mental burden. It is difficult to exceed in general business items
2^63The number of, will not encounter problems. But if you do scientific calculations,
int64It is difficult to meet the demand. In
PHPIn excess of
2^63The bottom layer will be converted to floating point type, and the calculation will lose precision.Mental burden: 1
PythonIntegers are unlimited in length and can be used for numerical calculation of any number of digits.Mental burden: 0
JavaIs a static strongly typed programming language, so there are type constraints in programming, which may not be particularly convenient in some cases. Such as
JSONSerialization. Explicit type conversion may be required when different types of variables operate on each other.Mental Burden: 2
PHP/JSIs a dynamic weak type programming language, the underlying automatic implicit type conversion. Programming is more convenient.Mental burden: 0.
Weak type dynamic language will bring maintainability problems in large-scale projects, code refactoring of existing systems, and code replacement of developers for projects.
Java/Go/C++Such static strongly typed programming languages can find problems at compile time. However, dynamic and weak types of languages may cause runtime errors due to refactoring or other maintenance operations, increasing mental burden.Mental Burden: 5
Java/C++/GoMulti-thread parallel programming and lock-free programming are provided, and data synchronization problem will exist in programming. thereforeCritical resources need to be locked. But the wrong lock operation will bring about deadlock and hot spot competition. Developers are required to have extremely high quality, otherwise it is difficult to be correct and perform well, which may require a lot of mind.Mental Burden: 10
PHP（php-fpm）Other programming languages and technologies (including
PHP + Swoole), which is a long life cycle in server-side programs. Operations on global/static variables may cause memory or resource handle leaks. Attention should be paid when programming.Mental Burden: 3
PHP（php-fpm）It has a short life cycle and will release all memory and handles immediately after the request is completed without worrying about leakage.Mental burden: 0
IOThe programming language and technology of the model meet a certain slowness
IOCauses the entire process or thread to hang. In extreme cases, all processes/threads will hang, resulting in the unavailability of online services. Developers need to pay special attention to settings
IOTimeout for operations to avoid process/thread blocking due to slow requests.Mental Burden: 2
Go/Node.js/SwooleThere is no need to worry about this problem.Mental burden: 0