A tag for questions related to the design of any aspect of programming languages.
Questions tagged [language-design]
1363 questions
0
votes
1 answer
Array Design Principles
There are hundreds of array topics in all the programming forums. maybe even thousands. daily.
But none of them touch upon this aspect.
Because arrays are indexed from 0, i often still enter access my data starting at one.
the reason being the zero…

aremvee
- 179
- 1
- 13
0
votes
2 answers
statically-typed languages with types decided at runtime?
for example, something like this in Ada (if it were to support this):
type Type_Name is range bottom .. top;
where "bottom" and "top" are variables.
or something like this in C (if it were to support this):
struct s {
int a;
if (z<3) {
…

Jorge Martinez
- 45
- 2
0
votes
1 answer
Would C/C++/Pascal/etc. be substantially slower if it was a stackless language?
And a related question: How would stack traces/similar debugging features look like in it?
And please excuse me if this is a stupid question, but I don't know much about low-level programming. I know most CPUs have instructions related to the stack,…

Llamageddon
- 3,306
- 4
- 25
- 44
-1
votes
3 answers
In javascript, when Prototypal inheritance is more adequate than closure for object creation?
As far as I understand,Prototypal inheritance and closure are two incompatible ways for creating objects.
With prototypes, all the instances share the same function
With closures, each instance has its own function (with its specific closure)
By…

viebel
- 19,372
- 10
- 49
- 83
-1
votes
1 answer
Why is access to private static members through a subclass forbidden?
From MDN Web Docs:
There is a restriction on private static fields: only the class which defines the private static field can access the field. This can lead to unexpected behavior when using this. In the following example, this refers to the…

Géry Ogam
- 6,336
- 4
- 38
- 67
-1
votes
2 answers
Why is the syntax of the destructor ~classname?
The syntax of the destructor is ~classname. This results in the need to explicitly write the type of object in the destructor call. To avoid this, C++17 introduced std::destroy_at.
So, what was Bjarne Stroustrup's original rationale for choosing the…

Blackteahamburger
- 595
- 1
- 18
-1
votes
2 answers
Design reason behind having some functions modify the object in-place
What is the design reason behind having random.shuffle modify the list in-place, instead of returning a new one?
Given that, for instance, str.replace() return a new string, and could not be any other way given that strings are immutable, wouldn't…

robertspierre
- 3,218
- 2
- 31
- 46
-1
votes
2 answers
Why does C# 9.0 have a "with" keyword instead of using existing syntax?
The C# 9.0 with keyword facilitates the creation of new records from existing records.
My question is: what technical reasons did or could motivate introducing this specific feature with a new keyword and syntax instead of just generating a new…

cdiggins
- 17,602
- 7
- 105
- 102
-1
votes
1 answer
What is the purpose of the `try` keyword in Swift?
Before you relieve the itching in your fingertips, I already understand:
how and when to use the try keyword
the differences between the try, try?, and try! keywords
What I want to understand is what the use of the unadorned try keyword buys me…

Integer Poet
- 747
- 5
- 19
-1
votes
2 answers
Why are method-local static variables bound to class and not to instances?
In this class
struct A
{
...
void method()
{
static x=0;
x++;
...
}
}
for each instance of A, a call to method() will increment x for all instances.
I expected x to be incremented for the instance in which…

slashmais
- 7,069
- 9
- 54
- 80
-1
votes
1 answer
Why is it Possible in C/C++ to Include a Header Multiple Times?
Considering the efforts it goes to add include guards to each header file and the added possibilities of errors they introduce (e.g. using the same macro name in more than one file), why are they not build into the language as default…

pooya13
- 2,060
- 2
- 23
- 29
-1
votes
1 answer
What is the reason that the designers of Rust chose the symbols !/&&/|| instead of the words not/and/or?
What was the rationale used for choosing the operators !/&&/|| over not/and/or? Is there some history behind it, or was it just a preference thing?
Some ideas I've had:
Rust followed C / C++. However, in the case of for-each loops, the more…

O.O.
- 828
- 8
- 17
-1
votes
2 answers
Compiler error - "use of unassigned local variable". what can go wrong?
Almost every blog I read says compiler flagging error "use of unassigned local variable" says its design decision because history says that unassigned variable are source of bug and compiler wants to stop you doing that.
I am not sure how assigning…

rahulaga-msft
- 3,964
- 6
- 26
- 44
-1
votes
3 answers
What problems would you foresee with my 'using block' construct being added to C++?
Header files with declarations like this:
void FooBar(System::Network::Win32::Sockets::Handle handle, System::Network::Win32::Sockets::Error& error /*, more fully-qualified param
declarations... */);
are common in certain frameworks. And using…

Omnifarious
- 54,333
- 19
- 131
- 194
-1
votes
2 answers
Scripting Language Design?
If I were to go to a dev. company and say "Please build me 'this' scripting language", are there any specific documents, and what types of documents that I should create, so they know exactly what I am wanting?
Any guidance is much…
anon271334