A tag for questions related to the design of any aspect of programming languages.
Questions tagged [language-design]
1363 questions
44
votes
12 answers
Are design patterns really language weaknesses?
Should today's patterns be seen as defects or missing features in Java and C++?
Subroutine was a design pattern for machine language in the 50s and 60s.
Object-Oriented Class was a design pattern for C in the 70s.
Visitors, Abstract Factories,…

Ewan Todd
- 7,315
- 26
- 33
44
votes
7 answers
Why Is Dynamic Typing So Often Associated with Interpreted Languages?
Simple question folks: I do a lot of programming (professionally and personally) in compiled languages like C++/Java and in interpreted languages like Python/Javascript. I personally find that my code is almost always more robust when I program in…

daveslab
- 10,000
- 21
- 60
- 86
43
votes
43 answers
Most interesting non-mainstream language?
I'm interested in compilers, interpreters and languages.
What is the most interesting, but forgotten or unknown, language you know about? And more importantly, why?
I'm interested both in compiled, interpreted and VM languages, but not esoteric…

gnud
- 77,584
- 5
- 64
- 78
43
votes
9 answers
Why are default arguments evaluated at definition time?
I had a very difficult time with understanding the root cause of a problem in an algorithm. Then, by simplifying the functions step by step I found out that evaluation of default arguments in Python doesn't behave as I expected.
The code is as…

Mert Nuhoglu
- 9,695
- 16
- 79
- 117
43
votes
4 answers
What's the motivation behind having copy and direct initialization behave differently?
Somewhat related to Why is copy constructor called instead of conversion constructor?
There are two syntaxes for initialization, direct- and copy-initialization:
A a(b);
A a = b;
I want to know the motivation for them having different defined…

Luchian Grigore
- 253,575
- 64
- 457
- 625
42
votes
7 answers
Why does C++ need the scope resolution operator?
(I know what the scope resolution operator does, and how and when to use it.)
Why does C++ have the :: operator, instead of using the . operator for this purpose? Java doesn't have a separate operator, and works fine. Is there some difference…

Karu
- 4,512
- 4
- 30
- 31
42
votes
3 answers
In C#, why is "int" an alias for System.Int32?
Since C# supports Int8, Int16, Int32 and Int64, why did the designers of the language choose to define int as an alias for Int32 instead of allowing it to vary depending on what the native architecture considers to be a word?
I have not had any…

Mike Nakis
- 56,297
- 11
- 110
- 142
42
votes
7 answers
Why is The Iteration Variable in a C# foreach statement read-only?
As I understand it, C#'s foreach iteration variable is immutable.
Which means I can't modify the iterator like this:
foreach (Position Location in Map)
{
//We want to fudge the position to hide the exact coordinates
Location = Location +…

MrValdez
- 8,515
- 10
- 56
- 79
42
votes
5 answers
Why don't PHP attributes allow functions?
I'm pretty new to PHP, but I've been programming in similar languages for years. I was flummoxed by the following:
class Foo {
public $path = array(
realpath(".")
);
}
It produced a syntax error: Parse error: syntax error,…

Schwern
- 153,029
- 25
- 195
- 336
42
votes
9 answers
Why are most string manipulations in Java based on regexp?
In Java there are a bunch of methods that all have to do with manipulating Strings.
The simplest example is the String.split("something") method.
Now the actual definition of many of those methods is that they all take a regular expression as their…

Niels Basjes
- 10,424
- 9
- 50
- 66
41
votes
3 answers
Why is C++20's `std::popcount` restricted to unsigned types?
The functions from P0553R4: Bit operations are constrained to only work on unsigned integers. The proposal does not give a reason for this constraint. I can see that this makes sense if the bit representation of a signed integer is not defined, but…

He3lixxx
- 3,263
- 1
- 12
- 31
41
votes
25 answers
What is the purpose of null?
I am in a compilers class and we are tasked with creating our own language, from scratch. Currently our dilemma is whether to include a 'null' type or not. What purpose does null provide? Some of our team is arguing that it is not strictly…

Allyn
- 20,271
- 16
- 57
- 68
41
votes
28 answers
does a disaster proof language exist?
When creating system services which must have a high reliability, I often end up writing the a lot of 'failsafe' mechanisms in case of things like: communications which are gone (for instance communication with the DB), what would happen if the…

Toad
- 15,593
- 16
- 82
- 128
41
votes
2 answers
Why does C++ mandate that complex only be instantiated for float, double, or long double?
According to the C++ ISO spec, §26.2/2:
The effect of instantiating the template complex for any type other than float, double or long double is unspecified.
Why would the standard authors explicitly add this restriction? This makes it…

templatetypedef
- 362,284
- 104
- 897
- 1,065
40
votes
4 answers
Whatever happened to the 'entry' keyword?
While cruising through my white book the other day, I noticed in the list of C keywords.
entry is one of the keywords on that list.
It is reserved for future use. Thinking back to my Fortran days, there was a function of some sort that used an…

EvilTeach
- 28,120
- 21
- 85
- 141