Racket is a general-purpose, multi-paradigm programming language in the Lisp-Scheme family. It emphasizes the creation of programming languages and is known for its macro system, module system, and support for functional, imperative, and object-oriented programming.
Racket Anti-Patterns Overview
Excessive Mutation
set!
, mutable variables, etc.) and imperative loops. Racket is primarily a functional language, so prefer immutable data and functional constructs like recursion, map
, filter
, and foldl
.Not Using Contracts
Not Using Pattern Matching
match
form provides powerful pattern matching capabilities that can simplify complex conditional logic.Not Using Modules
Not Using Racket's Data Structures
Not Using Macros Effectively
Not Using Higher-Order Functions
map
, filter
, foldl
, and foldr
to abstract common patterns and reduce code duplication. Racket provides these functions in its standard library.Not Using Tail Recursion
Not Using Proper Error Handling
with-handlers
to catch and handle exceptions, and ensure resources are properly cleaned up using dynamic-wind
or higher-level abstractions like call-with-input-file
.Not Using Racket's Iteration Constructs
for/list
, for/vector
, for/sum
, for/fold
, etc., instead of writing manual recursive loops. These forms are more concise and often more readable.Not Using Typed Racket
Not Using Documentation
Not Writing Tests
Not Using Racket's Class System Properly
Not Using Contracts for Data Structures
Not Using Proper Naming Conventions
?
suffix for predicates and a !
suffix for functions that mutate state. Consistent naming makes your code more readable and idiomatic.Not Using Racket's GUI Framework Properly