Skip to main content

Questions tagged [language-design]

For questions relating to the design of programming languages, including language semantics, syntax, type systems, data structures, or other design elements.

Filter by
Sorted by
Tagged with
17 votes
7 answers
3k views

The static keyword and clarity in language design

Across languages that use the word static as a keyword or reserved word, I have observed it to mean: "This variable, despite being declared locally, shall be ...
Karl Knechtel's user avatar
1 vote
1 answer
203 views

References in a language where everything is a reference?

I'm a big fan of Algol 68's treatment of variables. "Variables" are just constant references that point to memory allocated on the stack or on the heap. When you refer to a variable or a ...
texdr.aft's user avatar
  • 111
17 votes
10 answers
4k views

Are there any languages where conditions are not first-class expressions?

Novices writing in mainstream languages often don't realise that conditions like x < y are expressions which can occur anywhere an expression is syntactically ...
CPlus's user avatar
  • 8,261
2 votes
1 answer
254 views

What are the tradeoffs around supporting Unicode keywords and tokens?

Is the mass adoption of Unicode tokens as operators in general-purpose programming languages ​​a good idea? How acceptable is such a language to ordinary users and developers? Background I want to ...
Aster's user avatar
  • 3,198
7 votes
2 answers
495 views

Why implement function syntax as `f a b` or `f: a b` instead of `f(a,b)`?

Sorry if I am not using the correct terminology here, I'll correct it if it turns out to be that way. Programming languages such as Python or Mathematica typically have function syntax implemented as <...
CrSb0001's user avatar
  • 183
14 votes
3 answers
476 views

What makes a language 'beginner-friendly'?

When asking someone the question, "Which coding languages should a beginner learn?", the answers I most frequently get are JavaScript or Python. In both cases, a big reason for being ...
Redz's user avatar
  • 1,058
3 votes
5 answers
408 views

How to define comparators and maintain consistency

The comparative relationship between objects is very complicated, there are all comparable, partial comparison, all equal, partial equal situations. A total of twelve functions are needed. The return ...
Aster's user avatar
  • 3,198
7 votes
2 answers
475 views

Are delegates still relevant in modern C#?

Delegates have been part of the design of C# for decades. But would it be wrong to say that over time, all the uses of delegates have become better achieved through other means? (Or, dramatically ...
Eldritch Conundrum's user avatar
12 votes
4 answers
3k views

Whether the default behavior of +-×÷ should be saturation instead of wrapping when overflow?

For a long time, the rules for processing basic operations in various languages have been overflow. But this is actually very strange. The addition of two positive numbers can be a negative number, ...
Aster's user avatar
  • 3,198
40 votes
8 answers
17k views

Why is almost every programming language made in English?

Every programming language I know (Java, C++, C#, Python, etc.) are all made in English. That is, you can't, for example, type imprimir("hola") instead of ...
Daemons's user avatar
  • 505
7 votes
0 answers
407 views

What do you mean by the ‘computational model’ of a programming language?

What do you mean by the ‘computational model’ of a programming language? Are ‘abstract machines’ such as Stack, RAM, and Warren Abstract Machine (WAM) examples of computational models? Is the ...
Stephen's user avatar
  • 179
2 votes
0 answers
154 views

Issue with rules for custom DSL

I am struggle with implementing rules for a custom DSL with significant spaces. The key feature is that it requires spaces to be tracked and re-used. In most languages they are used to split tokens ...
defance's user avatar
  • 129
5 votes
0 answers
127 views

DB query language design [closed]

What are some good (academic) resources to learn about database query language design? I'm specifically interested in document databases, but all I can find is about XQuery and it's unclear to me what ...
Tilo's user avatar
  • 159
12 votes
1 answer
2k views

Async Implementation

I have recently been making my own programming language and I am finding most concepts easy to understand, however I'm not sure how to implement async/await in my language. ATM, I'm using C# to create ...
InvaderIzzy's user avatar
19 votes
3 answers
3k views

How can I specify a programming language step-by-step more formally than by providing a reference interpreter?

I want to give an exact specification of the meaning of my programming language. I know how to write an interpreter for it, but: I don't want to require people to read the interpreter code to learn ...
David Young's user avatar
  • 2,147
12 votes
9 answers
5k views

Should bytes be signed?

I’m trying to decide whether my language should provide signed or unsigned bytes, but I’m struggling to find a good reason to choose either side. Popular languages vary in their decision. For example, ...
feldentm's user avatar
  • 1,779
5 votes
4 answers
529 views

Why does C++ allow extra arguments to printf?

In the C++ standard library, the format and printf functions specifically accept extraneous arguments: It is not an error to ...
Deborah C's user avatar
5 votes
9 answers
1k views

Correctness of mixed signed/unsigned arithmetic

I'm implementing signed and unsigned integers in my language. They are represented in C as signed long and unsigned long ...
Matheus Moreira's user avatar
30 votes
11 answers
19k views

Why do so many programming languages not have a "built-in" way to do simple math functions?

Note 1: My question is not about the factorial function. It's about "simple math functions" that high-school level pocket calculators can do, but most programming languages cannot do without ...
Nike Dattani's user avatar
-2 votes
2 answers
201 views

Else-statements [closed]

Let's say your designing a new language with syntax and semantics similare to other C-style languages (C#, Java, C++, JS, etc). You want the language to have if-...
Knarf's user avatar
  • 113
1 vote
2 answers
404 views

Is it necessary to differentiate between && and & when I support overloads [closed]

It is an old tradition in programming languages to use & and | to represent bitwise operations, and ...
Aster's user avatar
  • 3,198
-1 votes
1 answer
295 views

Look behind in parsers [closed]

If Sandwich's AST generator finds that the first token is an identifier, one of two cases can be true: Function call Variable assignment It stores the identifier and checks if the next token is a = ...
The_AH's user avatar
  • 17
3 votes
4 answers
411 views

What evidence exists on using & and | as logical operators instead of && and ||?

I’m working on a small, dynamic language that isn’t going to include bitwise operators so I was thinking it was a bit unnecessary to use && and ...
user avatar
3 votes
0 answers
141 views

Unit Testing Built Into Language [closed]

I'm mostly looking to poke holes in this design, as well as suggestions on next steps. For the language I'm creating, I think I might have additional keywords and statements available just for test ...
Xtros's user avatar
  • 131
6 votes
4 answers
4k views

Does using Rust eliminate the need to implement garbage collection in a language?

I am new to language development. I am aware of Rust's ownership model that builds programs in a way that does not need garbage collection. So if I am to build a new programming language using safe ...
M4X_'s user avatar
  • 171
8 votes
2 answers
952 views

Why do many languages use square brackets for array indexing?

A lot of languages use square brackets for array indexing, and round brackets (also known as parentheses) for function calls. For example, in C: ...
G. Sliepen's user avatar
45 votes
6 answers
13k views

Why do programming languages use the asterisk * for multiplication?

Having had very little math(s) education I'm trying to bring myself up to speed for university, which currently involves teaching myself the times tables, where X ...
Hashim Aziz's user avatar
10 votes
2 answers
554 views

Can you represent a language with a group with a small/simple generator set?

I'm wondering whether its possible to construct a group where the elements are all possible valid programs, with a small or simple generator set. That way you could have a series of operations you can ...
debater-coder's user avatar
5 votes
0 answers
151 views

What are some design errors that lead to hard-to-debug code? [closed]

There are some design features in programming languages that make code written in the language difficult to debug (e.g. C's default fallthrough behavior). So it would be helpful to make a list of ...
idk's user avatar
  • 159
2 votes
1 answer
253 views

Implementing a Array programming language in C. What is the best and most efficient struct for the arrays? [closed]

...
rapasite's user avatar
3 votes
0 answers
87 views

Is it more readable to declare the return type of a function on the left side of it's name? [duplicate]

A lot of C-like programming languages (Java, C#, ...) use the following syntax for defining functions: returnType functionName(parameters...) { } Is there a ...
tigrou's user avatar
  • 131
14 votes
3 answers
649 views

Why does C# have events as a language construct, rather than in the standard library?

In C#, events and event listeners have direct support within the language, with event being a keyword, and event declarations being a special kind of member ...
kaya3's user avatar
  • 19.1k
23 votes
6 answers
3k views

Language features for making code easier to unit test

What can programming languages do to make unit testing easier? For the purposes of this question, I'm especially interested in unit testing procedural code with lots of heavy side effects. Let me ...
Greg Nisbet's user avatar
-4 votes
2 answers
301 views

What makes a very high level language? [closed]

Outline of question+justification soon to be expanded: Managing Complexity is job #1 Abstraction is our #1 tool A VHLL does abstraction best So VHLL's should be our aim Talking about VHLL's, with his ...
MicroservicesOnDDD's user avatar
3 votes
1 answer
232 views

Call-by-value: Left-to-right vs right-to-left

There are three standard evaluation strategies for the lambda calculus: Call-by-value (CBV) Call-by-name Call-by-need There are two variants of CBV that differ on how they behave with respect to ...
user76284's user avatar
  • 159
3 votes
1 answer
221 views

What syntactic ambiguities can arise in a language with optional semicolons for statement or expression separators?

What syntactic ambiguities can arise in a language with optional semicolons for statement or expression separators? Let's say that that the syntax for this language generally follows the C syntax and ...
WhiteMist's user avatar
  • 281
2 votes
0 answers
182 views

Making a Language as a Library That Runs in Another Language? [closed]

I want to make a language but I can't create all the libraries that are used in most programming languages. So I want to make a language that works in another language as a library (for example, ...
1 JustOnly 1's user avatar
43 votes
6 answers
8k views

What language design features made Lisp useful for Artificial Intelligence research?

Lisp is often claimed to be one of the "[original] favored programming language[s] for artificial intelligence (AI) research" (source, additional reference, cross-site related question that ...
lyxal's user avatar
  • 1,775
1 vote
1 answer
151 views

Fundamental trade offs in expressiveness? [closed]

Language designers and implementers face a number of trade offs. The most obvious being over complexity of design & implementation versus how easy it is to understand or use a language. The ...
Bruce Adams's user avatar
  • 2,843
26 votes
6 answers
3k views

Negative literals, or unary negated positive literals?

Are there benefits to number literal tokens including negative numbers? Or is the string -1234 being parsed as unary negation of positive number literal ...
bigyihsuan's user avatar
  • 1,821
12 votes
4 answers
2k views

Why would a language have different error handling for libraries and applications?

Rust has two popular packages for augmenting its error handling: anyhow, for libraries, created by David Tolnay. thiserror, for applications, created by David Tolnay. They control how errors are ...
BoppreH's user avatar
  • 1,441
2 votes
3 answers
232 views

Pros and cons of generalized `nil`-coalescing operators

Many languages extend their "indexing" operator . to a nil-coalescing variant ?. to deal with indexing chains such as <...
Luatic's user avatar
  • 330
14 votes
2 answers
1k views

How to prevent undecidable type systems?

Some languages have type systems complex enough to embed undecidable problems in the type system. This famous post details implementing a Turing-complete language in Rust's type system, and Swift's ...
Bbrk24's user avatar
  • 8,937
5 votes
1 answer
166 views

What parts of the code can be easily shared between the LSP and the Compiler?

I was originally thinking to design the compilier upfront as a compiler and LSP server as well, but the answers there dissuaded me from making them share all code. But, I would still like them to ...
Starship - On Strike's user avatar
-1 votes
1 answer
154 views

What is a good universal naming syntax? [closed]

Lots of languages do not clearly separate the declaration of a variable, function or type from naming that entity, or if they do it does not have a uniform syntax. Consider C++: Naming a variable: <...
G. Sliepen's user avatar
9 votes
6 answers
571 views

What is the 'type' (and correct name) of a member of an enumeration?

Consider a C style enum: enum colour { red, blue, green }; In haskell this would be: ...
Bruce Adams's user avatar
  • 2,843
4 votes
3 answers
247 views

C source compatibility versus C linker compatibility

Due to the large amount of existing code written in C, it's common for languages to provide some sort of mechanism for interoperating with C. One approach, taken by C++ and Objective C, is to make the ...
dan04's user avatar
  • 1,879
3 votes
1 answer
163 views

What are the pros and cons of showing multiple parse errors at once?

The alternative to showing multiple parse errors at once is to display and handle each error individually as they are encountered during the parsing process, which I would presume is simpler to ...
Starship - On Strike's user avatar
4 votes
2 answers
378 views

Does a simple syntax stack based language need a parser?

I have been working on a standard for a simple stack based language for a few weeks now. It has an extremely simple syntax. ...
poggingfish's user avatar
9 votes
2 answers
354 views

How do you design mutable lists?

Background I have a problem designing a list structure for my language. My language use explicitly mutability, that is, all mutability must be manually marked. But when I marked the mutability of ...
Aster's user avatar
  • 3,198