]> git.lizzy.rs Git - uwu-lang.git/blob - README.md
Update capitalization of Turing in the README (#1)
[uwu-lang.git] / README.md
1 # uwulang
2 UWU (**U**ltimate p**W**ogwamming lang**U**age) is a **functional**, **interpreted**, **weakly typed**, **lazy evaluation** programming language written in C.
3
4 ```uwu
5 fibo
6         bool.if(int.smaller($1, 0), 0,
7         bool.if(int.equal($1, 0),   1,
8         int.add(
9                 fibo(int.sub($1, 1)),
10                 fibo(int.sub($1, 2))
11         )))
12 ```
13
14 You can run the example using `./uwu example/test.uwu`
15
16 ## What this language is
17
18 - Demonstration of dlopen - 35%
19 - Demonstration of lambda - 30%
20 - Fun exercise for myself - 20%
21 - A meme - 10%
22 - Meant for actual use - 5%
23
24 It's Turing complete and somewhat useable.
25
26 ## Invocation
27
28 Make sure the submodules are checked out:
29
30 ```
31 git submodule update --init
32 ```
33
34 To build:
35
36 ```
37 make
38 make -C std
39 ```
40
41 To run:
42
43 ```
44 ./uwu <module> <args>
45 ```
46
47 `<module>` is a path relative to the current directory.
48 Several file names are tried, the first one that exists is used:
49
50 - `<module>`
51 - `<module>.uwu`
52 - `<module>.so`
53
54 If the file name ends with `.so`, it is treated as a native module.
55
56 ## Features
57
58 Makes heavy use of a module system with relative paths.
59
60 There is support for native modules written in C (or a C ABI compatible language) that are loaded at runtime. The standard library relies on this feature.
61
62 Strictly follows lambda principle. Functions without arguments are constants. Functions can (by design) not interact with anything globally, the input is passed to the main function and the only output is the return value of the main function. _However_, global interaction (e.g. print() or read()) could theoretically be added by native modules and since the VM does not cache any results and always calls functions.
63
64 Arguments are always passed by value, there are no references (except references to functions). This way, all memory allocation is stack based and no garbage collector is needed.
65
66 The syntax is very minimal. Almost everything is solved via functions (no control structures, no operators). The are only integer and string literals, but complex data structures are possible with native modules and available in the standard library.
67
68 Currently there are no floating point values, but they might be added in the future (One could also add them using native modules).
69
70 Typing is weak and handled at runtime, native modules can easily add their own types. Handling of type errors is up to the functions, usually they will throw an error and exit the program if incorrect types were passed to them.
71
72 ## Platform
73
74 Does not aim to run on a platform other than Linux. Only tested on x86_64 so far, but it should work on other architectures as well.
75
76 Uses shared object files for native modules, opens them with `dlopen`, which is POSIX.1-2001.
77
78 Requires a libc that implements asprintf (asprintf is not standard, glibc and musl implement it and there are drop-in replacements)
79
80 The current implementation of the VM does not take advantage of lambda (no caching of results), but such a feature might be added in the future. I might also add a compiler for LLVM or x86_64 NASM or a JIT in the future.
81
82 ## Further Documentation
83
84 See `doc/syntax.md` for a syntax documentation.
85 See `doc/std.md` for standard library documentation.