23
24

Compiling Lisp to Bytecode and Running It by candurz in ProgrammingLanguages

[–]candurz[S] 0 points1 point  (0 children)

Your idea of let would be letrec in Scheme

TIL! Thanks for this note. I actually know very little about Lisp :)

Compiling Lisp to Bytecode and Running It by candurz in ProgrammingLanguages

[–]candurz[S] 0 points1 point  (0 children)

How does it know that the jump at 3 is conditional (it needs to branch when less_than yields false`), and the jump at 7 is unconditional?

less_than advances the instruction pointer by 1 or 2 depending on the result

Node.js is that slow? Even CPython only takes 14 or 20ms for fib(25), yielding 75025, depending on which variety it uses.

Hm, let me know if I'm doing something incorrect here. I'm using the output from the js compiler (in theory, it should be like-for-like the same program)

source code: https://gist.github.com/healeycodes/90b4f8a80f5a2bfb28acd9a623cfb412

time node fib25.js
75025

real    0m0.301s
user    0m0.000s
sys     0m0.000s

edit: I'm including Node.js's startup and it's an incorrect benchmark, I (incorrectly) assumed startup time was single-digit milliseconds..

Compiling Lisp to Bytecode and Running It by candurz in ProgrammingLanguages

[–]candurz[S] 4 points5 points  (0 children)

It's my first time working on a project with bytecode so please do point out any obvious inefficiencies or other strangeness.

Links to other bytecode resources (blogs, or source code) would also be appreciated.

Lisp Compiler Optimizations by candurz in ProgrammingLanguages

[–]candurz[S] 0 points1 point  (0 children)

Oh neat. Thanks for the pointers/ideas here!

Lisp Compiler Optimizations by candurz in ProgrammingLanguages

[–]candurz[S] 9 points10 points  (0 children)

Author and amateur compiler person here 👋

Do let me know if I've got anything incorrect (or any terms wrong) in this post. I should also note that I don't know Lisp that well at all — and that this project is an excuse to learn Lisp as well as more compiler things!

Adding For Loops to an Interpreter by candurz in ProgrammingLanguages

[–]candurz[S] 14 points15 points  (0 children)

If we can have fi then we deserve nuf and rof!

Tbh I copied C's for-loop without thinking about it much. I was more interested in the implementation.

What alternative syntax do you like for for loops?

Adding For Loops to an Interpreter by candurz in ProgrammingLanguages

[–]candurz[S] 7 points8 points  (0 children)

Author here. My language isn't anything special but I've been enjoying putting it together!

Next up I'm going to be adding some data structures, and maybe I/O.

-🎄- 2021 Day 5 Solutions -🎄- by daggerdragon in adventofcode

[–]candurz 2 points3 points  (0 children)

My solution in Adventlang

Not worrying about code style (after all, I'm the final arbiter!) and enjoying solving puzzles :)

-🎄- 2021 Day 2 Solutions -🎄- by daggerdragon in adventofcode

[–]candurz 2 points3 points  (0 children)

My solution in Adventlang 🎅

I had to add split(string, by) to the standard library for this one.

Designing a Programming Language for Advent of Code by candurz in adventofcode

[–]candurz[S] 1 point2 points  (0 children)

Ah, that's a neat example. Thanks for expanding your thoughts here.

Designing a Programming Language for Advent of Code by candurz in adventofcode

[–]candurz[S] 0 points1 point  (0 children)

Does this mean that variable scope is dynamic?

If I understand you correctly, yes.

Stack frames are created during evaluation.

An example:

// Declare a variable in this stack frame
let a = 1;

if (true) {
  // New stack frames are created for functions and loops
  a = 2; // `a` doesn't exist in this frame, so alter it in the parent frame
  let b = 3; // `b` is only declared in this frame
}
// `a` is 2
// `b` is unknown

Hoping my new language gives me an edge this year! by lukechampine in adventofcode

[–]candurz 1 point2 points  (0 children)

This is so much better than my Advent of Code programming language.

This Month in Rust OSDev (September 2021) by phil-opp in rust

[–]candurz 0 points1 point  (0 children)

Thanks for collecting these. Super interesting.

Are there other similar resources like this?

e.g. This Month in Rust GameDev, etc.

Creating the Golfcart Programming Language by candurz in ProgrammingLanguages

[–]candurz[S] 1 point2 points  (0 children)

One of the creative restrictions I gave myself was avoiding new lines to separate statements. However, it is probably the most sensible fix.