diff options
author | metamuffin <metamuffin@disroot.org> | 2025-10-03 17:09:04 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-10-03 17:09:04 +0200 |
commit | 8444803182573e59414ebcbc4bec9da36aeac451 (patch) | |
tree | 1fa91c937ae009719ffa91dbff5d6d41d337b1d2 /blog/2022-11-07-programming-language-design.md | |
parent | ad523865eb95fe2581652bd2c89efc53a3857eed (diff) | |
download | metamuffin-website-8444803182573e59414ebcbc4bec9da36aeac451.tar metamuffin-website-8444803182573e59414ebcbc4bec9da36aeac451.tar.bz2 metamuffin-website-8444803182573e59414ebcbc4bec9da36aeac451.tar.zst |
various changes; add project list
Diffstat (limited to 'blog/2022-11-07-programming-language-design.md')
-rw-r--r-- | blog/2022-11-07-programming-language-design.md | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/blog/2022-11-07-programming-language-design.md b/blog/2022-11-07-programming-language-design.md deleted file mode 100644 index 674e696..0000000 --- a/blog/2022-11-07-programming-language-design.md +++ /dev/null @@ -1,70 +0,0 @@ -# Some Thoughts on Programming Language Design - -This is a collection of ideas to look at when inventing new langauges. - -## Other Ideas - -- The Language pushes abstraction to the limit by not noting any - hardware-related issues like memory-allocations, parallelism, heterogenous - computer architecture (CPU, GPU, …) - - requires a very "intellegent" compiler and a way to describe unknowns like - possible inputs, etc. in the language itself -- Start with assembly but add a very flexible macro system - -## Type System - -```diff -# Haskell -data LinkedList a = Nil | Cons a (Box (LinkedList a)) -data Test = Empty | Blub Int | State { x :: Int, y :: Int } -# Rust -enum LinkedList<T> { Nil, Cons(T, LinkedList<T>) } -``` - -## Memory Management - -- **Drop when out-of-scope** -- Garbage collections -- Reference counting - -## Compile-time logic - -- Annotation when calling function to be run as-far-as-possible at comptime - -```diff -fn format(template: String, args: [String]) -> String { - template.replace("@", (match, i) => args[i]) -} - -fun add(x, y) x + y - -fun main() print(format!("@ ist @; @", ["1+1", 1+1, x])) -# should expand to -fun main() print("1+1 ist 2; " ~ x)) -``` - -## Examples - -### Fizz-Buzz - -```diff -for (n in 0..100) { - if (n % (3*5) == 0) print("FizzBuzz") - else if (n % 3 == 0) print("Fizz") - else if (n % 5 == 0) print("Buzz") - else print(n) -} - - -if (true) x = 1 -if (true) { x = 1 } -``` - -``` -f(x) = 10 + g(x) -f x = 10 + g x - -main = { - -} -``` |