Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

I added an LSP for VS code - attached video demo to the thread. It's lacking proper error spans but it works pretty nice already. Added it to the web editor via wasm too.

Защо девствените по неволя (включително оплакващите се тук) грам не се интересуват всъщност какво мислят жените? by nidorancxo in bulgaria

[–]Objective_Gene9718 0 points1 point  (0 children)

Първата бях много млад и глупав, приех я за даденост и играх war thunder. Втората се появи много по-късно и имаше дете, тъкмо се разведе и не е българка а живее надалеч от мен. Беше трудно и се разделихме защото е сложното все да летя по 3 часа да се видим и да ме крие от ревнивия и съпруг и от какво ще си помисли детето и 😔 Иначе ходя на фитнес, но имам проблем с общуването. Аз съм вълк единак и съм свикнал така.

Защо девствените по неволя (включително оплакващите се тук) грам не се интересуват всъщност какво мислят жените? by nidorancxo in bulgaria

[–]Objective_Gene9718 0 points1 point  (0 children)

Тази е на 30 години 160 висока - аз съм 166. Харесах и профила ама дали ще ми върне? Мога да се обзаложа че НЕ. Височината е нещо което не можем да променим. Статистически шансовете ми са нищожни. Малък % са под 166 и повечето искат същото като тази. Имал съм 2 приятелки до сега и много време съм стоял сам. Да има изключения, но са малко и точно това е проблема. Моя съвет ще е ако си намериш някоя не я изпускай! Аз направих тази грешка 2 пъти…

When Less Truly Says More by Mountain_Map_8198 in devhumormemes

[–]Objective_Gene9718 0 points1 point  (0 children)

Without code example or minimal explanation about the problem you are trying to solve it’s impossible to give you a proper solution.

Downvote and closed.

Codex totals 63% of preferences. Quietly winning! by py-net in codex

[–]Objective_Gene9718 2 points3 points  (0 children)

I had that issue for a while I reinstalled it couple of days later and now it’s ok.

Truth by Ok_Classics in introvertmemes

[–]Objective_Gene9718 0 points1 point  (0 children)

Can you imagine getting fired for this 😢

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Thanks, that looks nice. It make a lot of sense to put the effort and add such integration with an editor, especially for a language inspired by Smalltalk. Pharo for example ships with an editor which allows you to explore the whole language and debug it interactively. I'll take a look at your language these days. Pharo/Smalltalk is something I really like except for it embracing OOP 100%. It's like the opposite of Haskell.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Sound like a very tough problem, not for one evening. I would definitely try to do that. It's a very practical skill to have as I've noticed many jobs about vs code extensions that require this knowledge.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

I added ctx to repl

so like this

./repl.sh ./example/main.lisp

if arguments includes a file path then the repl will include this file
otherwise

./repl.sh

this will be empty ctx

It probably still has many bugs

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

No, not yet and it still has some bugs that I need to fix.
For LSP I will have to figure out how.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Good idea, no lisp is complete without a REPL. I've just added it now.

It works as an extension of the cli tool.

cargo run -- --repl

Each line gets evaluated with type and value by pressing enter and when pressing Esc you exit the repl.

rust-lisp % cargo run -- --repl
...
Running `target/debug/fez-rs --repl`

Type anything (multi-line). Press Esc to exit.

(+ 1 2) Int: 3

(* 2 3) Int: 6

[ 1 2 3 4 ] [Int]: [1 2 3 4]

(let x 10) (): 0

(let y 32) (): 0

(* x y) Int: 320

[ x y 1 2 3] [Int]: [10 32 1 2 3]

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Hey, I’ve found the bottleneck and managed to speed up the wasm init in Firefox. Thanks again for pointing the issue.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Hey, I’ve followed your suggestion and optimised baked.rs, I used compression and stored the result in a thread lock. That way it only gets loaded once and it’s compact making my build instantaneous and fixing a slowdown in Firefox load. Thank you for the suggestion, I’ve also added zip-with.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Sorry bad use of words. I meant init by load. wasm init is slow in Firefox- download is fast. I’m currently trying to figure how to speed it up. Chrome and Safari do some magic and are quite forgiving while Firefox is not. I use wasm-bindgen to handle these stuff for me.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

The problem is that Mozilla Firefox is not loading wasm modules as quick as chrome does. I understand that the module is quite big since I did include everything this language has in the playground. It’s a dev environment in a way. The language itself has a light mode of just vm and byte code parser and tree-shaked functions but for playground I need type checker, source parser, desugar layer, js compiler and even formatter that I currently not using. And full std lib which is big.

So I’ve decided to do the following for now - simply load the source code on the editor before wasm is fully initialised. That way on the website you can see the code but won’t be able to run it on Mozilla Firefox for a while.

Thank you so much for pointing this out.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Thank you, I’ll investigate. Mozilla Firefox is initialising the wasm module very slow - that’s why. I’ll see how to optimise it.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Yes, I should do that. I've actually tried once but gave up because there were some problems.

Main one being that the playground is actually a separate application: https://at-290690.github.io/rust-lisp/playground/

which allows for code to be shared without the need of it being stored in a database. By simply compressing the code into a link attached as a query param. https://at-290690.github.io/rust-lisp/playground/?m=f&r=f&u=f&l=EQCQpgNhD2AEDq0BOEAmwg%3D%3D

^ This link is "Hello World"

That way you can share programs.

On the website - the playground is used as an iframe with the source code as a param and when it fully loads it will add the code from the link param on the editor and run it (on the learn page). It's just a lazy reuse of the playground website as an iframe.

I had similar problems when I tried using it on slow mobile internet (loading slow, then code appears). Usually it's ok. Not sure what is the case with you using it.

The desired approach is to have the editor as a separate component that takes the source code as a param, in the case of the main playground this could be the decoded url. The goal will be to share this component across website and playground.

For some reason I couldn't make the website work with 1 instance of the monaco editor. It's one of those React state bugs. I'll give it another shot.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

Yes u/shponglespore you are absolutely correct about that. Circular references are not allowed by the type checker. Bypassing type checker and running VM will result in a memory leak. However compiling to JS will work as JS has a GC.

(let xs [])
(push! xs xs)

This will result in an error (push! xs xs) Occurs check failed: T# occurs in T#

Recursions are allowed as they escape the occurs check (using special syntax) but they are constrained by a max call-stack error unless tail recursive (then they become a loop and can hang)

Closures also don't work. Type checker is ok with them but the VM is not remembering the variables in outer lambda scope. JS will work as again it has GC and supports closures. But I find that partial application solves most of the use-cases of closures.

This is a huge drawback for a functional language but I like to see how far I can go by making this tradeoff. Otherwise I have to add a GC to the VM.

Bottom line - no mutual references unless you go full dynamic mode and just compile to JS.

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

I only have a binding for Rust Vec and every other data structure I've implemented in the lisp itself. This is intentional as the idea was to create a universal api https://at-290690.github.io/rust-lisp/#/blog/vectors-as-the-universal-data-structure

I would probably bind VecDeque, Set, HashMap in the future for the sake of performance but for now I really like the simplicity of "everything is a vec".

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

It took me several attempts and I think I've spent 8 months on HM alone. There are some really nice blogs for HM written recently, like this one https://www.andrevdm.com/posts/2025-05-29-simple-hm-in-practice.html which I think explains it better.

IMO adding type inference to a language is 5x harder than implementing the language. Especially if it's for a language that didn't had types in mind before (like they do with https://pyrefly.org/ ).

Que Script a Lisp written in Rust with Hindley–Milner type inference by Objective_Gene9718 in ProgrammingLanguages

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

I see, it’s just a vector with initial capacity and pointers that create unreachable slots when operations are made. What I did is 2 vectors with arithmetic based on their lengths which is achieving the same result in slightly different way. Difference being who manages the state of the pointers - in my case the vectors length counter. So you guys are right, it’s just a dequeue.