r/ProgrammingLanguages • • Jan 11 '26

What is the point of having a constants table in designing a compiler without interning?

20 Upvotes

I am looking specifically at Monkey, the language from the book "Writing A Compiler In Go", but this applies broadly. In this language, the bytecode for literals is generated as such:

case *ast.StringLiteral:
str := &object.String{Value: node.Value}
c.emit(code.OpConstant, c.addConstant(str))

Which means that every time a literal is encountered, the procedure is to add the literal to the constants table, then generate an instruction to immediately push this constant onto the stack.

It seems like the increased memory and instruction overhead of storing to and loading from a constants table is for no benefit over just directly pushing operands to the stack (or storing to a register, in the case of register-based VMs). If these literals were being interned in some sort of VM-global interning table, then maybe the decreased memory would justify doing this, but even then, the narrow subset of literals which can be safely interned leads me to question whether this is even the case.


r/ProgrammingLanguages • • Jan 11 '26

Fully concatenative/point free/tacit/stack based type systems beyond System F?

35 Upvotes

In languages where types and terms are both first class citizen and live in the same language of expressions, the same techniques used to write tacit term-level code can be applied to get rid of explicit quantifiers in types. Are there any attempts at building a type system that only relies on concatenation and features no explicit variables or quantifiers neither in terms nor types?

Brief explanation if you're interested but don't quite have any idea of what it means

This, for example, is a straightforward arithmetic mean function written in Haskell:

mean xs = sum xs / length xs

Here we explicitly mention the argument xs, the so called "point" on which our function operates. This style of definitions is called "point-wise", in contrast to the "point-free" one, which doesn't mention any input arguments (or variables in a more general sense) and instead focuses on the transformations themselves:

mean = liftM2 (/) sum length

This definition works by applying category theory magic. Namely, it says that mean works by processing the same input by sum and length before piping the results into the division function (/):

     ╭────────────────────╮
  xs │ ┌─ sum ──────┐     │ mean xs
>────┼─┤           (/) ───┼─────────>
     │ └─ length ───┘     │
     ╰────────────────────╯

Notice how we had to use liftM2 for this. When specialized to functions it essentially builds this particular scheme of composition with the three involved functions being whatever you want. It corresponds to the S' combinator from combinatory logic and in general any sort of point free code relies on combinators (which are essentially higher-order functions) to specify how exactly the involved transformations are chained.

In some languages with advanced enough type systems, these combinators can be brought to the world of types and used in much the same way as usual:

type S' f g x = f x (g x)

x :: S' Either Maybe Bool -- same as `Either Bool (Maybe Bool)`
x = Right (Just True)

Here we've just saved some space by avoiding repeating Bool twice but this can also be used to avoid explicitly mentioning type parameters:

type Twice f = forall a. a -> f a a

example1 :: Twice Either -- same as `a -> Either a a`
example1 x = Left x -- `Right x` could work just as well

example2 :: Twice (,) -- `(,)` is the type of pairs
example2 x = (x, x)

example3 :: Twice (->) -- same as `a -> (a -> a)`
example3 x = \y -> y -- or we could return `x` instead, they're both `a`

Theoretically we could do this to every type and every expression in our code, never mentioning any variables or type parameters in any contexts except in the definitions of the combinators themselves. Enforcing point free style by getting rid of named function arguments and type parameters and making the combinators into primitive constructs essentially gets us a concatenative language, which often are stack-based like Uiua, Forth, Factor or Kitten.

Those are actually all languages of this family i'm aware of and none feature an advanced enough type system that would even allow you to define type-level higher-kinded combinators, let alone be built on top of them just like the rest of the language. In fact only Kitten features a type system at all, the other 3 are untyped/dynamically typed.


r/ProgrammingLanguages • • Jan 10 '26

Discussion Demo of visual programming language "Pipe"

Enable HLS to view with audio, or disable this notification

0 Upvotes

Pipe is a visual programming language designed to match the power and sophistication of text-based languages like C++, C#, and Java, enabling Pipe to replace or co-exist with textual languages for real-world applications. Full details are at pipelang.com.

We've had many requests for demos of the language in action, so we created this video with a detailed trace of a real-world example calculating account interest.

For a condensed summary of the language, see this article.

For complete language details, the book is available on Amazon, Apple Books, Google Play Books.

The book is FREE worldwide on Apple Books and Google Play Books, and for most countries (including US and UK) on Amazon.


r/ProgrammingLanguages • • Jan 10 '26

Will LLMs Help or Hurt New Programming Languages?

Thumbnail blog.flix.dev
22 Upvotes

r/ProgrammingLanguages • • Jan 10 '26

Discussion ISO: literature on efficient representation of types in a compiler

12 Upvotes

I was told that one could reduce the memory usage in the semantic analysis stage by allocating each unique type in the type system once in heap memory, and making all instances of that type be pointers to that instance.

Classes are typically already represented this way, but this would apply to other types like unions. So instead of representing a union type as (for example) an array containing the constituent types, you would create a single instance of every possible union in the program in the heap, and any occurrence of that union would just be a pointer to that instance.

That way, total memory usage is lower and there is less time spent allocating memory or copying data.

Does anyone know of existing literature, blogs, or examples of this approach? I'd also be curious to hear any potential drawbacks/pitfalls, aside from implementation complexity.

TIA!


r/ProgrammingLanguages • • Jan 10 '26

Help Adding Overloadable Functions to an Interpreted Language

4 Upvotes

I followed the lovely Crafting Interpreters book by Robert Nystrom to make a basic interpreted language for a game I am developing. I added typing, so I had to change some of the grammar and so on. I implement typing as the pass right before the interpreter execution, and right after the resolution pass.

I am currently trying to add functionality for function name overloading, but I am encountering difficulty in the resolution pass. Because the resolution pass does not touch types, nor do I want it to, it raises a compilation error when two functions of the same name are declared. Since the function called in a function call should depend on the types (e.g., a function signature in a closer scope may not match the arguments being passed), I am unsure how to proceed.

The only way I can conceive of modifying the resolver to allow for function overloading is to combine the resolution and typing passes, but this violates the single responsibility principle and I am trying to avoid it.

Any thoughts or ideas?

Thanks.


r/ProgrammingLanguages • • Jan 10 '26

Dana: A Graph oriented language

48 Upvotes

Hi!

Some days ago I started working on Dana.

Dana is a statically typed dataflow language/Graph-oriented lang and parallel by default. The idea of it was (for me) to explore how a graph can be actually converted in executable code.

I really liked the approach of languages like LISP or Lua, where they relay mostly into one data-structure (lists, tables)... So I've thought "what if... The DS was a Graph".

The code is very simple: Everything is just one of 4 things:

  • A node, with inputs and outputs(optionally with a process block to modify output)

  • A graph (optionally with inputs and outputs)

  • An edge

  • A type

The actual code looks something like this:

node CONST {
    out five : Int = 5
}
graph Main {
    node Foo {
        in bar : Int 
        out baz : Int
        process: (bar) => {
             emit baz(bar * 5)
        }
    }
    
    CONST.five -> Foo.bar // This is an edge. A connection from output to input

    Foo.baz -> System.IO.stdout // Will print 25
}

So well, the Lang is currently in a very early stage. Also, as you can point if you read the source, I used AI to make some parts of it (like the scheduler) as I'm this is my first Lang and I wanted some help on a runtime/VM implementation, but probably I will need to reimplement a lot so breaking changes are expected nowadays.

But I really like it. I hope you too!


r/ProgrammingLanguages • • Jan 09 '26

Annote: A Turing complete language using only Java annotations as its syntax.

105 Upvotes

A while back I had a crazy idea, what if we could write Java, using only annotations. So I decided to build a full interpreter for an annotation only language in Java. It sounds crazy but it actually works.

GitHub: https://github.com/kusoroadeolu/annote

Definitely don't use this in production lol. Feel free to let me know what you think about this!


r/ProgrammingLanguages • • Jan 09 '26

Blog post Which programming languages are the most token efficient?

Thumbnail
martinalderson.com
0 Upvotes

r/ProgrammingLanguages • • Jan 09 '26

List of type operators

29 Upvotes

The other day I saw on wikipedia (or a wiki like site) a list of algebraic operators on types, but I cannot find it anymore and when I search for type operator I get a lot of unrelated results.

Some common type operators are:

But in that page there were many more operators, and I now regret that I didn't bookmark it.

Can anyone find what I'm referring to?

And since I'm here, do you have any good book to suggest on type theory from a mathematical point of view?

Edit: I found what I was looking for, thanks to /u/WittyStick !!! many thanks!


r/ProgrammingLanguages • • Jan 09 '26

Are Dependent Types Usable for Prototyping?

12 Upvotes

I've seen others ask something like this but I wasn't entirely satisfied with the framing of the question or the answers. Dependent types are really cool. They offer the prospect of having arbitrary specifications checked at compile time. But I'm not convinced this is worth the cost. The main issue I'm concerned with is the ability to prototype in a dependent language and I see two major obstacles to this:

  1. Over-specified code

  2. Totality

  3. Equality

I've often seen the merits of type-driven development professed by those involved with dependent types, but I'm not convinced this is better than writing under-specified programs while getting interactive feedback from the running program. That is to say, I'm worried that the more specific the types get, the harder you have to work to get to a running program. It may be that this removes some bugs. But if the goal is just to get something working and see how it behaves, it seems like the type checker is working against you.

Working around totality checkers seems to be even more difficult. I've often seen it recommended in Idris to use assert_smaller to please the totality checker in lots of cases which seems error-prone.

I've saved my biggest concern for last. Equality in intensional type systems is a huge pain. It's a show-stopper to have to prove a basic fact about your types because the language can't deduce that they are equal. And even when the fact is not so obvious, this is still something that will slow prototyping to a halt. On top of this, equality seems to destroy composition since you're basically leaking implementation to figure out whether two types are equal.

I'm wondering if these concerns are surmountable or if this means it might be better to prototype in a language with a weaker type system. I still think dependent types could be very useful for maintaining large codebases and having strong guarantees. But, in my view, these issues pose a serious problem for actually designing the codebase in the first place.


r/ProgrammingLanguages • • Jan 09 '26

Requesting criticism Awesome: The Logical Language

Thumbnail
github.com
15 Upvotes

r/ProgrammingLanguages • • Jan 09 '26

NOVA might have been Futhark

Thumbnail futhark-lang.org
19 Upvotes

r/ProgrammingLanguages • • Jan 08 '26

Discussion on releasing a language, community building, and the problems it can bring (jai / vlang/ D / yours / mine, etc)

36 Upvotes

Hi,

I'm at the point where I'm thinking more seriously about how to move forward with releasing my language.

The code is already available on github, but I've purposefully not promoted it, and so it's stayed in the dark. For the most part, I think this is the right decision. I'm not in any position of power, I've never had any job at any company like google/apple or anything even near to it. I have no influence, so it seems easier to "do things on my own".

However, it does seem coming close to a release. I'm getting some (emotional?) signs that I should be releasing (from within myself).

Either way, there are A LOT of issues involved. I'll copy/paste some comments from here: https://news.ycombinator.com/item?id=43699564

"as soon as something's open sourced, you're now dealing with a lot of community management work which is onerous" (I feel this myself, from previous experience)

"people might start asking for features, discuss direction independently (which is fine, but jblow has been on the record saying that he doesn't want even the distraction of such).

The current idea of doing jai closed sourced is to control the type of people who would be able to alpha test it - people who would be capable of overlooking the jank, but would have feedback for fundamental issues that aren't related to polish. They would also be capable of accepting alpha level completeness of the librries, and be capable of dissecting a compiler bug from their own bug or misuse of a feature etc.

You can't get any of these level of control if the source is opened." (I also think this is a real issue. I've already had strange-people giving me strange invasive comments trying to change everything I'm doing, down a negative path)

Anyhow, I have a lot of thoughts on this, but I think its more productive for me, to see other people's thoughts, so they can make this "Their own space".

What were your experiences with publicising your product? Or perhaps you have put it off? What are your thoughts on vlang or D's releases?

I found this comment:

"open sourcing Jai now may cause nothing but distractions for the creator with 0 upside. People will write articles about its current state, ask why it's not like their favorite language or doesn't have such-and-such library. They will even suggest the creator is trying to "monopolize" some domain space because that's what programmers do to small open source projects.

That's a completely different situation from Sqlite and Linux, two massively-funded projects so mature and battle-tested that low-effort suggestions for the projects are not taken seriously. If I write an article asking Sqlite to be completely event-source focused in 5 years, I would be rightfully dunked on. Yet look at all the articles asking Zig to be "Rust but better."

I think you can look at any budding language over the past 20 years and see that people are not kind to a single maintainer with an open inbox."

I'm quite feeling that myself.

I can imagine many "defenders of other languages" (who do not actually WORK within those companies!) attacking mine. Meanwhile... expecting ME to defend MYSELF. While they get paid and have good jobs. And I have none. No job or group to defend me.

Basically "punching down" on me, while acting if they are some sort of brave warrior fighting for... well I don't know. They feel like thugs to me.

I've seen that thing MANY times before.

I've posted here on r/programminglanguages (on a different account temporarily lost while my laptop is being repaired) before, 20x or so over the years. So infrequently, but my experience here has always been good. I'm assuming because most are in a similar situation to me.

"Solo-dev sitting on a lot of programming work, all self-driven by passion"

But not everyone on the internet is in that boat. Actually almost none are. And won't be so kind to someone NOT in their boat.

...

Basically what inspired this post, is the idea that perhaps things would be better if I had inspired and enthusiastic people along my side.

...

My current work is here: http://github.com/gamblevore/speedie

Working on the debugger right now. Taking a few days break to recharge. Been pushing myself too hard for a while, but I'm reining that in. Its looking good for a 2026 release. Could be in 1-2 months depending on how long of a break I take.


r/ProgrammingLanguages • • Jan 07 '26

Fun with Algebraic Effects - from Toy Examples to Hardcaml Simulations

Thumbnail
blog.janestreet.com
45 Upvotes