[Racket](http://racket-lang.org/) is an excellent programming language. It’s actually “a programming language programming language” or, in other words, a programming language to create programming languages.

However, to anyone used to Ruby or Python, it seems rather “raw”. At first glance, you have a [collections API that’s not really ergonomic](https://www.youtube.com/watch?v=JUD_JwG0alg), no good date/time API, no [multimethods](https://en.wikipedia.org/wiki/Multiple_dispatch), no static typing (no, wait, that’s actually not a problem)…

At first glance, I said! ;)

When you learn to use the *right things*™ instead of *the first thing you learn*™, Racket is a language as pragmatic as any of those cited above.

### Few external libraries

As any other language, a few external libraries become “de facto” standard libraries, think OTP for Erlang or ActiveSupport for Ruby.

To install an external library (package) type in the command line:

\> raco pkg install ***the-package-name***

Here the list of **essential** packages for Racket:

- [***Threading Macros***](http://lexi-lambda.github.io/threading/threading.html) (package name: threading), by Alexis King. It provides [threading operators](https://clojure.org/guides/threading_macros) from Clojure, just easier and more flexible.
- [***Gregor***](https://docs.racket-lang.org/gregor/index.html) (package-name: gregor), by Jon Zeppieri. Excellent date/time library with everything you need. The “period” functions and structs worth it.

If you are feeling fancy, you can use [***Generic Collections***](https://docs.racket-lang.org/collections/index.html) (package-name: collections), by Alexis King. It’s really nice and works like a charm. Also, if you miss ordered hashes, the package [***Simple, Deterministic Dictionaries***](http://docs.racket-lang.org/ddict/index.html) (package name: ddict), by Andrew Kent, is an excellent alternative.

### Using the right functions

Most of the time, lists and hashmaps will do what you need. However, sooner or later you will need vectors or [more sofisticated data structures](http://docs.racket-lang.org/data/). Then, things become ugly.

Just avoid to use specific list and hashmap functions. Abuse [comprehensions](https://docs.racket-lang.org/guide/for.html), prefer [dictionary interface](https://docs.racket-lang.org/reference/dicts.html) and, above all, use [sequence interface](https://docs.racket-lang.org/reference/sequences.html).

Also, if you are not fond of “string=?” try “[equal?](https://docs.racket-lang.org/reference/booleans.html#%28def._%28%28quote._~23~25kernel%29._equal~3f%29%29)”. It works for strings, numbers, lists, hashes and a lot of other things.

Finally, get a good grasp of [Generic Interfaces](http://docs.racket-lang.org/reference/struct-generics.html) and [Pattern Matching](https://docs.racket-lang.org/reference/match.html). They are very powerful and you are not going to miss multimethods if you understand them.

### A helper function or two

Often you have a function that’s pretty much what you need, but you don’t like its name or arguments.

For example: [sequence-ref](https://docs.racket-lang.org/reference/sequences.html#%28def._%28%28lib._racket%2Fsequence..rkt%29._sequence-ref%29%29) and [sequence-tail](https://docs.racket-lang.org/reference/sequences.html#%28def._%28%28lib._racket%2Fsequence..rkt%29._sequence-tail%29%29) are useful, but I’d rather have “sequence-first” and “sequence-rest”, so I can skip the extra “position” argument.

No problem, just define them:

```
(define (sequence-first seq) (sequence-ref seq 0))
(define (sequence-rest seq) (sequence-tail seq 0))
```

Or, if you are using threading macros:

```
(define sequence-first (λ~> (sequence-ref 0)))
```

Actually, I redefine “first” and “rest” in terms of sequence. It’s far more ergonomic than the original “first” and “rest” (which work only for lists).

```
(define first (λ~> (sequence-ref 0)))
(define rest (λ~> (sequence-tail 0)))
```

Also, it’s possible to rename functions as you require them. That means it’s possible to forget the standard “map” function (that also works only for lists), and replace it by “sequence-map”.

```
(require (rename-in racket/sequence [sequence-map map]))
```

Yes, I rename a lot of functions in favor of the ones that use generic interfaces. Just be aware it can be a little confusing to anyone not used to your code.

### Final notes

Racket is awesome in day-by-day programming and it’s getting better as time passes. Plus, it has A LOT of really useful things you can’t easily find in other languages, start with [macros](http://www.greghendershott.com/fear-of-macros/index.html) and [plots](https://docs.racket-lang.org/plot/intro.html) (far better than “matplotlib”, IMHO), if you want a glimpse of them.
