Questions tagged [language-design]
Questions involving the design and structure of programming languages.
491 questions
11votes
6answers
2kviews
Is there precedent for a language that allows the "early return" pattern to go between function call boundaries?
Here's some C# that should illustrate what I'm asking. Thing FindThing(string key) { // Search for the thing with the right key. foreach (Thing th in things) { // Found it? if (...
1vote
1answer
98views
Go, Error Handling, and Big Text Files - express error semantics in types
The title Go, Error Handling, and Big Text Files is a blog post from Wesley Aptekar-Cassels from 2021. In this blog post he reports about a problem he faced parsing long text files. He tried scanner :=...
2votes
1answer
303views
Swift: What is the rationale behind forbidding named parameters for closures?
In Swift, functions can be defined with named parameters, for example: func greet(person: String) -> String { ... } which need to be used when the function is called : greet(person: "Anna&...
5votes
2answers
661views
Why did Python designers decide not to declare vars? [closed]
In Python when you want a local variable, you just assign to it x = 10. In most modern languages you declare local vars (regardless of type): JavaScript: let/const/var Swift: let/var Kotlin: val/var ...
4votes
5answers
384views
Why don't many languages implement an everything-before-is-a-comment symbol?
Python and PowerShell use # to denote to the parser that everything after them until the line break is a comment. They even provide block comments for multiline situations. However, there is no ...
0votes
0answers
93views
Is it possible to build a semantically unambigous grammar / language / graph?
It's been a long time that I had an idea of a semantic constraint as compiler optimizations which allows for sophisticated high level optimization allowing you to transform the AST/CFG based on a SFG (...
-1votes
2answers
180views
Could there be a <flex> tag?
<div> tags are display: block per default. <span> tags are display: inline per default. Could there be a tag that is display: flex per default? I don't mean a class, like bootstrap has. I ...
0votes
1answer
163views
Bytecode format and loading in language VMs
I am thinking about how to build a language VM. I have been able to get some of the basic constructs right, including jumps to functions within the chunk of bytecode that is currently loaded. But now ...
0votes
2answers
292views
Advantage of implicit/explicit declaration of global symbols (like functions)
In C and C++ we need to declare a function before its usage, if its definition comes after where it is called. (Well, there is also the "implicit declaration" rule in C, but it is rarely ...
5votes
1answer
2kviews
Does a programming language with ML-style modules need packages?
This is a clarification of a closed question. I've limited the scope as requested. First, a few definitions, following e.g. A modular module system. Consider any programming language with a selected ...
2votes
1answer
427views
How to model opcodes effectively for a language VM?
I am learning about building a language VM with the long-term goal of writing an own language. For guidance, I am looking at this LC3 tutorial by Justin Meiners and Building a Language VM by Fletcher ...
1vote
5answers
752views
Why don't languages auto import everything?
Why is there a such thing as import in programming languages? If a package does not exist, then trying to import it would cause an error anyway. So why don't languages just auto import ALL available ...
-1votes
1answer
155views
Is it a good idea to let keywords have different lexical rules from names of types, variables, functions, etc? [closed]
For example, keywords have a special prefix. Objective-C has @interface, @implementation, but that's for compatibility with C. It inherits all the C keywords of course, with no @. How about a language ...
5votes
1answer
515views
Why does Rust allow a leading `|` in or patterns?
In the code snippet found in this tweet, pattern matching is used like this: let (|x| x) = |_| Some(1); // same as `let (x | x) = |_| Some(1);` Which threw me off. Rust's pattern syntax is defined as:...
38votes
10answers
10kviews
Why do heavily object-oriented languages avoid having functions as a primitive type?
As has been covered to the point of parody, heavily object-oriented languages, such as C# or Java, tend to lack the feature of having functions as a primitive type. You can argue about whether or not ...