TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Forsp: A Forth+Lisp Hybrid Lambda Calculus Language

228 点作者 xorvoid11 个月前

23 条评论

NackerHughes11 个月前
This is incredible. I&#x27;ll be tinkering with this for a while, guaranteed. As the advantages of combining Lisp and Forth in this way are slowly revealed to me it&#x27;s like unlocking parts of my brain to interact with each other that never have done before.<p>Pretentiousness on my part aside, this is a pretty mind-blowing concept. The interpreter being in less than 1000 lines of (comprehensible) C is all the more commendable (most of these minimal languages turn out to be some monolithic Rust thing or similar, which kinda defeats the entire purpose imo).<p>Excited to take a closer look at the source to see how the various data structures etc. are laid out in memory. I won&#x27;t be able to resist making comparisons to my current&#x2F;other favourite mini-language &#x27;fe&#x27; (<a href="https:&#x2F;&#x2F;github.com&#x2F;rxi&#x2F;fe">https:&#x2F;&#x2F;github.com&#x2F;rxi&#x2F;fe</a>), a sub-1000-line Lisp also written in C. If you haven&#x27;t seen that one I&#x27;d definitely recommend checking it out.<p>Thank you for putting this online. Happy hacking!
评论 #40650649 未加载
评论 #40650572 未加载
um111 个月前
Very cool. I like that both lisp and forth were “discovered” and that this cvbp is more fundamental than both(?!). This reminds me of [pdf] <a href="https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;pdf&#x2F;10.1145&#x2F;181993.181999" rel="nofollow">https:&#x2F;&#x2F;dl.acm.org&#x2F;doi&#x2F;pdf&#x2F;10.1145&#x2F;181993.181999</a> and wonder if&#x2F;how it relates.
评论 #40642357 未加载
评论 #40642224 未加载
评论 #40646161 未加载
评论 #40644463 未加载
sevensor11 个月前
What I like about this is how neatly it reduces everything to a small set of concepts. Much like lisp and forth, but not the same as either. It&#x27;s exciting to think that there may be more of these out there, waiting to be discovered!
thsksbd11 个月前
I been wanting to make a forth+lisp language for a while now - inspired by HP&#x27;s RPL (its so close to being a lisp!).<p>Super cool
评论 #40642343 未加载
pierrebai11 个月前
Reading the example, I really wish the syntax for push and pop had been &quot;&lt;foo&quot; (push foo on stack) and &quot;&gt;bar&quot; (pop from stack into bar). I find the choice of $ and ^ not obvious. Especially since, for me, ^ implies popping, not pushing.
评论 #40651381 未加载
评论 #40652410 未加载
pmarreck11 个月前
This looks really neat, although I&#x27;m still wrapping my head around it! It&#x27;s funny how things that are even more fundamentally simple than what has been discovered, can be (initially) harder to reason about!<p>So you could presumably also write a Lisp interpreter AND a Forth interpreter using it?<p>(Might as well write a Turing machine interpreter too for the trifecta... assuming one can decide on the syntax...)<p>That plus some additional functionality to make it more usable in the general sense (adding math functions, string manipulation, maybe some basic I&#x2F;O) and it might be a VERY interesting instructional tool.<p>I&#x27;ve heard the term &quot;thunk&quot; but I forget what it means...
评论 #40649092 未加载
评论 #40654059 未加载
kazinator11 个月前
What has Lisp semantics and a stack with &quot;call by push value&quot; and whatnot is any one of the stack-based virtual machines used for compiling Lisp over the past 60 years.
im3w1l11 个月前
Another recent attempt at a language combining features of Forth and Lisp <a href="https:&#x2F;&#x2F;github.com&#x2F;rickardnorlander&#x2F;misc&#x2F;tree&#x2F;main&#x2F;cursed_lang">https:&#x2F;&#x2F;github.com&#x2F;rickardnorlander&#x2F;misc&#x2F;tree&#x2F;main&#x2F;cursed_la...</a><p>Someone even asked the same question<p><pre><code> &#x27; seems redundant. &#x27;x could just be (x)? </code></pre> though for that language the answer was that yes it&#x27;s exactly the same.
diffxx11 个月前
Cool language. One modest suggestion: perhaps return 0 rather than 1. Feature request: addition and division as well as subtraction and multiplication ;)
评论 #40642377 未加载
tonymontana6911 个月前
Reminds me of the language from this paper, which also shows how to smoothly integrate I&#x2F;O and state into such a style <a href="https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;2212.08177" rel="nofollow">https:&#x2F;&#x2F;arxiv.org&#x2F;abs&#x2F;2212.08177</a>
CrociDB11 个月前
Forth+Lisp = Wet dreams of every programming nerd
评论 #40651768 未加载
tangjurine11 个月前
If you have time, could you explain the ycombinator and if parts a bit more? Been a while since I looked at this stuff
nickcw11 个月前
I like this very much!<p>pop is kinda like ! in FORTH and push is like @ so I think $foo would be more FORTHy as !foo and ^foo as @foo
ungamedplayer11 个月前
If you like to work the other way I present <a href="https:&#x2F;&#x2F;github.com&#x2F;garlic0x1&#x2F;forth">https:&#x2F;&#x2F;github.com&#x2F;garlic0x1&#x2F;forth</a> forth in common lisp.
throw15675422811 个月前
Wow he even provides an interpreter in C. How would a compiler implementation for this language foreseeably differ from the interpreter given, does anyone know? Trying to learn about this more.
评论 #40645570 未加载
tonyg11 个月前
Could ^a be dispensed with? It looks like (a) is equivalent to it.
评论 #40645320 未加载
评论 #40644978 未加载
mkovach11 个月前
Since it is written in C, we need to write COBOL and FORTRAN interpreters with it, make sure the manpages are in Latin, and we&#x27;ll hit the ancient languages nerdvonia.
评论 #40649459 未加载
dugmartin11 个月前
I really like the syntax and ergonomics - nice job @xorvoid.
pbrhocwp11 个月前
Very nice! Thanks a lot for the discovery.
James_K11 个月前
I&#x27;ve never really got Forth. It&#x27;s good for sending commands to a printer, but actually programming in it seems like a drag. I get that it&#x27;s technically the same as lisp code, just backwards without the parens, but adding the parens just makes it easier to understand. Adding variables is smart and would make it more tolerable but I would still rather work in lisp.
评论 #40647545 未加载
评论 #40646659 未加载
评论 #40645709 未加载
评论 #40646810 未加载
评论 #40649298 未加载
评论 #40648874 未加载
评论 #40646144 未加载
评论 #40654498 未加载
评论 #40646409 未加载
alexisread11 个月前
Hmm, really nice! I might have to steal all of this for my language (<a href="https:&#x2F;&#x2F;github.com&#x2F;alexisread&#x2F;minim&#x2F;blob&#x2F;develop&#x2F;minim&#x2F;minim.org">https:&#x2F;&#x2F;github.com&#x2F;alexisread&#x2F;minim&#x2F;blob&#x2F;develop&#x2F;minim&#x2F;minim...</a> really in flux ATM)<p>Reminds me of <a href="https:&#x2F;&#x2F;pygmy.utoh.org&#x2F;3ins4th.html" rel="nofollow">https:&#x2F;&#x2F;pygmy.utoh.org&#x2F;3ins4th.html</a> except the third instruction is execute rather than quote.<p>In the spirit of building from scratch, I&#x27;d like to highlight sectorforth&#x2F;milliforth (<a href="https:&#x2F;&#x2F;github.com&#x2F;fuzzballcat&#x2F;milliForth&#x2F;blob&#x2F;master&#x2F;sector.asm">https:&#x2F;&#x2F;github.com&#x2F;fuzzballcat&#x2F;milliForth&#x2F;blob&#x2F;master&#x2F;sector...</a>) - they implement as little as possible to get a working system ie. just the basic fetch&#x2F;store ops, numerical and I&#x2F;O.<p>The parser can probably be reduced - there&#x27;s a nice paper detailing Cognition (a forth dialect, but the parsing could be broken out into a lib - <a href="https:&#x2F;&#x2F;ret2pop.nullring.xyz&#x2F;blog&#x2F;cognition.html" rel="nofollow">https:&#x2F;&#x2F;ret2pop.nullring.xyz&#x2F;blog&#x2F;cognition.html</a>) where using a couple of crank operators, you can implement custom syntax in a forth-style way (as opposed to say PEGs).<p>In terms of variables and scoping, Dreams (another forth dialect- <a href="http:&#x2F;&#x2F;elilabs.com&#x2F;~rj&#x2F;dreams&#x2F;dreams-rep.html" rel="nofollow">http:&#x2F;&#x2F;elilabs.com&#x2F;~rj&#x2F;dreams&#x2F;dreams-rep.html</a>) uses mianly dynamic scoping, and builds it&#x27;s structs (C-style structs) using the standard forth struct words. This allows it to be hard-realtime though as you don&#x27;t need to walk the lexical tree to bind variables. You can also early bind like with CBPV. I guess this is also similar to REBOL&#x27;s BINDology (<a href="https:&#x2F;&#x2F;github.com&#x2F;r3n&#x2F;rebol-wiki&#x2F;wiki&#x2F;Bindology">https:&#x2F;&#x2F;github.com&#x2F;r3n&#x2F;rebol-wiki&#x2F;wiki&#x2F;Bindology</a>)<p>Lots of overlap here with these things. Just for completeness there&#x27;s also dynamic variable handling (over lexically scoped structures) with wat (<a href="https:&#x2F;&#x2F;github.com&#x2F;GiacomoCau&#x2F;wat-js&#x2F;tree&#x2F;master">https:&#x2F;&#x2F;github.com&#x2F;GiacomoCau&#x2F;wat-js&#x2F;tree&#x2F;master</a>) though this is not realtime.<p>Is it possible to make the closures dynamically scoped by default here? I&#x27;ve not had time to think about this properly. I like the fact that eval is lazy here like in forth or REBOL, rather than eager as in lisp - the idea of passing around blocks&#x2F;thunks appeals wrt realtime (well with dynamic scoping) and parallelism.<p>The env per-thread I guess could be compared to the forth dictionary? Dreams abstracts this by virtue of it&#x27;s (token) threading model which appears useful for task switching, objects and the like.<p>I&#x27;d also like to highlight able forth which has: Compiler-only design (like Freeforth) - Word-classes (like Retro) - A straightforward bootstrap process using a minimal set of seed words (like seedForth) - No (ZERO) special forms, not even integers, and a consistent model for adding literals without the complexity of i.e. recognises - A single flat word-list that can be freely manipulated and composed of other word-lists - No separate [assembly] code words - Explicit optimizations (ONLY) i.e. explicit tail-call elimination<p>I&#x27;ve only started looking into able forth so can&#x27;t really comment on it much, but the no-special-forms appeals here.<p>Sorry, random thoughts here, I&#x27;d like to discuss further when I&#x27;ve had time to digest your language. :)
评论 #40645980 未加载
kitd11 个月前
&gt; <i>It&#x27;s a hybrid language combining Forth and Lisp, so naturally it&#x27;s called Forsp</i><p>Shame. Missed a golden opportunity to call it &quot;Lithp&quot; :)
评论 #40648469 未加载
FrustratedMonky11 个月前
Nice, anyone using this? Have practical feedback?<p>Does this have potential to grow, or would most people just say &#x27;use lisp&#x27;.
评论 #40647195 未加载