28 votes
Accepted

Visual programming tools, why don’t they work with the AST directly?

Many of these tools do work directly with the abstract syntax tree (or rather, a direct one-to-one visualisation of it). That includes Blockly, which you've seen, and the other block-based languages ...
user avatar
24 votes
Accepted

Automatic Downcasting by Inferring the Type

Upcasts always succeed. Downcasts can result in a runtime error, when the object runtime type is not a subtype of the type used in the cast. Since the second is a dangerous operation, most typed ...
user avatar
  • 14.1k
14 votes
Accepted

Does it make sense to have both the concept of 'null' and 'Maybe'?

The null value as a default present everywhere is just a really broken idea, so forget about that. You should always have exactly the concept that best describes ...
user avatar
11 votes
Accepted

Types as first class Citizen

First class types enable something called dependent typing. These allow the programmer to use values of types at type level. For example, the type of all pairs of integers is a regular type, while the ...
user avatar
  • 435
10 votes
Accepted

Why is the object destructor paradigm in garbage collected languages pervasively absent?

The pattern you're talking about, where objects know how to clean their resources up, falls into three relevant categories. Let's not conflate destructors with finalizers - only one is related to ...
9 votes

Why are strings immutable in some languages?

This issue is strongly connected to the notion of what it means to be an instance of a class. In strict Object-Oriented terms, a class has an associated invariant: a predicate which always holds true ...
user avatar
9 votes
Accepted

Why would you introduce the goto statement into a modern language?

There are two kinds of programmers: Those who for whatever reason never, ever use goto, and go to any lengths to avoid it, and those who use goto in one of the very rare situations where it is the ...
user avatar
  • 24.9k
9 votes
Accepted

Why are struct and class essentially the same in C++?

Bjarne Stroustrup writes in his The Design and Evolution of C++ book (item 3.5.1): At this point, the object model becomes real in the sense that an object is more than the simple aggregation of ...
user avatar
  • 2,952
8 votes

Why would you introduce the goto statement into a modern language?

The goto in itself isn't "evil", it is just easy to misuse. A famous paper by Knuth is "Structured Programming with goto statements", ACM Computing Surveys 6:4 (dec ...
user avatar
  • 13.6k
8 votes
Accepted

Safe way to explicitly define new types instead of using Algebraic data types for my functional language

You're on the right track: people have come up with the same way to do this. The general concept is known as abstract types. With the Church encoding, the type of a pair of elements of types $a$ and $...
user avatar
7 votes

Why isn't there a .= operator? (or ->= etc)

IMO, the biggest reason is that identifiers are not first class values in programming languages and "." is not a real operator like + or ...
user avatar
  • 1,370
7 votes
Accepted

Can a language be Turing Complete if its only provision for unlimited code/memory is through recursion?

Given your very strict interpretation of limited memory size, limiting also the size of integers, one consequence is that it is not possible to play encoding games with integers (such as Gödel ...
user avatar
  • 19.1k
7 votes

Why would you introduce the goto statement into a modern language?

Most algorithms and forms of business logic can fit nicely into the control structures that are built into modern languages, in large measure because such structures were designed to fit the needs of ...
user avatar
  • 1,107
7 votes

Why are strings immutable in some languages?

Things like strings and dates are naturally values. In C++ terms, we expect them to have a copy constructor, an assignment operator, and an equality operator, but we never expect to take their address....
user avatar
  • 616
7 votes

Which is easier for human perception: type of variable before or after its name?

I don't think there is any research (with good methodology) on this. The language I'd most expect to have actually thought about this and made an empirically-based decision is the Quorum programming ...
user avatar
7 votes

Why is the syntax of some programming languages very much not according to earlier conventions?

Today, most people who learn a programming language know very little mathematical notation and are more familiar with other programming languages, and with symbols that are available on their computer ...
user avatar
6 votes
Accepted

What is the point of delimiters and whitespace handling

Now, is it right that only identifiers and literals have to be separated by delimiters or whitespace? How do I ensure that? If by "right" you mean it is the case in every programming ...
user avatar
  • 11k
6 votes

Why are strings immutable in some languages?

Java was designed to allow execution of subsections of a program's code in security constrained environments. The way this requirement was implemented was by setting a "SecurityManager" on a thread ...
user avatar
  • 201
6 votes
Accepted

Examples of context sensitive syntactic constructs (statements)

Here are three context-sensitive syntaxes actually found in programming languages. I don't believe I've ever seen a language which has types, names and values distributed as per your example, but it ...
user avatar
  • 11k
6 votes

Visual programming tools, why don’t they work with the AST directly?

At least two reasons: Because source code is a much more concise representation. Laying out an AST as a graph would take up a lot more visual real estate. Programmers prize having as much context ...
user avatar
  • 140k
6 votes

Lazy concatenative functional language

It can be done. Here's a presentation explaining the language and how the compiler works (so far). You can play with an asm.js version at http://hackerfoo.com/eval.html
user avatar
6 votes
Accepted

Can String be a subtype of Character in a programming language?

Character and String are conceptually very, very different. Google for "inheritance vs. composition" - you seem to think that Character and String should be connected via inheritance, but in reality a ...
user avatar
  • 24.9k
5 votes

How to bridge theory and implementation for while loops?

I think you're missing the notion of continuation. Although your compiler may not rely on that notion, as a compiler designer with a functional language as source or intermediate (or target) language, ...
user avatar
5 votes
Accepted

How to bridge theory and implementation for while loops?

So I managed to solve this issue today. The code for my while loop: ...
user avatar
  • 499
5 votes

Why is the object destructor paradigm in garbage collected languages pervasively absent?

In a nutshell Finalization is not a simple matter to be handled by garbage collectors. It is easy to use with reference counting GC, but this family of GC is often incomplete, requiring memory leaks ...
user avatar
  • 19.1k
5 votes

Should names of built-in funtions be part of BNF grammar?

If your language has a small set of functions and there is no mechanism for adding other ones, then you could include the function names as keywords. But that's not a very likely scenario, unless your ...
user avatar
  • 11k
4 votes

Why is the object destructor paradigm in garbage collected languages pervasively absent?

The object destructor pattern is fundamental to error handling in systems programming, but has nothing to do with garbage collection. Rather, it has to do with matching object lifetime to a scope, ...
user avatar
4 votes

Functional programming with branches that have no order?

Here's the problem: You always need some way to resolve ambiguity when there are overlapping clauses There is no easy syntactic way to ensure that clauses don't overlap. So, if you can think of a ...
user avatar
  • 29.1k
4 votes

Top-down typing strategy - is there a name for this?

There is no top-down or bottom-up typing strategy when defining a language. It is an implementation issue. A type system will only define operator operand constraints on your AST. The kind constraints ...
user avatar
  • 19.1k
4 votes

Why would you introduce the goto statement into a modern language?

I’ve used goto in exactly one program, not counting BASIC when I was a child. It was to break out of a couple of levels of nested inner loops in performance-...
user avatar
  • 1,111

Only top scored, non community-wiki answers of a minimum length are eligible