Questions tagged [language-design]

Questions involving the design and structure of programming languages.

Filter by
Sorted by
Tagged with
2
votes
1answer
376 views

I'm moving away from using global variables after 7 years, I need help figuring out the basics

Until recently I was a huge fan of global variables because they are simple and allow building solutions to problems quickly. At one point I had to make a slight change to my application: it needed ...
2
votes
2answers
492 views

The dilemma of implementing virtual inheritance

I am working on a program language, and I came to the dilemma whether it should support virtual inheritance or not. As a designer and implementer of the language, including that feature represents ...
9
votes
1answer
352 views

Name of technique for inferring type arguments of a type parameter?

Setup: Let's assume we have a type called Iterator which has a type parameter Element: interface Iterator<Element> {} Then we have an interface Iterable which has one method which will return ...
0
votes
1answer
264 views

Do any programming languages let you use other languages without restriction within them?

This may be a stupid question, and it would certainly take one Hell of a lexer, but do any extant programming languages allow you to do something like: c# (1.2) { // c# code } Perl (5) { # ...
8
votes
2answers
593 views

Only one number type in language design

I am currently learning about compiler construction and language design and I am thinking about what native datatypes I want to support in my language. Now there is a whole lot of languages that make ...
1
vote
1answer
223 views

How do languages ensure 'interior immutability'?

In C#, i can declare an immutable field on a class using readonly. This works for value types, but if its a reference type, there is nothing stopping me calling methods on the object to change its ...
6
votes
0answers
163 views

Why does GHC represent recursion in Haskell with recursive binders instead of a fixpoint operator?

GHC's Core data type represents recursion with recursive binders in the Let constructor; as I understand it, all let expressions in Haskell are effectively let rec expressions. Why does GHC use this ...
2
votes
1answer
140 views

Mark&sweep GC with automatic freeing resources

Note: I use term "resource" in opposition to memory here, resource here is file, socket, etc. Is there a language implementation that uses M&S GC (but not necessarily only that kind ¹) that is ...
5
votes
2answers
1k views

Type-based memory safety without manual memory manage or runtime garbage collection? [closed]

Let's say we wanted a typeful, pure functional programming language, like Haskell or Idris, that is aimed at systems programming without garbage collection and has no runtime (or at least not more ...
0
votes
2answers
142 views

How to validate reference use?

I use "reference" term here like in C++ world, not like in C# (for example). I use non-C++ syntax on purpose -- this is general question, not about this particular implementation. Starting something ...
12
votes
4answers
2k views

Is having a generator language facility such as `yield` a good idea?

PHP, C#, Python and likely a few other languages have a yield keyword that is used to create generator functions. In PHP: http://php.net/manual/en/language.generators.syntax.php In Python: https://...
5
votes
2answers
187 views

How to support inheritance when designing an OO language without classes

I'm designing a programming language for a game, to be used as the main way of interacting with the game, as opposed to using other methods of control, such as the arrow keys or mouse. My plan is to ...
4
votes
1answer
142 views

Tool for validation of new code syntax in existing language

Does a programming language team have any tool to validate their new ideas about new code syntax? As an example, let's assume the Java language team starts developing new feature, which requires new ...
8
votes
8answers
740 views

Is there a compelling reason why columns in SQL are nullable by default?

As a CS student, I've learned a decent number of programming languages over the years, most of which have had some concept of a "nullable" or "optional" type. Note that I'm not talking about null ...
8
votes
2answers
13k views

Why C allows multiple global declarations of the same variable but NOT multiple local declarations?

I noticed that if I declare a global variable multiple times the compiler does not even output a warning. However if I declare a local variable in a function multiple times, for example, the gcc ...
3
votes
1answer
100 views

Why do the column expressions come before the table references in SELECT queries?

It strikes me as weird that the column expressions (everything between SELECT and FROM) in an SQL SELECT statement come before the table references, when the column expressions depend directly on the ...
34
votes
3answers
5k views

Why is there no static keyword in Kotlin?

Kotlin is known primarily as a drop-in replacement for Java, but it gets rid of a well-known Java construct: the static keyword. Instead, that class-level functionality is offered mainly by companion ...
11
votes
8answers
3k views

Unifying programming and database query [closed]

Consider a common tutorial for object-oriented programming languages like C++ or Java: create a simple order processing system with objects representing accounts, orders, items etc (or something more ...
3
votes
1answer
2k views

What is the motivation for Go lang syntax? [closed]

Since the Go lang is getting popular, I started to play with it. I do derive from Java language so when I saw the Go syntax it has been a bit strange to me. sample code from go lang project site: ...
2
votes
2answers
390 views

Is implementing operator overloading with variable arity possible?

Implementing operator overloading for e.g. + (plus) isn't terribly difficult if you know it's a binary operator. One can just parse expression + expression But what if the programmer can choose ...
6
votes
2answers
696 views

OOP without Inheritance [closed]

I'm making a language, and I'm considering disallowing inheritance. To be clear, this means: class A {} //Valid interface B{} //Valid class A2 extends A {} //Invalid class B2 implements B {} //...
3
votes
6answers
233 views

Language Design: skipping occurrences of an identifier instead of accessing enclosing scope

No idea how to write a good title for this question. I'm thinking about introducing an operator in a DSL that makes hidden identifiers (like variables) accessible. Think this.foo in Java or C# to ...
8
votes
4answers
1k views

Why C++ core language is becoming fused with the standard library?

In my understanding, standard library is a whole separate piece of software than a compiler is. In my opinion, they should be kept separate. Advantages of this approach pretty much boil down to "they ...
2
votes
2answers
406 views

Automatically convert mutations in imperative code into functional actions?

I wonder if somebody tried creating a language where you can write mutations in a straightforward imperative style, and the compiler transforms the changes automatically to pure, Redux-style actions. ...
8
votes
0answers
296 views

Different kind of checked exceptions - Guarantee to only throw X

It is a widely held position that checked exceptions as implemented in Java are a bad idea. If you mark a method as throwing, calling code has to either catch the exception, or be marked as throwing, ...
4
votes
3answers
303 views

Why are minor breaking language changes not handled with transpilers?

For any successful programming language, making a breaking change to the language is extremely difficult. This is the case even for those changes where the legacy code could be reliably and ...
77
votes
14answers
17k views

Why is Arithmetic Overflow ignored?

Ever tried to sum up all numbers from 1 to 2,000,000 in your favorite programming language? The result is easy to calculate manually: 2,000,001,000,000, which some 900 times larger than the maximum ...
3
votes
3answers
1k views

In Java, why does Integer.MIN_VALUE == -Integer.MIN_VALUE

Quite simply, I was aghast when I discovered one of my unit tests was failing because -Integer.MIN_VALUE == Integer.MIN_VALUE! Why would the language designers choose this, what is the mathematical ...
1
vote
0answers
235 views

Why are most ReactiveX implementations push-based?

Feel free to correct my history, but as far as I understand it, Rx and the Reactive Manifesto trace their roots back to C# and its Reactive Extensions, which is uses push (callback-based) messaging, ...
2
votes
1answer
783 views

Custom language with mixed markup and Python, parsing in Python

I need a system for creating Python subclasses in a simple manner, and I was thinking of using a (custom) config language similar to json, xml, etc. Here's the initial structure I thought of (one ...
6
votes
3answers
1k views

Why do many languages semantically distinguish “async” functions from “non-async” ones?

I've seen this in C#, Hack, and now Kotlin: await or an equivalent operation can only be performed in special "async" contexts. Return values from these are, to borrow Hack's terminology, "awaitable" ...
0
votes
1answer
210 views

Implement an actor-based concurrent language in ruby?

How would one implement an actor-based concurrent language in ruby? My thought is that only the correct way of creating programs is using actors, but I'm not entirely sure on how this could be done, ...
26
votes
10answers
7k views

Programming language where every function call/block is done in a separate thread? [closed]

I'm currently creating a programming language for fun where the idea is that every function call/new block (if clauses, loops etc) will work in a separate thread. Instead of creating new Threads the ...
-2
votes
2answers
223 views

Categorize a language?

Is it true that one doesn't "implement a programming language"? I was told that in some comment around here several years ago and I read that actually you do "implement a programming language". The ...
6
votes
1answer
613 views

Does C use “$”?

As a general rule, programming languages are designed for use by humans, and thus for entry using a US-QWERTY keyboard. (This makes some number of conceptual skips, myself as proof as I'm doing most ...
2
votes
2answers
3k views

Multiple arguments vs a tuple argument

In functional languages without type checking, is there any substantial disadvantage (apart from readability) to limiting all functions to take exactly one argument - that is, replacing multi-argument ...
18
votes
2answers
5k views

Is Microsoft discouraging the use of 'var' in C#? (VS2017)

I'm looking at the upcoming Visual Studio 2017. Under the section titled Boosted Productivity there is an image of Visual Studio being used to replace all occurrences of var with the explicit type. ...
6
votes
2answers
826 views

What is the common procedure when producing jump targets in bytecode?

Over the course of the past few days, I've been trying many different methods for correctly calculating jump targets in bytecode, but none have been practical or reliable. Furthermore, the methods I'...
4
votes
3answers
2k views

How are literal values encoded into bytecode?

Note: This question is somewhat related to How exactly is bytecode "parsed"?, but it is not a duplicate of it. In this question, I'm asking about a specific part of how bytecode is generated, not how ...
0
votes
2answers
473 views

What's the point of Swift's function notation?

Why does Swift use this function notation: func greet(person: String, day: String) -> String { return "Hello \(person), today is \(day)." } Like, I don't get why it uses the small arrow -> ...
4
votes
2answers
482 views

Variable assignment in a postfix language

TL;DR is val name <- more readable than name val <-? I'm designing a semi-concatenative, postfix language. I haven't given much thought to the style in which variable are assigned, and now I ...
5
votes
2answers
379 views

Why isn't it a common practice for languages to have method arguments passed inside method names?

Why is not it a common practice for languages to have method arguments passed inside method names? For instance, wouldn't something like: shop.Sell(15)Notebooks (although looking pretty unusual) be ...
5
votes
3answers
444 views

What is the procedure(if any) to select bytes to represent opcodes?

TL;DR What procedure is followed when selecting bytes to represent opcodes? Are byte(s) for opcodes just randomly chosen, and them mapped to mnemonics? I recently learned from this answer that ...
-1
votes
1answer
261 views

Why do class based languages like c# and java still use files to store code? [closed]

In quite a few object oriented languages, especially the ones without free standing functions, it's now best practice to have one class per file, with the file name being the same as the class name. E....
2
votes
3answers
134 views

Is there a structure/pattern/format that most functions follow?

First time posting. I know this is a very generalized question, sorry for that, I don't know how to more appropriately word this. I've noticed a trend, a pattern in methods, it seems in almost all ...
22
votes
7answers
14k views

Should “Set” have a Get method?

Let's have this C# class (it would be almost the same in Java) public class MyClass { public string A {get; set;} public string B {get; set;} public override bool Equals(object obj) { ...
51
votes
3answers
9k views

What is a type system?

Background I am designing a language, as a side project. I have a working assembler, static analyser, and virtual machine for it. Since I can already compile and run non-trivial programs using the ...
5
votes
0answers
108 views

Why exogenous exceptions? [duplicate]

So in a relatively famous blog post, Eric Lippert categorizes exceptions as lethal, vexing, bone-headed, and exogenous. He defines vexing exceptions as ones created by unfortunate design decisions and ...
0
votes
0answers
112 views

LALR parsing (with Ply) non-deterministic and sometimes fails

I have written a parser using Python Ply library. While doing tests with an input file I have noticed a strange behaviour : sometimes the input is correctly parsed with no error and sometimes, there ...
0
votes
1answer
87 views

Grammar design preference for recursion

I would like to know if one of the two following equivalent grammars (since they can produce the same rules) is preferred (and why). For instance the second grammar is more concise but is it a good ...

1
2
3 4 5
10