Questions involving the design and structure of programming languages.

learn more… | top users | synonyms

0
votes
1answer
39 views

SQL: Empty value list for the IN predicate (literals, not subqueries)

Recently, while writing some Spring/JPA code, I stumbled on an issue I tend to face with from time to time: I passed an empty collection to a repository method that generates an IN expression for the ...
1
vote
3answers
184 views

Should I create .Clone() on a class or create a copy-constructor?

I'm quite unsure what I should use in C# - both should in theory do the same, but I think both are quite easely overseen. Or is there another possibility I have to take in consideration? I know in C++...
3
votes
2answers
171 views

Why is overflow silently allowed in Ada?

Silent failure for such trivial code. How can they claim high integrity? with ada.text_io; use ada.text_io; procedure overflow is procedure p (i: positive) is x: integer := integer'last; ...
0
votes
1answer
31 views

Why can't an ES2015 WeakMap have primitive keys?

There are six primitive data types in JavaScript: Boolean, Number, String, Symbol, undefined, null A WeakMap can't have primitive data types as keys. And a WeakSet can't have primitive values. Why ...
-1
votes
0answers
77 views

Why does C handle negative modulo values non-standardly [duplicate]

In math the standard for modulo is the remainder of the division; wether the object is positive, negative, or zero. so (-1)%4 would be "3" But in C (and a few other programming languages), (-1)%4 ...
9
votes
3answers
516 views

What rationale is used when programming language designers decide what sign the result of modulo operation takes?

Going through Modulo operation (the avenue I entered while exploring the difference between rem and mod) I came across: In mathematics the result of the modulo operation is the remainder of the ...
-1
votes
3answers
131 views

Why doesn't System.String include a constructor taking an IEnumerable<char>?

Why doesn't System.String include a constructor capable of taking a IEnumerable<char>? The expected behavior would be: var foo = "hello"; var bar = new string(foo.Select(x => x)); Actual ...
4
votes
5answers
297 views

How are mixed, sizeless lists implemented in higher level languages?

Most higher level (or scripting) languages out there have data structures that can hold different types of data (like numbers, strings and even functions) in the same structure, and you can also add ...
2
votes
1answer
106 views

Designing generic operations in object oriented languages

I found an interesting quote in SICP that I think is highly relevant in object oriented design: We see that, in general, a type may have more than one subtype. Triangles and quadrilaterals, for ...
0
votes
2answers
180 views

Is it important that a language is coherent to itself?

I am currently designing a programming language and I'm at the stage of making all the design choices that will guide the developement. My language has a slightly different syntax and concept to many ...
3
votes
4answers
222 views

Would implementing a “Throwable Event System” be abusive?

I have been thinking for a couple years now about using Throwable events and implementing a sort of event system that uses throw to dispatch an event, or let a different method handle it with throws. ...
0
votes
2answers
212 views

Why is having a NotImplementedException a good thing? [duplicate]

C# has made a language feature of the NotImplementedException. It's added to a lot of auto-generated code, such as event handler stubs: // Auto-generated private void TextBox_MouseDown(object sender, ...
1
vote
3answers
407 views

Requiring multithreading/concurrency for implementation of scripting language

Here's the deal: I'm looking at designing my own scripting/interpreted language for fun. I'm only in the planning stages right now; I want to make sure I have a very strong hold on exactly how I will ...
4
votes
3answers
183 views

Role and importance of static method in OOP

Background Thinking about OOP I feel that it binds data and behavior together, taking the real world example we already have array data type which is a collection of homogeneous type but in Java we ...
3
votes
2answers
166 views

Is there some rationale behind SQL's lack of closure for what are standard operations in imperative languages?

Is there some historical or practical reason why SQL (or more specifically T-SQL in my case) does not support the closure property in many areas where many other language families like C do? (That is,...
14
votes
3answers
491 views

Does there exist a programming language specifically designed for dependency injection?

Many general programming languages are flexible enough to allow you to support dependency injection. Even without library or framework support. But even if a language is Turing complete enough to ...
1
vote
1answer
165 views

Thinking about a language for build definitions

I want to write a little tool that parses build definitions and converts them to a ninja.build file. It should not abstract compilation like CMake or Meson, but be similar to make in that you manually ...
5
votes
5answers
3k views

Scalability and Programming languages

What makes a language scalable ? I believe scalability is more about system design. It sounds really odd to me, to say that one language is more scalable than the another.
17
votes
9answers
3k views

Why are self-hosting compilers considered a rite of passage for new languages?

I've heard in a number of places now that people expect languages to use, or at least have, a self-hosting compiler in order to deserve respect. I'm curious as to why this is. A compiler seems like a ...
0
votes
2answers
95 views

Advantages and disadvantages of an FFI vs. a C/C++/etc API

I am trying to understand the advantages and disadvantages of a Foreign Function Interface (FFI) (in which the high-level languagd can call most C functions directly and can manipulate C data ...
4
votes
2answers
122 views

A question about implementing objects in a language written in C

I'm fairly new to programming (about four months learning), and have decided to mess about with an attempt at writing a language in C for both fun and practice, and am wondering how objects are ...
4
votes
2answers
62 views

Type of multi methods in a static object-functional language

I'm currently working on expanding the capabilities of my pet programming language project's type system, and have come across an interesting area where my research into other language's type systems ...
32
votes
6answers
9k views

Why design a modern language without an exception-handling mechanism?

Many modern languages provide rich exception handling features, but Apple's Swift programming language does not provide an exception handling mechanism. Steeped in exceptions as I am, I'm having ...
1
vote
0answers
44 views

Namespaces for a custom XML like language: URIs or not

I am working on an XML like language that features a namespace system also. Now my question is: Should I use URIs as namespace names too (1) or should I follow the naming of java/.net/php namespaces (...
0
votes
1answer
56 views

Why is the “global” RegEx flag in JavaScript considered a property of regular expression itself?

In JavaScript, RegEx objects can be instantiated with flags such as g for global matching and i for case-insensitive. Intuitively, it makes sense for i to be a property of the constructed RegEx, ...
114
votes
26answers
24k views

Are null references really a bad thing?

I've heard it said that the inclusion of null references in programming languages is the "billion dollar mistake". But why? Sure, they can cause NullReferenceExceptions, but so what? Any element of ...
0
votes
1answer
68 views

How do I create a parse tree, given a grammar? [closed]

I'm implementing a toy programming language and I've got as far as a working tokenizer that takes a stream of characters like this. 1 2 3 (2 *) map And outputs a stream of tokens { number "1" } { ...
3
votes
2answers
134 views

Can a generic piece of C code be converted an FSM?

I understand that any language worth its salt can encode a Finite state machine. My question is the opposite, is it possible to convert an arbitrary piece of code ( say in C ) to a functionally ...
5
votes
4answers
464 views

Why does the type go after the variable name in modern programming languages?

Why is it that in nearly all modern programming languages (Go, Rust, Kotlin, Swift, Scala, Nim, even Python last version) types always come after the variable name in the variable declaration, and not ...
4
votes
3answers
181 views

Why don't languages that have big integer support have unsigned versions?

A cursory glance at C#, Java, and other languages indicates this is not a feature that's required. I tried searching for justification for this maybe from a language design team or blog, but I haven't ...
2
votes
3answers
265 views

Why does C# not allow scope-local using Directive?

One thing I do not get with C#'s using Directive is why I can only "use" a namespace at file level, and not within any arbitrary block scope. (using namespace x; of C++ does allow this and certainly ...
6
votes
1answer
431 views

Why double colon instead of dot?

It is rumoured that early C++ implementations have had dot operator for namespace access. There is an opinion that the dot is more convenient that the modern double colon operator. What was the ...
100
votes
6answers
18k views

Why is XML called a “language” exactly?

I've been wondering why XML has an L in its name. By itself, XML doesn't "do" anything. It's just a data storage format, not a language! Languages "do" things. The way you get XML to "do" stuff, to ...
16
votes
2answers
2k views

Why is there a new() constraint in C# but no other similar constraint?

In C# generics, we can declare a constraint for a type parameter T to have a default constructor, by saying where T : new(). However, no other kinds of constraints like this are valid - new(string) ...
1
vote
1answer
69 views

Had operator precedence rules changed through the history of a computer language?

I would think it would be a massive breaking change if something like this were to happen on a widely deployed language like C/C++, but maybe it had happened in the past. Bonus related question: How ...
2
votes
5answers
113 views

Implicit value vs. reference type semantics

This question has kind of been asked before here Why are structs and classes separate concepts in C#? but I'm interested in a specific aspect of this that wasn't really answered. I'm trying to ...
5
votes
3answers
447 views

Why should a language prefer indentation over explicit markers for blocks?

I am learning Haskell, and I was looking for an auto indentation tool. I didn't look much, and learned that in Haskell (as in Python), indentation signifies a block. As a result, I'm guessing that it'...
2
votes
2answers
519 views

Why packages and modules are separate concepts in Java 9?

Java 9 will have modules in addition to packages. Usually languages have one or the other. And most programmers perceive two terms as synonyms. Modules are built on top of packages, treating them as ...
2
votes
2answers
148 views

Why did languages such as shell scripting and perl use $ in front of variable names?

Context Perhaps I'm just use to C-esque styled languages but having a sigil in front of a variable (e.g. $VAR) always strikes me as weird. Question Why do some languages such as Perl and shell ...
11
votes
4answers
349 views

What do language designers do to decide or prove that a particular feature works correctly?

I'm interested in language design and in general I can reason easily about widely known features (e.g. inheritance, polymorphism, delegates, lambdas, captures, garbage collection, exceptions, generics,...
28
votes
1answer
2k views

How does the C++ standards committee test their design ideas?

Does the C++ committee test their new design specifications with some sort of prototype compiler before releasing a new standard? Or do they release a standard which is, in effect, only theoretical ...
1
vote
1answer
111 views

Alternatives to anonymous class

In the language I work with, Progress OpenEdge 11.5.1, there is nothing like anonymous classes. However, the system design would really benefit the use of such classes. Is there some nice known way ...
14
votes
7answers
5k views

In Java, why were protected members made accessible to classes of the same package?

From the official documentation... Modifier Class Package Subclass World public Y Y Y Y protected Y Y Y N no modifier Y Y N ...
5
votes
1answer
335 views

Will ECMAScript add classes to JavaScript? What does this mean?

I heard that some sort of class system will be added to JavaScript with ECMAScript and I find that a little confusing, because I've just finished reading a JS book, JavaScript, The Good Parts by ...
28
votes
15answers
2k views

I'm writing about language syntax. Is there a language out there in which parameters are placed inside method name?

in JavaScript: function getTopCustomersOfTheYear(howManyCustomers, whichYear) { // Some code here. } getTopCustomersOfTheYear(50, 2010); in C#: public List<Customer> ...
0
votes
2answers
208 views

Do some built-in functions loop behind the scenes?

I mostly code in C# & VB, but I think this question is pretty universal. I try to limit loops to increase performance. For instance, string functions that split the string into an array, or do a ...
1
vote
5answers
406 views

Why does Kotlin require type after variable, rather than before?

C, C++, C#, Java, as well as many other statically typed languages have the type before variable like (int a =5, auto c = 4, etc.). Non-statically typed languages (such as Javascript, basic) use var (...
0
votes
8answers
463 views

Why is there no language supporting a if..elseif..any..else construction? [closed]

Not for the first time, I wanted to do something like this: if condition1 result1 elseif condition2 result2 else result3 else result4, so 'if result3 did not run' then run result4. But this ...
14
votes
3answers
1k views

What is the reasoning behind naming of the .NETs Select (Map) and Aggregate (Reduce)?

In other programming languages, I have seen Map and Reduce, and those are cornerstones of functional programming. I could not find any reasoning or history why LINQ has Aggregate (same as Reduce) and ...
9
votes
2answers
218 views

language with two binary operators of same precedence, left-associative & right-associative

Are there any programming (or scripting) language (or some domain specific language) having two binary operators opl and opr of same precedence with opl being left-associative and opr being right-...