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
5 votes
5 answers
859 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
29 votes
11 answers
18k 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
176 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
352 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
  • 2,552
-1 votes
1 answer
216 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
  • 9
2 votes
4 answers
358 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
2 votes
0 answers
127 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
  • 121
5 votes
4 answers
2k views

Creating a new language with Rust without Garbage Collection?

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
  • 153
8 votes
2 answers
763 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
42 votes
6 answers
12k 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
502 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
143 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
223 views

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

...
rapasite's user avatar
2 votes
0 answers
80 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
  • 121
14 votes
3 answers
519 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
  • 16.3k
22 votes
6 answers
2k 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
268 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
166 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
2 votes
1 answer
202 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
  • 153
2 votes
0 answers
163 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
42 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,747
1 vote
1 answer
131 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,733
25 votes
6 answers
2k 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,633
11 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,401
2 votes
3 answers
181 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
  • 288
13 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,563
4 votes
1 answer
118 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
134 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
526 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,733
4 votes
3 answers
232 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,534
3 votes
1 answer
149 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
317 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
300 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
  • 2,552
2 votes
3 answers
285 views

What are the differences between designing a print function Python-style as opposed to C-style?

A regular Python print statement might look like this (Dart printing looks similar to this): print(a_number) # for a number print(a_string) # for a string These ...
Redz's user avatar
  • 900
7 votes
3 answers
264 views

When is ABI stability “worth it”?

ABI stands for application binary interface, and it represents how different precompiled components of a program interact. This can be a program calling out to an OS function or part of the language ...
Bbrk24's user avatar
  • 8,563
2 votes
0 answers
164 views

Why would an APL implementation include "Deep Transpose"?

APL64 includes a ⎕DTR system function which, as far as I can tell, is equivalent to ⍉¨⍉ i.e. the transposed outer array with ...
Adám's user avatar
  • 3,018
25 votes
6 answers
1k 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 ...
Michael Homer's user avatar
  • 10.9k
5 votes
2 answers
318 views

How do you solve Expression Problem in your language design?

The Expression Problem refers to add new representations and new behaviors to the original data types without modifying the source code. This restriction is very common, the interface may be a ...
Aster's user avatar
  • 2,552
5 votes
4 answers
251 views

How can multiline lambdas be designed in indent based languages?

How can multiline lambdas be designed in indent based languages? In Go, language with curly brackets, I will write multiline lambdas like this: ...
nchistov's user avatar
  • 1,521
-5 votes
1 answer
157 views

Are you allowed to use almost identical language to another language? [closed]

In Python, you use the term print. If there was another language that worked in the exact same way as Python, but used slightly different terms (like ...
taylor.2317's user avatar
3 votes
4 answers
180 views

What are the different ways of implementing special methods?

What mechanisms could languages use to detect certain methods and handle them specially? For example, in Python, special methods are named differently, using double underscores: ...
nchistov's user avatar
  • 1,521
3 votes
2 answers
488 views

Why do many programming languages use parentheses `()` for function definitions and calls?

Why do many programming languages use brackets () for function definitions and calls? For example, in Python: def f(): ... f() ...
nchistov's user avatar
  • 1,521
7 votes
2 answers
402 views

Why color literals?

One of the stranger features of Swift is color literals -- invocations of the #colorLiteral macro that look like colored squares in Xcode. In this image, the macro ...
Bbrk24's user avatar
  • 8,563
7 votes
4 answers
356 views

What are the advantages of allowing users to directly handle memory addresses with pointers?

Pointers are variables that store a memory address. They allow the programmer to directly deal with memory which can be used to pass variables by reference or even for performance reasons. However, ...
FireTheLost's user avatar
  • 1,553
5 votes
1 answer
139 views

How should unapplied method references be handled?

Several OO languages allow you to grab unapplied method references. Some, such as Kotlin or Python, have them accessible from the class itself and just append self ...
Bbrk24's user avatar
  • 8,563
7 votes
1 answer
158 views

Disjoint language extensions (C++ and Objective-C)

Objective-C and C++ are both extensions of C (or at least started out to be). So for the purpose of this question I allow myself the slightly inaccurate assumption that both languages are pure ...
chrysante's user avatar
  • 628
4 votes
3 answers
196 views

What syntax could infix method calls use?

In my language, I intend to have infix methods. The utility of this syntax feature is to express methods with the semantics of taking two objects, probably of the same type, in semantically equivalent ...
abel1502's user avatar
  • 2,459
4 votes
2 answers
356 views

What does the name of a programming language say about the language? [closed]

Names can be chosen for a programming language in order to communicate information about that programming language. For example, C is named C because many of its features are taken from an earlier ...
Redz's user avatar
  • 900
2 votes
1 answer
130 views

What are grammar checker tools that can be used when designing a new language?

When designing a programming language, before even writing the compiler's code, what are existing tools allowing to write a grammar, which can then check it for ambiguities and test it with sample ...
privpub19's user avatar
1 vote
3 answers
135 views

How can I get around ambiguity with prefix notation?

I’m designing a language which uses Prefix (Polish) notation when applying functions. However, I’ve run into a problem: I’m not sure how to distinguish between function calls and variable references, ...
Jacob's user avatar
  • 323