[racket] Beginners request for code review.

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Thu Jan 31 00:28:22 EST 2013

Piotr,

This isn't good Racket code, it's *gorgeous*.  That was my impression at
first glance, and the more I look, the more I like it.  Your Bezier library
absolutely does not read like the code of a novice Racketeer.  Few enough
people regularly use a combination of objects, pattern matching, map, cut,
macros, contracts, named let, multiple values, submodules... let alone
using them all in readable and idiomatic fashion.

There are some minor improvements to be made, certainly -- for instance,
you could use define/private instead of define for private methods, it
avoids allocating a closure for each object -- but only at the nitpick
level, that I can see.  The important thing is that you've found a lot of
the useful Racket tools, certainly more than are even strictly necessary
for good code, and you've put them to good use.

I do hope you get some more in-depth feedback.  I'll try to find time to
give your code a closer read myself.  But as for "beginner" or "passable",
I can say with confidence that you've vaulted past those on your first
attempt.  I've submitted code to the Racket sources myself that I'm less
proud of than you should be of your library.  (Should I have admitted
that?  Oh, well.  You've all been running it anyway.)  Seriously, you can
consider yourself a bona fide Racketeer, no disclaimers or qualifications
needed.

Welcome to the club.

Carl Eastlund

On Wed, Jan 30, 2013 at 8:20 PM, Piotr Klibert
<piotr.klibert at 10clouds.com>wrote:

> Hello all.
>
> TL;DR: I "want" a code review. Link to the repository at the end.
>
> This is my first post here so I think it's appropriate to introduce
> myself. I'm a professional programmer and I have been programming for
> nearly twenty years now. At work I use Python and CoffeeScript; before that
> I used PHP, C++ and C, but I have no formal education in the field, which
> means that I missed an opportunity to learn about many interesting, but not
> immediately usable things.
>
> For the last few years I have been trying to compensate for this in my
> spare time. I have learnt, to various degrees, languages such as OCaml, F#,
> Smalltalk, Erlang, J and Prolog among other more or less interesting
> languages, dialects and environments.
>
> Still, until about a year ago I knew nothing about Lisps. I decided to
> take a look at one of them and by pure chance I chose Racket. I am in love
> with it ever since.
>
> For the last year I was scribbling Racket code from time to time and
> reading a lot about it: from docs to blog posts to source code. Everything
> I wrote was short and incomplete, I was essentially playing with newly
> discovered features without trying to build anything in particular.
>
> It took me so long, because Racket is vast and because I was concurrently
> playing with Erlang and Smalltalk. I still don't know much about Racket and
> I consider myself a beginner, but I decided that it's time to actually do
> something instead of just playing.
>
> Two weeks ago at work I was asked to prototype a JS app that would display
> on <canvas> and would allow a user to type some text and then bend it
> freely along the curve.
>
> I needed to figure a bit of math for this. HTML canvas API is rather low
> level one and essentially everything in the app would have to be computed
> by hand. I chose to play with math in Racket, using its GUI capabilities
> and I planned to switch to JS once the equations and basic algorithms were
> established. Which I did, the project started and the app is being
> developed right now (I'm not involved anymore).
>
> All this left me with about 200 lines of Racket code - the greatest amount
> I've written to date. I thought that this is the chance I was waiting for -
> all I had to do was to refactor the spaghetti into modules, add some event
> handlers and I would end up with a working Racket app.
>
> For a few days more I was cleaning up the code and optimizing it, trying
> to transform it into something I wouldn't be embarrassed of. I still didn't
> write a proper contracts nor docs, but I somehow succeeded - I have a
> little app that works and looks ok to my eyes.
>
> And that's the problem.
>
> I know very well that I'm a beginner and I know that there are vast parts
> of Racket that I don't know of. I would like to ask anyone who has a few
>  moments of free time to review what I wrote and tell me if it is a "good"
> - ok, passable - Racket code; what should I do to make it better, what
> mistakes I made and - maybe - what I managed to get right. I'm especially
> concerned with the style of the code and it's structure, but any comment is
> fine.
>
> The code lives here:
> http://bazaar.launchpad.net/~klibertp/+junk/bezier/files
>
> I will really appreciate any feedback from anyone. Thanks in advance!
>
> Best regards,
> Piotr Klibert
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130131/fdc4d385/attachment.html>

Posted on the users mailing list.