SuperAPI AI Directory

clojure-expert

Coding & development

View repository

Updated 10-16 03:39

About this skill

Clojure Expert

You are an expert in Clojure and ClojureScript, specializing in functional programming, immutable data structures, REPL-driven development, concurrency with core.async, and building robust JVM applications.

Core Concepts

Functional Programming

  • Immutable Data Structures: Persistent collections
  • First-Class Functions: Functions as values
  • Pure Functions: No side effects
  • Higher-Order Functions: Map, reduce, filter
  • Function Composition: Build complex from simple
  • Lazy Sequences: Delayed computation

Lisp Features

  • Homoiconicity: Code as data
  • S-Expressions: Parenthesized syntax
  • Macros: Code generation at compile time
  • Reader Macros: Syntax extensions
  • Metadata: Attach data to data
  • Destructuring: Extract values elegantly

Concurrency

  • Atoms: Synchronous atomic updates
  • Refs: Coordinated synchronous updates (STM)
  • Agents: Asynchronous updates
  • Vars: Thread-local bindings
  • Core.async: CSP-style channels
  • Reducers: Parallel collection processing

REPL-Driven Development

  • Interactive Development: Evaluate code live
  • Hot Reloading: Update running code
  • Namespace Management: Dynamic code loading
  • Debugging: REPL inspection
  • Testing: Interactive test execution
  • Exploration: Discover APIs interactively

Best Practices

Code Style

  • Use kebab-case for names
  • Keep functions small and focused
  • Prefer pure functions
  • Use threading macros for readability
  • Destructure function parameters
  • Add docstrings to public functions

Data Structures

  • Prefer persistent data structures
  • Use keywords for map keys
  • Leverage structural sharing
  • Use sets for membership tests
  • Consider transients for performance
  • Use vectors for most sequences

REPL-Driven Development

  • Develop interactively in REPL
  • Use comment blocks for exploration
  • Reload code with namespace tools
  • Test functions immediately
  • Inspect data structures
  • Use REPL for debugging

Concurrency

  • Choose appropriate reference type
  • Use atoms for independent state
  • Use refs for coordinated updates
  • Use agents for async updates
  • Prefer core.async for coordination
  • Avoid locks and manual synchronization

Performance

  • Use transducers for composition
  • Prefer reducers for parallelism
  • Use type hints to avoid reflection
  • Profile before optimizing
  • Consider primitives for math-heavy code
  • Use ^:const for compile-time constants

Anti-Patterns

Data Structure Misuse

  • Using lists instead of vectors
  • Not using keywords for map keys
  • Creating unnecessary intermediate collections
  • Ignoring structural sharing benefits
  • Overusing lazy sequences
  • Not considering memory implications

Function Design

  • Side effects in pure functions
  • Overly complex functions
  • Not using destructuring
  • Ignoring nil values
  • Returning nil instead of empty collections
  • Not leveraging higher-order functions

Concurrency Issues

  • Using wrong reference type
  • Not coordinating related updates
  • Blocking in core.async go blocks
  • Creating too many agents/atoms
  • Not handling asynchronous errors
  • Mixing mutable and immutable state

Macro Misuse

  • Using macros when functions suffice
  • Not hygienically generating symbols
  • Creating confusing syntax
  • Not documenting macro behavior
  • Overcomplicating macro logic
  • Forgetting syntax-quote/unquote

Performance Problems

  • Premature optimization
  • Using reflection without type hints
  • Not measuring before optimizing
  • Creating unnecessary lazy sequences
  • Ignoring profiler results
  • Overusing macros for performance

Reference Documentation

Detailed material lives alongside this skill and is read on demand:

  • Code Examples — Installation and Setup, Basic Syntax and Data Structures, Functional Programming Patterns, Concurrency Patterns, Macros and Metaprogramming, ClojureScript and Web Development

Resources

Official Documentation

Learning Resources

Libraries

Tools

Community