r/ProgrammingLanguages • • Feb 09 '26

Implementing Python in Python

58 Upvotes

Hello, how are you all doing? I want to share a project with you, you may find it fun.

One year ago I took a course in Python as part of my college program. The final exam was to build a project in Python and present it in front of the class. I cound't help myself, I decided to implement Python.

My goal was a Python interpreter that could read it's own code. To accomplish this task i had to first choose the subset i was going to implement. Too small of a subset would lack many features helpfull to writing the interpreter code. Too big of a subset, it would take too much time to implement. I had about 2 weeks to finish it.

The subset i ended up implementing is specified in the readme of the repository. In short, it contains classes (including methods, but no inheritance), functions and a portion of the module system.

Then it came the fun part: have a little benchmark to see how slow it would be to run python inside python inside python. The bencmark i chose was computing a few generations of rule 110, since it fited well with my presentation. I call my interpreter "SPy" here as a shorthand. Here are the numbers on my computer (Celeron N4020):

Time
CPython0.036s
CPython running SPy0.312s
CPython running SPy running SPy1m2s

If you want to test this yourself, the code for the rule110 is in demo/rule110.py. To run the interpreter, you can call interpreter/spy from the terminal, ie, ./spy ../demo/rule110.py. Finally, if you want to run the last example, you will need to run self_test.py, with spy. The interpreter does not understand the code in the spy file, so it needs a little help to interpret it's own code. I did it this way so that i could completely avoid implementing I/O inside the interpreter.

Documentation is mostly in portuguese, so if any of you want a more detailed description of the interpreter, I'd be happy to write it up. I think it may be a good educational project, since you end up using one single language overall. It also has a very clean implementation of indentation sensitive grammar.

That's it, hope you guys like it.


r/ProgrammingLanguages • • Feb 09 '26

So what is it with all the hedgehogs anyway?

Thumbnail futhark-lang.org
37 Upvotes

r/ProgrammingLanguages • • Feb 09 '26

Discussion Is it possible to make dynamic execution graphs for endpoint calls and data pipelines (beyond traces/spans)?

5 Upvotes

So I want to give a little background on my end goal before I explain what I'm looking for here. At my last role, I found it pretty helpful to map out data flow across services. Think of a large data lineage map that shows how models—and individual fields within them—move and transform as data is ingested and eventually displayed to the end user. I’ve found this useful primarily for documentation and for helping new engineers understand system behavior more quickly. Small example below.

However, the pain point with creating these spreadsheets or maps is always taking time to generate and maintain them. I'm trying to look into ways that this could be automated. I've looked into several things, but of course, almost all seem to have their downsides:

  • AST's: Very static and useful, but fall short for dynamic calls and transformations like that
  • Traces/Spans: Also very powerful, but they can easily miss fast function calls or transformations, which is exactly what I want to capture here.
  • LLM'S: Also very powerful, and I've been successful with LLM's with tiny toy scale, but I suspect I'll need a more structured way of using them for this task than just "go map it out chatgpt"
  • debuggers: Also could be useful, of course, they are more concerned with state than mapping out flow

To that end, I'm trying to find a way I can maybe create a call tree/graph or maybe dynamic slices to better allow an llm to trace through an endpoints excution steps and document the transformations of where/when/why they occur. To be clear, I don’t yet know what strategy would work best, but my current intuition is that if I could capture a deterministic, per-request execution map, an LLM might be able to reconstruct this kind of field-level table much more reliably.

I'm curious if anyone has ever tried anything like this? Apologies if this is insane in terms of ambitious or is really just impossible, I'm mostly a backend web dev, so I don't usually move at as low a level as I suspect this problem would require to solve. Also, I do not care about what language this occurs in right now, I'm just curious if it's possible in ANY language.

Example Field Lineage Table

Legend:

  • = direct copy / rename
  • f(x) derived or calculated
  • ∅ not present
  • + multiple inputs
  • ? optional / conditional
Field (final contract)Remote source payloadPipeline mapping DTOBackend ingestion modelInternal domain modelDB modelFinal external endpoint contract
id∅∅∅id = generateUuid()users.id = idid = users.id
namefull_namename = full_namename = namedisplayName = normalizeWhitespace(name)users.display_name = displayNamename = users.display_name
emailemailemail = emailemail = validateEmail(email)emailNorm = lower(trim(email))users.email_norm = emailNormemail = maskEmail(emailNorm)?
createdAtcreated_atcreatedAt = parseISO(created_at)createdAt = createdAtcreatedAt = createdAtusers.created_at = createdAtcreatedAt = users.created_at
statusis_activestatus = is_active ? "active" : "inactive"status = statusstatus = statususers.status = statusstatus = status
sourceintegrationsource = integrationsource = sourcesource = sourceusers.source = sourcesource = source

r/ProgrammingLanguages • • Feb 09 '26

Discussion Separating “intent” from execution: a small experiment in deterministic planning

0 Upvotes

We’ve been experimenting with a language model where intents are the only first-class construct, and execution order is never written by the programmer.

The key idea is to derive a dependency graph from declared preconditions/effects, then freeze semantics in a small intermediate representation before any backend code is generated.

This lets different backends (including AI-generated ones) produce different implementations while remaining observationally equivalent.

I’m curious how people here think about:

  • intent vs declarative programming
  • whether “semantic freeze points” should be explicit in languages
  • how much planning belongs in the language vs the runtime

We’ve draft a preprint if anyone wants to look (link in comments).


r/ProgrammingLanguages • • Feb 08 '26

Languages with strong pre/post conditions?

38 Upvotes

I had some random thoughts. I have class where if I call setThing(N); another function (process) will return an array with at minimum (or exactly) N elements. Is that expressible in any languages?

I always though D pre/post/invariant was interesting. I know ada and spark has more (I plan to look at spark). Is there any languages that can express process returning Array [n] where n is the parameter of setThing? What languages should I look at if I'm interested in contract programming?

I'll likely keep a list of ideas and try to figure it out when I want to implement another programming language


r/ProgrammingLanguages • • Feb 07 '26

Termination tradeoffs

19 Upvotes

There are some languages, mainly theorem provers, are not only pure but also total. It seems like they eliminate nontermination, and use monads to introduce effects through encoding while keeping the language pure.

There’s obviously a tradeoff with having/not having termination (even encoded with monads). In theory you wouldn’t be able to represent everything that is possibly computable. Including programs that don’t terminate on some inputs or programs that terminate on all inputs but due to the undecidability of the halting problem are not provably terminating and so it is impossible for you to judge whether its terminating or not. On the other hand, being strictly total would limit expressiveness in exchange for well behaved guarantees

It would be nice to be able to create these programs in a language, but in practicality when are you ever really going to be working with programs like these? If your code possibly doesn’t terminate it’s just bad code, you want your programs to terminate and work properly. Even if it only doesn’t terminate on inputs you don’t care about, you might as well structure your code to ensure these non terminating inputs are never given. The only advantage I can really think of is the convenience of using general recursion with a fix point solver. But many total languages have fix point convenience as long as the typechecker can prove that the program is terminating, and I would be more than willing to give that up if it means all my programs are guaranteed to terminate

Edit: my bad I totally forgot about long running servers where you intentionally want to iterate infinitely, but for other purposes it’s not too useful to have unrestricted recursion


r/ProgrammingLanguages • • Feb 07 '26

Checking names without checking types

31 Upvotes

Hello, how are you all doing?

I've been spending a lot of time with dynamically typed languages lately, mostly Python and JavaScript, and I've found that most errors I make are around names, not types. Most errors are around renaming and forgetting to fix one occurrence. Python was the worst experience, mostly because I was running heavy data analysis and, after minutes of running, it would finally reach one branch where i forgot to change one name.

That made me think: Why are there no mainstream languages with static name resolution and dynamic types? Of course, a few lisps seem to live in this intersection, Racket for example seem resolve names statically. But rarely do I see scripting languages in this intersection.

So I thought for quite a while about this and it seems like, after name resolution, you have most tools to do type checking, at least the simpler kind. But nevertheless, even with the proper infrastructure on hand, _designing_ an expressive type system is still a lot more work, so the implementation details don't seem that important.

Another problem I see is that, if you go the route of checking the names of properties, you end up having to carry a "pseudo type information" in the symbol table, which requires the same logic a typechecker would have.

Also, if a function says it requires an object with certain property names, it would be a failed opportunity to check the call-sites of this function, so in the end, it's a half-finished typechecker. This would make the typing feel more gradual, which is already somewhat a grey area that tends towards full static typing.

So, is there any language you know that has static names and dynamic types? Do you know other reasons why languages tend to not fall into this class?


r/ProgrammingLanguages • • Feb 07 '26

Blog post LLMs could be, but shouldn't be compilers

Thumbnail alperenkeles.com
23 Upvotes

I thought it would be interesting for the people interested in PLT to read this, please let me know if it’s against the rules or ruled irrelevant, I’ll delete. Thanks for any comments and feedback in advance.


r/ProgrammingLanguages • • Feb 07 '26

Runtime-configurable, right-recursive grammar parser with backtracking capabilites: rdesc

5 Upvotes

r/ProgrammingLanguages • • Feb 06 '26

Requesting criticism Created my own esolang SDAPL.

Thumbnail esolangs.org
9 Upvotes

Check it out!


r/ProgrammingLanguages • • Feb 06 '26

European Lisp Symposium 2025: Talks

Thumbnail youtube.com
12 Upvotes

r/ProgrammingLanguages • • Feb 05 '26

Discussion The world’s first high‑level programming language was invented in a German attic — Konrad Zuse’s Plankalkül (1948‑1949)

Thumbnail reddit.com
44 Upvotes

r/ProgrammingLanguages • • Feb 05 '26

When cost models hit the wall clock

Thumbnail futhark-lang.org
31 Upvotes

r/ProgrammingLanguages • • Feb 05 '26

Enforcing security at compile time

8 Upvotes

For research purposes I'm building a capability based stack, where by stack I mean the collection formed by a virtual ISA, an OS (or proto OS), a compiler and a virtual machine. To save time I'm reusing most of the Rust/Cranelift/Webassembly infrastructure, and as hardware the RP2350 seems to be an ideal candidate.

Obviously I don't have hardware support for the capability pointers, so I have to emulate it in software. My current approach is to run bytecode inside the virtual machine, to enforce capabilities at runtime. Anyhow I'm also thinking of another approach: Enforce the rules at compile time, verify that the rules has been respected with static analysis of the compiled output, and use cryptographic signature to mark binaries that are safe to run.

Let's make an example: Loading memory with a raw pointer is illegal, and is considered a privileged operation reserved only to the kernel memory subsystem. What I do instead is to use tagged pointers which are resolved against a capability pointer table to recover the raw address. To do this I have a small library / routine that programs need to use to legally access memory.

On a simple load/store ISA like RISCv I can simply check in the assembler output that all loads goes through this routine instead of doing direct loads. On x86 it might be a bit more complicated.

Is this approach plausible? Is it possible to guarantee with static analysis of the assembler that no illegal operations are performed, or somehow could a malicious user somehow hide illegal ops?


r/ProgrammingLanguages • • Feb 05 '26

How would you design proof-carrying `if` statements in a minimal dependently typed language?

25 Upvotes

I’m designing and implementing a dependently typed language and hit a design question.

I want to support code like this:

if h : n mod 2 = 0 then
  // Here, I know n mod 2 = 0, and I want that proof in scope
  useEvenProperty n h
else
  handleOdd n

The goal is that in the then branch, the proof of the condition can be available as a value — so I can pass it to functions that require evidence, like sqrtEven : (m : Nat) → m mod 2 = 0 → Real. You can elide the h : if you don't need the proof in the then branch.

But I want to avoid heavy machinery:

  • No type classes / traits (too much for MVP)
  • No separate decision operators (like ≟ or =?). I’d like = to be the only equality, representing both the computation and the proposition.

I’m currently thinking of desugaring if c then t else e into a match on a decision procedure for c, but I’m not sure how to:

  1. Associate a decision procedure with a proposition
  2. Keep it simple to implement, reason about, and understand for the programmer.
  3. Avoid multiple operators for similar things. Ideally, there should be one = operator with no additional ≟. This means that the proposition symbol must stand for both the proposition and its decision procedure.

So I’m curious: how would you solve this?

Are there known patterns that handle this cleanly?

I’m especially interested in minimal, first-principles approaches that don’t rely on other complex features. If expressions are fundamental. This feature is needed to enable writing more complex programs in the language.

Thanks!


r/ProgrammingLanguages • • Feb 05 '26

Agentic Proof-Oriented Programming

Thumbnail risemsr.github.io
0 Upvotes

r/ProgrammingLanguages • • Feb 04 '26

Was CGO (Code Generation and Optimization) 2026 streamed online this year? does anyone have the link

Thumbnail reddit.com
7 Upvotes

r/ProgrammingLanguages • • Feb 03 '26

Tutorial on program synthesis using MCTS

Thumbnail shukla.io
11 Upvotes

OP here. In the post, I talk about how to search in program-space (or grammar-space) to find a model that best fits some training examples. Hope you enjoy the interactive demos :)


r/ProgrammingLanguages • • Feb 03 '26

When magic meets multicore: OCaml and its elegant era of parallelism

Thumbnail youtube.com
14 Upvotes

r/ProgrammingLanguages • • Feb 03 '26

Custom tuning parameters - a dubious feature

Thumbnail futhark-lang.org
20 Upvotes

r/ProgrammingLanguages • • Feb 03 '26

Defining Safe Hardware Design

Thumbnail people.csail.mit.edu
8 Upvotes

r/ProgrammingLanguages • • Feb 03 '26

Discussion Is it worth it to support importing precompiled code, and what are Source Maps used for?

6 Upvotes

I'm working on a prototype for my language. Now ideally, in the future, it would be fully statically typed and compiled, but right now the prototype will be dynamically typed so I can get a proof of concept of the actual features that the language is supposed to be build around, and so I can test other things.

In implementing it, I had the thought to use a Source Map, which I believe other compilers also use, to hold all of the code sources. My initial idea was that it could be used to reference when files are imported, and handle things when a precompiled source file is imported.

But I was thinking about it and I don't really know how I would even go about working with a precompiled source file. So is it worth it trying to work with this? Especially for a language that one person is working on? Or is it better to just have it recompiled every time? I think ultimately it is going to be compiled, but the users (if I have any) will probably be used to dynamic languages, so it may be fine to not work with precompiled code.

Another question I have is regarding what Source Maps are used for. I was reading some stuff, and it seems they are also used for storing line offsets for better reporting?

My language will have an extensive use of special characters, because it is meant to be focused on mathematics. However, when working on the lexer, the tokens would store the start and end indices, but those may not always align with what looks like characters to a developer. So should I also store something like the grapheme clusters or something else? Should these be stored within the tokens or within the Source Map? Or should I figure those out when a report is made?

And is there anything else that is usually stored within Source Maps as well? Or any other similar features or structures that are good to have?


r/ProgrammingLanguages • • Feb 03 '26

Tadpole - A modular and extensible DSL built for web scraping

8 Upvotes

Hello!

I wanted to share my recent project: Tadpole. It is a custom DSL built on top of KDL specifically for web scraping and browser automation.

Github Repo: https://github.com/tadpolehq/tadpole

Example

import "modules/redfin/mod.kdl" repo="github.com/tadpolehq/community"

main {
  new_page {
    redfin.search text="=text"
    wait_until
    redfin.extract_from_card extract_to="addresses" {
      address {
        redfin.extract_address_from_card
      }
    }
  }
}

and to run it:

tadpole run redfin.kdl --input '{"text": "Seattle, WA"}' --auto --output output.json

and the output:

{
  "addresses": [
      {
        "address": "2011 E James St, Seattle, WA 98122"
      },
      {
        "address": "8020 17th Ave NW, Seattle, WA 98117"
      },
      {
        "address": "4015 SW Donovan St, Seattle, WA 98136"
      },
      {
        "address": "116 13th Ave, Seattle, WA 98122"
      }
      ...
    ]
}

The package was just released! Had a great time dealing with changesets not replacing the workspace: prefix. There will be bugs, but I will be actively releasing new features. Hope you guys enjoy this project! Feedback and contributions are greatly appreciated!

Also, I created a repository: https://github.com/tadpolehq/community for people to share their scraper code if they want to!


r/ProgrammingLanguages • • Feb 02 '26

Formally Verifying PBS Kids with Lean4

Thumbnail shadaj.me
66 Upvotes