Design mistakes in five programming languages

Source: Internet
Author: User

In recent years, the design of programming languages has gone through a process similar to the Renaissance. This is mainly based on the following two facts: (1) multi-core technology drives PC consumers to focus more on parallel programs. (2) The performance of dynamic languages is getting better and better. In the validity period, dynamic languages can be used to implement Internet services, and they are coming out of the "scripting language" shadow.

This article tries to collect design errors for the most important programming languages so that those Programming Language designers can design new programming languages.
Language. I have avoided some ambiguous problems, such as dynamic or static types. I also omitted the errors that do not seem serious and are easily modified. For example, add "parameter"
(Parametric type), which is already available in Java. Sun added this feature in the eighth year after the release of Java 1.0. Another recent example is:
As mentioned in the Google go language design FAQ: "generics may well be added at some
Point. We don't feel an urgency for them, although we understand some
Programmers do ."

0. NULL pointer

In almost all mainstream programming languages, a reference to an object may be a null pointer, which may cause a runtime error. C. a.r. Hoare recently claimed to be responsible for this "invention". However, many other designers should be criticized for such a design. The following is the confession of C. a.r Hoare ":

I call it my
Billion-dollar mistake. It was the partition tion of the null reference in
1965. [...] More recent programming versions like spec # have introduced
Declarations for non-null references. This is the solution, which I
Reject in 1965.-C. a.r. Hoare

I call it an error of hundreds of millions of dollars ". This NULL pointer was invented in 1965 ....... The current programming language introduces the declarative specification of "non-null reference. This solution was rejected by me in 1965.

Other languages, such as C/C ++, are even more exaggerated. When they are shipped to such errors, they will be crash directly.
Java, Python, and other languages throw an nullpointerexception, but the problem is that this runtimeexception
It may be thrown by almost all statements. In fact, you only need a static language to ensure that no NULL pointer or reference will appear. Example: Cyclone
Is a secure C variant that introduces non-null pointers and pointer operation restrictions.

Some languages even make it impossible to create null pointers, although this makes it impossible for clear pointers to perform operations. Haskell is such a language that provides maybe monad, which forces programmers to consider the "null" situation.

1. Difficult syntax to parse

The programming language syntax should come from lalr or be better
LL (1 ). Today's programmers need appropriate tools to support their development languages, that is, the commonly used IDE, compiler, or other programming tools that can help you parse programming languages. This does not appear in
Single front-end. Maybe multiple compilers have been implemented. This may make our start easier. However, one counterexample in our reality is
C ++, almost no C ++ compiler can perfectly and correctly interpret the C ++ language, and the behavior of different C ++ compilers is so strange. The overhead of programming syntax is negligible,
Programmers should enjoy a faster and more efficient return in programming.

2. undefined Semantics

Do not say "Implementation Specification" in the language specification "! Use as few terms as possible as "undefined" to describe language behavior
(Many undefined behaviors appear in C/C ++ )! The golden standard is standardml, which is a complete formal semantics. C
The language is such a counterexample, and there are too many undefined rules. However, due to its widespread use, the definition of certain behaviors has become the consensus of the world (the Regulation of rivers and lakes, or the rules of potential ).
For example, in C, the integer overflow behavior is undefined, and the compiler also has the ability to deduce "x <x + 1
"Is always true. Unfortunately, this is what the compiler should do and is handed over to the programmer. So in the world of C, a lot of Integer Overflow Code appears. When integer overflow occurs, almost all
The behavior is the same as that of an x86 processor (for example, maxint + 1 = MININT ).

Explicit semantics makes verification and error check easier. Although software verification is slow, it will certainly come. As I can imagine, the next opportunity for programming languages will be easier verification, which may take 10 to 20 years, but the language that begins today will become the mainstream in the world.

3. Bad Unicode support

Almost all programs need to process strings, but don't forget that not everyone can program in English. Today, almost all programming languages do not support Unicode. Therefore, we can only program in ANSI English. In this era, programmers should use Unicode for programming. Therefore, the source code can also declare what it uses for encoding.

The conversion and differentiation between text and byte order is more difficult than the language in the standard library. Of course, this also affects the syntax. It may be helpful to solve this problem when I read Python 3.

4. pre-processor

Pre-processors such as C ++ and MP4 have been widely used. The use of pre-processors is more like a hack than
A clean solution.
They are used to use external files (such as header files, but do not have the correct module mechanism), Conditional compilation, macro replacement, and so on. Integrating these functions with programming languages can increase program performance and
There is nothing bad about development efficiency.

If you want to give an inverse example, it is the modular system of the pre-compiler. C # include and C ++
It is even more painful because the template needs to write a large header file and it will be contained in almost all other files. A truly modular system does not need to use extern.
Keyword, And the link of the program is not required, but should be used directly.

Http://beza1e1.tuxen.de/articles/proglang_mistakes.html:

The http://coolshell.cn /? P = 2598

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.