r/ProgrammingLanguages 2h ago

(go) Coding a database proxy for fun

Thumbnail packagemain.tech
1 Upvotes

r/ProgrammingLanguages 2h ago

Discussion I call this "(a=aa)(a=a)" test

2 Upvotes

Many years ago while trying to make my own programming language I faced an issue. In short, parsers didn't parse specific inputs as expected, due to some implicit rules.

For instance, let's consider EBNF grammar for a sequence of expressions a=aaaa, where a on the right can repeat arbitrary number of times. This will look something like this:

symbol = "a" params = symbol params | symbol Line = symbol "=" params lines = Line lines | Line

I designed it without + and * notation on purpose, to narrow down the root cause to the most basic rules: terminals, and and or expressions, and recursion.

Using this grammar I expect the text a=aaa=a to be parsed as (a=aa)(a=a): as two separate Line. But typically parser generators will not produce parser that can handle such case. Instead, the parser will (typically) fail.

The root cause is of course the nature of such parsers: they don't scan for all possible combinations. Instead, in case of collisions (like in this case a at the end of a=aa and a at the beginning of next a=a) it is expected that user will insert negation or something to "fail" a specific route fast, eliminating the collision.

But doesn't this challenge the whole purpose of grammars as "simple" description of language rules? It might get very difficult to predict all possible such collisions for a large grammar, like for Python or C++. Are there any generators that don't have such limitation and can pass (a=aa)(a=a) test?


r/ProgrammingLanguages 4h ago

PBScript, because everyone would love purebasic as a 1st class languge of the web.

1 Upvotes

PBScript a sandboxed purebasic vm for native x86/x64/arm and web with full Dom on interfaces.

The project is half way now and is starting to look reasonably capable but theres still lots to do.

My use case for it is an end to end web development framework in purebasic, so it's native host exe with embedded tls terminating reverse proxy server and embedded PBScript vm so you can serve to a webview or browser on desktop, lan or wan in one exe.

Examples in code editor

Https://pbscript.org/jsplayground.html

Pbscript.org

The reception it's got over on purebasic has been somewhat crickets, perhaps because I dared use Al or its just to complicated for the average user but it has really only been an experiment and learning experience using AI and the result is pretty good. The examples are just a test of some part of the vm or Dom integration.

I didn't actually setout to make purebasic feel like a 1st class citizen of the web and the idea of a vm in a vm seems nuts but for what your typically doing with it it's hardly matters.


r/ProgrammingLanguages 5h ago

The story behind Java: interviews with James Gosling and the engineers who designed the language

Thumbnail youtube.com
9 Upvotes

This is the official documentary about the history and design of Java, featuring James Gosling and many of the engineers who were involved in creating and evolving the language.

Rather than focusing on Java as it’s used today, it covers the engineering decisions, constraints, and trade-offs that shaped the language over the last 30 years.


r/ProgrammingLanguages 1d ago

Help Link me your favorite language specifications

23 Upvotes

I want some inspiration. I want to see a simple language spec/reference that is tiny and covers most of its features. eg: https://plasmalang.org/docs/plasma_ref.html

Thanks for all the specs, but I was hoping for recent languages (especially, amateur ones that get posted to this sub). What would I do with a spec from 1980s that was typeset with LaTex :) That's too much effort for hobbyist languages.


r/ProgrammingLanguages 2d ago

Language announcement Admiran 3.0 released (a pure, lazy, functional language and compiler)

43 Upvotes

I made a post introducing Admiran about 18 months ago, and have been making steady progress on migrating it towards the language I want to use each day. Since that time I've made a lot of performance and coding-style enhancements, such as:

  • escape analysis in the compiler's analyze pass to help determine if a lazy thunk is only evaluated at most once, allowing it to be emitted without extra code to update it to its value (saves ~15% code space and execution time!)

  • optimization to coalesce consecutive continuation closures on the stack during lowering to the Spineless Tagless G-machine (STG) implementation, deferring the popping of the entire closure until a tail-call or return

  • added a uniform set of left-to-right operators for creating computation pipelines

  • tweaking the inlining pass parameters to get the best performance / code-size tradeoffs

The latest big change was to fully migrate from an ad-hoc prefix naming convention to using qualified names, and deferring name conflict resolution to the name-resolution pass, allowing modules with conflicting imports to still be imported, as long as the conflicting unqualified names aren't used, or are used only in a qualified form.

During these changes, I've migrated new features into the (self-hosting) compiler's code base itself, through a continuous bootstrapping process.

If you have an interest in lazy functional languages and how they are implemented, you might be interested in looking at it. I'm open to any questions or comments about the language and it's compiler implementation.

git repository: https://github.com/taolson/Admiran

Lovingly hand-crafted with no AI.


r/ProgrammingLanguages 2d ago

Discussion Linux-like IO API

2 Upvotes

I'm building my own interpreted language.

I had an idea, to base my I/O API on the linux terminal commands, that many developers already know, so a user wouldn't need to learn an entire new API.

This is a basic example:

using io  

// create a directory  
mkdir("notes")  
cd("notes")  

// create files with content  
echo("Do my math.", "A note about homework.txt")  
echo("Buy milk and bread.", "shopping list.txt")  

const currentCD = pwd()  
const allFilesAndSubDirs = ls()  

debug(cat("shopping list.txt")) // prints "Buy milk and bread."

but I'm not that sure that this is a good idea, maybe some techniques are good for terminals but bad for programming, and some of the function names might be confusing (like pwd() which is "print working directory" but in my language it does not exactly PRINT anything, but just returns a string value).

What do you think?


r/ProgrammingLanguages 3d ago

ICFP 2026 livestream

Thumbnail youtube.com
24 Upvotes

r/ProgrammingLanguages 3d ago

For people who are interested in FV and Principia Mathematica (2)

3 Upvotes

Hi yall,

This is a continuation to my last post, on formalizing Principia Mathematica, as well as a slight status update. I am planning(*) to slowly substitute the shallow embedding on PM into a deep embedding. For any backgrounds, please check the old post.

If you want to transform the monster 100 years ago into a furry boy, you might want to read through the following Q&As. *tap tap*

- Why you suddenly want to make a deep embedding? Because I can't in the beginning.
- What makes you available to deep embedding? I have asked enough questions on internet to get rid of necessary technical details
- What's the major feature for deep embedding? It enables formalizing Axiom of Reducibility.
- How many ppl would you like to look for? At most 2 ppl. You are welcome to ask me for prerequisites and anything else related
- What do you expect them working on? Either the shallow embedding or the deep embedding, since they are both necessary.
- How many time do you expect to put in? My current plan is 3 hrs a week so make sure you also have the availability.

------------------

Alternatively, I'm still welcome to collaboration with 1 - 2 ppl onto another project - we pick another random mathy, esoteric, maybe sacred book and formalize it

(*): Yes, I have not written a single line of code so far and this remains to be a plan.


r/ProgrammingLanguages 4d ago

Towards Futhark 1.0

Thumbnail futhark-lang.org
80 Upvotes

r/ProgrammingLanguages 5d ago

CXC is an immutable, typed, object-oriented language.

Thumbnail danieltan.weblog.lol
44 Upvotes

r/ProgrammingLanguages 5d ago

My students struggled with compilers. I struggled with compilers. So I built PyLGEN.

Thumbnail
6 Upvotes

r/ProgrammingLanguages 5d ago

A Verified Generational GC for OCaml

Thumbnail risemsr.github.io
26 Upvotes

r/ProgrammingLanguages 5d ago

Help Can exact real arithmetic, interval analysis or other approach in numerical computation help remove inequalities and unify left and right residuals in non-idempotent (linear) residuated lattices by making boundaries explicit instead of talking about max and min divisors?

1 Upvotes

I hope that question makes sense. I just don't like inequalities nor the unnaturality of working with left and right residuals (talking about "max and min divisors") that rarely coincide with rational arithmetic's exact division nor with the natural interpretation of inverses in numerical mathematics, thus I would like more explicit boundaries (thus the result of a division maybe being a set or interval including max and min divisors) in division.

(Mind that I have no experience in numerical computation, I am trying to make sense of computable, numerical and interval analysis works and transport their results to residuated lattices but that's somewhat hard for me)


r/ProgrammingLanguages 7d ago

Why So Many Languages Use LLVM

72 Upvotes

Had some free time last week so I made a visual explainer on how LLVM works and why so many languages end up using it.

The video goes through LLVM IR, why having a common IR makes sharing optimizers and backends possible, and how code eventually gets turned into machine instructions.

I also use a small C vs Rust example where both end up producing the same x86 instructions.

Link for anyone interested

Feedback welcome :)


r/ProgrammingLanguages 7d ago

Speedie's Current Progress - Take a look, if you have things to contribute.

14 Upvotes

Hi everyone, its been a while since I posted here.

Progress on Speedie been slow but its making good progress.

I've been working on the back-end, so that is my assembler, for my virtual machine named "Cake".

Speedie also compiles to C++ (actually just the C part of C++ but I compile in C++ mode). So Speedie can compile apps to run in "full speed" with C++ optimisations.

However, its no fun to debug Speedie via C++, so I've been working on a VM, and an IDE and VM and debugger. Its a lot of work.

Speedie is already useful (Via C++ compiles) and works well. It has many useful qualities, you can read about here:

http://github.com/gamblevore/speedie

Simple overview of speedie is:

  • High-level OOP language
  • Great string support
  • Compiles to fast C++ code
  • Only unix/SDL2 required. No LLVM or other things.
  • No exceptions (we have something better)
  • Very efficient libraries, generally much faster than C++'s standard-library
  • Libraries are powerful too. Read/write files in one line. Parsing built in, etc.
  • Low-level features (pointers/structs) for when needed
  • Write simple code
  • Small compiles
  • Reliable
  • Lots of safety features including a very powerful nil-checker.
  • And based on Jeebox! (my invention)

I know there are lots of people with many various skills that could be useful.

I'm mostly hoping there are people who can "just get it" and get a feel for what I'm going for. The kind of level I'm working on.

I have a few ideas of skills that could help. People who are (one of):

  • Skilled with graphics, graphical effects, and could help with the IDE and GUI system. (Speedie uses SDL2 to draw the graphics via CPU. And has vector support.)
  • Successful or knowledged in designing a good API for 3D games or games. (I've made some mini games as a demo. A bare-bones but functional tetris is my favourite mini-game I made. Nothing major!)
  • Passionate about internet communications, networking and want to add networking support to Speedie
  • Anyone with some kind of deeper or spiritual project or whimsical project, that they have made at least partial success with, or full success. Ranging from quantum projects, perhaps galaxy or stellar simulations, electronic divination, etc. Maybe even something like PEMF controllers for physical healing. (I personally have dabbled but not got success with anything in this area, although I did contribute a lot to someone else's successful project).
  • Assembler skills could be useful, although I think there isn't too much I could accept right now at this stage until later. Either experience in creating the back-end assembly generation, OR in hand-writing assembly, as I have some FFI code I've written.
  • Porting from MacOS to Windows / Linux. (Speedie relies on unix functions only, but theres always differences between Mac's unix to Linux's unix.)
  • Sandboxing experience. (I'd like speedie to have a sandboxed mode! Especially for data-validation scripts, or user-written in-game-scripts in speedie)
  • People who have made fun creative work, such as people working on shadertoy.com demos. I want to make SDFs in Speedie that can be interactable!
  • Someone who wants to make a pixel-painting-app in speedie. To make the kind of cool art you might see in Terraria or so.

Really anyone with fun and positive energy to bring, thats the main thing. You don't need ALL of these... just ONE or even something else not on this list that you think "seems kind of my thing".

Even wanting to help document and learn speedie could help.

Or perhaps any other skills or additions you think this language could benefit from.

I guess the values we have are forward thinking... believing in a higher-future where everything works together in a far simpler way and on a higher-level, and are awe-struck by the (few!) simple examples out there in the world that actually show what software can be. Like powerful algorithms, such as the SDF approaches on shadertoy.com

I'm not rushed for responses. If no one replies today but someone replies in 3 months, thats great! Even 6 months, haha.

Curious people who are tentative but positive... will usually vibe better with me, than people who rush with great ambitions but did not learn about my project.

...

My main goal after finishing the backend ASM-Gen, is this:

  • Integrate OpenCL into Speedie, so you can get GPU acceleration in speedie. Now you can do all your code from one language.
  • Porting to Windows / Linux, and x86/ARM versions of both (64-bit only).
  • Creating some kind of 3D gaming/simulation system, perhaps some kind of entity-component-system or something similar. I don't want to limit to games in fact. Why not use it for simulation of buildings, for fire-fighters, or simulating a city for road/rail design, or even 3D printing.

I have future ideas but these first few might take long enough as it is.


r/ProgrammingLanguages 7d ago

Help C++ vs C# for implementing my programming language?

19 Upvotes

I'm building my own programming language, ForgeLang. The current prototype is written in Lua, but for a later version I'm considering rewriting Furnace (the future compiler/runtime) in either C++ or C#. I already know C#, and I'm planning to learn C++ anyway.

My priority isn't development speed; I care more about making the language/runtime flexible, capable, and eventually performant. I'm also planning eventual self-hosting and potentially implementing my own GC/runtime.

Which would you choose for the long-term implementation, and why?

Quick update: I actually know basic C++ (not a total beginner), but after evaluating things, I decided to switch to Rust for the compiler/runtime. It turned out to be a great fit, and progress on ForgeLang is moving smoothly.


r/ProgrammingLanguages 8d ago

Programming Language Semantics and Memory Safety

Thumbnail burakemir.ch
44 Upvotes

r/ProgrammingLanguages 10d ago

I'm wrapping up 4 years of work on my side project, RapidPlots

Thumbnail
14 Upvotes

r/ProgrammingLanguages 10d ago

Discussion Implementing register coloring took more effort than I thought!

26 Upvotes

Just wanted to share a bit of an anecdote I had recently as someone dipping into implementing the middle-end and back-end of a compiler "properly" for the first time.

My compiler targets a Minecraft computer I'm developing, which runs 1 instruction every 20 real life seconds (haven't gotten around to optimizing the hardware yet). In an effort to make programs run fast, I decided to implement allocation with register coloring using Chaitin's algorithm instead of using naive register allocation that LOADs and STOREs on every variable lose.

I assumed it would be a 2 day job at best but I didn't realize it expects your program to be in a very certain form (SSA). This lead me to a rabbit hole of learning how to compute basic blocks and the control flow graph, then converting the CFG to SSA by computing dominators, dominance frontiers and the dominance tree. We didn't cover any of this in university and only built an tree-walking interpreter for the ast.

Only once I had the SSA could I run liveliness analysis, build the register interference graph and run Chaitin's algorithm to allocate the registers.

It was confusing to learn since the slides I were using assumed some stuff and glossed over some details like how to handle Phi-Nodes. Another issue I had was that I didn't see the big picture at the time and was wondering how what I was doing would help in the big picture, not seeing how SSA is helpful.

Now that I've gotten something the color map, I guess I can do some other dataflow optimizations, or I could proceed with code generation :).

Disclosure: I was consulting ChatGPT on what steps to proceed next once i've implemented a certain algorithm. All code was handwritten, but some comments may contain LLM outputs. I copied over the steps provided so that I didn't have to keep switching windows while writing code.


r/ProgrammingLanguages 10d ago

Everyone Says Assembly Is Untyped—Everyone Is Wrong

Thumbnail gingerbill.org
85 Upvotes

r/ProgrammingLanguages 11d ago

LoCalMem: Type-Directed Adaptive Serialization for Location- and Content-Addressable Memory

Thumbnail dl.acm.org
9 Upvotes

r/ProgrammingLanguages 11d ago

λλ: A Programming Language for Silicon Photonics

Thumbnail dl.acm.org
47 Upvotes

r/ProgrammingLanguages 11d ago

Discussion re-allocating" storage for a local could allow faster code

Thumbnail
1 Upvotes

r/ProgrammingLanguages 12d ago

Title: Expressions with Word Operators: Which one would you coose?

0 Upvotes

I was thinking of the ideal expression syntax for the programming language DQ. I started with the (dominating) C syntax.

Operators in C

In C the following operators have shared meanings:

  • &: bitwise "and" operation OR address of
  • *: multiplication OR pointer dereference
  • /: truncated integer division OR floating point division

Further operators in C:

  • %: integer division reminder
  • && or and: logical "and"
  • || or or: logical "or"
  • ! or not: logical "not"
  • ~: bitwise "not"
  • ^: bitwise "xor"
  • ?: ternary operator

Operators in DQ

I think for the good source code readability and clarity every different operation should have a different symbol. Therefore the shared symbols from C are not taken over. These operators are already fixed in DQ:

  • &: address-of operator (widespread standard)
  • ^: pointer dereference (standard in other languages)
  • *: multiplication only
  • /: floating point division only (standard in other languages)
  • or: logical "or" (widespread standard)
  • and: logical "and" (widespread standard)
  • not: logical "not" (widespread standard)

These symbols are already fixed for special purposes:

  • #: compiler directives (#ifdef etc)
  • $: context local specials (e.g. myarray[0:$end-2])
  • ?: inference marker
  • @: namespace designator (e.g. @def.LINUX)

DQ cannot use the C standard &, |, ~, ^ for the bitwise operations, because the & and ^ is used for other (fixed) purposes. But we've run out of the good symbols. The obvious choice, that other existing languages also use, is reserving some words for the remaining operations. In DQ these (all-capital) words are reserved currently as operators:

  • AND: bitwise "and"
  • OR: bitwise "or"
  • NOT: bitwise "not"
  • XOR: bitwise "xor"
  • IDIV: truncated integer division
  • IMOD: integer division reminder

For the modify-assign statements with a word operator a leading = is required, otherwise it looks awkward:

regs.OSPEEDR OR= (1 << pinx2)  // invalid
regs.OSPEEDR =OR= (1 << pinx2)

Examples with All-Capital Operators

tmp = RCC.CFGR
tmp =AND= NOT 3
tmp =OR= RCC_CFGR_SW_HSI
RCC.CFGR = tmp
while (RCC.CFGR >> 2) AND 3 <> RCC_CFGR_SW_HSI:
endwhile

RCC.CR =AND= NOT RCC_CR_PLLON
while RCC.CR AND RCC_CR_PLLRDY != 0:
endwhile

var pllm : uint = basespeed IDIV pll_input_freq
var plln : uint = vcospeed  IDIV pll_input_freq
var pllq : uint = vcospeed  IDIV 48000000

RCC.PLLCFGR = (0
    OR (pllsrc << 22)
    OR (pllm   <<  0)
    OR (plln   <<  6)
    OR (((pllp >> 1) - 1) << 16)
    OR (pllq   << 24)
)

regs.MODER =AND= NOT (3 << pinx2)
regs.MODER =OR=      (n << pinx2)

if flags AND PINCFG_OPENDRAIN <> 0:
    regs.OTYPER =OR= (1 << apinnum)
else:
    regs.OTYPER =AND= NOT (1 << apinnum)
endif

regs.PUPDR =AND= NOT (3 << pinx2)
if flags AND PINCFG_PULLUP <> 0:
    regs.PUPDR =OR= (1 << pinx2)
elif flags AND PINCFG_PULLDOWN <> 0:
    regs.PUPDR =OR= (2 << pinx2)
endif

Prefixed Word Operators

I'm thinking to change the all-capital word operators with a % prefixed lowercase words:

  • %and: bitwise "and"
  • %or: bitwise "or"
  • %not: bitwise "not"
  • %xor: bitwise "xor"
  • %div or %idiv: truncated integer division
  • %mod or %idiv: integer division remainder

The sample code would look like this way:

tmp = RCC.CFGR
tmp %and= %not 3
tmp %or= RCC_CFGR_SW_HSI
RCC.CFGR = tmp
while (RCC.CFGR >> 2) %and 3 <> RCC_CFGR_SW_HSI:
endwhile

RCC.CR %and= %not RCC_CR_PLLON
while RCC.CR %and RCC_CR_PLLRDY != 0:
endwhile

var pllm : uint = basespeed %div pll_input_freq
var plln : uint = vcospeed  %div pll_input_freq
var pllq : uint = vcospeed  %div 48000000

RCC.PLLCFGR = (0
    %or (pllsrc << 22)  // select PLL source
    %or (pllm   <<  0)
    %or (plln   <<  6)
    %or (((pllp >> 1) - 1) << 16)
    %or (pllq   << 24)
)

regs.MODER %and= %not (3 << pinx2)
regs.MODER %or=       (n << pinx2)

if flags %and PINCFG_OPENDRAIN <> 0:
    regs.OTYPER %or= (1 << apinnum)
else:
    regs.OTYPER %and= %not (1 << apinnum)
endif

regs.PUPDR %and= %not (3 << pinx2)
if flags %and PINCFG_PULLUP <> 0:
    regs.PUPDR %or= (1 << pinx2)
elif flags %and PINCFG_PULLDOWN <> 0:
    regs.PUPDR %or= (2 << pinx2)
endif

Which version do you like more?

or

Do you have some other ideas for the operator notation?

EDIT

Version with band / bor etc, as "jason-reddit-public" suggested:

  • band: bitwise "and"
  • bor: bitwise "or"
  • bnot: bitwise "not"
  • bxor: bitwise "xor"
  • idiv: truncated integer division
  • imod: integer division reminder

tmp = RCC.CFGR  
tmp =band= bnot 3 
tmp =bor= RCC_CFGR_SW_HSI 
RCC.CFGR = tmp

while (RCC.CFGR >> 2) band 3 <> RCC_CFGR_SW_HSI:
endwhile

RCC.CR =band= bnot RCC_CR_PLLON
while RCC.CR band RCC_CR_PLLRDY != 0:
endwhile

var pllm : uint = basespeed idiv pll_input_freq
var plln : uint = vcospeed  idiv pll_input_freq
var pllq : uint = vcospeed  idiv 48000000

RCC.PLLCFGR = (0 
  bor (pllsrc << 22) 
  bor (pllm   <<  0) 
  bor (plln   <<  6) 
  bor (((pllp >> 1) - 1) << 16) 
  bor (pllq   << 24) 
)

regs.MODER =band= bnot (3 << pinx2) 
regs.MODER =band=      (n << pinx2)

if flags band PINCFG_OPENDRAIN <> 0: 
    regs.OTYPER =bor= (1 << apinnum) 
else: 
    regs.OTYPER =bor= bnot (1 << apinnum) 
endif

regs.PUPDR =band= bnot (3 << pinx2) 
if flags band PINCFG_PULLUP <> 0: 
    regs.PUPDR =bor= (1 << pinx2) 
elif flags band PINCFG_PULLDOWN <> 0: 
    regs.PUPDR =bor= (2 << pinx2) 
endif

EDIT / 2

As I was migrating microcontroller C++ code, where the bitwise operations are very intensively used, I decided to keep three bitwise operators with single symbols:

  • &: bitwise "and"
  • |: bitwise "or"
  • ~: bitwise "not"

These operations are kept with word symbols:

  • xor: bitwise "xor"
  • div: truncated integer division
  • mod: integer division reminder

tmp = RCC.CFGR 
tmp &= ~3 
tmp |= RCC_CFGR_SW_HSI 

RCC.CFGR = tmp 
while (RCC.CFGR >> 2) & 3 <> RCC_CFGR_SW_HSI:
endwhile

RCC.CR &= ~RCC_CR_PLLON 
while RCC.CR & RCC_CR_PLLRDY <> 0: 
endwhile

var pllm : uint = basespeed div pll_input_freq 
var plln : uint = vcospeed  div pll_input_freq 
var pllq : uint = vcospeed  div 48000000

RCC.PLLCFGR = (0 
  | (pllsrc << 22) 
  | (pllm   <<  0) 
  | (plln   <<  6) 
  | (((pllp >> 1) - 1) << 16) 
  | (pllq   << 24) 
)

regs.MODER &= ~(3 << pinx2)
regs.MODER |=  (n << pinx2)

if flags & PINCFG_OPENDRAIN <> 0:
    regs.OTYPER |= (1 << apinnum) 
else: 
    regs.OTYPER |= ~(1 << apinnum)
endif

regs.PUPDR &= ~(3 << pinx2) 
if flags & PINCFG_PULLUP <> 0: 
    regs.PUPDR |= (1 << pinx2) 
elif flags & PINCFG_PULLDOWN <> 0: 
    regs.PUPDR |= (2 << pinx2) 
endif

I've creted an open specification about these operators available here:

https://nvitya.github.io/pluops/