Skip to main content
91 votes

How can we compare expressive power between two Turing-complete languages?

Surprisingly yes, this is possible! This is actually pretty important for people that work on optimizing compilers. If I add this new feature, will it break any existing optimization pass? I will show ...
David Young's user avatar
  • 2,257
49 votes

I want to make breaking changes to my language, what techniques exist to allow a smooth transition of the ecosystem?

Other languages have released many major versions without as much drama. What techniques can be used to speed up the transition period? We thought about this A LOT on the C# design team. A few ...
Eric Lippert's user avatar
  • 3,459
46 votes

What's the relation between a language being managed and its compiler being reversible?

The main reason why Java (and in theory C# as well) is more easily decompilable than languages which get compiled to native machine code is that Java and C# both provide a feature which makes this ...
Doc Brown's user avatar
  • 561
39 votes

What are different ways of handling runtime errors?

Monadic errors, like Result<T> in Rust. You need to manually catch the error in order to get the result. Exceptions, like in Kotlin/Scala/Python/C#. By ...
ice1000's user avatar
  • 2,454
36 votes
Accepted

Why do some PL choose to have a dedicated keyword for elseif instead of like in C?

They do this to avoid the dangling else problem. In many programming languages, the syntax for else-if statements is ambiguous. For example, consider the following C program: ...
hugomg's user avatar
  • 1,345
31 votes

What are the drawbacks of using indentation for code blocks?

Awkward code pasting Copying/Cutting and pasting code becomes less than trivial, since the new location may need less or more indentation. An IDE that's aware of the language in use may be able to ...
Adám's user avatar
  • 3,156
31 votes

What are the drawbacks of using indentation for code blocks?

Writing a book Writing a book with code blocks in this language will be difficult, because between two pages, if a code block is cut in half, readers will have a hard time to figure out how many ...
ice1000's user avatar
  • 2,454
23 votes

Why do some PL choose to have a dedicated keyword for elseif instead of like in C?

The way the chaining of else if blocks is defined in C follows naturally from the way the grammar allows for braceless blocks: ...
zdimension's user avatar
22 votes
Accepted

Why does Rust have an infinite loop construct?

The rust loop {} syntax has a unique feature: it has a return value. Consider this code: ...
mousetail's user avatar
  • 8,359
21 votes

What are the drawbacks of using indentation for code blocks?

Limited auto-formatting Complete auto-formatting isn't possible. For a language where proper indentation and/or code layout can be inferred from the non-whitespace syntax, it is possible to completely ...
Adám's user avatar
  • 3,156
21 votes

What are the drawbacks of using indentation for code blocks?

Tabs and Spaces In languages that support both tabs and spaces for indentation (*cough* Python), the compiler/interpreter often gets angry if you accidentally mix them, and keeping the one your ...
Ginger's user avatar
  • 2,629
21 votes

Which horizontal whitespace should be supported?

Tabs and spaces are those whitespace characters most widely supported by common keyboard layouts. They’re both available in ASCII, and likely to be preserved by systems that don’t correctly handle ...
Jon Purdy's user avatar
  • 2,437
20 votes
Accepted

What are the syntax options for implementing a ternary "if" operator?

Here are some options (including the ones you mentioned): C-family languages (e.g., C, C++, Java, JavaScript): Syntax: condition ? ifTrue : ifFalse Advantage: ...
The Thonnu's user avatar
  • 1,518
20 votes

I want to make breaking changes to my language, what techniques exist to allow a smooth transition of the ecosystem?

Make breaking changes opt-in ahead of time This is the route taken by Swift and Python, for example. Python lets you do this at the source level, per-file, with the special form ...
Bbrk24's user avatar
  • 9,067
19 votes

What are different ways of handling runtime errors?

Interrupts especially the Processor / Software interrupts. It temporarily stops execution of the current thread, handles the event and (optionally) resumes the thread. (source)
Glorfindel's user avatar
  • 1,503
19 votes

What are different ways of handling runtime errors?

Algebraic effects This is a concept I learned relatively recently, and it’s a concept found exclusively in academic and functional languages for now. Effectively, it is a resumable exception. When you ...
Seggan's user avatar
  • 2,723
16 votes

What are different ways of handling runtime errors?

A great blog post with many different techniques is the The [Midori] Error Model by Joe Duffy. In addition to that and the other answers, I want to add Lisp conditions and restarts. See here, here, ...
Gavin D. Howard's user avatar
16 votes

Why do some PL choose to have a dedicated keyword for elseif instead of like in C?

Another reason for elseif/elsif/elif is if the conditional construct has a keyword terminator, like the shell's fi or Lua's <...
Norman Ramsey's user avatar
16 votes

What are the drawbacks of using indentation for code blocks?

One-liners and code golf It will be difficult to write simple one-line code if code blocks must start at the second line. In CLI (command-line interface) applications, there are many use cases like <...
ice1000's user avatar
  • 2,454
15 votes

What are the drawbacks of using indentation for code blocks?

Accessibility For blind and visually impaired (B/VI) programmers, using indentation-sensitive languages with a screenreader has some extra challenges compared to free-format languages. The most ...
Jon Purdy's user avatar
  • 2,437
14 votes

What's the relation between a language being managed and its compiler being reversible?

Your specific questions are not really answerable, because your question contains a number of assumptions that are not true (or at least, not entirely accurate). the compilation process was ...
Philip Kendall's user avatar
13 votes

What are the drawbacks of using indentation for code blocks?

There is more than one way to define layout-sensitive programming languages, where indentation matters. The Python way is different from the Haskell way, which is different from the F# way... For ...
hugomg's user avatar
  • 1,345
13 votes

What are the drawbacks of using indentation for code blocks?

Source code size For interpreted languages, where the source needs to be sent over the Internet, like JavaScript, source code size is incredibly important. Having the option to just remove all white-...
mousetail's user avatar
  • 8,359
13 votes

Why do some PL choose to have a dedicated keyword for elseif instead of like in C?

They need one In C-style languages like JS, you can put a single statement after an if to run just that one: ...
Rydwolf Programs's user avatar
13 votes

What are different ways of handling runtime errors?

Aborts/Panics This is the system Rust uses: There's a "result" type (Result<T>) for recoverable errors, like a malformed URL in a HTTP library, and ...
Ginger's user avatar
  • 2,629
13 votes

What are the syntax options for implementing a ternary "if" operator?

There's always the Smalltalk postfix form. result = condition ifTrue: [ ... ] ifFalse: [ ... ]. This has the benefit of not even being special syntax. It's just an ...
Silvio Mayolo's user avatar
12 votes

What are the different ways of handling multiple return values?

Push them onto the stack This really only applies to stack-based languages, and perhaps Assembly. The good thing about this approach is that its somewhat more natural to work with the returned values. ...
user's user avatar
  • 842
11 votes

What are the different ways of handling multiple return values?

Custom types In languages such as Java and Kotlin, which really love their nominal typing, you would make a new class specific to that one function. For example, ...
user's user avatar
  • 842

Only top scored, non community-wiki answers of a minimum length are eligible