A tag for questions related to the design of any aspect of programming languages.
Questions tagged [language-design]
1363 questions
61
votes
5 answers
Why is Clojure dynamically typed?
One thing I like very much is reading about different programming languages. Currently, I'm learning Scala but that doesn't mean I'm not interested in Groovy, Clojure, Python, and many others. All these languages have a unique look and feel and some…

lhk
- 27,458
- 30
- 122
- 201
60
votes
4 answers
Why can't C# member names be the same as the enclosing type name?
In C#, the following code doesn't compile:
class Foo {
public string Foo;
}
The question is: why?
More exactly, I understand that this doesn't compile because (I quote):
member names cannot be the same as their enclosing type
Ok, fine. I…

Vivien Barousse
- 20,555
- 2
- 63
- 64
59
votes
2 answers
Why are slices in Python 3 still copies and not views?
As I only now noticed after commenting on this answer, slices in Python 3 return shallow copies of whatever they're slicing rather than views. Why is this still the case? Even leaving aside numpy's usage of views rather than copies for slicing, the…

JAB
- 20,783
- 6
- 71
- 80
59
votes
4 answers
James Gosling's explanation of why Java's byte is signed
I was initially surprised that Java decides to specify that byte is signed, with a range from -128..127 (inclusive). I'm under the impression that most 8-bit number representations are unsigned, with a range of 0..255 instead (e.g. IPv4 in…

polygenelubricants
- 376,812
- 128
- 561
- 623
59
votes
12 answers
Could a final variable be reassigned in catch, even if assignment is last operation in try?
I am quite convinced that here
final int i;
try { i = calculateIndex(); }
catch (Exception e) { i = 1; }
i cannot possibly have already been assigned if control reaches the catch-block. However, Java compiler disagrees and claims the final local…

Marko Topolnik
- 195,646
- 29
- 319
- 436
58
votes
4 answers
What is the difference between a class and a type in Scala (and Java)?
Scala
Where can differences between a class and a type be observed in Scala and why is this distinction important?
Is it only a consideration from the language design point-of-view or has it "practical" impact when programming Scala?
Or is it…

soc
- 27,983
- 20
- 111
- 215
58
votes
6 answers
Why aren't C# static class extension methods supported?
I know from this question that extension methods can only operate on class instances, not the static class itself. This means I can't extend useful static classes like Convert and Math.
What I want to know is, why is this the case? From the link…

Justin Morgan
- 2,427
- 2
- 16
- 19
58
votes
2 answers
What is the operator "" in C++?
I fell on this page where the author talks about the standardisation of the operator "":
The decision of the C++ standards committee to standardise operator ""
was [...]
What is he/she talking about? I can't find any information about this, and…

yolenoyer
- 8,797
- 2
- 27
- 61
58
votes
3 answers
OptionalInt vs Optional
When scrolling through the documentation for the java.util package, I was surpised to find that Optional and OptionalInt have no relationship to each other. This seems very hard to belive, as it suggests that they are unrelated classes.
Why…

Michael
- 2,673
- 1
- 16
- 27
57
votes
5 answers
Why must I provide 'operator ==' when 'operator <=>' is enough?
#include
struct A
{
int n;
auto operator<=>(A const& other) const
{
if (n < other.n)
{
return std::strong_ordering::less;
}
else if (n > other.n)
{
return…

xmllmx
- 39,765
- 26
- 162
- 323
53
votes
6 answers
Why does Python's itertools.permutations contain duplicates? (When the original list has duplicates)
It is universally agreed that a list of n distinct symbols has n! permutations. However, when the symbols are not distinct, the most common convention, in mathematics and elsewhere, seems to be to count only distinct permutations. Thus the…

ShreevatsaR
- 38,402
- 17
- 102
- 126
53
votes
12 answers
New language on top of PHP?
I'm a PHP developer. I like PHP! It is a really good language if you know how to use it, but I know it allows very bad design sometimes.
It reminds me of JavaScript which has good parts and bad parts. One particular project, CoffeeScript, tries to…

Eber Freitas Dias
- 879
- 6
- 18
53
votes
4 answers
What is typestate?
What does TypeState refer to in respect to language design? I saw it mentioned in some discussions regarding a new language by mozilla called Rust.

Brad The App Guy
- 16,255
- 2
- 41
- 60
52
votes
7 answers
What is the point of make_heap?
Can someone please tell me the point of the STL heap function templates like std::make_heap? Why would anyone ever use them? Is there a practical use?

rlbond
- 65,341
- 56
- 178
- 228
52
votes
5 answers
Why doesn't Scala have static members inside a class?
I know you can define them indirectly achieve something similar with companion objects but I am wondering why as a language design were statics dropped out of class definitions.

numan salati
- 19,394
- 9
- 63
- 66