Questions involving the design and structure of programming languages.

learn more… | top users | synonyms

0
votes
2answers
107 views

Why is having a NotImplementedException a good thing?

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
403 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
167 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 ...
2
votes
2answers
156 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
482 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
164 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
85 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
120 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
61 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
43 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
54 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, ...
113
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
61 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" } { ...
2
votes
2answers
130 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 ...
3
votes
4answers
438 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 ...
3
votes
3answers
173 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
259 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 ...
4
votes
1answer
380 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 ...
101
votes
6answers
17k 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 ...
14
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
65 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
103 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
442 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
471 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
142 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
344 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
108 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
333 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
206 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
377 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
459 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 ...
13
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
208 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-...
1
vote
4answers
230 views

Which programming languages provide a Schwartzian transform like interface for sorting

Introduction The Schwartzian transform -- also known as map-sort-map or decorate-sort-undecorate (DSU) --, attributed to Randal Schwartz of the Perl community, sorts elements of a list or array by a ...
1
vote
1answer
105 views

In Go, why isn't append() implemented as a method, but as a function?

In Python, lists offer an append() method which can be called using standard Python method syntax; for example: >>> my_list = [] >>> my_list.append('a', 'b', 'c') >>> ...
0
votes
3answers
147 views

Why don't empty iterables in python raise Exceptions when you try to iterate over them [duplicate]

I find this behaviour in Python quite peculiar and I believe it can lead to many bugs especially if you have a function/method that takes in a list and returns another list after carrying out some ...
71
votes
12answers
8k views

I've been told that Exceptions should only be used in exceptional cases. How do I know if my case is exceptional?

My specific case here is that the user can pass in a string into the application, the application parses it and assigns it to structured objects. Sometimes the user may type in something invalid. ...
89
votes
8answers
13k views

Why did BASIC use line numbers?

Why did old BASICs (and maybe other languages) use line numbers as part of the source code? I mean, what problems did it (try to) solve?
1
vote
4answers
693 views

Why do so many languages restrict string literals to a single source line? [closed]

In, for example, the Bash scripting language, the following creates a string called $VAR which begins at the first " quote and continues until the next unescaped " quote. $VAR=" hello world! ...
0
votes
1answer
93 views

Is it possible to detect misuse of passing self type argument in compile time?

I just hit the very basic problem in OOP and I cannot see any working solution except postponing appropriate check until run time. It is pretty clear notion of an action "do something with value of ...
2
votes
4answers
153 views

Is the var token necessary to signal variable declaration?

When creating a variable foo, Python lets you just write foo = bar. However many languages, like C# or JavaScript, require additional syntax like var foo = bar or foo := bar to signal the same thing. ...
9
votes
3answers
372 views

How useful is C's “true” sizing of variables?

One thing that always intuitively struck me as a positive feature of C (well, actually of its implementations like gcc, clang, ...) is the fact that it does not store any hidden information next to ...
4
votes
8answers
673 views

One-use variables - has any language ever had them?

A principle that I follow is that, when an identifier is established, it should be a signal to the reader that the value referred to is indeed an abstraction which will be used more than once. That is,...
1
vote
1answer
83 views

Does exception handling belong at the lowest level of the runtime?

I'm designing a fairly simplistic stack-based programming language, and implementing it in Python. (no link, because it's not fully implemented yet.) The language itself is essentially intended to be ...