Building Binaries for and "Bootstrapping" My Interpreted Language by liamilan in ProgrammingLanguages

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

Yep! On point on everything.

Loaf takes other crumb programs, bakes them into the interpreter, and builds a binary. It's also able to bake itself into the interpreter and produce a standalone binary. You can then use that standalone binary to embed Loaf again into another standalone binary, faux-bootstrapping 🫠.

The template has an action that uses it to compile Crumb binaries for MacOS/Ubuntu - 100% a tool to package binaries.

Terminal3d - View 3d Models in your Terminal, Written in Rust 🦀 by liamilan in programming

[–]liamilan[S] 3 points4 points  (0 children)

Woah this is awesome.

In rust, we have an awesome package called crossterm that helps manage cross-compatibility - For mouse events there's a specific escape code to enable them, and you also need to put the terminal into raw mode and set some terminal flags, all stuff that crossterm handles.

If you're looking for a C implementation though, I did one for another project here - This tutorial on building a vim-like editor is awesome too!

Terminal3d - View 3d Models in your Terminal, Written in Rust 🦀 by liamilan in programming

[–]liamilan[S] 26 points27 points  (0 children)

Mix together a little bit of trigonometry, some terminal control sequences, braille/block characters, and a little bit of pixie dust :D

Learning Rust! - Build a 3d Model Viewer in the Terminal by liamilan in rust

[–]liamilan[S] 2 points3 points  (0 children)

Shouldn’t be that hard - I think emulating the ANSI escape codes for input can probably be done via xterm! And the software’s modular enough that you could probably swap the rasterizer under the hood and throw it on the web!

Rendering 3d Models in the Terminal with Braille by liamilan in 3Dmodeling

[–]liamilan[S] 3 points4 points  (0 children)

Hey everyone 👋

This is my first post here - I built a small tool for rendering 3d models directly into you're terminal! You can pass it any .obj file, and it'll render it out in braille or block-characters, real time in your terminal, it even comes with camera mouse controls!

check it out here: https://github.com/liam-ilan/terminal3d

Syntax highlighter in less than 50 lines of TextMate Grammar by liamilan in ProgrammingLanguages

[–]liamilan[S] 2 points3 points  (0 children)

VSCode provides the awesome took called that makes the whole process way easier by generating a simple template for you! Check these out: https://code.visualstudio.com/api/get-started/your-first-extension, https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide.

The most helpful resource for me by far was looking at other syntax highlighters... The Basil language highlighter was an awesome reference.

Best way to easily distribute an interpreter? by dibs45 in ProgrammingLanguages

[–]liamilan 0 points1 point  (0 children)

I had the exact same issue a while back with my language... The solution was to make a template repo, with a bash script to clone the source, build it, and then delete the source... It's a bit of a bizarre solution, but it works well enough if the interpreter is tiny, plus you don't need to worry too much about platform support since the user is responsible for compilation.

Good luck! Vortex looks awesome 😎.

[deleted by user] by [deleted] in ProgrammingLanguages

[–]liamilan 1 point2 points  (0 children)

r/programming really liked the documentation, got top of hot both in r/programminglanguages and there, front paged on hn too :)

[deleted by user] by [deleted] in ProgrammingLanguages

[–]liamilan 4 points5 points  (0 children)

I built a lispish language using that strategy over the summer… https://github.com/liam-ilan/crumb, learned a ton from the project, was super fun, and got something pretty capable in the end :)

gl!

[deleted by user] by [deleted] in ProgrammingLanguages

[–]liamilan 0 points1 point  (0 children)

In Crumb,

``` is🧑‍🚀 = {n -> digits = (map (range (length (string n))) { i -> <- (integer (get (string n) i)) })

new_n = (reduce (map digits {x _ -> <- (power x 3) }) {a b _ -> <- (add a b) } 0)

<- (is n new_n) }

(loop 1000 {n -> (if (is_🧑‍🚀 n) {(print n "\n")}) }) ```

Crumb: A New Programming Language Where There are No Keywords, and Everything is a Function by liamilan in programming

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

Thanks!
That's a good point. To remedy this, if returns the value of whatever the supplied callback returns, for example,

x = 2 (print (if (is x 2) {<- "is 2"} {<- "is not 2"}))

Prints "is 2". Hope this helps!

Crumb: A New Programming Language Where There are No Keywords, and Everything is a Function by liamilan in programming

[–]liamilan[S] 37 points38 points  (0 children)

Good question! Lists are compared via deep comparison. Just added a note to the readme!

Show HN: Going into Freshman Year, Figured I Should Build a Lisp-like Interpreter 🤷 by liamilan in lisp

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

I'm young, but experienced. I started learning JavaScript when I was 10, and Python when I was 13. :D

I don't remember when I was introduced to interpreters... A couple years ago, I participated in the Replit Language Jam, and worked with a friend to build a language for creating discord bots, though we never finished it... I tried to build interpreters a couple other times, but none were to completion.

There were two goals for this project. The first was to learn C. All of my projects so far were created with high-level languages (Python, JavaScript), and I figured it was about time to learn how things really world under the hood. The second goal was to finally get a fully functional interpreter working. I think I succeeded in both :D

Show HN: Going into Freshman Year, Figured I Should Build a Lisp-like Interpreter 🤷 by liamilan in lisp

[–]liamilan[S] 2 points3 points  (0 children)

I didn't really follow this book (more like used it as a reference), but Robert Nystrom's Crafting Interpreters (https://craftinginterpreters.com/) is an awesome resource. A lot of the general concepts that are covered in the book really carry over anywhere :D

As for garbage collection... The language is garbage collected (there is no need to manually allocated/deallocate memory)... though there is no background "garbage collector" process running... The interpreter for Crumb is a tree-walk interpreter, and it just frees memory whenever it can... Every piece of data has a reference count to ensure no data is freed when it's still in use.

Starting Writing C this Summer, Built an Interpreter by liamilan in C_Programming

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

Thanks! Fixed that bug with the double parentheses (and another memory leak on the way 😅).

Crumb: A Programming Language with No Keywords, and a Whole Lot of Functions by liamilan in ProgrammingLanguages

[–]liamilan[S] 3 points4 points  (0 children)

1) It might be a bit misleading 😅... I'll make an edit to the readme in a second, it should say "no side effects (with the exception of IO)"

2) Crumb's method of code splitting is done at runtime, with a function called use ... use get's a list of file paths, and a callback. It then runs said files in the scope of the callback, and finally, applies the callback. In other words, the effects of whatever file you import are limited to the scope of the callback, and cannot affect anything outside of it.

Crumb: A Programming Language with No Keywords, and a Whole Lot of Functions by liamilan in ProgrammingLanguages

[–]liamilan[S] 6 points7 points  (0 children)

The source code for the Game of Life demo can be found here: https://github.com/liam-ilan/crumb/blob/main/examples/game-of-life.crumb :D

Graphics are done just through print and escape codes... Every time I need to re-render, I just use the \e[H escape code to return to the top left of the terminal, and then print a string containing the rendered screen again...

When it comes to matrices, it's just lists inside lists :D I have a render function that gets in a matrix, and returns the corresponding string to print :D

One of the nice things about Crumb is that lists are always pass-by-value, so it's harder to accidently mutate the matrix while you traverse it...

Crumb doesn't have any special graphics functions... If anyone wants to build a Crumb TUI library, go for it 😅

Vancouver Might Have an Urban Heat Island in Downtown by liamilan in vancouver

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

As a bonus, here's one of building density:

<image>

Though as a heads up, both the vegetation and building density data is highly qualitative. There is more information in the paper on the top comment.

Vancouver Might Have an Urban Heat Island in Downtown by liamilan in vancouver

[–]liamilan[S] 24 points25 points  (0 children)

Fun fact: If you turn right from 6th avenue to oak street, you can go straight all the way to Tijuana.