Frequent Questions
175 questions
154
votes
1
answer
51k
views
How should I read type system notation?
I sometimes read articles or papers about type systems that use some funny-looking, two-dimensional notation with lots of unfamiliar symbols and Greek letters. The notation seems mathematical, but it’...
90
votes
7
answers
13k
views
How can we compare expressive power between two Turing-complete languages?
Is this possible?
Is there an accepted (and unambiguous) notion of "expressive power" that could differ between two different Turing-complete languages?
It seems like, for example, Python is ...
18
votes
8
answers
1k
views
What are advantages and disadvantages of C-style for loops?
There are two kinds of for loops: the kind that Python has, also called a "foreach":
for i in [1, 2, 3]:
print(i)
and the kind that C has, which is ...
18
votes
8
answers
2k
views
What are the advantages/disadvantages of prefix type syntax?
Famously, C’s functions and variables have their types specified before the function/variable name:
bar foo() {...}
bar foo = ...;
Most older C derivatives also ...
17
votes
1
answer
1k
views
How can we define a denotational semantics for recursive functions?
Motivation
I want to define a denotational semantics (see here or here) for recursive functions in my language, by representing them as mathematical functions.
Background
Consider a simple language ...
35
votes
10
answers
4k
views
Why would a language have a concept of undefined behavior instead of raising an error?
Certain constructs or conditions in programming just are not allowed. Languages such as Java or Swift handle these by raising an error when encountered. C and C++ on the other hand say 'Anything could ...
30
votes
6
answers
2k
views
How have modern language designs dealt with Unicode strings?
Languages developed over the last fifteen years or so have been within the era where Unicode is ubiquitous, and so could design their core string types accordingly. There are a lot of new issues that ...
28
votes
6
answers
2k
views
Why don't many languages have integer range types?
An integer range type like 0..100 means that a value can be any integer in that range. Arithmetic operations on range types produce other range types, for example ...
22
votes
14
answers
5k
views
Preserving backwards compatibility when adding new keywords
Inspired by Why do keywords have to be reserved words?
Suppose that you're the BDFL of a programming language. Version 1 of the language becomes decently popular. A few years later, you decide to ...
18
votes
7
answers
918
views
What are the pros and cons of an Option type in comparison to nullable types?
There seem to be two main ways that languages handle the same concept:
Nullable types, like Kotlin, C#, and many other OOP languages
Options, like Rust and Haskell,...
16
votes
1
answer
3k
views
What are denotational semantics, and what are they useful for?
The semantics of a language can be specified either by denotational semantics or operational semantics. These are sometimes summarised as:
Denotational semantics specify the "meaning" of ...
14
votes
3
answers
844
views
How do language designers determine what feature flags are part of the standard library and what are part of syntax?
Java has the @Override annotation. This annotation, when applied on a method, basically says that this method is intended to be an override of a superclass method. ...
14
votes
3
answers
2k
views
What does it mean for a type system or language to be "sound"?
Type systems and programming languages are sometimes described as being sound, or unsound, or sometimes just "not sound". What does being sound actually imply about them? Is it always the ...
12
votes
2
answers
493
views
What are the run-time implications of gradual typing?
Statically-typed languages specify the types of variables and functions and reject programs they know won't work before they run. Dynamically-typed languages don't include these annotations or checks, ...
10
votes
2
answers
421
views
How can isolated focus on syntax be counterproductive in the earlier stages of a language's design?
I'm relatively new to the field of PL design, and I want to build a language. Before I start, I want to learn from the languages that have come before mine. Syntax seems like it matters, and so I want ...