编程与软件工程beautifulracket.com
为什么选 Racket?为什么是 Lisp?
Why Racket? Why Lisp?
2019 — 2022,它一次次回到首页
黑点是上首页(≥ 50 分)的那次投稿,空心点是没冲上去的投稿,点越大分数越高。
导读
这是《Beautiful Racket》一书的附录文章,作者用务实、可操作的方式回答“为什么选 Racket?为什么选 Lisp?”这一经典问题,列举函数式编程、宏系统、语言可扩展性等具体好处,并直面“为什么 Lisp 至今仍小众”的质疑。该文多年来多次登上 Hacker News 首页,是 Lisp 拥护者常引的经典辩护文。
为什么经久不衰:它把常被玄学化的“Lisp 优势”落到具体、可验证的论据上,无论你是否用 Lisp,都能启发你思考语言表达力与宏系统的价值。
HN 评论精选
Racket 支持在源码中嵌入图片并让图片成为一等值,这是独特优势但也有兼容性代价
Racket 最神奇的一点是源码和求值器支持图片而不只是文本。你可以在注释里直接插入解释算法的图片,这比大多数语言里带语法高亮的 ASCII 注释是巨大进步——很多时候我写的算法没有白板上的图就很难理解。Racket 还更进一步,让图片成为可以赋值给变量或从函数返回的值,类似 Mathematica 或 Python 的交互式笔记本。当然也有缺点:代码不再是纯文本,无法用 vi、emacs 或非 Racket 的 IDE 编辑。
civility查看英文原文
I think one of the most amazing parts of Racket, and one of the reasons someone should try it out if they haven't, is that the source code and evaluator support images and not just text. The following link shows one aspect of this: https://docs.racket-lang.org/quick/ Just being able to put an image in a comment explaining your algorithm into your code would be huge improvement over the traditional syntax colored ascii you get with most languages and editors. There are many times I've written an algorithm which is difficult to understand without the associated diagram I drew on the whiteboard or in an image editor. Racket lets you insert that image or photo directly into your source, and I think this is a significant improvement over putting a link to that image in a comment. Racket also goes a step beyond that by letting images be values which can be assigned to variables or returned from functions. The link above shows this clearly. I'm sure there is some value in this as a teaching aid, and I think that's why they did it, but you can also return mathematical plots from your functions and so on. This feature is similar to the various interactive notebooks people use for Mathematica or Python, so it's not really specific to Racket, but it is interesting to play with. Obviously there are downsides to putting images in your source. After you do that, your code is no longer ascii, and it won't be something you can edit with vi, emacs, or any non-Racket IDE. Also I doubt it will play nicely with git any time soon. However, it's a neat feature of Racket whereas many of the other benefits in the article apply to any Scheme (Chez, Gambit, Chicken, Guile, etc...) or lisp. I wish there was some reasonable standard (like a better version of Rich Text) that was commonly adopted so other languages could put graphical pictures in the source code.
Lisp 的价值难以在一小时内说清,因为它是改变思维方式的学习,这对任何学科都成立
“如果 __ 这么好,就该能在一小时内用简洁实用的语言讲清它的好处”——这段话几乎适用于任何领域。学过外语的人能体会其价值,却无法在一小时内解释清楚。这是一种改变你已有知识组织方式的学习,你怎么推销它?这也同样回答了“如果 Lisp 这么好为什么没人用”——三角函数、音乐不也一样吗?
ken查看英文原文
> If __ are so great, then it should be possible to summarize their benefits in concise, practical terms. It should be possible to demonstrate the power of __ in one hour, not 100. If __ advocates refuse to do this, then we shouldn’t be surprised when __ remain stuck near the bottom of the charts. This paragraph seems like it would be equally true for almost any subject you filled in the blanks with. As someone who had to learn a foreign (natural) language in school, I can see the benefit now, but there's no way I could explain it, and certainly not in an hour. It's a type of learning which causes a change in how you organize things you already know. How do you sell that? (No, I don't believe "so you can talk to people in that language" is a realistic benefit. I don't think even my school thought that. The selection of languages offered is simply not useful. I've never met anyone this side of Stuttgart with which to use my German. Of the top 10 non-English languages spoken in my state, only 1 was offered as a class at my school. It almost looked like they went out of their way to find teachers in less common languages.) (BTW, that's also the same answer as "If Lisp is so great why isn't anyone using it?" It works for any subject. If trig is so great, why aren't you using it? If music is so great, why did you stop playing after you graduated, and were no longer required?) I'm not trying to downplay the importance. It's a real problem, for many fields. As a Lisp programmer, it's my nature to try to sell everyone on learning Lisp even if they won't use it, and also to over-generalize problems to nearly the point of absurdity. How do you get someone to want to learn something when it may have no immediate and apparent practical value to them? Especially today when their whole "learning" slice is competing with Netflix and Facebook and all the rest. I guess the trendy answer right now is something in the neighborhood of "freemium gamification" and for reasons I can't explain that makes me sad.
Lisp 的杀手锏是编译期计算:宏让假设集中一处,静态与动态检查也不必取舍
在我看来 Lisp 的杀手级特性是编译期计算:宏系统不是 C 预处理器或 C++ 模板那种受限的附加语言,整个语言在编译期和运行期都可用,甚至能复用已测试的函数。这让你把编程中的每个假设都集中在一处,不必因语言表达力不足而把不确定性散落多处——这才是“可变更的软件”而不只是“可读的软件”。有了编译期计算,静态/动态类型检查也不必二选一。
cracauer查看英文原文
In my mind there is one killer feature in Lisp, and that is Compile-Time-Computing. You have a macro system that isn't some lameass additional language with severe limitations like the C preprocessor or C++ templates. You have all the language available both at compile time and at run time. You can even use functions you already have (and tested) in both places. This allows you to leave every single assumption you make during programming in one place. You don't have to splatter uncertainty about what the program is supposed to do into multiple places because you language isn't expressive enough, e.g. you cannot just redefine control structures to express an assumption. That is what leads to "changeable software", not just "readable software". My writings on the subject: https://medium.com/@MartinCracauer/a-gentle-introduction-to-compile-time-computing-part-1-d4d96099cea0 https://medium.com/@MartinCracauer/a-gentle-introduction-to-compile-time-computing-part-2-cb0a46f6cfe8 Example - using scientific units attached to literals in source code, but keep them at compile time and don't slow down runtime with unit checking: https://medium.com/@MartinCracauer/a-gentle-introduction-to-compile-time-computing-part-3-scientific-units-8e41d8a727ca And speaking about early or late (static/dynamic) type checking. If you have compile-time computing you don't have to choose. How silly would it be to make a programming language that can only do one or the other. https://medium.com/@MartinCracauer/static-type-checking-in-the-programmable-programming-language-lisp-79bb79eb068a Finally, there is turnaround time during development: https://hackernoon.com/software-development-at-1-hz-5530bb58fc0e
Lisp 的核心魅力是函数式编程加 REPL 式自底向上开发,作者最终选了 Haskell
我写过关于 Common Lisp 和 Scheme 的书。它们对我的核心魅力是函数式编程与在交互式 REPL 中自底向上构建小函数的结合。Python 和 Ruby 也支持 REPL 式开发,但函数性不够。我最近在 Racket 和 Haskell 之间为商业产品做原型选型,最终选了 Haskell——我把 Haskell 视为另一种支持 REPL 式开发的 Lisp 语言。
mark_l_watson查看英文原文
I have written books on Common Lisp and Scheme. Their power feature to me is the combination of functional programming (functions without side effects) and how these small functions can be built bottom-up in an interactive repl. Other languages like Python and Ruby also support repl style development, but aren't sufficiently functional. A little off topic, but I am working on a commercial product (KGcreator, a tool for generating graph data for knowledge graphs) and started prototyping in both Racket and Haskell. It was a tough call but I chose Haskell. I think of Haskell as being another Lisp language that also supports repl style development.
历次讨论
同类还值得读
开源应用架构
The Architecture of Open Source Applications
《开源软件架构》(AOSA)是一本在线免费书,邀请知名开源项目的作者亲自剖析其内部设计,涵盖 SQLAlchemy、LLVM、Audacity、Apache、Bash 等系统。
编程与软件工程上首页 9 次 · 2011–2024aosabook.org编辑精选编程语言简史:简短、不完整且多半错误
A Brief, Incomplete, and Mostly Wrong History of Programming Languages
一篇以戏谑、故意不准确的方式回顾编程语言史的博客文章,用夸张轶事和讽刺定义串起 Lisp、C、C++、Java、JavaScript、PHP 等语言。
编程与软件工程上首页 8 次 · 2009–2021james-iry.blogspot.comSQLite 是如何测试的
How SQLite is tested
SQLite 官方文档页,系统介绍 SQLite 的测试体系:多种测试方法(TCL 测试、模糊测试、回归测试、静态分析等)和海量测试用例,展示了这个小型开源项目如何靠极致测试获得…
编程与软件工程上首页 8 次 · 2009–2025sqlite.org编辑精选高级编程语言(2009)
Advanced programming languages (2009)
Matt Might 的经典文章,按用途推荐“高级编程语言”:如果追求就业就选主流语言,如果追求表达力、学术研究或创业,则推荐 Haskell、OCaml、Scala 等函数式语…
编程与软件工程上首页 8 次 · 2009–2022matt.might.net我的 Forth 与栈机器经历
Yosefk - My history with Forth & stack machines
作者以亲身经历回顾了使用 Forth 语言和栈式机器的历程:既赞叹其简洁优雅、代码量小、可自举的优点,也坦率指出栈操作在实际编程中的痛苦,以及 Forth 社区文化中的问题。
编程与软件工程上首页 8 次 · 2010–2024yosefk.com编辑精选