Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
How to Program Racket (racket-lang.org)
71 points by shawndumas on Feb 15, 2015 | hide | past | favorite | 18 comments


This is the kind of thing sorely missing from other language teaching - once you learn the basics, how to write good, idiomatic code? Btw, I can also recommend Kent Beck's Smalltalk Best Practice Patterns is you are learning Pharo Smalltalk.


Thanks for the reference, I just ordered a copy. I have been using Pharo lately and I need a brush up on good coding practices.

The linked article is good and surprised me, especially using 'define' inside functions instead of 'let'.


A pre-publication version http://stephane.ducasse.free.fr/FreeBooks/BestSmalltalkPract... is in Stéphane Ducasse's free collection of old Smalltak books http://stephane.ducasse.free.fr/FreeBooks/ , though not linked from that page for some reason.


This has also surprised me. And it seems the main reason is that of indentation. I do not feel this is enough reason to use 'define' instead of 'let'.


> once you learn the basics, how to write good, idiomatic code?

... apart from reading good source written by others, which you can't really find by yourself since you lack the "good taste" needed to judge the quality of a piece of code. I'd be interested in a compilation of good snippets of source code for several languages. For example (I may be wrong) like PAIP for Common Lisp.


How to Design Programs[1], while not an introduction to Racket per se, is a wonderful way to get started with the Lisp-family of languages and with computer programming in general.

Once you work all the way through Part 1 of the book, you really do get a sense that Felleisen, et al. are trying to teach you the why and how of good program design, not simply introduce you to a particular syntax.

A small study group has been meeting in St. Louis since mid October 2014[2]. Slowly but surely, we're working our way through HtDP2e and learning a lot from the book and each during as we go along.

[1] http://www.ccs.neu.edu/home/matthias/HtDP2e/

[2] http://www.meetup.com/STL-Racket/


"not simply introduce you to a particular syntax"

I don't think Felleisen, et al. get that much credit for this, except of course in having the uncommon wisdom in choosing The One True Way ^_^, which for instruction is the simple Lisp dialect of Scheme. There's almost no syntax to teach, e.g. literals (e.g. numbers and strings), atoms, lists, and special forms like define/lambda and if. Which of course is a major reason to use a Lisp for introductory programming, you spend seconds to minutes instead of weeks teaching syntax (of course the students spend a bit more time in the lab learning how to use the editor to properly indent the code so it can be comprehended, but isn't that pretty much what you must do with Python??).

BTW, a counterargument I recently came across in the great SICP vs. HoDP conflict is that the latter has no "magic". Does that resonate with you? (I can't comment having started reading SICP back when it was a lively Technical Report.)


Re: syntax, what you say is true. There was a period late last night when HN comments could not be updated by their authors. Almost right away, I realized I could have expressed my point better: "...not simply introduce you to the authors' preferred language."

I have not spent much time with SICP, so I can't really make a comparison. But I can speculate a little: the point of HtDP is to lay the foundation for and then form the reader-student according to a systematic "design recipe" that is expanded and refined as one works through the book. Many of the deeper ideas and surprises of computer programming are not explored, as they are in SICP, so fans of the latter would probably find HtDP to be a "flatter" learning experience.


"...not simply introduce you to the authors' preferred language"

Heh, but that doesn't work either ^_^. Sussman was the co-inventor of Scheme and still loves it, Ableson I don't know, and don't Felleisen et. al. love the syntax and Scheme at least to a substantial degree?

(I don't know anything about Racket, Felleisen and company essentially ended up doing a drive-by shooting of Scheme with R6RS, leaving a very bad taste in my mouth about them, their technical judgement and skill, language aesthetics, etc. ... but I gather I should look at what they've done.)


"Heh, but that doesn't work either..."

Well, the point of my original comment may have become obscured, I'm not sure.

It was that HtDP is not so much a book about Racket/Lisp/Scheme, as it is a book that aims primarily to impart sound fundamentals for the design of computer programs, regardless of the language used. And as I wrote previously, that becomes quite apparent by the end of Part 1, when the "design recipe" has seen its second major restatement.

By the way, I am only familiar with the 2nd edition of HtDP. I can't really comment on the 1st edition, and it's possible that it gives a different impression.


Ah, I get you.

Yeah, SICP, going from the 2nd Edition because my previous edition copies were tossed or whatever, is that too, but aimed at teaching different things. Except for the 4th Chapter, Metalinguistic Abstractions, which of course introduces the metacircular interpreter ... but if that's "The Maxwell Equations of CS".... That chapter has other treats, and ends with logic programming.

And per Wikipedia and my general knowledge: "Before SICP, the introductory courses were almost always filled with learning the details of some programming language, while SICP focuses on finding general patterns from specific problems and building software tools that embody each pattern."

But of course, even if we agree this is the way to teach introductory courses, there is much debate on what to teach, with MIT abandoning SICP in the post-doc.com crash panic including a crash in enrollment.

(More than halved after being a steady 2/5th of the undergraduate body for decades. It's gone back up, BTW, along with Stanford's. CMU only accepts 135 students into its program, and UCB, being a state school, probably also has limits, explicit or implicit.)


For me this highlights one of the uniquie features of the Racket community. It tends to row in the same direction based on a shared core value: education. Coding style is not the primary way people express their inner snowflake. Partly because extending the Lisp is more satisfying and accessible even to relatively new community members and partly because there are more than 50 years of Lisp coding conventions to draw on and mostly because the PLI group has been standardizing coding conventions roughly by consensus in the form of HTDP for nearly fifteen years.


It's nice to see these written down and published. I think most large public projects should consider writing something similar, rather than leave it up to the reader to guess - and that includes the dreaded tabs/spaces, line length and naming decisions.


Curious the use of this language in industry. Appreciate if someone can share the use of Racket in production.


My craft + tech startup www.youpatch.com uses Racket for the clever bits: image-processing, pdf generation, and I find it's great for prototyping and R&D. Here's my talk wide-ranging talk about it (video and slides) http://agile-jitsu.blogspot.com.au/2015/01/my-talk-at-racket...

Also at RacketCon 2014 Brian Masterbrook talked about using Racket at www.airstash.com for testing hardware: links at con.racket-lang.org


Dan Liebgold (Naughty Dog) at RacketCon 2013.

"Racket on the Playstation 3? It's Not What you Think!"

https://www.youtube.com/watch?v=oSmqbnhHp1c


Racket is the runtime powering HN. Arc targets it.


I use Racket to run an internal website for few hundreds of T.A. in my department in the university. I like that everything is escaped automatically, so you don't have to worry that someone try to use "<script>alert('test');</script>" as name.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: