Skip to content

Commit

Permalink
hello world example more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWoollett-Light committed Jan 14, 2024
1 parent 4012460 commit db24bb1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,3 @@

[![GitHub deployments](https://img.shields.io/github/deployments/jonathanwoollett-light/language/github-pages?label=website)](https://jonathanwoollett-light.github.io/language/)
[![codecov](https://codecov.io/gh/JonathanWoollett-Light/language/branch/master/graph/badge.svg?token=II1xtnbCDX)](https://codecov.io/gh/JonathanWoollett-Light/language)

- Less keywords than C.
- No stack overflow.
- No generics/templates.
- No macros.
- No hidden memory allocations.
- Full type inference with formal verification.

Rust's `Hello World!` binary from `cargo new` is almost 5mb, in this language its 512 bytes.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ <h3>Hello, World!</h3>
<div>
<h5>Language</h5>
<p class="code">include https://raw.githubusercontent.com/JonathanWoollett-Light/language/master/syscalls.lang<br>x := "Hello, World!\n"<br>write 1 &x<br>exit 0</p>
<p class="code">language new hello-world<br>cd hello-world<br>language build</p>
<p class="code">language new hello-world<br>cd hello-world<br>language build<br>cat ./build/assembly.s</p>
<p class="code assembly">.global _start<br>_start:<br>mov x8, #64<br>mov x0, #1<br>ldr x1, =a<br>mov x2, #14<br>svc #0<br>mov x8, #93<br>mov x0, #0<br>svc #0<br>.data<br>a: .byte 72,101,108,108,111,44,32,87,111,114,108,100,33,10</p>
</div>
<div>
<h5>Rust</h5>
<p class="code">fn main() {<br> println!("Hello, world!");<br>}</p>
<p class="code">cargo new hello-world<br>cd hello-world<br>cargo rustc --release -- --emit asm</p>
<p class="code">cargo new hello-world<br>cd hello-world<br>cargo rustc --release -- --emit asm<br>cat $(find . | grep "hello_world-.*\.s")</p>
<p class="code assembly"> .text<br> .file "hello_world.72da610180e2e4bd-cgu.0"<br> .section .text._ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E,"ax",@progbits<br> .p2align 2<br> .type _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E,@function<br>_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E:<br> .cfi_startproc<br> str x30, [sp, #-16]!<br> .cfi_def_cfa_offset 16<br> .cfi_offset w30, -16<br> blr x0<br> //APP<br> //NO_APP<br> ldr x30, [sp], #16<br> .cfi_def_cfa_offset 0<br> .cfi_restore w30<br> ret<br>.Lfunc_end0:<br> .size _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E, .Lfunc_end0-_ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E<br> .cfi_endproc<br><br> .section .text._ZN3std2rt10lang_start17h29862496ae07c657E,"ax",@progbits<br> .hidden _ZN3std2rt10lang_start17h29862496ae07c657E<br> .globl _ZN3std2rt10lang_start17h29862496ae07c657E<br> .p2align 2<br> .type _ZN3std2rt10lang_start17h29862496ae07c657E,@function<br>_ZN3std2rt10lang_start17h29862496ae07c657E:<br> .cfi_startproc<br> stp x30, x0, [sp, #-16]!<br> .cfi_def_cfa_offset 16<br> .cfi_offset w30, -16<br> mov w4, w3<br> mov x3, x2<br> mov x2, x1<br> adrp x1, .L__unnamed_1<br> add x1, x1, :lo12:.L__unnamed_1<br> add x0, sp, #8<br> bl _ZN3std2rt19lang_start_internal17h95d6f6a22ba2f96dE<br> ldr x30, [sp], #16<br> .cfi_def_cfa_offset 0<br> .cfi_restore w30<br> ret<br>.Lfunc_end1:<br> .size _ZN3std2rt10lang_start17h29862496ae07c657E, .Lfunc_end1-_ZN3std2rt10lang_start17h29862496ae07c657E<br> .cfi_endproc<br><br> .section ".text._ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE","ax",@progbits<br> .p2align 2<br> .type _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE,@function<br>_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE:<br> .cfi_startproc<br> str x30, [sp, #-16]!<br> .cfi_def_cfa_offset 16<br> .cfi_offset w30, -16<br> ldr x0, [x0]<br> bl _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E<br> mov w0, wzr<br> ldr x30, [sp], #16<br> .cfi_def_cfa_offset 0<br> .cfi_restore w30<br> ret<br>.Lfunc_end2:<br> .size _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE, .Lfunc_end2-_ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE<br> .cfi_endproc<br><br> .section ".text._ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE","ax",@progbits<br> .p2align 2<br> .type _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE,@function<br>_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE:<br> .cfi_startproc<br> str x30, [sp, #-16]!<br> .cfi_def_cfa_offset 16<br> .cfi_offset w30, -16<br> ldr x0, [x0]<br> bl _ZN3std10sys_common9backtrace28__rust_begin_short_backtrace17h929d74729e9673e1E<br> mov w0, wzr<br> ldr x30, [sp], #16<br> .cfi_def_cfa_offset 0<br> .cfi_restore w30<br> ret<br>.Lfunc_end3:<br> .size _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE, .Lfunc_end3-_ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE<br> .cfi_endproc<br><br> .section ".text._ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE","ax",@progbits<br> .p2align 2<br> .type _ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE,@function<br>_ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE:<br> .cfi_startproc<br> ret<br>.Lfunc_end4:<br> .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<br> .cfi_endproc<br><br> .section .text._ZN11hello_world4main17hff90392c72a0ce9aE,"ax",@progbits<br> .p2align 2<br> .type _ZN11hello_world4main17hff90392c72a0ce9aE,@function<br>_ZN11hello_world4main17hff90392c72a0ce9aE:<br> .cfi_startproc<br> sub sp, sp, #64<br> .cfi_def_cfa_offset 64<br> str x30, [sp, #48]<br> .cfi_offset w30, -16<br> adrp x8, .L__unnamed_2<br> add x8, x8, :lo12:.L__unnamed_2<br> mov w9, #1<br> adrp x10, .L__unnamed_3<br> add x10, x10, :lo12:.L__unnamed_3<br> mov x0, sp<br> stp xzr, xzr, [sp, #24]<br> stp x8, x9, [sp]<br> str x10, [sp, #16]<br> bl _ZN3std2io5stdio6_print17h111c70694d02e77dE<br> ldr x30, [sp, #48]<br> add sp, sp, #64<br> .cfi_def_cfa_offset 0<br> .cfi_restore w30<br> ret<br>.Lfunc_end5:<br> .size _ZN11hello_world4main17hff90392c72a0ce9aE, .Lfunc_end5-_ZN11hello_world4main17hff90392c72a0ce9aE<br> .cfi_endproc<br><br> .section .text.main,"ax",@progbits<br> .globl main<br> .p2align 2<br> .type main,@function<br>main:<br> .cfi_startproc<br> str x30, [sp, #-16]!<br> .cfi_def_cfa_offset 16<br> .cfi_offset w30, -16<br> mov x2, x1<br> sxtw x1, w0<br> adrp x0, _ZN11hello_world4main17hff90392c72a0ce9aE<br> add x0, x0, :lo12:_ZN11hello_world4main17hff90392c72a0ce9aE<br> mov w3, wzr<br> bl _ZN3std2rt10lang_start17h29862496ae07c657E<br> ldr x30, [sp], #16<br> ret<br>.Lfunc_end6:<br> .size main, .Lfunc_end6-main<br> .cfi_endproc<br><br> .type .L__unnamed_1,@object<br> .section .data.rel.ro..L__unnamed_1,"aw",@progbits<br> .p2align 3, 0x0<br>.L__unnamed_1:<br> .xword _ZN4core3ptr85drop_in_place$LT$std..rt..lang_start$LT$$LP$$RP$$GT$..$u7b$$u7b$closure$u7d$$u7d$$GT$17h6d6d5a499b7ddfabE<br> .asciz "\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000"<br> .xword _ZN4core3ops8function6FnOnce40call_once$u7b$$u7b$vtable.shim$u7d$$u7d$17h7571627a657c34aaE<br> .xword _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE<br> .xword _ZN3std2rt10lang_start28_$u7b$$u7b$closure$u7d$$u7d$17hc6a0e8f9cdb08ebbE<br> .size .L__unnamed_1, 48<br><br> .type .L__unnamed_4,@object<br> .section .rodata..L__unnamed_4,"a",@progbits<br>.L__unnamed_4:<br> .ascii "Hello, world!\n"<br> .size .L__unnamed_4, 14<br><br> .type .L__unnamed_2,@object<br> .section .data.rel.ro..L__unnamed_2,"aw",@progbits<br> .p2align 3, 0x0<br>.L__unnamed_2:<br> .xword .L__unnamed_4<br> .asciz "\016\000\000\000\000\000\000"<br> .size .L__unnamed_2, 16<br><br> .type .L__unnamed_3,@object<br> .section .rodata..L__unnamed_3,"a",@progbits<br> .p2align 3, 0x0<br>.L__unnamed_3:<br> .size .L__unnamed_3, 0<br><br> .ident "rustc version 1.76.0-nightly (9fad68599 2023-12-03)"<br> .section ".note.GNU-stack","",@progbits</p>
</div>
</div>
Expand Down

0 comments on commit db24bb1

Please sign in to comment.