Questions tagged [language-design]

Questions involving the design and structure of programming languages.

Filter by
Sorted by
Tagged with
0 votes
1 answer
72 views

Can we reliably use unaligned scalars on contemporary hardware?

Processors have come a long way in their handling of unaligned data - from crashing at the very notion of it, through suffering severe penalties, all the way to having almost no impact. I suppose it ...
  • 623
2 votes
4 answers
324 views

What are the trade-offs between garbage collection and Automatic Reference Counting?

By "Automatic Reference Counting", I am refering to the specific feature of the Clang compiler. By "Garbage Collection", I am refering to Tracing Garbage Collection, not to "...
1 vote
3 answers
451 views

Why does HTML collapse whitespace?

I've been trying to better understand (at least at a high level) why the early versions of HTML were designed the way they were. Most of the decisions make sense; I can deduce (at least at a high ...
7 votes
6 answers
2k views

What is the purpose of a delegate type variable?

In C#, we have delegates, which are essentially variables (holders) for methods that follow a signature. So, I could write delegate void MyDelegate(int num); MyDelegate myMethodHolder; Now, ...
  • 181
3 votes
3 answers
409 views

Is there any performance hit associated by the definition of a static constructor or due to availability of it?

This question is mostly related to the way language implementer do implements static class initalization (pretty specialized question). It is for curiosity and also to potentially improve my code to ...
2 votes
1 answer
167 views

Is there a language implemented as a neuron network?

Does there exist some language whose execution model is implemented as a neuron network, or maybe as some other type of a network/grid (e.g. network of finite automata)? That is, specifically, without ...
  • 269
0 votes
2 answers
572 views

How can Python, a language that supports Object Oriented Programming, be implemented in C, which is not an Object Oriented Programming language?

To my understanding, C does not have the concept of objects, then how can Python be implemented in C to support something that C can not? How is the concept of "Object" modeled in C? What is ...
  • 39
2 votes
1 answer
91 views

Hot reloading anonymous functions in a custom scripting language

I am implementing anonymous functions (lambdas) in a scripting language that supports hot reloading. The language currently supports passing user defined functions (pointers) to plugin functions which ...
4 votes
4 answers
339 views

Is there a cancel after certain amount of time try catch type of block?

I'm going through a beginner programming learning guides and the teacher brings up the try catch block paradigm. The code you put in the try block is run and if an error happens the code in the catch ...
8 votes
1 answer
350 views

What type of syntax notation is this?

SQL Server documentation uses this notation, which is very easy to understand and consume. Is this a BNF Syntax Diagram? Or is this a different type of notation? Source: SQL server documentation page ...
10 votes
6 answers
1k views

Do any programming languages use types as values? Would there be any point?

The standard way that types are handled in programming languages that have such a concept, is that they are: removed entirely at compile time and are just used to determine memory layout, function ...
  • 1,277
-1 votes
1 answer
69 views

Appropriate base type for simply typed lambda calculus

Given the following hypothetical programming language: Intended for practical programming A simply typed lambda calculus (STLC) All objects are functions, based on Church encodings I am aware that ...
4 votes
5 answers
2k views

Why don't languages like C have NAND operators?

I know that some golfing languages like APL have a dedicated NAND operator, but I'm thinking about languages like C, C++, Java, Rust, Go, Swift, Kotlin, even instruction sets, etc. since these are the ...
  • 486
-1 votes
3 answers
488 views

Why are constants declared with `let`?

A few weeks ago, I went on Udemy course on Swift, the instructor mentioned that constants are called let in Swift because it's standard in OOP (JavaScript uses it for example). I know this may seem ...
60 votes
9 answers
7k views

Why do "checked exceptions", i.e., "value-or-error return values", work well in Rust and Go but not in Java?

Java has "checked exceptions", which force the caller of the method to either handle an exception or to rethrow it, e.g. // requires ParseException to be handled or rethrown int i = ...
  • 9,466
-1 votes
1 answer
170 views

What advantage is gained by continuing to not provide an UPSERT statement in T-SQL (or any given major SQL dialect)?

This question is asking about a generally applicable engineering principle. It is using T-SQL as a specific example, but the question is about the engineering principles behind major SQL dialects in ...
  • 3,085
3 votes
1 answer
119 views

Choosing the design of a scientific DSL: purely or impurely functional?

My aim is to create a language specific to the scientific field (which would be used mainly in the field of machine learning and physics) which would be based on the functional paradigm, a paradigm ...
  • 219
5 votes
5 answers
516 views

Reasons to use (and not to use) a repeated delimiter to escape that delimiter?

For the designer of a language syntax, what are some reasons to choose a repeated delimiter to escape that delimiter, instead of having a separate escape character to escape that delimiter. A common ...
1 vote
1 answer
82 views

How do covariant parameterized types nested inside invariant parameterized types act?

Here is a concrete example of what I'm asking about: MutableList[ImmutableList[Object]] Where ImmutableList is covariant wrt its first parameter, but MutableList is invariant wrt its first parameter. ...
1 vote
4 answers
621 views

Why have separate keywords for 'extends' and 'implements' in Java? [closed]

Short answer that I've come to accept: Firstly, it helps with readability, being able to see which is the superclass apart from interfaces. Secondly, though 'extends' and 'implements' do the same ...
  • 308
5 votes
1 answer
218 views

Real-world scenarios for protected inheritance

C++ supports protected inheritance: A class can derive from a base class B in a way that the "outside" world doesn't see that class "as a B" but the class itself and it's derived ...
1 vote
2 answers
274 views

Is there a statically typed programming language that implements Polymorphism without using a superclass or an interface?

Is there a statically typed programming language that implements Polymorphism without using a superclass or an interface (if such implementation is even possible)?
  • 119
0 votes
1 answer
129 views

How to deal with metaclasses in strong-typed language : is it ok to mix classes and metaclasses?

I'm working on a programming language design ans I'm struggling with how I should type the concept of Class. Let me show you some code to illustrate my problem : class MyClass { } function ...
  • 241
2 votes
4 answers
213 views

A language design with variable qualifier

I am planning to design a programming language. One challenge I face with is whether it is a good idea to have const as a variable qualifier instead of a type qualifier. For example in C++: const int ...
  • 29
10 votes
4 answers
800 views

Why does C++ have classes?

The title is deceptive; the question is really "why does C++ have classes and not only structs?" Often, people ask why C++ has structs if they are functionally equivalent to classes. The answer is (...
2 votes
1 answer
332 views

Can syntactic `await` always be elided?

(This question isn't a duplicate of Why do we need the async keyword? - it's more of the opposite: I'm not questioning the async keyword - I'm asking if compilers could elide the use of await ...
  • 680
91 votes
11 answers
19k views

Why F#, Rust and others use Option type instead of nullable types like C# 8 or TypeScript?

AFAIK, Option type will have runtime overhead, while nullable types won't, because Option time is an enum (consuming memory). Why not just mark optional references as optional, then the compiler can ...
0 votes
2 answers
781 views

In C++, Why do bitwise operators convert 8 or 16 bit integers to 32 bit?

Is there a logical reason why the integer is upgraded to 32+ bits? I was trying to make an 8bit mask, and found myself a bit disappointed that the upgrade will corrupt my equations. sizeof( quint8(0)...
  • 3,389
4 votes
1 answer
462 views

Design decisions behind access modifiers in C#

I'm currently writing a small language of my own, and have been considering the difference between the C++ style, where the access modifier applies to a block of members, and the C#/Java style, where ...
2 votes
1 answer
267 views

Why did C++11 add find_if() instead of overloading find()?

Why did c++11 add a separate find_if() instead of simply overloading the existing find()? Wouldn't overloading the function be sufficient?
0 votes
4 answers
234 views

Language design : use equals symbol = both for affectation and comparison, like in MySQL

I'm currently designing a database query language and I came to wonder what should be the best syntax for the comparison operator. Most modern languages use ==, but amongst the database languages ...
  • 241
43 votes
5 answers
9k views

What makes a scripting language "embeddable"?

According to my experience, Wikipedia and prior answers, a scripting language is vague category of languages which are high-level (no manual memory management) and interpreted. Popular examples are ...
  • 593
-4 votes
1 answer
232 views

Is it a good idea to use a Parser Combinator to parse unstructured input?

I'm writing a parser that needs to accept unstructured input. By that I mean it needs to take in a raw signal (text, in this case) and look for significant character sequences while accumulating the ...
29 votes
9 answers
9k views

In OOP, isn't the 'protected' keyword required?

Some modern languages (e.g. Swift, Dart) do not support the protected access modifier keyword. Swift is a protocol-oriented language, but I've heard that Dart is a completely object-oriented language. ...
52 votes
7 answers
12k views

Is it a bad design for a programming language to allow spaces in identifiers? [closed]

Some (link 1, link 2) programming languages allow spaces in their identifiers (e.g. variables, procedures) but most of them don't and instead programmers usually use camel case, snake case and other ...
14 votes
1 answer
778 views

Why was "self" chosen over "this" for the name of the first parameter of python methods?

What was the rationale for choosing the name self instead of this when defining class methods in Python? Yes, of course, you can name it whatever you want - but the widely agreed-upon name for the ...
-3 votes
2 answers
276 views

Ideas for a more compact for loop? [closed]

A for loop is quite an important part of a programming language so you don't want to spend a lot of time typing it out every time for prototyping. An example of a quite ugly syntax is: for(int x=0;x&...
  • 253
0 votes
2 answers
207 views

What is the reason python uses range in for loops?

Is there some philosophical reasoning behind why python uses this syntax: for x in range(1,11,3): instead of, for example, the BASIC syntax: for x = 1 to 10 step 3 If Python is supposed to be more ...
  • 253
0 votes
1 answer
208 views

Are parser generators useful for parsing a shell language?

From my understanding, parser generators accept as input some form of context-free grammar description. The context-sensitive features are handled during semantic rather than syntactic analysis (...
4 votes
1 answer
5k views

Storage of global variables

In C, global variables are stored with the program code. I.e. the space to hold them is part of the object file (either in the data or bss section), instead of being allocated during execution (to ...
  • 159
1 vote
1 answer
267 views

What is the BNF (or BNF-like) syntax for a specific number of repetitions?

I would like to write something like <byte> ::= <bit>*8 to mean that a <byte> is a sequence of exactly 8 <bit>'s. Is there a way to do this in BNF[1][2] or a widely used ...
14 votes
5 answers
3k views

Can every language be categorized as either compiled or interpreted? [duplicate]

As per Wikipedia: A compiled language is a programming language whose implementations are typically compilers (translators that generate machine code from source code). And an interpreted language is ...
  • 778
3 votes
3 answers
509 views

Language design : How to type higher order functions parameters?

I'm trying to design a theoretical programming language and I'm facing a problem with high order functions. The language is strong-typed, so the way to define a standard function is like so : ...
  • 241
1 vote
2 answers
267 views

Is it possible to bootstrap a transpiled language?

There're multiple topics about bootstrapping a compiled language, languages that are compiled into machine code directly; However, I can't find good explanation about bootstrapping a transpiled ...
2 votes
3 answers
434 views

Why are Lisp programs a sequence of S-expressions and not a single list?

This is quite basic question that started puzzling me recently while studying Lisp (and derivatives). I have read some Lisp books and web sites and this subject is somewhat obscured by other Lisp ...
  • 31
3 votes
3 answers
358 views

What motivates the design of the root Object type in Java and C#?

In Java and C#, all classes derive from the root class Object (java.lang.Object and System.Object respectively). In both languages/libraries this class comes with a set of methods that are inherited ...
  • 680
2 votes
2 answers
387 views

Why does C# type pattern matching use a different variable scoping behavior than traditional switch blocks?

Traditional switch blocks have one scope, so the following throws a compiler error "A local variable or function named 'message' is already defined in this scope": switch(value) { case 1: ...
  • 859
1 vote
1 answer
175 views

Question about Backus-NaurForm (BNF)

To write the grammar for Whole Numbers (0,1,2...) in BNF, we may write: Number ::⇒ Digit MoreDigits MoreDigits ::⇒ MoreDigits ::⇒ Number Digit ::⇒ 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 For a ...
5 votes
3 answers
459 views

Why datatypes are marked as thread-safe instead of procedures?

In Rust, Send (or Sync) marker traits are used to indicate whether a value of a type (or a reference to that) can be worked on within threaded context. However, it is an attribute of a function or a ...
1 vote
2 answers
2k views

What does the colon before the name mean in this JSON like string?

I encountered this string that looks like JSON syntax but I've never seen a property with a colon before it and not with a backwards greater than or equals sign: Badge { :id=>36, :name=&...

1
2 3 4 5
10