6 ms·
Show HN: Rust but Lisp
- FrankWilhoit 5mo agoAnd for why?
- macmac 5mo agoTo get proper macros.
- fao_ 5mo agoScheme already has hygenic macros, I don't get why you'd vibecode a worse (less battle tested, llm-generated) replacement. I'm not sure why this hit the front-page, to be honest, because it doesn't seem noteworthy or interesting (Anyone and their mother can vibecode something like this in eight hours)
- xigoi 5mo agoBecause Rust syntax is ugly and overcomplicated.
- GalaxyNova 5mo agoIt seems like this is more like writing Rust in an s-expression syntax instead of having a proper lisp dialect that compiles to Rust, which is cool I guess but not very interesting. It's quite weird-looking for someone who's done any amount of lisp programming.
- shawn_w 5mo agoA let that defines variables that have a lifetime beyond the scope of the expression? Yeah, that's really unusual. And it's not even the oddest looking thing from the first example block of code.
- noosphr 5mo ago>Rust semantics with LISP syntax. A transparent s-expression frontend that compiles directly to Rust — no runtime, no GC The first paragraph says literally that.
- monocasa 5mo agoYeah, it sort of reminds me of the microcode assembly of a few of the lisp machines, that, while in s-expressions were also clearly not lisp themselves. But could be an interesting target for some lisp macros.
- hawkice 5mo agoI think some comments are missing the upside of it being precisely Rust, without any new semantics. If you want lisp that compiles to machine code, Common Lisp can get reasonably efficient. The purpose of bringing Rust into it is to surface Rust-specific semantics -- which many people quite like!
- j16sdiz 5mo ago[flagged]
- hawkice 5mo agoIncorrect, and mean-spirited. Come on.
- IncreasePosts 5mo agoFor what it's worth I thought it was a nice comment and I saw no sign of AI in it
- busfahrer 5mo agoSo I'm guessing it's sort of like Fennel, which consciously doesn't completely hide its underlying Lua runtime? https://fennel-lang.org/ https://fennel-lang.org/
- larodi 5mo agothis is actually very interesting approach to syntax remixing, while keeping the ontology
- stuaxo 5mo ago"no runtime, no GC, just" I am BEGGING every project to not have this LLMism in their docs. It reads as No X no Y just slop to me every time.
- andrepd 5mo agoIt's completely nonsensical too. Why would a parser for an alternative syntax introduce a GC?!
- vermilingua 5mo agoClaims to have all the syntax covered, but not a single example of specifying lifetimes or the turbofish, some of the trickiest rust syntax
- andrepd 5mo agoIt's a vibecoded parser...
- gleenn 5mo agoTechnically it's a transpiler.
- kibwen 5mo agoIf you already have the ability to express the grammar productions in Rust that allow for optionally-specified types (e.g. variable declaration), then you have the ability to express lifetimes and the turbofish (which is just a curious way to call a generic function with a specific type parameter). The only weird thing would be that Lisp uses the apostrophe character for something very different than Rust, but you could just pick any other way to denote lifetimes.
- vermilingua 5mo agoCould! > Everything Rust has … expressed as s-expressions. No semantic gap.
- kccqzy 5mo agoThe HRTB is probably the trickiest syntax for specifying lifetimes. It looks like `for<'a> F: Fn(&'a (u8, u16)) -> &'a u8`.
- stdatomic 5mo agoCan you translate this for those of us who don't speak rust?
- amelius 5mo agoThis is probably what Rust's internal ASTs look like. But why would you want to input programs as ASTs?
- physPop 5mo agoso you can do the transformations (see the rlisp macro section)
- amelius 5mo agoYes, but you could do the same by transforming Rust's ASTs. The only downside is that your input format is different from the format you are transforming. But the upside is that readability is much improved, which matters because code is typically read far more often than it is written.
- jaggederest 5mo agoUnfortunately, given the clear LLM basis of this project, s-expressions aren't a great choice. I've found coding agents struggle really hard with s-expression parentheses matching. Much better to give them something more M-expr styled, I think a grammar that is LL(1) is probably helpful in that regard. Basically the more you can piggyback on the training data depth for algol-style and pythonic languages the better.
- dleslie 5mo agoOpus 4.6 handles elisp just fine. But I suppose YMMV.
- 2ndorderthought 5mo agoWhy are we even spending time on this. It's vibe coded slop. The creator probably never even ran it before it got to HN
- gleenn 5mo agoThat has definitely not been my experience as of late. I have produced multiple, largeish Clojure projects with AI that have been perfectly formatted and functional. Perhaps you were using an older or possibly smaller model? I am admittedly using Claude with higher end models and mid to high effort but it has been working great for months for me at this point.
- jaggederest 5mo agoNope, but to be fair when you're working on your own novel S-exprs you don't have LSPs to guide the coding agent. I imagine that it works a lot better in the context of a known and understood language environment like Clojure, CL, scheme, etc. The other option would be to write an LSP in a non-S-expr language to ensure that no turn can end with mismatched parens, for example.
- deleted 5mo ago[deleted]
- thatxliner 5mo ago
- ecto 5mo agoReaders may enjoy my lisp, Loon, which takes heavy inspiration from Rust https://loonlang.com/guide/ownership https://loonlang.com/guide/ownership
- kibwen 5mo agoAgreed, a Lisp built around the concept of ownership is much more interesting than just a way to write Rust via S-expressions.
- imachine1980_ 5mo agoHow does ownership work within the Lisp tree structure?, What is the difference between ownership on this setting and ARC?
- ecto 5mo agoARC refcounts everything (many owners) whereas Loon refcounts only inside immutable shared tree nodes (one owner per handle)
- akch 5mo agoThat page is beautiful! What ssg / theme are you using to build it?
- ecto 5mo agoThanks :) Check out the code - it's Loon! https://github.com/ecto/loon/blob/main/web/src/pages/guide/ownership.loon https://github.com/ecto/loon/blob/main/web/src/pages/guide/o...
- helenite 5mo agoThe website seems to have some bugs on mobile, seen on Chrome 147.0.7727.137 - Cannot horizontally scroll the code snippets on homepage when it overflows. The scroll bars appear but swiping the snippet does nothing. - Footer links are unresponsive (loon, GitHub, MIT Licence links) - In the changelog page, scrolling makes the hamburger menu hide release dates behind it - Hamburger close chevron looks misaligned (not sure if this was a deliberate choice)
- OhMeadhbh 5mo agoHow do you change the syntax to eliminate reverse compatibility? I guess you could change the names of most key functions between releases. But to be compatible with rust you would need to make breaking changes every release.
- nxobject 5mo ago"Lust", or "Risp"?
- zephen 5mo agoNah. It's sort of, but not quite, like "El jefe" "L rut piss"
- moron4hire 5mo agoI don't understand why this had to be LLM generated. S-expression syntax parsers are not hard to write. That's rather much the point of S-expressions.
- Maxatar 5mo ago>S-expression syntax parsers are not hard to write. I'm not sure I quite understand the point of your comment. Are you implying that LLMs should be used for very hard to write code? I feel like the best use of LLMs is to automate the easy stuff so that I can focus on the hard to write stuff.
- slopinthebag 5mo agoHow is pure unbridled AI slop like this making the front page? Voting rings? I don't even feel bad saying this because clearly OP is just the front for Claude here.
- skulk 5mo agoSo if I wanted to actually use this and I write some rust-but-lisp code and there's a compile error, will it show me a nice error message with an arrow pointing to where the error happened in my lisp code? Can I use the amazing `rust-analyzer` LSP to get cool IDE features? I suspect the answer is no, but these might be good further prompts to use.
- thatxliner 5mo agoGood idea! I'm adding error messages + spans ala ariadne now
- eiiot 5mo ago> compiles directly to Rust — no runtime, no GC, just (s-expr → .rs → binary). Can we please write our own READMEs before posting to HN?
- stevefan1999 5mo agoGreenspun's tenth rule of programming is an aphorism in computer programming and especially programming language circles that states:[1][2] Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp. Maybe we should one day include Golang or Rust to it https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule https://en.wikipedia.org/wiki/Greenspun%27s_tenth_rule
- kibwen 5mo agoGreenspun's tenth rule was formulated in a time before things like first-class functions were commonplace in industrial languages. Rust supports not just functional programming idioms but outright Scheme-style macros, it's out of scope for Greenspun's.
- thatxliner 5mo agoFor everyone who is shaming on the project for "not implementing enough," then you can definitely help me with it. For everyone who is shaming on the project for being "LLM slop," sure but that's the reason why something like this can exist in the first place. The point isn't to be a finished, production-ready product. The point is to be an interesting work, and just a sly bit silly
- chrisweekly 5mo agoShould be named "Rutht"
- NooneAtAll3 5mo agodoes there exist something that can do the opposite? some pre-processor that "compiles into rust" from less awful syntax?
- zareith 5mo agoAnyone working on something similar that compiles to go?
- moefh 5mo agoPretty nifty. As of now, the code doesn't compile: there's some stray "span" stuff in codegen.rs[1], and it's trying to format `Warning` which doesn't implement `Display` in main.rs[2]. Fixing these, it runs mostly as advertised, but it seems to assume that one-letter types are always generic parameters, so it's impossible to (for example) generate this: struct X; enum A { P(X), Q } Trying this: (struct X) (enum A (P X) Q) produces this: struct X; enum A<P, X> { Q } while using a multi-letter type like `String`: (enum A (P String) Q) produces the expected: enum A { P(String), Q } One way to solve this would be to always require the generic annotation, and let it be empty when there are no generics, but when I tried that it did something weird: (struct X) (enum A () (P X) Q) produces: struct X; enum A { _ /* List([], Some(Span { start: 54, end: 56 })) */, P(X), Q } I have no idea where the `_` and the comment came from. [1] https://github.com/ThatXliner/rust-but-lisp/blob/70c51a107b2ca898b71a0b55e070c466c3bb1704/src/codegen.rs#L61 https://github.com/ThatXliner/rust-but-lisp/blob/70c51a107b2... [2] https://github.com/ThatXliner/rust-but-lisp/blob/70c51a107b2ca898b71a0b55e070c466c3bb1704/src/main.rs#L59 https://github.com/ThatXliner/rust-but-lisp/blob/70c51a107b2...
- lefra 5mo ago> ((. dx powf 2.0) + (. dy powf 2.0)) sqrt)) I don't know what this is, but clearly not Lisp...
- geon 5mo agoI’ve seen this done with C as well. https://www.eriksvedang.com/carp https://www.eriksvedang.com/carp https://github.com/tomhrr/dale https://github.com/tomhrr/dale
- ColonelPhantom 5mo agoCarp is memory safe via linear types + references, similar to Rust, so I would not describe it as C-like but rather Rust-like.
- tmtvl 5mo agoReminds me of when I brainstormed an S-expression-based alternative syntax for Rust in the comments on an article about Rust's syntax: <https://news.ycombinator.com/item?id=41399712 https://news.ycombinator.com/item?id=41399712>.
- rbanffy 5mo agoI actually like it better than plain Rust…
- goldsteinq 5mo agoI think this misses the point of LISP macros. LISP macros are just functions written in LISP, so here macros need to be functions written in Rust-but-LISP, but it is not so. In fact, I think this macro language lacks conditionals, so it’s not even Turing-complete.
- knh190 5mo ago[dead]
- pivoshenko 5mo agoHmm, interesting ...