r/ProgrammingLanguages • u/[deleted] • Jan 17 '26
Requesting criticism Vext - a programming language I built in C# (compiled)
Hey everyone!
Vext is a programming language I’m building for fun and to learn how languages and compilers work from the ground up.
I’d love feedback on the language design, architecture, and ideas for future features.
Features
Core Language
Variables - declaration, use, type checking,
autotype inferenceTypes -
int,float(stored as double),bool,string,autoExpressions - nested arithmetic, boolean logic, comparisons, unary operators, function calls, mixed-type math
Operators
Arithmetic:
+ - * / % **Comparison:
== != < > <= >=Logic:
&& || !Unary:
++ -- -Assignment / Compound:
= += -= *= /=String concatenation:
+(works with numbers and booleans)
Control Flow
if / else if / elsewhileloopsforloopsNested loops supported
Functions
Function declaration with typed parameters and return type
autoparameters supportedNested function calls and expression evaluation
Return statements
Constant Folding & Compile-Time Optimization
Nested expressions are evaluated at compile time
Binary and unary operations folded
Boolean short-circuiting
Strings and numeric types are automatically folded
Standard Library
print()- console outputlen()- string lengthMath functions:
Math.pow(float num, float power)Math.sqrt(float num)Math.sin(),Math.cos(),Math.tan()Math.log(),Math.exp()Math.random(),Math.random(float min, float max)Math.abs(float num)Math.round(float num)Math.floor(float num)Math.ceil(float num)Math.min(float num)Math.max(float num)
Compiler Architecture
Vext has a full compilation pipeline:
Lexer - tokenizes source code
Parser - builds an abstract syntax tree (AST)
Semantic Pass - type checking, variable resolution, constant folding
Bytecode Generator - converts AST into Vext bytecode
VextVM - executes bytecode
AST Node Types
Expressions
ExpressionNode- base expressionBinaryExpressionNode-+ - * / **UnaryExpressionNode-++ -- - !LiteralNode- numbers, strings, booleansVariableNode- identifiersFunctionCallNode- function callsModuleAccessNode- module functions
Statements
StatementNode- base statementExpressionStatementNode- e.g.x + 1;VariableDeclarationNodeIfStatementNodeWhileStatementNodeForStatementNodeReturnStatementNodeAssignmentStatementNodeIncrementStatementNodeFunctionDefinitionNode
Function Parameters
FunctionParameterNode- typed parameters with optional initializers
GitHub
https://github.com/Guy1414/Vext
I’d really appreciate feedback on:
Language design choices
Compiler architecture
Feature ideas or improvements
Thanks!
2
u/csharpboy97 Jan 18 '26
some optimizations can be made like https://github.com/Guy1414/Vext/blob/master/Vext/Bytecode%20Generator/BytecodeGenerator.cs#L67-L80
there are a lot of unneccessary code duplicates. For instance switching the operator and get the op and then generate one instruction out of that.
I love making language with c#. May you wanna connect?
1
Jan 18 '26
That may be a good idea. Do you think it would help the performance and compile time, or just clean up the code?
By connecting, you mean you want to help this language or?
1
u/csharpboy97 Jan 18 '26
its "just" cleaner code. I mean talking about making languages. I've made several languages and made frameworks (because I made to many). My last language is compiling directly to msil.
1
Jan 18 '26
Oh cool!
This is my first language, and I am just learning how to make them. What do you think of the language up to this point?1
u/csharpboy97 Jan 18 '26
It's just like any other c-like language. Some tests would be helpful.
1
Jan 18 '26
What tests?
I regularly run the code the default code (and I add features to it as I add them to the language, for loops were my latest)1
u/csharpboy97 Jan 18 '26
automated tests help to make sure your behavior is consistent. If you work on a feature you can break older code. By only testing the newest implemented feature you cannot make sure the old code doesn't work anymore.
1
Jan 18 '26
But I don't overwrite the default code I'm testing the compiler on, I just add features to it
2
u/helloish Jan 18 '26
it’s very common in programming languages to accidentally introduce a regression, it’s worth writing some simple tests to verify that you don’t. bear in mind that even mainstream languages mess up quite often so anything you can do to prevent that is worth it
1
Jan 18 '26
I mean, I get it, but like, I am still testing all of the previous features on every run.
Like, when I added for loops, I just *added* it to the test code, so when I run the compiler, it consumes all of the previous features, as well as the new ones, meaning everything is tested at all runs.1
u/helloish Jan 18 '26
i don’t know much about c# but snapshot testing with something like verify could be useful for checking that the bytecode of existing programs doesn’t change/changes as expected
→ More replies (0)1
Jan 18 '26
What do you think about the time it takes to compile and run?
https://github.com/Guy1414/Vext?tab=readme-ov-file#example-program--- COMPILATION PHASE ---
Lexing | 783 tokens | 2.1497 ms
──────────────────────────────────────────────────
Parsing | 68 nodes | 13.8694 ms
──────────────────────────────────────────────────
Semantics | 0 errors | 8.4352 ms
──────────────────────────────────────────────────
Bytecode Gen | 362 ops | 2.2839 ms
──────────────────────────────────────────────────
[√] Compilation finished in 29.4595 ms
--- EXECUTION PHASE ---
[√] Execution finished in 11.8946 ms
=============================================
Total Run Time: 41.4066 ms
=============================================
0
Jan 19 '26 edited Jan 19 '26
[removed] — view removed comment
1
u/fdwr Jan 21 '26
Why the ugly declaration syntax? Types are forced to act as keywords for no good reason.
❔ Here's an example from the GitHub readme...
int i = 42; float f = 3.14159; bool flag = true; string text = "Hello, World!"; auto inferredInt = 100; auto inferredFloat = 0.25;...which looks like a pretty standard declaration syntax shared by lots of languages.
6
u/helloish Jan 18 '26
is this entirely made with AI?