There are many programming languages in the world and each of them has its own little quirks - a strange syntax, unusual functionality or non-standard implementations. Sometimes it confuses not only beginners, but also experienced developers. Sometimes these quirks seriously stop learning a language or, on the contrary, become a well-known chip.
There are so many similar things in programming languages, but we have chosen the most famous ones for you.
Blank rows in Oracle SQL
Image courtesy Nic Hughes CC BY 2.0 ')
Oracle considers strings of length zero NULL equivalent. This is a significant difference from other databases and the ANSI / ISO SQL standard, which means that the empty string is a previously known value, and NULL is an unknown value, and they cannot be equivalent. This can be a pain for writing code for several RDBMS or rewriting code.
There was confusion back in 1979, when the first version of SQL was released, and the corresponding standard had not yet been developed. However, Oracle warns that in the near future this empty line phenomenon may disappear.
Quotes:
“Yes, this is one of the“ great ”features of Oracle DB.” -
Lukas Eder“An empty string is equivalent to NULL not greater than the number 0” -
Ben Blank"WHAT!? I'm so glad we don't use Oracle. It scares ”-
Jeff Davis+ as a universal concatenation operator in javascript
Image courtesy MicroAssist CC BY-SA 2.0The + operator is overloaded in JavaScript, and serves as both a mathematical addition of numbers and string concatenation. That is, if one of the operands is lowercase and the other is numeric, then instead of 1 + 1 = 2 you will get '1' + 1 = '11 ': JavaScript without warning will result in the number to a string.
The reason for this is insufficient control over type compatibility. For example, in Python + it is used exactly for the same purposes, but you will never be able to add up the number and symbol.
Quotes:
“The problem is that hidden type conversion in expressions is unpredictable.” -
Anonymous"JavaScript should throw an exception in this case" -
crgwbr“+ For string concatenation is a nightmare” -
Matteo RivaPerl modules must return true
Image courtesy anthony kelly CC BY 2.0Every Perl module must return true. If this does not happen, then the developer runs the risk of badly damaging his karma and facing a compilation error.
The reason for this is clear and understandable if you understand what a module is in Perl. The compilation program, considering the modules connected to the code, first of all checks their execution. Even if there is no initialization code in the module, Perl still expects to get True at the output.
Quotes:
"This thing always leaves me nauseous feeling" -
Drew Hall“This has no practical use, given the annoyance that arises continuously” -
SchwernTrigraphs in C and C ++
Image courtesy REUTERS / Gary HershornC and C ++ languages support trigraphs - three-letter symbols that are automatically converted to single-characters. So, for example, the combination ??! will give you |. If you want to confuse the uneducated enemy who decided to read your code as much as possible, use the combination of ?? (and ??) instead of square brackets.
The meaning of trigraphs is not at all in the desire of language developers to obfuscate code, but in the fact that once upon a time many keyboards simply did not contain common characters, such as curly brackets.
Quotes:
"Google will not help if you are looking for something on request ??! ??!" -
Isaac“Everybody hates trigraphs so much that C99 brought digraphs as an alternative ... even more obfuscation” -
dododge"The joy of trigraphs - makes C unreadable since 1977" -
Martin BeckettPHP registry sensitivity
Image courtesy Gregg O'Connell CC BY 2.0While most programming languages are case-sensitive, in PHP the names of functions, classes, and methods are insensitive to it. But what really strikes developers is that the names of variables, constants, and class properties are still case-sensitive.
It is not known for certain where this discrepancy has come from, but the most likely option is the initial desire of the creators of PHP to separate the CGI interface into a separate full-fledged programming language.
Quotes:
“Well, this is PHP. Do not be surprised ”-
Grzechooo“That's why PHP programmers use underscores instead of CamelCase, calling their functions” -
paperstreet7"I have no idea how to create programming languages ..." - creator of PHP
Rasmus Lerdorf“Is there something in PHP that is not puzzling?” -
Lambda FairyTrue Zero in Ruby
Image courtesy DaveBleasdale CC BY 2.0In Ruby 0 == TRUE. This is unexpected, at odds with most other languages, including Python and C, where 0 is still FALSE, and is often confusing for newcomers to Ruby.
The reason is that in Ruby, only boolean false and zero (nil) are calculated in FALSE; everything else is TRUE. 0 is treated like any other number.
Quotes:
“It can be strange if I didn’t think it was good” -
Chris Lutz“That's why I love Ruby. I do not have to deal with such a zero-false evil "-
Edditoria“0 == true // arg, the C compiler in my head exploded !!” -
kennySpaces in python
Image courtesy Paul Kitchener CC BY 2.0Instead of punctuation or keywords, Python uses indentation to indicate the block to which the line of code belongs. Incorrect number of spaces or mixing spaces and tabs can lead to errors.
The creators of the language wanted to make the code more readable and reduce the number of keystrokes due to the fact that many editors and IDEs indent automatically.
Quotes:
“No, really: this is what prevents me from ever
loving Python” -
wazoox“I love the padding in Python, but there is a nuance: when copying and pasting code from the Internet, this often leads to the need for additional cleaning” -
Greg“If you need imposed indents, you're too lazy.” - J
oris MeysArrays in C are subject to pointer arithmetic
Image courtesy BlueGum CC BY-ND 2.0In addition, you can get a reference to an array element as a [i], you can get it as i [a].
The reason is that arrays in C are pointers to memory blocks, so a [i] = * (a + i) = * (i + a) = i [a].
Quotes:
"... it is priceless when you participate in the C obfuscation contest ..." -
Confusion“I do not regard this as a feature, it’s just a look at the C kernel. Everything is for pointers and getting memory access as quickly as possible. In a sense, it's beautiful. ”-
Michael NealePerl Predefined Variables
Image courtesy Emily Mathews CC BY 2.0If you carefully read the description of the language of Perl, you can find a sufficiently large number of predefined variables with, to put it mildly, strange names (but with a fairly long English equivalent).
They serve to provide information or provide access to various aspects of the program. So, for example, $ @ is an error message, $$ is a process identifier, $ ^ V is the version of Perl used. Beginners often have to look into the documentation.
Quotes:
“Very annoying” -
MatrixFrog"A cool thing for
odnostrochnikov , by the way" -
niXar“I think the worst of them are $ @ and @ $. Both work, but I still do not know what the second is doing ... ”-
Artem Russakovskii“By the way, there is still a serious problem with these variables: they do not googling!” -
malvimAutomatic semicolon insertion in javascript
Image courtesy Nate Angell CC BY 2.0JavaScript requires a semicolon at the end of each complete expression. If this has not been done, and then comes, say, an empty line, JavaScript regards it as a developer’s inattention and independently inserts a semicolon, which sometimes helps, but often leads to errors and unexpected program behavior.
Initially, semicolon insertion was intended for convenience in order to make C-like JavaScript syntax easier for new developers.
Quotes:
"You will definitely have problems if you develop a language with the expectation that your users are idiots" -
Rob Van Dam“Tip: figure out the right place for the semicolon and put it. This is the best ”-
Doug Crockford“Inserting a semicolon is one of the worst parts of javascript” -
fennecAutopacking in Java and Caching Integer
Image courtesy Erich Ferdinand CC BY 2.0Java automatically packs primitives into objects, for example, int into an Integer. In general, nothing terrible, but Integer is cached if its value lies between -128 and 127. This can lead to unexpected results when comparing autopacked objects, since the program will assign a value of TRUE if both objects have a value from -128 to 127, and FALSE in all other cases.
Autoboxing reduces the amount of code, and caching the Integer improves performance. But you need to remember the pitfalls.
Quotes:
“Here is the result of premature optimization” -
Joschua“This is not a common mistake, but a good reason to use native Java types for numbers, logical variables, and so on.” -
Ravi Wallau"I'm so glad I write in C #" -
WillAuthor translation: Ilya Bubnov
___
PS Choose a direction and start learning from one of the technologies described above, you can
on the website GeekBrains .