Questions involving the design and structure of programming languages.

learn more… | top users | synonyms

0
votes
2answers
133 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, ...
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,...
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 ...
14
votes
3answers
483 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
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, ...
0
votes
2answers
87 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 ...
0
votes
1answer
62 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
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 ...
2
votes
2answers
131 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
3answers
176 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 ...
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 ...
4
votes
1answer
382 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 ...
2
votes
5answers
104 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 ...
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 ...
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 ...
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 ...
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,...
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'...
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 ...
0
votes
2answers
207 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
378 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 (...
2
votes
2answers
472 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 ...
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
232 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
148 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 ...
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 ...
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?
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. ...
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 ...
6
votes
8answers
675 views

Can “return this” pattern be optimized to no cost performance?

return this (or similar construct) allows method chaining. Lack of it is painful, because you have to write such code (C#): var list = new List<string>(); list.Add("hello"); list.Add("world"); ...
2
votes
2answers
188 views

For what reasons Java and C# initialize static data on demand?

I am reading "The Go Programming Language" right now and I have read package initialization chapter which tells (or I read it wrong) that Go uses eagerly initialization. So in time we saw say C++ ...
2
votes
3answers
183 views

Why does the overriding rule of C++ not care about visibility changes?

In C++, it is possible to write an overriding for a base class's method even if the visibility declaration of the two don't match. What are the possible design considerations under the decision of not ...
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 ...
2
votes
2answers
191 views

C# / VB.NET build expression trees only from lambda expressions — why?

Based on the context, C# can generate the expression tree for a LambdaExpression from lambda expression syntax: Expression<Func<string, int>> expr1 = s => s.Length; as can VB.NET: ...
2
votes
1answer
162 views

What was the reason behind using quotes in Go's import statements?

The usage of quotes in Go's import statement strikes me as unnecessary. Typical Go import statements look like: import "foo/bar" import other_name "foo/bar" import ( "foo/bar" x "foo/baz/bar" ...
-1
votes
2answers
88 views

Hypothetical extension to C# property initializer syntax

In C#, when you call a constructor, you can add one or more property initializers in curly braces: var foo = new Bar() { Armpit = new Flapdoodle() { Limpet = 2 } }; What if that feature were ...
2
votes
2answers
113 views

Should the Vector type inherit from the Array type in an environment where both are first-class objects

I have created a programming language that is based on java for a personal project. The language already has generic classes and functions and the generics are completely compatible with primitive ...
6
votes
3answers
334 views

Why is the most common integer number 32 bits, but the most common floating point number 64 bits?

Coming from a Java and C# background, I've learned to use int (32 bits) whenever I need a whole number, and double (64 bits) when dealing with fractional values. Most methods from their respective ...
1
vote
1answer
178 views

Are decorators/annotations the result of bad design decisions?

Talking generic, there are programming languages who make more or less use of annotations and decorators. Be it to add type information to variables in a dynamically typed language or to add "...
6
votes
4answers
504 views

Why use plus equals += for event registration?

In C#, you register an event like: window.onClick += myHandler; But why use this instead of a "register" method that takes your handler and registers it. E.g.: window.registerOnClick(myHandler); ...
-1
votes
1answer
125 views

Naming choice in Java — clone vs. copy [closed]

We have "copy constructor" but "clone method". This asymmetry in naming puzzles me -- does anyone know for what reason the method was not named "copy" (and interface per analogy "Copyable")? This ...
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 ...