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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 $...
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 ...
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 ...
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 ...
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....
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...

D.W.♦
- 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
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 ...
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, ...
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:
...
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 ...
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 ...
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, ...
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 ...
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 ...
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-...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
language-design × 61programming-languages × 45
type-theory × 6
functional-programming × 6
compilers × 4
history × 4
object-oriented × 4
terminology × 3
syntax × 3
formal-languages × 2
context-free × 2
parsers × 2
memory-management × 2
type-checking × 2
type-inference × 2
c++ × 2
variable-binding × 2
garbage-collection × 2
computability × 1
optimization × 1
recursion × 1
artificial-intelligence × 1
lambda-calculus × 1
concurrency × 1
loops × 1