Each language has its own uniqueness, or peculiar syntax, or uncommon functions, or non-standard execution methods. Therefore, whether you are a veteran or a newbie, you will always be suddenly drunk at any time. This article summarizes 10 frequently-mentioned "singular" features.
650) This. width = 650; "src =" http: // 183.61.143.148/group1/m00/02/21/tz2plfqhi5zcjhn0aaf0dp30s7c165.png "/>
1. javascript: +Is a connector
Problem description:In JS, the plus sign is used between numbers and can be used as a regular addition. However, if a character is encountered, it can also be used as a character connector. For example, the result of '1' + 1 is 11.
Cause analysis:
The fundamental reason is that JS is a weak type language. For example, Python also uses the "+" character as the character connector, but because it is a strong-type language, once a character is found to be added with an integer, it will prompt that this is an error operation.
Opinions of netizens:
"The problem is that this is an unpredictable forced silent conversion, which is easy to ignore ." Anonymous
"JS should throw an exception in this case ." Crgwbr
"It is a nightmare to use + to connect characters ." Matteo Riva
2. Perl:The module must return a value of true.
Problem description:In most cases, the Perl module must end with 1; statement at the end. Otherwise, if the return value of the last statement is not true, the system reports an error.
Cause analysis:
The Perl module contains the initial code and subroutine. When a module File is loaded, Perl checks whether the code is successfully executed based on whether the returned value is true. Even if no initial code is available, Perl still expects the final statement to return true; otherwise, an error is returned.
Opinions of netizens:
"This often makes me feel uneasy ." Drew Hall
"This is the least practical use ." Schwern
3. C/C ++:Usage of three-letter words
Problem description:
For example, the system can see ??! It will be automatically converted to |, see ?? (It is converted [. This can cause unexpected results and greatly reduce the readability of the Code.
Cause analysis:
During early programming, some special characters, such as braces, cannot be directly typed on the keyboard. Therefore, this indirect method is used.
Opinions of netizens:
"If you are knowledgeable about Google, you cannot understand what it is ??!??!" Isaac
"C has become obscure since 1977 with three letters ." Martin Beckett
4. php:Case Sensitive Processing
Problem description:
The case sensitivity of PHP is quite confusing. Some cases are differentiated, while others are not. For example, variable names, constant names, function names, method names, and class names are not differentiated.
Cause analysis:
It is likely that PHP has evolved from a CGI script set into a mature programming language.
Opinions of netizens:
"This is why PHP programmers are used to naming functions with underscores, rather than using the hump naming method ." Paperstreet7
"Everything is possible in PHP !" Grzechooo
5. Ruby: 0As true value
Problem description:
In Ruby, 0 is equivalent to true. This is a nightmare for programmers with C and Python basics.
Cause analysis:
Only the Boolean values false and nil are equivalent to false, and the rest are equivalent to true. 0, 2, 3, and so on will be treated the same.
Opinions of netizens:
"This is crazy, although the original intention is good ." Chris Lutz
"0 = true! My C language head is almost broken !" Kenny
6. Python:Hierarchy by number of spaces
Problem description:
Unlike using keywords or vertices, Py uses the indent level for hierarchical Division to determine the position of each line of code. Incorrect numbers of spaces (or inconsistent numbers of spaces and separators) may cause program errors.
Cause analysis:
The intention of the authors of Py is to make the code more readable, reduce unnecessary input, and expect the programmer to take responsibility for maintaining the Definition of the code.
Opinions of netizens:
"In my heart, this is the root cause of my respect for py ." Wazoox
"If we really need a similar force mechanism, are we really too lazy !" Joris MEYS
7. C:The array index working mode is equivalent to pointer
Problem description:
In C, a [I] And I [a] can be exchanged, and both statements can produce the same result.
Cause analysis:
In C, there is no difference between arrays and pointers for memory blocks, that is:
A [I] = * (a + I) = * (I + a) = I [A].
Opinions of netizens:
"In the C language chaos code competition, this is worthless ." Confusion
"I think this is exposing the core of the C language, pointers and more directly dealing with memory ." Michael Neale
8. Perl's:Predefined Variables
Problem description:
Perl has a very long list of special variables with complicated names (although there are long English words ). Therefore, it is common to read Perl documents repeatedly unless you are a senior developer of Perl.
Cause analysis:
These variables have different meanings, such as process ID ($), error message ([email protected]), and regular expression match ($ ^ r ).
Opinions of netizens:
"Very annoying !" Matrixfrog
"For simplified developers, it may be the Gospel ." Nixar
"The problem with these variables is that they cannot be found through Google !" Malvim
9. javascript:Automatic semicolon insertion
Problem description:
JS uses semicolons (;) as a sign of the end of the statement and inserts them independently, even if the code is broken. Therefore, errors often occur.
Cause analysis:
Automation is intended to bring convenience, especially for new users.
Opinions of netizens:
"If we treat users as dummies when designing the features of a language, there will be problems ." Rob van Dam
"Automatic semicolon insertion is one of the biggest headaches for Javascript ." Fennec
10. Java:Autoboxing and integer Cache
Problem description:
Java will automatically convert basic data to an object (automatically boxed), for example, converting int to an integer object. By default, the value of the cached integer object is-128 to 127. In this case, a problem occurs when we use = to compare two integer objects with the same value (true in-128 and 127, and false in the rest)
Cause analysis:
The automatic packing mechanism reduces the amount of code input, and the integer cache improves the processing speed.
Opinions of netizens:
"Fortunately, I am just a C # programmer ." Will
"This is not an error. Instead, it gives us a reason to use the original type (such as booleans) for digital processing ." Raviwallau
The above is about ten "singular" Features and want to learnProgramming Language tutorialFor more information, log on to the E-mentor Yiyou network.
This article is from the blog, please be sure to keep this source http://yuguotianqing.blog.51cto.com/9292883/1557808
Programming features that make programmers speechless