Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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 ...
Michael Homer's 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 ...
chi's user avatar
  • 14.6k
16 votes

automatic memory allocation

There are three types of memory in C: static (global variables), automatic (stack) and dynamic (heap). All three are needed to express programs conveniently and efficiently. Why static memory is ...
Gilles 'SO- stop being evil''s user avatar
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 ...
Andrej Bauer's user avatar
  • 30.8k
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 ...
ThreeFx's user avatar
  • 433
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 ...
gnasher729's user avatar
  • 30.4k
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 ...
HEKTO's user avatar
  • 3,098
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 $...
Gilles 'SO- stop being evil''s user avatar
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 ...
supercat's user avatar
  • 1,261
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 ...
Derek Elkins left SE's 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 ...
Gilles 'SO- stop being evil''s user avatar
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 ...
Jules's user avatar
  • 201
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 ...
gnasher729's user avatar
  • 30.4k
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.'s user avatar
  • 161k
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
HackerFoo's user avatar
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 ...
rici's user avatar
  • 12k
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 ...
rici's user avatar
  • 12k
5 votes

Why is the address-of operator in C/C++ represented with the "&" symbol?

Because B did! A user on software engineering.sx contacted Ken Thompson: From: Ken Thompson c copied from b so & and * are same there. b got * from earlier languages - some assembly, bcpl and i ...
Pål GD's user avatar
  • 16.5k
5 votes
Accepted

Why does Python allow stand-alone expressions?

The python creators decided that any expression is valid as a statement. While not all expressions are useful as statements, it would make the language more complex to have to remember which ...
mousetail's user avatar
  • 166
4 votes
Accepted

Return destinations for an expression-oriented programming language

1) In a sense, yes. Guy Steele wrote the "Lambda papers", where he reduced many different constructs to lambda expressions, in a compositional way. He used the lambda abstractions of Scheme for this, ...
chi's user avatar
  • 14.6k
4 votes

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

Subtyping is conceptually very different from inheritance. Subtyping refers to shared interfaces; $\tau$ is a subtype of $\tau'$, i.e. $\tau <: \tau'$, then all expressions of type $\tau$ could be ...
xuq01's user avatar
  • 1,190
4 votes

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

As far as I know, the value null in C# is a possible value for some variables, depending on its type (am I right?). For example, instances of some class. For the ...
Euge's user avatar
  • 630
4 votes
Accepted

Can all optimizations be expressed in source code?

The key to remember is that, at its core, a compiler is just a translator between two languages. One is often machine code, and there may be some intermediate steps, but translation is the key. With ...
Joey Eremondi's user avatar
4 votes
Accepted

Why don't imperative languages like C or Go support Haskell-like parametric polymorphism?

The real answer is that the designers of those languages chose not to include it. It's certainly technically possible. As has been said in the comments, Rust does, Java does, C# does, etc. However, ...
Joey Eremondi's user avatar
4 votes
Accepted

Was multiple inheritance ever implemented by adding redundant data members?

It does not matter how you implement multiple inheritance, the inherent issues coming from that still apply. If $C$ is a class, and $D$ a derived class (subclass), and $d:D$ we can write ...
chi's user avatar
  • 14.6k
4 votes

Is there a reason to NOT wrap preprocessor macros in parens?

#define PLUS + 3 PLUS 5 Any more questions?
gnasher729's user avatar
  • 30.4k
4 votes
Accepted

Regarding Backus' Commentary on von Neumann-style Programming

Reading the quote literally without the interpolated interpretation, I think what Backus is saying is that a powerful language is one which makes no distinction between expressions and statements. ...
Steve's user avatar
  • 494
4 votes

automatic memory allocation

Because functions can be recursive. Since a function may call itself (in)directly, the compiler needs to ensure that the nested invocation gets its own variables. And the stack is the most simple ...
cmaster - reinstate monica's user avatar
3 votes

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

If you can define type unions, like X or Y, and if you have a type named Null which represents only the ...
coredump's user avatar
  • 133
3 votes

Automatic Downcasting by Inferring the Type

It's a matter of where do you want to draw the line. You can design a language that will detect validity of implicit downcast: ...
Agent_L's user avatar
  • 213

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