r/ProgrammingLanguages

List of known problems in design of existing languages?

Is there alphabetic list of desing flaws/bad ideas in various programming languages?

For exampe you might find short description of dangling-else from under d letter in list.

reddit.com
u/KukkaisPrinssi — 13 hours ago
▲ 55 r/ProgrammingLanguages+3 crossposts

Phase — a statically-typed bytecode-interpreted language in C, with an essay on implementation

Phase is a statically-typed bytecode-interpreted programming language written in ~4,800 lines of C with zero external dependencies. It features a 25-opcode stack-based VM, 21 error types with source-mapped diagnostics, 5 primitive types, and a standard interpreter pipeline (lexer, parser, type checker, bytecode generator, VM).

I also wrote a technical piece on how it works by following out("Hello world!") end-to-end through every stage.

Writing: williamalexakis.com/interpreter-in-c

Repo: github.com/williamalexakis/phase

u/williamalexakis — 1 day ago

The current state of code generation is making me appreciate theorem provers so much more

watching the industry just blindly accept whatever an autoregressive model spits out is honestly exhausting. we are basically building software on top of glorified autocomplete that just guesses the most likely next token. it feels like mainstream programming is completely forgetting that correctness actually matters

Been messing around with Lean 4 lately just to cleanse my palate. There is something incredibly satisfying about a compiler that just flat out rejects your code if the mathematical proof doesn't close. it forces you to actually design the semantics properly instead of just brute-forcing edge cases with a dozen unit tests

tbh it feels like the only way we survive this flood of probabilistic slop is if we heavily shift our language ecosystems toward strict formal verification as a baseline. was reading earlier about how alternative architectures (like EBMs) are actually starting to max out these theorem proving benchmarks, which is kinda fascinating to see

maybe there's hope that the future of PL design won't just be about generating plausible strings of text, but actually building languages and environments where invalid state transitions are mathematically impossible to express. anyone else diving into proof assistants lately just to escape the madness?

u/mrcanada66 — 1 day ago

Parsing Math with Pratt Parsing

I wrote a beginner-friendly blog post about Pratt parsing, hopefully it can help more people understand it. This is actually what I wanted to see when I was learning it; when I was reading Bjarne Stroustrup's book on C++ he also builds a little math parser and it is really simple to follow. The code for the full project is also available at the end of the post under the citations.

washingtonramos.com
u/KingOfPotatoFarms — 1 day ago

Flower Compiler (Bootstrapped Compiler)

Hey all!

For the past few months I've been working on a language called Flower. It was originally written in C (files can be found under /vendor/) but is now fully bootstrapped (with some caveats). The goal is to eventually move toward a fully self-hosted toolchain and custom backend, but for now it transcompiles to C.

Some current language features:

  • structs
  • pointers (@T)
  • arrays
  • function definitions/calls
  • manual memory management (new / prune)
  • operator precedence parsing
  • struct literals / array literals
  • casts
  • dereferencing / address-of
  • control flow (if, while, for, etc.)

Example:

struct Vec2 {
    x: float,
    y: float
}

float length(v: Vec2):
    return v.x * v.x + v.y * v.y
end

I thought I knew a decent amount of C and programming before hand, especially considering this isn't my first time making a language in C, but I've noticed how far my skills have come especially regarding just being able to problem solve and properly organize my project structure.

Recently I added parser error recovery in v1.1.0, and after a lot of trial and error I think I've finalized my parser to a recursive-descent style approach.

Let me know any criticism, opinions, or comments you have! I'd love to get some input :)

https://github.com/IvyMycelia/flower/blob/main/

u/TrendyBananaYTdev — 2 days ago

The Borrow Checker and Rapid Prototyping

How would you feel about a language that has a borrow checker with a prototyping mode for rapid iteration? In this mode, proper annotations would still be required (failure to do so would result in compile errors) because the compiler still needs that information to reason about lifetimes, but violations of the rules themselves would result in warnings. Compiling in safe mode would be just like Rust, resulting in errors.

Do you think this would meaningfully improve iteration times for domains which require it (game dev, for example)?

Would this defeat the purpose of a borrow checker, in that most would follow the path of least resistance and not bother to clean up after themselves, resulting in an ecosystem of unsafe libraries?

reddit.com
u/West_Violinist_6809 — 1 day ago

[Online BYOPL course] Build your own programming language

Hi everyone, I am new here!

Each year I teach an undergraduate-level college course on programing languages in which I start from the beginning, namely BNF grammars, and then describe parser generators, in our case Jison.

Next I introduce and cover the functional paradigm in depth. This allows us to design and implement our own functional programming language, which I call SLang, for Simple LANGuage. In this course, the implementation strategy is via interpreters. Note that I also have another course on my YT channel that explains how to build a javac compiler from scratch.

In the second half of the BYOPL course, we design and implement a non-functional version of SLang which includes non-functional features like assignment statements, sequencing, etc. We also implement recursive functions by "tying the knot".

Other topics covered in this semester-long course include the lambda calculus, eager vs lazy evaluation, six distinct parameter-passing mechanisms, infinite lists, type systems, etc.

This is a college course which I was teaching synchronously online in Spring 2021, during COVID times. I just started editing and posting those videos two days ago. I will keep posting new videos daily over the summer. You can start the course right now as it is just beginning.

If you want to check it out, here is the BYOPL course playlist:

https://www.youtube.com/playlist?list=PLIgSR01UTt8OHY8WhAqOmr8EzArJYd5Z0

On my YT channel, I also have a full discrete math course (158 videos), as well as other playlists on cybersecurity topics and a few others. Here is my channel:

https://www.youtube.com/@davidfurcy

Looking forward to your feedback!

u/AnotherCSprof — 3 days ago

can a language be safe and be a subset of C?

Imagine you start with the C language and then make the following changes:

  1. Remove pointer arithmetic. You want an array, you declare an array.
  2. Change the compilation of string and array literals to emit a length prefix.
  3. Rewrite the entire standard library so that all string and array functions enforce a length header in front of the data.
  4. Add RTTI to all unions and varargs so that incorrect casts fail rather than UB.
  5. Remove `void *`.
  6. Forbid malloc() without static compile-time verification that the matching free() exists (with some sort of Bounded Model Checking to sidestep a rather inconvenient Halting Problem).

Is such a language possible?

Has it ever been attempted?

reddit.com
u/Null-Test-2026 — 4 days ago
▲ 3 r/ProgrammingLanguages+1 crossposts

IR for my compiler

Since few days, I have been working on a compiler written in python. I have successfully implemented a frontend and I want a backend to generate IR for. I have decided to make my own IR but I don't know a lot about them. Can y'all please provide me with information with types of IR, optimization tricks they utilise, and how they are implemented or work. Any type of material will be thankful.

reddit.com
u/juicyroaster — 4 days ago

Name for function that returns the same type of all its parameters

Hi all,
apologies for my inexperience, I'm not formally trained in CS.

I'm writing a small programming language to play around with some ideas, and I've come to the point of implementing constants folding. While doing so, I realized the AST token I use to group binary operators could probably be split in 2 different tokens instead: one for operations that return the same type of all the inputs (like addition/multiplication/etc: `add(a: T, b:T) -> T`) and one for operations that return a different type (e.g.: `greather_than(a: T, b;T) -> bool` and friends).

Out of curiosity, is there a specific name for a function whose output type is the same as the type of all its parameters ? It would help me name those 2 different categories appropriately.

reddit.com
u/Jumpy-Iron-7742 — 5 days ago
▲ 24 r/ProgrammingLanguages+1 crossposts

Compile time evaluation

I want to include compile time evaluation in my language.

For context I have most of the language design and compiler planned out and am currently implementing it. Currently writing the parser that turns a stream of tokens into the ast. The plan is to target llvm ir for the moment.

While I have enough to do before I have to address it I want to get some information about executing code at compile time. I am explicitly not talking about macros for them I already have an idea. My questions are:

  1. How to decide rather to execute a function or keep the call in code

  2. Security concern about access to the system on compile time evaluation

  3. How to execute it without writing a separate interpreter

  4. Does llvm provide any supporting features for this

Thanks

reddit.com
u/RedCrafter_LP — 5 days ago

When to desugar?

I had a light bulb moment last night and I'm embarrassed I didn't think of it sooner because its used in so many other languages. I realized lots of things could be desugared into simpler syntax (not IR). But the more I think about it, the more it seems not-so-straightforward.

Consider:

fn stuff(likesFemBoys = false) {
    // Stuff
}

We could avoid a "DefaultParam" Node by turning the function into

fn stuff(likesFemBoys: Bool) {
    likesFemBoys = false;
    // Stuff
}

But, depending on how a language is implemented, it raises some issues. If your language doesn't allow parameters to be implicitly mutable, you'll need to use a temp to work around it. Something like:

fn stuff(likesFemBoys: Bool) {
   let xx_default_likesFemBoys = false;
   // Stuff
}

Well now you have to use xx_default_likesFemBoys everywhere likesFemBoys is used. And, you have to ensure that no user defined identifier can start with xx_default_. It feels a bit ... hacky?

You could defer doing all that till you get to IR and have the DefaultParam Node in your AST. But, all the previous stages will have to explicitly handle the sugared nodes (there's typically a lot), when we could have desugared them earlier and keep everything consistent and simpler.

But if you desugar them earlier, you might have to do workarounds like what was described above. Error messages could also become trickier to get right.

Another example is handling nulls. E.g. as seen in other languages

let name = findName() ?? "NoName";

Which might be desugared into:

mut tmp = findName();
if tmp == null tmp = "NoName";
let name = tmp;

When would be appropriate to desugar this? Would you create an AST node for it? Or simply parse it as an assignment statement, if statement, and another assignment statement?

reddit.com
u/Ifeee001 — 4 days ago

Creating a new lang

I wanna make a language for my Undergraduate Thesis, I guys know any place that have something like a tutorial or roadmap to make one? I just found a person talking about analyzers

reddit.com
u/miojo_noiado — 4 days ago
▲ 8 r/ProgrammingLanguages+2 crossposts

I built a lightweight VM/runtime for AI-generated scripts from scratch

Most runtimes used by AI agents today are designed for humans, not disposable AI-generated code.

I’ve been experimenting with a small scripting runtime called Autolang focused on:

  • low startup latency,
  • strict static restrictions,
  • restartable arena memory,
  • opcode execution limits,
  • and lightweight orchestration around existing ecosystems (Python/C++/JS).

The goal isn’t replacing Python, but creating a safer intermediary layer for short-lived AI-generated scripts.

I’m curious whether people here think this direction makes sense for modern AI-agent systems, especially compared to approaches like Wasm, Lua, or sandboxed Python.

I’d also genuinely appreciate feedback on runtime/compiler design and possible performance improvements if the project sounds interesting.

autolang.adagroup.com.vn
u/TomatoKindly7082 — 5 days ago
▲ 98 r/ProgrammingLanguages+3 crossposts

Rewriting C until it's quantum code (A tutorial)

OP here. I'm trying out a new interactive way to teach complex concepts. What do you think of the style? How about content, could you follow along okay?

shukla.io
u/CarbonFire — 7 days ago