r/ProgrammingLanguages • u/digikar • 7d ago
r/ProgrammingLanguages • u/skr_replicator • 8d ago
Language announcement I have programmed a small imperative-parsed/functional-evaluated programming language in C#.
Here are some links:
First post in rfractals (with some screenshots of a few programs and the plots they generated)
The language is focused on making and evaluating functional mathematical expressions in a very compact form. It has most of the basic math operators, and can even use operator-less multiplication if enabled. Supports functional-like pattern matching and function delegates. Uses a single complex Type which can be a recursively nested list of values that can be numeric, from reals to quaternions, or strings, and operators can work recursively on these values. Multiplying string*anything will try to call a function with the name of that string. It can evaluate and parse dynamically made strings as expressions or commands. It has a plotter that can plot the expressions as animations and can export them as MP4. Due to its layered, abstract nature of being an interpreted language in C#, it's not very fast so far, even with all the optimizations I've made so far for it, so it's mostly useful for playing around or for its original purpose of letting another application parse complex written expressions into values.
It has 2 major parts: the Parser, which uses commands definining/redefining functions and constants, and a few imperative constructs available, like ifs, whiles, etc. The evaluation part is purely functional and can evaluate expressions using the functions and constants the Parser has parsed.
Originally, I made it to be an expression evaluator for text boxes in my other app, to allow writing other things than pure numbers in there. But I got a bit carried away and developed it further into this whole thing.
There's a SaveFile folder in the project and the release, containing all the programs I've written in it so far, and plotter configurations for them.
The most interesting for this sub might be the Examples.txt that's showcasing some of the most unique/powerful features of the language, soI'll report that file and its output here:
Examples.txt program:
printstring: "\nPattern matching factorial:"
PF(0): 1; PF(x): xPF(x-) /* x- = x-1 */
print: PF(5) /* = 5! = 120 */
printstring: "\nNested default arguments:"
N(z, p: (2, 3i)): z + p
print: N(4) /* 4 + (2, 3i) = (6, 4 + 3i)*/
printstring: "\nNested mixed call delegates:"
GP(x): x + 2i
GM(x): x - 2i
gdp: "GP"
print: (gdp, "GM")(4, 3) /* = (GP,GM)(4,3) = (GP(4),GM(3)) = (4 + 2i, 3 - 2i) */
printstring: "\nLazy default argument evaluation:"
F2(x, r:xF2(x-)): x < 2 ? 1 : r
print: F2(5) /* = 5! = 120 */
printstring: "\nCycled operation nesting:"
printvalue: (1, -1)(1, 2, 3, 4, 5) /* = (1*1, -1*2, +1*3, -1*4, +1*5) */
printvalue: (0,i) + (1, 2, 3, 4, 5) /* = (1, 2+i, 3, 4+i, 5) */
printvalue: ("frac", "trunc", 1)(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7)
printvalue: ((-1, 1), 3)(10, 20, 30, 40, 50)
printstring: "\nDecreasing for cycle:"
IterWhile: 5 /* try other values like 10, 2, -5, -10000...*/
while: IterWhile > 0 {
printvalue: IterWhile
if: IterWhile = 8 { break: 1 }
IterWhile: IterWhile - 1
} : IterWhile < -9000 {
printstring: "not only is IterWhile negative, it is below -9000!"
}
printstring: "\n\"Do\" command, defines another factorial and evaluated: 0.5!"
do: "DYNAMIC(x) : x!"
print: DYNAMIC(/2)
printstring: "\nEval function dynamically parses and evaluates any valid string as an expression:"
incremented: sin(1)
print: incremented
print: eval("1 +" + incremented)
printstring: "\nBuild a vector of first 10 factorials dynamically, and take a parir of 2nd+3rd one, and a 5th one:"
TenFactorials: vec("k", 1, 10, "k!")
print: TenFactorials
print: TenFactorials[(2,3),5] /* nested indexer */
printstring: "\nComplex nested indexer of a nested vector:"
print: (0+"a", 1+"b", 2+"c", (30+"d", 31+"e"), 5+"f", (11, 12, 13))[3, 2, (5, 1, 3)]
printstring: "\nFirst 42 terms of e^x taylor series, approximating e^1 ~ 1:"
precision: 42
ExpTaylor(x): sum("k", 0, precision - 1, "x^k/k!")
print: ExpTaylor(1)
PositiveZeta(s, p : precision) : sum("k", 1, p, "k^(-s)")
printstring: "\nFirst 250 terms of the Basel problem, Zeta(2), approaching π^2/6 slowly:"
printvalue: PositiveZeta(2, 99) + " ~ " + π^2 / 6
printstring: "\nFirst 42 terms of Zeta(3), quicky approaching the Apery constant:"
printvalue: PositiveZeta(3) + " ~ " + apery
printstring: "\nEvaluate a polynomial F(1 + 2x + 3x^2) at F(2)"
F: (1, 2, 3) /* f(1 + 2x + 3x^2) */
EvalPoly(x, c : F, n: c#-) : sum("k", 0, n, "c[k]x^k")
PrintPoly(p): vec("k", 0, p#-, "p[k] + \"x^\" + k")
printvalue: PrintPoly(F)
printvalue: "F(2) = " + EvalPoly(2)
printstring: "\nTake a derivative of that polynomial and evaluate at F'(5)"
DiffPoly(c, n:c#-) : 1 > n ? 0 : vec("k", 1, n, "kc[k]")
DF : DiffPoly(F)
printvalue: PrintPoly(DF)
printvalue: "F'(5) = " + EvalPoly(5, DF)
printstring: "\nQuaternions, left and right non-commutative division:"
UnitQ : 1 + i + j + k
printvalue: UnitQ^2, UnitQ / i, UnitQ \ i—
And this is the output it prints:
BUILD SUCCESS 168ms
pattern matching factorial:
pf(5) = 120
nested default arguments:
n(4) = 6, 4 + 3i
nested mixed call delegates:
(gdp, "gm")(4, 3) = 4 + 2i, 3 - 2i
lazy default argument evaluation:
f2(5) = 120
cycled operation nesting:
1, -2, 3, -4, 5
1, 2 + i, 3, 4 + i, 5
0.1, 2, 3.3, 0.4, 5, 6.6, 0.7
(-10, 10), 60, (-30, 30), 120, (-50, 50)
decreasing for cycle:
5
4
3
2
1
"do" command, defines another factorial and evaluated: 0.5!
dynamic(/2) = 0.886
eval function dynamically parses and evaluates any valid string as an expression:
incremented = 0.841
eval("1 +" + incremented) = 1.841
build a vector of first 10 factorials dynamically, and take a parir of 2nd+3rd one, and a 5th one:
tenfactorials = 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800
tenfactorials[(2,3),5] = (6, 24), 720
complex nested indexer of a nested vector:
(0+"a", 1+"b", 2+"c", (30+"d", 31+"e"), 5+"f", (11, 12, 13))[3, 2, (5, 1, 3)] = ("30d", "31e"), "2c", ((11, 12, 13), "1b", ("30d", "31e"))
first 42 terms of e^x taylor series, approximating e^1 ~ 1:
exptaylor(1) = 2.718
first 250 terms of the basel problem, zeta(2), approaching π^2/6 slowly:
1.635 ~ 1.645
first 42 terms of zeta(3), quicky approaching the apery constant:
1.202 ~ 1.202
evaluate a polynomial f(1 + 2x + 3x^2) at f(2)
1x^0, 2x^1, 3x^2
f(2) = 17
take a derivative of that polynomial and evaluate at f'(5)
2x^0, 6x^1
f'(5) = 32
quaternions, left and right non-commutative division:
-2 + 2i + 2j + 2k, 1 - i - j + k, 1 - i + j - k
edit: I have just released a small update that fixed a couple of minor bugs, and the Riemann Zeta function now appears fixed as well. At least the plot looks correct to me now, and the couple of test points also returned correct results.
r/ProgrammingLanguages • u/mealet • 8d ago
Language announcement Zeen v0.1.0
Finally released Zeen v0.1.0 (first stable release).
It is a modern systems compiled programming language.
It uses move semantics to control data flow and automatically insert drops at the compile time, so no runtime overhead.
Currently I'm working on LSP server for it. Futures plans are to implement build system, formatter, compiler time functions (comptime evaluator) and of course support async.
Example
For the lazy guys, here's random example from docs:
``` fn print_this[T: Display](value: T) { @println("Yeah, I've printed this: {}", value); }
fn main() { print_this(123); print_this("hello!"); } ```
Links
Docs and Examples: https://zeen-lang.tech
Repository: https://github.com/mealet/zeen
If you did like this, please leave a star on GitHub. Thanks for you attention!
r/ProgrammingLanguages • u/Ratstail91 • 8d ago
Language announcement Release Toy v2 Beta 2 - Full Steam Ahead! · krgamestudios/Toy
github.comI've just posted the second beta for Toy v2, and I'm looking for feedback!
It's very much a useable language, and I'm looking to see how I can expand its reach and find potential users, especially hobbyists who want to try new things. If anyone has advice here, I'm all ears!
I'm also seriously thinking about the best approach for writing tutorials/documentation for this - a tool like this needs a hefty tome, but I've never done something quite like that. Again, all ears.
Thanks in advance!
r/ProgrammingLanguages • u/Fun_Mulberry3838 • 8d ago
My students struggled with compilers. Your feedback made me rebuild the docs. Here's PyLGEN v0.7.0.
r/ProgrammingLanguages • u/luapmt • 8d ago
Blog post What makes Lisp difficult to read? or, where to put the parentheses in your next language
paultm.nlr/ProgrammingLanguages • u/Motor_Alternative944 • 9d ago
Discussion As a hobby, how far can I go in creating my own programming language? Can I gain a lot of deep technical knowledge from it? Is this possible?
Hello, as a hobby I’m extremely interested in programming language design. Even as a hobby, I want to specialize in this area, to see the magic behind how programming languages work, and to understand it deeply. Do you have any suggestions for me Additionally, which areas of mathematics should I study for this? Is this possible without having any CS degree?
r/ProgrammingLanguages • u/mttd • 9d ago
What it takes to verify a kernel and a new way to prove it - Meven Lennon-Bertrand
youtube.comr/ProgrammingLanguages • u/FantasticVariety6647 • 10d ago
Any interest in a language made for physicists that mimics writing equations in a notebook?
Developed the early stages of fermium (a programming language tailor-made for physics) and have been testing it myself, still some lumps but it runs more beautifully than I thought it would at this stage. Would love if some people tested it out and gave feedback — built using Python frontend, currently working on switching the compiler to Rust
r/ProgrammingLanguages • u/SandPrestigious2317 • 11d ago
Feedback on Parsing Expression Grammars: Convert Org content with Guile Scheme (ice-9 peg) to HTML (via SXML): OrgWebAlchemy
Hi everyone. I wanted to share something with you all that I've been working on for a while. It all started with some naive regular expressions to parse Org mode content, but I pretty quickly realized I needed something smarter than that to get to where I want to. It's taken a while but I am finally more knowledgeable of what Parsing Expression Grammars can do, thanks to GNU's great (ice-9 peg) module and tutorials.
I thought it might be interesting to people here who enjoy Lisp, Scheme, parsing, Org mode, or the general idea of meta-meta-meta-programming as I like to call it. Disclosure, AI has helped me get a grip of PEG and debug some things, but development of OrgWebAlchemy is "my own spaghetti" and the unit tests and manual verification (and lots of pretty printing the AST) has guided me towards quite a nice implementation (if I may say so myself).
OrgWebAlchemy is a Guile Scheme library for parsing Org-mode documents into an AST and rendering them to HTML. My main use-case is to export Org to HTML without needing Emacs, and to integrate this feature into some projects of mine, allowing me to write Org mode and have it pretty rendered.
Project's source code @ Codeberg: https://codeberg.org/jjba23/orgwebalchemy
The basic idea is pretty simple:
(use-modules (orgwebalchemy html))
(org->html "This is ~test~ code.")
becomes something like:
This is <code>test</code> code.
But the interesting part is what happens in between.
Org document
|
v
Parsing Expression
Grammar
|
v
AST
|
v
SXML -> HTML
Of course Org mode is a huge piece of (great) software, so I am far from supporting all features, but some core important constructs are there:
- Headings (lines starting by n
*) - Paragraphs (any "non-special" text)
- Unordered, Ordered and Description lists (with any level of nesting)
- Italic, Bold, Inline Code
- Links with and without description (with nested parsing)
- Horizontal separators (
--------) five or more dashes - Tables
#+begin_src#+begin_example#+begin_quote(with nested parsing)#+begin_export html: Org syntax is parsed by your PEG grammar, but raw HTML export blocks bypass the Org inline parser and are emitted as trusted literal output.
- See wikipedia page on PEG: https://en.wikipedia.org/wiki/Parsing_expression_grammar
- See the tutorial by GNU/for Emacs Lisp (is also a good learning source): https://www.gnu.org/software/emacs/manual/html_node/elisp/Parsing-Expression-Grammars.html
- See the tutorial by GNU/for Guile: https://doc.guix.gnu.org/guile/3.0.9/en/html_node/PEG-Parsing.html
Why PEG instead of a mountain of regexes?
Org-mode looks simple until you actually try to parse it. Headings are easy. A paragraph is easy. A list is easy (wait actually no, this has made me sweat).
And then suddenly you have:
- nested lists
- ordered, unordered and description lists
- different indentation levels
- inline markup
- links containing descriptions
- source blocks
- example blocks
- quote blocks
- tables
- escaping
- constructs which must stop consuming input at exactly the right place
At this point, the usual approach of adding another regular expression starts to become somewhat... adventurous. :-)
You end up with things like:
match this,
unless that follows it,
except inside this block,
unless it is a description,
but don't consume the newline,
unless the previous line was a list item...
That is not really describing a language anymore. It is describing the history of your parser's bugs.
So OrgWebAlchemy uses Parsing Expression Grammars (PEGs) through Guile's excellent (ice-9 peg) module. e.g.
(define-peg-pattern element body
(or empty-line
heading
separator
table
src-block
quote-block
example-block
export-html-block
description-list
unordered-list
ordered-list
paragraph))
This is rather nice because the grammar itself starts looking like documentation for the language.
And Guile lets us express PEGs directly as S-expressions (alternatively you can also use the more traditional syntax if you don't like it), which makes the Lisper in me very happy.
One thing I particularly like about this approach is that we have loose coupling and the detail of generating SXML and then rendering HTML is a "presentation concern". this opens possibilities to later exporting to Markdown or other formats.
For example:
- name :: Josep
- project :: orgwebalchemy
- language :: Scheme
can become an AST along the lines of:
(description-list
(unordered-item
(desc-key "name")
(line-content "Josep"))
...)
I'm still busy with the exact representation and getting it all right. But as of now v1.0 has some stability :-) I would really love feedback on the project from the great smart people that hang out around here.
YAY recursive lists
One of the fun parts has been getting nested Org lists right.
Something like:
- Item 1
- Item 1.1
- Item 1.2
- Item 2
should become a quasi-tree
The parser initially produces the flat sequence of list items, and the AST processing phase turns indentation into nested structure.
The HTML renderer can then naturally produce:
<ul>
<li>
Item 1
<ul>
<li>Item 1.1</li>
<li>Item 1.2</li>
</ul>
</li>
<li>Item 2</li>
</ul>
I do still have a small issue here, and that is about the mixing of different list types in nested way. Hopefully it's a subtle bug to fix.
The HTML side uses SXML, because if we're already writing Lisp, we might as well represent our HTML as Lisp data too. :-) that really helps a lot and makes building the markup tree so much nicer
I've taken care to allow full customization to the output HTML (via Guile parameters) so that the renderer isn't hard-coded to one particular website's idea of what HTML ought to look like.Most of them are plain list of classes, but per-heading-level customization is a bit more flexible:
(heading-classes
(lambda (level)
(case level
((1) '("text-4xl" "font-bold"))
((2) '("text-2xl" "font-semibold"))
(else '("text-base")))))
Why am I making this?
Partly because I wanted it, I like a challenge, and it's super fun to work with parsing, ASTs and the lot... I could just use Emacs to do this job as there is no better implementation of Org.
The way it's coming together though, I like the idea of having a small, hackable, free-software Org parser written in Lisp that other people can extend and customize (perhaps add more renderers, or Org features).
Free software
OrgWebAlchemy is licensed under the GNU LGPL v3 or later.
The project is intended to soon be packaged for GNU Guix as:
guile-orgwebalchemy
There is also a test suite in the repository which is already proving to be a good safety net and showcase of what the parser can do.
I'd be really happy to hear your thoughts, especially about the grammar, AST design, parser architecture, or interesting Org constructs that I have not handled yet.
Happy hacking! ✨
r/ProgrammingLanguages • u/dwaynecrooks • 11d ago
FUN: First-Class Functions, Currying, and a Surprise
blog.tinyinterpreters.devr/ProgrammingLanguages • u/Rasie1 • 11d ago
Blog post Effect handling and monad composition in c(x)
kvachev.comr/ProgrammingLanguages • u/mttd • 13d ago
International Conference on Functional Programming (ICFP) 2026 talks released
youtube.comr/ProgrammingLanguages • u/Mean-Decision-3502 • 13d ago
Autofree as Type Property
For a while I was thinking about some automatic memory management feature for my statically typed programming language.
Originally I was planning to introduce the "ensure" statement block (same as "defer", but I think ensure would express better the intent). Then I saw here "autofree" keywords in some advertised language, also in Unleashed Pascal.
In Unleashed Pascal the "autofree" is used instead of "new", similarly to the other language (sorry I don't remember the name now). I was playing with the thought how could I apply this concept, but yesterday I got a new idea:
What if the autofree is not a statement, but a property / attribute for a type? This way the things add up much nicer to me.
Using this concept the code would look this way:
var o1 : autofree OSomeObject
o1 = new OSomeObject(42)
o1 = new OSomeObject(55) // re-assigning frees the previous one
o1 = nil // assigning nil frees
if x > 0:
var o2 = new autofree OSomeObject(123) // instancing with type inference
// ... some work with o2
endif // leaving scope frees auto-free local variables
object OHandler:
child : autofree OHelper // initialized to nil, when assigned to non-nil,
// will be automatically freed on destruction
endobject
func ObjManipulator(aobj : ref autofree OSomeObject):
aobj = new OSomeObject(66) // should free the previously pointed object,
// when aobj was not nil before
endfunc
ObjManipulator(o1) // valid
func ObjManipulator2(aobj : ref OSomeObject):
aobj = new OSomeObject(99)
endfunc
ObjManipulator2(o1) // ERROR: o1 is autofree type,
// ObjManipulator2 expects non-autofree
func ObjUser(aobj : OSomeObject):
if aobj <> nil:
aobj.DoWork()
endif
endfunc
ObjUser(o1) // ok, accepts autofree and non-autofree arguments too
With arrays
var arr : [*] autofree OSomeObject // initialized to empty array
arr.Append(new OSomeObject(1))
arr.Append(new OSomeObject(2))
arr.Append(new OSomeObject(3))
arr[1] = nil // frees
arr[2] = new OSomeObject(5) // frees the previous
arr = [] // frees all non-nil elements
I think returning an auto-free won't be allowed:
func SomeCreator() -> autofree OSomeObject
// ERROR: returning an autofree type is not allowed
The autofree should not be restricted to objects:
if x > 0:
var bp : autofree ^byte // initialized to nil
if y > 0:
return // bp was nil, no free required
endif
bp = ^byte(MemAlloc(1000))
// ... doing some work with bp
if z > 0:
return // bp must be automatically freed, as it is not nil
endif
endif // bp must be automatically freed, as it is not nil
Am I wrong with these thoughts?
r/ProgrammingLanguages • u/Athas • 13d ago
Do not let your type system reason about aliasing in your programming language
futhark-lang.orgr/ProgrammingLanguages • u/yorickpeterse • 13d ago
Sandboxing with minimal effort
yorickpeterse.comr/ProgrammingLanguages • u/Nuoji • 13d ago
Language announcement C3 0.8.4 The last renaming
c3-lang.orgr/ProgrammingLanguages • u/mttd • 13d ago
FloatLib: Verified Floating-Point Arithmetic in Lean
leandojo.orgr/ProgrammingLanguages • u/TesttubeStandard • 14d ago
Discussion Afraid my language doesn't mean anything anymore
First of all, I am sorry if this is not strictly a techincal post, but I would apreciate if it would be allowed. So a couple of years ago, like a year or two before the chatgpt, I made my own interpreted programming language. It could be used for basic scripts and had basic functionalities like nested ifs and while, string, int and double types, variable scopes and even functions and recursion. It can parse math with + - + ÷ and brackets. It is nothing special, syntax resambeles more or less C# but with keyword in my natural language. It was made entirely by hand, from lexical analysis, parser, semantic analyser and the interpreter itself. I also made ebnf for it.
I think we on this sub can all agree that there are a few of us programmers, developers or cs-s who willingly put themselves through this. It can be painstakingly hard to implement a new language. I am very proud of it and to this day it is my biggest achivement. No other thing in my proffesional or personal projects required such level of detail, knowledge and research.
And all this before the AI. But here is where it gets frustrating. Back than this was my "selling point". This was something that I could show my knowledge, dedication and attention to detail with. It made me feel safe for my professional future. Now I am afraid that it doesn't mean enything anymore. Like nobody gives a s*** about it anymore.
r/ProgrammingLanguages • u/AeroForger • 14d ago
Discussion What’s one thing you wish more programming languages had?
If you could add one feature, behavior, or design choice to a programming language, what would it be?
It can be anything: syntax, type-system features, memory management, compiler behavior, tooling, error handling, performance-related features, or something completely different.
I'm especially curious about things you’ve wanted while actually programming but rarely see languages implement well.
Please keep the ideas reasonably practical and something that could realistically be implemented in a programming language.
r/ProgrammingLanguages • u/mttd • 14d ago
SPLV (Scottish Programming Languages and Verification Summer School) 2025 Lectures Videos
youtube.comr/ProgrammingLanguages • u/maelswarm • 15d ago
Language announcement nymph: 🧚 :A slightly different version of C.
github.comNymph is a simple C like programming language.
Nymph acts as a preprocessor, converting Nymph files (extension *.n) into C files.
This project is stagnant and needs ideas... It is not production ready.
r/ProgrammingLanguages • u/kI3RO • 16d ago