Home Backend Development PHP Problem 10 language features that confuse programmers

10 language features that confuse programmers

Nov 25, 2016 am 09:59 AM

Each language has its own unique features, such as peculiar syntax, unusual functions, or non-standard execution methods. Therefore, no matter whether you are a newbie or an experienced player, you will suddenly get drunk when looking at a certain feature. The article summarizes 10 "weird" features that are often mentioned.

1. Javascript: + is a connector

Problem description: In JS, the + sign is used between numbers and can be used as a regular addition; but if it encounters characters, 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 weakly typed language. For example, Python also uses the + sign as the character connector, but because it is a strongly typed language, once it finds that a character is added to an integer, it will prompt that this is an error operation.

  Opinions of netizens:

 “The problem is that this is an unpredictable mandatory silent conversion, which is easy to ignore.” Anonymous

  “JS should handle this situation by throwing exceptions.” crgwbr

  “Use + to perform character concatenation is simply a nightmare. ”Matteo Riva

  2. Perl: The module must return a TRUE value

 Problem description: In most cases, the Perl module must end with a 1; statement, otherwise , if the return value of the last statement is not TRUE, the system will report an error.

 Cause analysis:

 The Perl module contains initial code and subroutines. When the module file is loaded, Perl will determine whether the code was successfully executed based on whether TRUE is returned. Even if there is no initial code, Perl still expects the last statement to return TRUE, otherwise an error will be reported.

                                                               ifier |

 Problem description:

 For example, when the system sees ??!, it will automatically convert it to |, and when it sees ??(, it will convert it to [. This can easily cause unexpected results, and will greatly reduce the code Readability.

 Cause analysis:

 In the early days of programming, certain special characters, such as braces, could not be typed directly on the keyboard, so this indirect method was used.

 Opinions from netizens:

“If you are as knowledgeable as Google, you must not understand what ??!??!” Isaac

  “Since the three-letter word was introduced in 1977, C has become obscure and difficult to understand.” Martin Beckett

  4. PHP: Case sensitive processing

Problem description:

 PHP’s case processing is confusing, distinguishing in some places and not in others. For example: variable names, constant names are distinguished; function names, method names, and class names are not distinguished.

Analysis of the cause:

 It is probably an artifact that emerged during the development of PHP from a CGI script set to a mature programming language

 Netizens’ opinion:

 “This is why PHP programmers are accustomed to naming functions with underscores instead of underscores. The reason for adopting camel case naming. ”paperstreet7

  In PHP, everything is possible! ”Grzechooo

  5. Ruby: 0 as a true value

 Problem description:

 In Ruby, a 0 value is equivalent to a TRUE value. . This is a nightmare for programmers with C and Python background.

Cause analysis:

 Only the boolean values ​​FALSE and nil are equivalent to FALSE, and the rest are equivalent to TRUE. 2, 3, etc. will be treated the same.

  Opinions of netizens:

 “This is simply crazy, although the original intention is well-intentioned.” Chris Lutz

  “0==true! I am a C language brain. Almost collapsed! "Kenny

  6. Python: Divide levels by number of spaces

 Problem description:

 Different from using keywords or punctuation, PY uses indentation levels to divide each line of code clearly The incorrect number of spaces (or the inconsistent number of spaces and transposition characters) may cause the program to report errors

 Cause analysis:

 The PY author’s intention is to make the code more readable and reduce unnecessary input. I hope that programmers themselves should take the responsibility of maintaining code clarity.

 Netizens’ opinions:

 “Sincerely, this is the fundamental reason why I stay away from PY.” wazoox

  “If we really need something like this. Enforcement mechanism, are we really too lazy! "Joris Meys

 7. C: The working mode of array index is equivalent to that of pointer

 Problem description:

 In C, a[i] and i[a] are interchangeable, and both writing methods can produce the same result. The result.

 Cause analysis:

 In C, there is no difference between arrays and pointers for memory blocks, that is to say:

 a[i] = *(a + i) = *(i + a ) = i[a].

 Netizens’ opinion:

 “This is worthless in the C language confusing code competition. "Confusion

" "I think this reveals the core of the C language, pointers and more direct dealing with memory. ”Michael Neale

 8. Perl’s: Predefined variables

 Problem description:

Perl has a very long list of special variables, and the names in them are very complicated (although there are corresponding long English words). Therefore, unless you are a senior Perl developer, it is common to read the Perl documentation repeatedly.

  Cause analysis:

  These variables have different meanings, such as: process ID ($$), error message ($@), regular expression matching ($^R).

  Netizens’ opinions:

 “Very annoying!” MatrixFrog

 “Maybe a boon for streamlined developers.” niXar

 “The problem with these variables is: they cannot be found through Google!” malvim

9. JavaScript: Automatic semicolon insertion

 Problem description:

 JS uses semicolon as a sign of the end of a statement, and will insert it by itself, even if the code breaks. This often leads to errors.

Cause analysis:

The original intention of automation is to bring convenience, especially to novices.

  Netizens’ opinions:

  “If we always regard users as fools when designing language features, problems will arise.” Rob Van Dam

  “Automatic semicolon insertion is the most troublesome thing about JS One of the places. ”fennec

 10. Java: Autoboxing and Integer caching

 Problem description:

 Java will automatically convert basic type data into objects (autoboxing), such as converting int to An Integer object. At the same time, by default, the value of the cached Integer object is -128 to 127. In this case, there will be a problem when using == to compare two Integer objects with the same value (TRUE within -128 and 127, and the rest is FALSE)

 Cause analysis:

 The automatic boxing mechanism reduces the code Input volume, while Integer caching improves processing speed.

  Opinions of netizens:

 “Fortunately, I am just a C# programmer.” Will

  “This is not a mistake, but it gives us a reason to use primitive types (such as: booleans) for number processing. ”RaviWallau


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

Revealing the appeal of C language: Uncovering the potential of programmers Revealing the appeal of C language: Uncovering the potential of programmers Feb 24, 2024 pm 11:21 PM

The Charm of Learning C Language: Unlocking the Potential of Programmers With the continuous development of technology, computer programming has become a field that has attracted much attention. Among many programming languages, C language has always been loved by programmers. Its simplicity, efficiency and wide application make learning C language the first step for many people to enter the field of programming. This article will discuss the charm of learning C language and how to unlock the potential of programmers by learning C language. First of all, the charm of learning C language lies in its simplicity. Compared with other programming languages, C language

2023过年,又限制放烟花?程序猿有办法! 2023过年,又限制放烟花?程序猿有办法! Jan 20, 2023 pm 02:57 PM

本篇文章给大家介绍如何用前端代码实现一个烟花绽放的绚烂效果,其实主要就是用前端三剑客来实现,也就是HTML+CSS+JS,下面一起来看一下,作者会解说相应的代码,希望对需要的朋友有所帮助。

Make money by taking on private jobs! A complete list of order-taking platforms for programmers in 2023! Make money by taking on private jobs! A complete list of order-taking platforms for programmers in 2023! Jan 09, 2023 am 09:50 AM

Last week we did a public welfare live broadcast about "2023PHP Entrepreneurship". Many students asked about specific order-taking platforms. Below, php Chinese website has compiled 22 relatively reliable platforms for reference!

what do programmers do what do programmers do Aug 03, 2019 pm 01:40 PM

Programmer's job responsibilities: 1. Responsible for the detailed design, coding and organization and implementation of internal testing of software projects; 2. Assist project managers and related personnel to communicate with customers and maintain good customer relationships; 3. Participate in demand research and project feasibility performance analysis, technical feasibility analysis and demand analysis; 4. Familiar with and proficient in the relevant software technologies for delivering software projects developed by the software department; 5. Responsible for timely feedback on software development situations to the project manager; 6. Participate in software development and maintenance Solve major technical problems during the process; 7. Responsible for the formulation of relevant technical documents, etc.

520 programmers' exclusive way to express romantic feelings! Can't refuse! 520 programmers' exclusive way to express romantic feelings! Can't refuse! May 19, 2022 pm 03:07 PM

520 is approaching, and he is here again for the annual show of tormenting dogs! Want to see how the most rational code and the most romantic confession can collide? Let’s take you through the most complete and complete advertising code one by one to see if the romance of programmers can capture the hearts of your goddesses?

A brief analysis of how to download and install historical versions of VSCode A brief analysis of how to download and install historical versions of VSCode Apr 17, 2023 pm 07:18 PM

Download and install historical versions of VSCode VSCode installation download installation reference VSCode installation Windows version: Windows10 VSCode version: VScode1.65.0 (64-bit User version) This article

List of the best Windows 11 terminal emulators in 2022: Top 15 recommendations List of the best Windows 11 terminal emulators in 2022: Top 15 recommendations Apr 24, 2023 pm 04:31 PM

Terminal emulators allow you to emulate the functionality of a standard computer terminal. With it, you can perform data transfers and access another computer remotely. When combined with advanced operating systems like Windows 11, the creative possibilities of these tools are endless. However, there are many third-party terminal emulators available. Therefore, it is difficult to choose the right one. But, just as we do with the must-have Windows 11 apps, we've selected the best Terminals you can use and increase your productivity. How do we choose the best Windows 11 terminal emulator? Before selecting the tools on this list, our team of experts first tested them for compatibility with Windows 11. We also checked them

See all articles