All Questions

Filter by
Sorted by
Tagged with
2 votes
1 answer
94 views

Is there a way to define expressiveness that includes a notion of computational complexity?

There is a nice answer here providing an exposition of Felleisen's definition of expressiveness. But there is a missing piece for me. It feels like adding tail calls to a language that lacks any ...
Moonchild's user avatar
  • 597
7 votes
6 answers
3k views

Why do relational comparison operators never short-circuit?

I just thought about the possibility for the less-than and-greater than operators to short-circuit. That is, they can skip evaluating their second operand if the value of the second operand logically ...
user16217248's user avatar
  • 6,382
1 vote
6 answers
525 views

Why tag function definition with def, fn, fun, func or function etc?

What makes it hard for compilers/interpreters that we need to tag the function definition with keyword fn/fun/func/function? I can understand that types for numbers: int, int32, float32, float64... ...
Anubhav's user avatar
  • 143
5 votes
2 answers
2k views

Creating a new language with Rust without Garbage Collection?

I am new to language development. I am aware of Rust's ownership model that builds programs in a way that does not need garbage collection. So if I am to build a new programming language using safe ...
M4X_'s user avatar
  • 153
6 votes
1 answer
445 views

What, if any, runtime cost is incurred by using 64-bit ints on 32-bit platforms in LLVM?

I'm writing a language frontend for LLVM, and I noticed that the IR docs say that integers of (almost)any width can be used without limit. I presume this to mean that LLVM or its backends convert ...
Ginger's user avatar
  • 2,047
2 votes
1 answer
373 views

Is it correct that Python does not encourage us to read objects's content? [closed]

After playing around Python a little bit, I feel like Python does not encourage us to read objects's content. Take JavaScript for example: just a simple act of calling an object will list all the ...
Ooker's user avatar
  • 147
16 votes
6 answers
3k views

Possible to mix garbage collection and manual memory management?

Do you think it is possible to have a language that uses garbage collection (GC) by default, but allows you take more control with manual memory management like C++ or Rust, in areas of the software ...
Rob N's user avatar
  • 923
2 votes
1 answer
203 views

Are enum members literals or constants in an IR?

While implementing enums in Tyr, I just realized that enum constants are the only form of literal-like entity that is not represented like a literal in the intermediate representation. The enum ...
feldentm's user avatar
  • 1,248
7 votes
2 answers
496 views

Why do many languages use square brackets for array indexing?

A lot of languages use square brackets for array indexing, and round brackets (also known as parentheses) for function calls. For example, in C: ...
G. Sliepen's user avatar
3 votes
1 answer
561 views

Why is the ECMAScript specification formatted the way it is? [closed]

The ECMAScript specification and its drafts are very accessible, but they're formatted a bit oddly -- case in point, the current version of the ToBigInt abstract operation uses three fonts: The base (...
Bbrk24's user avatar
  • 8,089
42 votes
5 answers
11k views

Why do programming languages use the asterisk * for multiplication?

Having had very little math(s) education I'm trying to bring myself up to speed for university, which currently involves teaching myself the times tables, where X ...
Hashim Aziz's user avatar
10 votes
0 answers
226 views

What styles of interpreter are not well-supported by RPython?

The RPython toolchain translates interpreters to JIT compilers. The interpreter may be written in any style; the corresponding JIT compiler is defined by annotations on the main loops of the ...
Corbin's user avatar
  • 385
5 votes
1 answer
207 views

What is the difference between having an auto type and having dynamic typing?

In C++, you can define variables with auto instead of giving it a default type such as int. Like this (where ...
Redz's user avatar
  • 881
5 votes
2 answers
149 views

How to ensure coherent choices of representatives in an e-graph?

E-graphs are a neat intermediate representation for program transformations and optimisations, which group program terms into equivalence classes (e-classes). An optimising compiler can then select ...
kaya3's user avatar
  • 14.6k
8 votes
4 answers
835 views

Data structures for scopes and variable shadowing

Let's say I have some code in my target language like: ...
Rob N's user avatar
  • 923
12 votes
3 answers
2k views

Is type checking usually preceded by a pass that looks at just names and declarations?

Let's say I've parsed a file of code into an AST, and now I want to walk the AST and type check it. My AST nodes have a signature like this (C++) ...
Rob N's user avatar
  • 923
2 votes
1 answer
199 views

Can a language like Mojo include multiple dispatch like in Julia? [closed]

Julia supports multiple dispatch of functions when appropriate type annotations are provided. Is Julia's strong type system necessary to support that, or could a new language like Mojo include ...
user238607's user avatar
6 votes
0 answers
112 views

Extending Hindley Milner with (mutual) recursion

What's a good approach for extending Hindley Milner with mutual recursion without de-sugaring to let+fix+records? My thinking is (assuming no polymorphic recursion) Collect mutually recursive lets ...
aindurti's user avatar
  • 161
8 votes
1 answer
253 views

What are the tradeoffs between using sea of nodes, CFG of basic blocks, and egraphs for compiler optimizations?

I've heard of "sea of nodes" intermediate representations mostly in the context of just-in-time compilation (JVM, V8, Graal) whereas intermediate representations such as LLVM IR are used in ...
Troy Sargent's user avatar
3 votes
2 answers
227 views

Why does the C library include fgetpos()/fsetpos() if the same functionality can be achieved with ftell()/fseek()?

C includes 2 methods for saving the position of a stream and setting it later. Using fseek() and ftell(): ...
user16217248's user avatar
  • 6,382
14 votes
5 answers
1k views

What are some techniques for faster, fine-grained incremental compilation and static analysis?

An incremental compiler is one which only needs to recompile the parts of a program which changed since the last output, as opposed to a batch compiler which must re-compile everything. Incremental ...
tarzh's user avatar
  • 2,025
18 votes
10 answers
4k views

Why would accessing uninitialized memory necessarily be undefined behavior?

In C, accessing any indeterminate/uninitialized memory is undefined behavior, period. Even in the case that the type in question is guaranteed to have no trap representations, such as ...
user16217248's user avatar
  • 6,382
6 votes
1 answer
563 views

What is a CAS language?

Is it by any chance just this (otherwise Google was no help)? I've seen throwaway remarks on this site by SK_Logic and Jorg-W-Mittag that use this term but I'm not entirely convinced and cannot find ...
Pete Lomax's user avatar
9 votes
1 answer
233 views

How to efficiently generate stack traces

Errors are a lot easier to troubleshoot if the language reports precise source locations. In case of runtime errors, the stack trace is probably important, showing each function in the call stack and ...
BoppreH's user avatar
  • 1,391
14 votes
2 answers
2k views

How do languages support executing untrusted user code at runtime?

Many dynamic languages such as Javascript, PHP and Python have a built-in eval function for executing code from a string. It's well known that such functions are ...
kaya3's user avatar
  • 14.6k
8 votes
1 answer
336 views

Creating an interface for stringifying objects that allows loop detection

Suppose a language has a rust-style trait system but is garbage collected and most types are reference types by default. I could create a trait like this: ...
mousetail's user avatar
  • 6,424
15 votes
4 answers
4k views

Why does Rust choose not to provide `for` comprehensions?

Okay, so this might be a silly question. I'm a big fan of functional programming paradigms in higher-level scripting languages, so I'm probably using Rust wrong. However, I'm new to Rust and I'm ...
Philip Grabenhorst's user avatar
6 votes
1 answer
182 views

How do you implement a structural subtyping checker?

In a structurally-typed language, one type is a subtype of another iff it has all of the fields/methods of the other with compatible types, meaning that field or return types are subtypes, parameter ...
Michael Homer's user avatar
  • 9,210
10 votes
2 answers
454 views

Can you represent a language with a group with a small/simple generator set?

I'm wondering whether its possible to construct a group where the elements are all possible valid programs, with a small or simple generator set. That way you could have a series of operations you can ...
debater-coder's user avatar
4 votes
2 answers
417 views

Were there attempts to support triggering accessors on modifying subelements of properties?

Some languages offer the feature of properties, different from normal member variables, that trigger some code when you read from or write to the property. The triggered code are called accessors. The ...
user23013's user avatar
  • 1,812
5 votes
0 answers
119 views

What are some design errors that lead to hard-to-debug code? [closed]

There are some design features in programming languages that make code written in the language difficult to debug (e.g. C's default fallthrough behavior). So it would be helpful to make a list of ...
idk's user avatar
  • 159
11 votes
1 answer
307 views

Typeclasses, traits, interfaces, protocols: is there any consistent terminology?

Many languages have some form of expressing "user-defined duck typing": defining a type by its behavior, rather than anything about the structure or data of an instance of the type itself. ...
apropos's user avatar
  • 157
27 votes
6 answers
11k views

Why do programming languages use delimiters (quotes) for strings?

Almost every programming language requires strings (or char* or equivelent) to be marked with quotes. Few languages allow other delimiters, many languages allow ...
Safwan Samsudeen's user avatar
27 votes
1 answer
4k views

Why did JavaScript choose to include a void operator?

In JavaScript, there is an operator void that, given an expression, evaluates it but then ignores the result and evaluates to ...
mousetail's user avatar
  • 6,424
34 votes
6 answers
4k views

How to ensure that an optimising compiler will terminate?

An optimising compiler typically applies some set of rewrites to some intermediate representation of the program, replacing terms with other terms which are supposed to be equivalent but more ...
kaya3's user avatar
  • 14.6k
7 votes
3 answers
299 views

How to incorporate sum types into SQL?

The blog post states that a major drawback of SQL is its lack of sum type support. Assuming we could redesign SQL today (without necessarily having to worry about compatibility) what are some specific ...
Jw C's user avatar
  • 103
29 votes
2 answers
8k views

How expressive of a type system is too expressive, for the average programmer?

The advantages of an expressive type system cannot be denied. The usual definition applies - how much valid behaviour a chosen system allows, while also preventing invalid behaviour. In terms of "...
blueberry's user avatar
  • 1,115
2 votes
1 answer
181 views

Implementing a Array programming language in C. What is the best and most efficient struct for the arrays? [closed]

...
rapasite's user avatar
7 votes
1 answer
1k views

Why can you implement a Monoid type in Java or C#, but not Monad or Functor?

Haskell and some other functional languages have Monad and Monoid types (and Semigroup, Functor, Applicative, and many others), and lists, trees, Maybe, and other types subtype all or some of these. ...
Michael Homer's user avatar
  • 9,210
4 votes
1 answer
201 views

Can analysis of periodic loop behaviour be generalised to unstructured control flow?

The basic form of a loop is as follows: loopvars := init body: loopvars := f(loopvars) done := term(loopvars) br done, end, body end: Suppose we've recognised ...
Moonchild's user avatar
  • 597
3 votes
1 answer
169 views

How can I design a Functor trait to handle trait?

In programming languages like Rust, variables of different types that implement the same trait can have different sizes, i.e., the number of bytes used in the memory representation of the type. For ...
Jw C's user avatar
  • 103
2 votes
0 answers
70 views

Is it more readable to declare the return type of a function on the left side of it's name? [duplicate]

A lot of C-like programming languages (Java, C#, ...) use the following syntax for defining functions: returnType functionName(parameters...) { } Is there a ...
tigrou's user avatar
  • 121
7 votes
1 answer
177 views

Techniques for resilient parsing in the face of mismatched brackets?

Suppose you want to build an IDE-grade parser for a language with highly uniform and nestable syntax (e.g. Lisp). Without a lot of "special" constructs like top-level functions, you can't ...
Ken Micklas's user avatar
14 votes
3 answers
460 views

Why does C# have events as a language construct, rather than in the standard library?

In C#, events and event listeners have direct support within the language, with event being a keyword, and event declarations being a special kind of member ...
kaya3's user avatar
  • 14.6k
5 votes
4 answers
389 views

How do interpreters avoid stack buffer overflow-related undefined behavior and exploits?

Most interpreters (including those for bytecode-based languages like Java) are assumed to be exempt of UB at the low-level. For instance, I would never expect NodeJS or the Hotspot JVM to allow ...
MrAnima's user avatar
  • 203
9 votes
5 answers
992 views

How to make logical operators that return operands consistent in a statically typed language?

In C++, 3 || 4 returns true. But in Python, 3 or 4 returns 3 instead. That's a logical operator that returns its operand. I don'...
user23013's user avatar
  • 1,812
6 votes
5 answers
315 views

Declaring infix operators like Haskell's in other languages?

Haskell has support for declaring custom infix operators, including their precedence and associativity. In addition, any identifier can be used as binary infix operator by placing it between ...
Christian Lindig's user avatar
1 vote
1 answer
163 views

Scalability of a language [closed]

When building a language, one of the things to consider is scalability, the ability of a programming language to efficiently manage large or small amounts of code. How should one factor this when ...
DialFrost's user avatar
  • 135
22 votes
6 answers
2k views

Language features for making code easier to unit test

What can programming languages do to make unit testing easier? For the purposes of this question, I'm especially interested in unit testing procedural code with lots of heavy side effects. Let me ...
Greg Nisbet's user avatar
9 votes
8 answers
3k views

Invalid signed integer in C and similar languages

In C a signed integer is just a binary number and all binary numbers are valid integers. There is no NaN value. C uses 2s complement for signed integers meaning ...
John Rennie's user avatar

15 30 50 per page
1
2 3 4 5
12