🚧Anything and everything might not work and much isn't yet implemented🚧
- Fewer keywords than C. "An idiot admires complexity, a genius admires simplicity" - Terry A Davis
- Infallible type inference unlike Rust which constantly fails to infer type infomation.
- No stack overflow becuase there is no recursion. There is always a better iterative solution.
- No hidden memory allocations unlike Zig which still does fallible stack allocation.
- Formal verification like Ada but simpler.
- No generics or templates becuase it doesn't need hints to figure out the types that work.
Supports aarch64. Doesn't support RISC-V. Won't support x86-64.
Hello, World!
Placeholder
include https://placeholder/syscalls.lang
write stdout "Hello, World!\n"
exit 0
placeholder new hello-world
cd hello-world
placeholder build
cat ./build/assembly.s
.global _start
_start:
mov x8, #64
mov x0, #1
ldr x1, =a
mov x2, #14
svc #0
mov x8, #93
mov x0, #0
svc #0
.data
a: .byte 72,101,108,108,111,44,32,87,111,114,108,100,33,10
Rust
fn main() {
println!("Hello, world!");
}
cargo new hello-world
cd hello-world
cargo rustc --release -- --emit asm
cat $(find . | grep "hello_world-.*\.s")
.text
.file "hello_world.72da610180e2e4bd-cgu.0"
.section .text._ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E,"ax",@progbits
.p2align 2
.type _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E,@function
_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E:
.cfi_startproc
str x30, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_offset w30, -16
blr x0
//APP
//NO_APP
ldr x30, [sp], #16
.cfi_def_cfa_offset 0
.cfi_restore w30
ret
.Lfunc_end0:
.size _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E, .Lfunc_end0-_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E
.cfi_endproc
.section .text._ZN3std2rt10lang_start17h29862496ae07c657E,"ax",@progbits
.hidden _ZN3std2rt10lang_start17h29862496ae07c657E
.globl _ZN3std2rt10lang_start17h29862496ae07c657E
.p2align 2
.type _ZN3std2rt10lang_start17h29862496ae07c657E,@function
_ZN3std2rt10lang_start17h29862496ae07c657E:
.cfi_startproc
stp x30, x0, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_offset w30, -16
mov w4, w3
mov x3, x2
mov x2, x1
adrp x1, .L__unnamed_1
add x1, x1, :lo12:.L__unnamed_1
add x0, sp, #8
bl _ZN3std2rt19lang_start_internal17h95d6f6a22ba2f96dE
ldr x30, [sp], #16
.cfi_def_cfa_offset 0
.cfi_restore w30
ret
.Lfunc_end1:
.size _ZN3std2rt10lang_start17h29862496ae07c657E, .Lfunc_end1-_ZN3std2rt10lang_start17h29862496ae07c657E
.cfi_endproc
.section ".text._ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE","ax",@progbits
.p2align 2
.type _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE,@function
_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE:
.cfi_startproc
str x30, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_offset w30, -16
ldr x0, [x0]
bl _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E
mov w0, wzr
ldr x30, [sp], #16
.cfi_def_cfa_offset 0
.cfi_restore w30
ret
.Lfunc_end2:
.size _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE, .Lfunc_end2-_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE
.cfi_endproc
.section ".text._ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE","ax",@progbits
.p2align 2
.type _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE,@function
_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE:
.cfi_startproc
str x30, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_offset w30, -16
ldr x0, [x0]
bl _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E
mov w0, wzr
ldr x30, [sp], #16
.cfi_def_cfa_offset 0
.cfi_restore w30
ret
.Lfunc_end3:
.size _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE, .Lfunc_end3-_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE
.cfi_endproc
.section ".text._ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE","ax",@progbits
.p2align 2
.type _ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE,@function
_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE:
.cfi_startproc
ret
.Lfunc_end4:
.size _ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE, .Lfunc_end4-_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE
.cfi_endproc
.section .text._ZN11hello_world4main17hff90392c72a0ce9aE,"ax",@progbits
.p2align 2
.type _ZN11hello_world4main17hff90392c72a0ce9aE,@function
_ZN11hello_world4main17hff90392c72a0ce9aE:
.cfi_startproc
sub sp, sp, #64
.cfi_def_cfa_offset 64
str x30, [sp, #48]
.cfi_offset w30, -16
adrp x8, .L__unnamed_2
add x8, x8, :lo12:.L__unnamed_2
mov w9, #1
adrp x10, .L__unnamed_3
add x10, x10, :lo12:.L__unnamed_3
mov x0, sp
stp xzr, xzr, [sp, #24]
stp x8, x9, [sp]
str x10, [sp, #16]
bl _ZN3std2io5stdio6_print17h111c70694d02e77dE
ldr x30, [sp, #48]
add sp, sp, #64
.cfi_def_cfa_offset 0
.cfi_restore w30
ret
.Lfunc_end5:
.size _ZN11hello_world4main17hff90392c72a0ce9aE, .Lfunc_end5-_ZN11hello_world4main17hff90392c72a0ce9aE
.cfi_endproc
.section .text.main,"ax",@progbits
.globl main
.p2align 2
.type main,@function
main:
.cfi_startproc
str x30, [sp, #-16]!
.cfi_def_cfa_offset 16
.cfi_offset w30, -16
mov x2, x1
sxtw x1, w0
adrp x0, _ZN11hello_world4main17hff90392c72a0ce9aE
add x0, x0, :lo12:_ZN11hello_world4main17hff90392c72a0ce9aE
mov w3, wzr
bl _ZN3std2rt10lang_start17h29862496ae07c657E
ldr x30, [sp], #16
ret
.Lfunc_end6:
.size main, .Lfunc_end6-main
.cfi_endproc
.type .L__unnamed_1,@object
.section .data.rel.ro..L__unnamed_1,"aw",@progbits
.p2align 3, 0x0
.L__unnamed_1:
.xword _ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE
.asciz "\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000"
.xword _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE
.xword _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE
.xword _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE
.size .L__unnamed_1, 48
.type .L__unnamed_4,@object
.section .rodata..L__unnamed_4,"a",@progbits
.L__unnamed_4:
.ascii "Hello, world!\n"
.size .L__unnamed_4, 14
.type .L__unnamed_2,@object
.section .data.rel.ro..L__unnamed_2,"aw",@progbits
.p2align 3, 0x0
.L__unnamed_2:
.xword .L__unnamed_4
.asciz "\016\000\000\000\000\000\000"
.size .L__unnamed_2, 16
.type .L__unnamed_3,@object
.section .rodata..L__unnamed_3,"a",@progbits
.p2align 3, 0x0
.L__unnamed_3:
.size .L__unnamed_3, 0
.ident "rustc version 1.76.0-nightly (9fad68599 2023-12-03)"
.section ".note.GNU-stack","",@progbits
Keywords
- if: Rust's if without the brackets1.
- loop: Rust's loop without the brackets1.
- break: Jumps out of the current loop1.
- def: Python's def without the :2.
- in: The arguments given to a function3.
- out: The output given to a function. a := b - c + d after unrolling and type inference is equivalent to
c + d @ x
@ can only be defined on the outermost expression in a line, the outputs of nested expression are used to chain the expressions together.
b - x @ y
a := y @ null - fail: If reachable triggers a failure in formal verification.
- assume: Mark code which will be passed to formal verification but excluded at run-time. assume x %= 4 tells the verifier { 0 ≤ x < 4 }.
- valueof: Gets the value of a value.
a := valueof 1 // a = value_literal = 0
b := valueof c // b = value_variable = 1 - unreachable: Marks the end of execution, all following statements are unreachable.
- macro: Similar to macros in C. Macro evaluation happens before the AST is parsed and simply performs a find and replace on the text contents of source files. Since := is a function, macro is how constants used in the definition of := are defined. Unless writing your own core, you should never need to use this.
- asm: The prefix for a line with in-line assembly e.g. asm mov x0, 1.
- section: Defines the valid address space.
section 100 200 read // read 100 to 200
section 300 400 write // write 300 to 400
section 500 600 readwrite // read+write 500 to 600
Notes
- if, loop and break will be removed as intrinsics and added to the core library as functions when the compiler is re-written in the language. At this point functions will be able to mutate their child AST. This will enable equivalent support to procedural macros found in other languages but better.
- I'm not commited to using def as the function keyword. I'm considering fn.
- I'm thinking about splitting in into lhs and rhs as this will make all input patterns differentiable to a function. Currently with in when you have a function my_function calling it with a my_function b or my_function a b appears identical to the function.
Features that might require new keywords
- Generation of unique errors codes.
- Defered logging.
- Non-exhaustive checking. E.g. use gradient descent to search for a minimium to check.
- Starting new threads during execution. The current assumption is based on bare-metal where the program begins with all hardware threads running.
- Functions mutating the AST like procedural macros.