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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

No more "minimal early Lisps", pulleezz

47 点作者 primodemus超过 14 年前

14 条评论

mechanical_fish超过 14 年前
It's this friendly, open attitude to new young programmers that has made Lisp as popular as it is today.<p>I can't wait to see this person's algebra textbook. "Integral calculus is so old and boring, puleezz. Wake me up when you've rediscovered quaternions."<p>And people wonder how PHP can be so popular. I could spend all day enumerating PHP's faults, but when people who have never written an X before build an X in PHP, the PHP community welcomes them with smiles, not sneers.<p>I wish, I really do, that one percent of one percent of the world's programmers had actually implemented a simple Lisp in Lisp, let alone reached the point where such a thing seemed boring. But lecturing us on our lameness is not going to help.
评论 #2049826 未加载
评论 #2049399 未加载
评论 #2049485 未加载
评论 #2049715 未加载
smithbits超过 14 年前
"Surely you're not learning much by repeating JMC's flawed Ur-Lisp from 1959." No. Implementing an ur-lisp teaches you all kinds of things if you've never implemented a programming language before. It's a solid bite-sized project that's harming no one. Think I'll go write another one, maybe in Haskell this time.
评论 #2049603 未加载
评论 #2048985 未加载
评论 #2048983 未加载
fogus超过 14 年前
Here are a few of the culprits:<p><a href="http://www.paulgraham.com/rootsoflisp.html" rel="nofollow">http://www.paulgraham.com/rootsoflisp.html</a><p><a href="http://www.fogus.me/fun/lithp/" rel="nofollow">http://www.fogus.me/fun/lithp/</a><p><a href="http://nakkaya.com/2010/08/24/a-micro-manual-for-lisp-implemented-in-c/" rel="nofollow">http://nakkaya.com/2010/08/24/a-micro-manual-for-lisp-implem...</a><p><a href="http://www.zogotounga.net/comp/squeak/lispkit.htm" rel="nofollow">http://www.zogotounga.net/comp/squeak/lispkit.htm</a><p>Curse them all.
评论 #2049660 未加载
评论 #2048971 未加载
评论 #2049374 未加载
rayiner超过 14 年前
People write minimal Lisps because they're easy while being elucidating. You can describe a compiler for a more-than-minimal Lisp in a forum post.<p>1) Specify representations for: integers, strings, symbols, and cons-es; specify a data structure for the symbol table and define INTERN properly.<p>2) Implement the reader, cribbing heavily from CLHS 2.1.4, 2.2. Set up constituent, whitespace, and terminating character classes, and implement reader macros for at least quote, double quote, and left/right parens.<p>3) Specify a representation for the environment, which will map symbols to offsets of variables on the stack frame; have a stack of these objects.<p>4) Figure out what special operators to handle. You can get away with just: lambda, progn, if, quote, let.<p>5) Starting from each top level form, walk the code recursively. Each element you encounter will either be: a) a top-level definition b) a single symbol variable reference c) a list with a symbol at its head which is a special form d) a list with a symbol at its head which is a function call<p>As you walk the code, push a new environment onto the stack for each lambda and let you come across, which you pop off when you're done walking the corresponding body (but make sure you save it somewhere).<p>5.1) In one pass, collect information on closed-over variables. Walk the code looking for variables which are referenced (5b) but are not present in the environment. In that case search up the stack. If you find it in a parent environment, it's a closed-over variable. If you don't find it at all, it's a global variable.<p>5.2) Use the environment structures you just collected to assign local variables to stack slots. Figure out a closure representation (use a code pointer followed by an array of closed-over variables). Use the info you collected in (5.1) to assign variables to stack slots and closure variable references to closure variable slots.<p>5.3) In a second pass, generate code. When you reach:<p>a) A TLD, emit a call to the runtime to associate a global name with a lambda b) A variable reference, emit code to either load the value from the stack slot noted in your environment structure, or from the appropriate closure slot, or emit a call to the runtime to look up a global value. c) A special form: generate function prologues/epilogs when you reach a lambda form, use labels and jumps to implement 'if', and use whatever data facilities your assembler has to handle quote-ed literals. When you reach a nested lambda, emit its code as a separate function, then at the point where it is used as a value in the parent function call a closure creation function providing it with the address of the generated code plus the values of all closed-over variables. d) A function call, emit a call to the runtime to look up the global value, then evaluate each of the arguments left to right, pushing them onto the stack. Then, jump to the body of the function.<p>6) Implement the runtime functions for cons handling, the global symbol table, and closure creation.<p>Extend as you see fit to include mutable variables, etc.
yan超过 14 年前
Wow. Summary: "I only liked implementing Lisps when they were on vinyl.'<p>I don't understand smugness when it comes to other peoples' small projects. No one sets out to implement CLv2, just further their own knowledge via a smallish side-project.
评论 #2049565 未加载
poink超过 14 年前
Oh boy! I hope he takes people to task for writing Hello World programs next.
评论 #2049132 未加载
ihodes超过 14 年前
In the comments the author noted that he'd "never met a Lisp that [he] liked". Maybe that's why he doesn't see the value in learning something from writing a basic Lisp yourself.
swaits超过 14 年前
What if it just happens to be fun? Do whatever you want!
Semiapies超过 14 年前
<i>"And some of these [toy, throwaway] languages then become successful, and fuck up my life, because I may be forced to use them to access some library or script some program."</i><p>That thing you just stepped in? That's a big pile of bullshit.
评论 #2049845 未加载
omouse超过 14 年前
It's fine and fun to make a minimal early Lisp, just remember you don't <i>have</i> to release it to the public. Make it open-source, but don't post it on the web or just give it out to a few friends to try out or whatever.
评论 #2049856 未加载
blacksmythe超过 14 年前
<p><pre><code> &#62;&#62; consider writing a Haskell, not a Lisp. </code></pre> Has anyone written a Haskell (or subset) as a hobby project? I would think it would be much harder than writing a simple Lisp, which seems to be designed so that simple versions can be written almost recurvisely, where more advanced functions are decomposed into a few primatives.
评论 #2049613 未加载
pmarin超过 14 年前
I am just wondering how this "article" got 42 points...
anatoly超过 14 年前
I don't understand what he means by "semantic concepts". Anyone?
评论 #2049147 未加载
rwmj超过 14 年前
And implement something that compiles down to native code too.