View closure.aeon
# __get_binding_of_caller and __run_code is a compiler hack to invoke VM
# instructions directly.
class Closure:
def construct(code):
let @code = code
let @binding = __get_binding_of_caller(_)
pub def call(args...):
__run_code(_, @code, args, @binding)
View 1_ping_pong.aeon
# The __foo stuff is a compiler hack for running raw instructions,
# so __foo runs the "foo" instruction. The single "_" stuff is to
# tell the compiler to automatically generate a register for a value.
class Pid:
def construct(id):
let @id = id
pub def id:
@id
View lexer.rb
# line 1 "lib/aeon/lexer.rl"
# line 3 "lib/aeon/lexer.rl"
module Aeon
class Lexer
# line 9 "lib/aeon/lexer.rb"
class << self
attr_accessor :_aeon_lexer_trans_keys
View bootstrap.aeon
![no_module]
let object_class = __get_toplevel(_)
let object_iproto = __set_object(_)
# Make sure that instance methods of Object are also available to Object (the
# class) itself.
__set_prototype(object_class, object_iproto)
__set_literal_attr(object_class, '__iproto', object_iproto)
View gist:cb5b1f58d7f10a4d3b96f24e28b87d77
aeon $ cat -n /tmp/test.aeon
1 class Integer:
2 # Overwrites the default prototype with the actual integer prototype.
3 __set_literal_attr(self, __get_integer_prototype(_), '__prototype')
4
5 def +(other):
6 __integer_add(_, self, other)
7
8 def -(other):
9 __integer_sub(_, self, other)
View gist:0e72898c5f7727de2303747ae62383bc
eon $ cat -n /tmp/test.aeon
1 def add(Integer left, Integer right) -> Integer:
2 return __integer_add(left, right)
3
4 def print(String message) -> Integer:
5 return __stdout_write(message)
6
7 def int_to_string(Integer int) -> String:
8 return __integer_to_string(int)
9
View gist:c162e5184a1f14c50f3d47ea65afe552
def add(Integer left, Integer right) -> Integer:
return __integer_add(left, right)
def print(String message) -> Integer:
return __stdout_write(message)
def int_to_string(Integer int) -> String:
return __integer_to_string(int)
let a = 10
View gist:5369ccf26b569068a6948f32fcdfabe0
aeon $ cat -n /tmp/test.aeon
1 def add(Integer left, Integer right) -> Integer:
2 __get_local(0, 0)
3 __get_local(1, 1)
4 __integer_add(2, 0, 1)
5 __return(2)
6
7 def print(String message) -> Integer:
8 __get_local(0, 0)
9 __stdout_write(1, 0)
View this_is_why_socket_stdlib_is_fucking_terrible.rb
require 'socket'
Socket.gethostbyname('localhost') # => ["localhost.localdomain", ["localhost", "x1carbon", "localhost", "x1carbon"], 10, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01", "\x7F\x00\x00\x01"]
TCPSocket.gethostbyname('localhost') # => ["localhost.localdomain", ["localhost", "x1carbon", "localhost", "x1carbon"], 10, "::1", "127.0.0.1"]
View results.txt
Numbers indicate the amount of iterations in 5 seconds.
The C example was compiled using:
clang -Wall -Wextra -pedantic -O2 test.c -o test
Results:
C: 2272688181
LuaJIT 170557787 => ~13x slower