TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Haskell Programmer Tries to Learn Racket

257 pointsby jackhammer2022about 11 years ago

16 comments

gaigeprabout 11 years ago
&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 未加载
nnqabout 11 years ago
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 未加载
Strilancabout 11 years ago
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 未加载
brudgersabout 11 years ago
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 未加载
Zoxoabout 11 years ago
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 未加载
JimmyMabout 11 years ago
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.
nextosabout 11 years ago
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 未加载
mahmudabout 11 years ago
That was intellectually honest. Good read.
kenkoabout 11 years ago
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 未加载
derengelabout 11 years ago
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 未加载
comexabout 11 years ago
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 未加载
SmileyKeithabout 11 years ago
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.
charlieflowersabout 11 years ago
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 未加载
toolsliveabout 11 years ago
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 未加载
gambogiabout 11 years ago
&quot;Someone who knows Haskell learns some Racket&quot;<p>&quot;Tonight at 11: this rose gardener learns to plant tulips&quot;
评论 #7600206 未加载
wglbabout 11 years ago
Nicely written, and a fun exploration.