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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

A Haskell Programmer Tries to Learn Racket

257 点作者 jackhammer2022大约 11 年前

16 条评论

gaigepr大约 11 年前
&quot;...but nothing beyond that. As long as Node.js exists in this world, I can&#x27;t truly hate anything else.&quot;<p>I found this hilarious. I am also rather underwhelmed (to be nice) with Nodejs and a little bothered at its wide adoption.<p>I have also been learning racket recently; my formal language and functional programming class uses it. I had some previous experience with common lisp but the raw nature of scheme still pleasantly surprised me a little bit.<p>EDIT: From what I remember, javascript was &quot;inspired&quot; by scheme. Obviously that when well...
评论 #7595540 未加载
评论 #7595990 未加载
评论 #7599358 未加载
评论 #7595705 未加载
评论 #7595522 未加载
nnq大约 11 年前
This sums up quite a lot about Lisps in general. I&#x27;m amazed OP got so fast to this &quot;insight&quot; :)<p><pre><code> (And this is probably Lisp&#x27;s greatest weakness as well – with this level of possible diversity, everyone has to use the “common lowest denominator” simply because nobody can agree on what alternative syntax &#x2F; library &#x2F; etc. is better and should be used.) Off-topic: it&#x27;s not enough to give everyone opportunity to improve the language; you have to choose the winners and promote them heavily. The rules of free market don&#x27;t work here; people won&#x27;t use the best thing, they&#x27;ll use the one which is available out of the box and which is used by their peers.</code></pre>
评论 #7596960 未加载
评论 #7596945 未加载
评论 #7597074 未加载
评论 #7597730 未加载
Strilanc大约 11 年前
Is this... a Let&#x27;s Play of learning a programming language? Because it&#x27;s surprisingly effective. I learned and I was entertained.
评论 #7595517 未加载
brudgers大约 11 年前
As others have said, this does justice to the idea of actually learning a new language...or perhaps because it is Racket a new family or ecosystem of languages. Anyway, if you&#x27;re still curious about pairs verus lists and why anyone would use dotted pairs, I like to think about it as where Lisps show that they are from the age when running close to the metal was a given.<p>And it all goes back to <i>car</i> and <i>cdr</i> and the fact that they are (or rather were) embedded assembly language and there to give raw access to Lisp&#x27;s linked memory model (as opposed to the sequential memory model of Fortran). A dotted pair has two efficiency advantages over a proper list and both stem from the fact that the last cell of the last pair of a proper list contains &#x27;nil (or &#x27;null in Racket).<p>Storing two values in a proper list requires two cons cells - the first with the first value and a pointer to the second cons cell and a second cons cell containing the second value and a null pointer. In contrast, a dotted pair holds two values in a single cons cell - halving the memory requirement.<p>The second advantage is that when there are only two values there&#x27;s no need to walk the list and test for &#x27;null (or &#x27;nil) on the <i>cdr</i>. This saves an instruction step.<p>Philosophically, dotted pairs allow for <i>car</i> and <i>cdr</i> to be used symmetrically. Calling <i>cdr</i> on a dotted pair returns the second value directly just as calling <i>car</i> on any list returns the first value directly. Lastly, one of the things that is awesome about Lisp is the way in which lists can model data structures, and in the case of a dotted pairs their efficiencies are available to all those structures which consist of or rely on paired values.<p>Of course, this may be obvious and on a machine with 10+ GB of RAM not really applicable, but I find it fun to think about anyway.
评论 #7596167 未加载
评论 #7596057 未加载
Zoxo大约 11 年前
I like the approach you took to writing this post. This wasn&#x27;t the typical attempt to summarize an entire programming language in a page (which IMO is done too often, too poorly), but rather an exploration. As you went through each section, I could see how you were approaching various problems and learned a lot about Racket in the process. I would love to see more of this style of post.
评论 #7595262 未加载
JimmyM大约 11 年前
This is how I usually implemented quicksort in Racket:<p><pre><code> (define (quicksort xs) (if (null? xs) xs (let* ([hd (car xs)] [tail (cdr xs)] [smaller (filter (lambda (x) (&lt; x hd)) tail)] [bigger (filter (lambda (x) (&gt;= x hd)) tail)]) (append (quicksort smaller) (list hd) (quicksort bigger)))) </code></pre> It&#x27;s great to see a hugely superior implementation, and I love that people are writing about and using Racket like this because the more people do that the more resources there will be for people like me to learn from.
nextos大约 11 年前
I love Scheme. And I love Clojure, which is IMHO Scheme plus some great ideas from Haskell.<p>I regret there&#x27;s no Scheme or Clojure running on LLVM, which I think is a much better platform than the JVM. Julia, that resembles Dylan (another Lisp), is the perfect example.
评论 #7598441 未加载
评论 #7598544 未加载
mahmud大约 11 年前
That was intellectually honest. Good read.
kenko大约 11 年前
It seems as if several of the author&#x27;s problems come, oddly for someone who&#x27;s used both strict (Pascal) and non-strict (Haskell) langauges, from being confused about Racket&#x27;s strictness. Why is time a special form? Because otherwise (time (expensive)) would just get the result of (expensive). Why doesn&#x27;t (list 1 (2 3) 4) work? Because list isn&#x27;t a special form, it&#x27;s a function. Why doesn&#x27;t quote turn &#x27;(list 1 2 3) into &#x27;(1 2 3)? (Well, this one isn&#x27;t about evaluation order, admittedly.) Because if it did it ... wouldn&#x27;t be quote.
评论 #7600189 未加载
derengel大约 11 年前
A friend of a friend has considerably code in Scheme, Common Lisp and Clojure, when you ask him which is the true Lisp, guess what will he answer? Haskell!<p>Haskell does really create a big impact on some developers.<p>Just an anecdote ;)
评论 #7596276 未加载
comex大约 11 年前
One note:<p>&gt; Racket&#x27;s default IDE is better than GHCi and probably on par with Emacs (you almost certainly can configure Emacs to be better than anything, but it&#x27;s not trivial and people don&#x27;t bother, while DrRacket provides autocompletion and documentation out of the box).<p>Last I used it (a few years ago), DrRacket was very laggy, so I would find it very hard to use for a serious project. YMMV, maybe it&#x27;s improved.
评论 #7601020 未加载
评论 #7596464 未加载
评论 #7595972 未加载
评论 #7595888 未加载
评论 #7595631 未加载
评论 #7596794 未加载
SmileyKeith大约 11 年前
I love the play by play of exactly what you&#x27;re thinking as you&#x27;re doing something new. I find them quite informative.
charlieflowers大约 11 年前
Web apps are a hack on a hack, yes. But it&#x27;s kind of ironic he hates Javascript so much when Javascript is a pretty cool programming language heavily influenced by Scheme, which is awfully similar to Racket.<p>But hey, I like people who call it like they see it, and there certainly are some drawbacks to Javascript too.
评论 #7596402 未加载
toolslive大约 11 年前
he will be amazed when he discovers custodians. <a href="http://docs.racket-lang.org/reference/eval-model.html#%28part._custodian-model%29" rel="nofollow">http:&#x2F;&#x2F;docs.racket-lang.org&#x2F;reference&#x2F;eval-model.html#%28par...</a>
评论 #7597053 未加载
gambogi大约 11 年前
&quot;Someone who knows Haskell learns some Racket&quot;<p>&quot;Tonight at 11: this rose gardener learns to plant tulips&quot;
评论 #7600206 未加载
wglb大约 11 年前
Nicely written, and a fun exploration.