Clojure for Domain-specific Languages


Clojure for Domain-specific Languages
eBook: $32.99
Formats: PDF, PacktLib, ePub and Mobi formats
$28.04
save 15%!
Print + free eBook + free PacktLib access to the book: $87.98    Print cover: $54.99
$54.99
save 37%!
Free Shipping!
UK, US, Europe and selected countries in Asia.
Also available on:
Overview
Table of Contents
Author
Support
Sample Chapters
  • Explore DSL concepts from existing Clojure DSLs and libraries
  • Bring Clojure into your Java applications as Clojure can be hosted on a Java platform
  • A tutorial-based guide to develop custom domain-specific languages

Book Details

Language : English
Paperback : 268 pages [ 235mm x 191mm ]
Release Date : December 2013
ISBN : 1782166505
ISBN 13 : 9781782166504
Author(s) : Ryan D. Kelker
Topics and Technologies : All Books, Application Development, Open Source


Table of Contents

Preface
Chapter 1: An Overview of Domain-specific Languages with Clojure
Chapter 2: Design Concepts with Clojure
Chapter 3: Clojure Editing and Project Creation
Chapter 4: Features, Functions, and Macros
Chapter 5: Collections and Sequencing
Chapter 6: Assignment and Concurrency
Chapter 7: Flow Control, Error Handling, and Math
Chapter 8: Methods for Abstraction
Chapter 9: An Example Twitter DSL
Chapter 10: Unit Testing
Chapter 11: Clojure DSLs inside Java
Appendix
Index
  • Chapter 1: An Overview of Domain-specific Languages with Clojure
    • Domain-specific languages (DSL)
      • Limited scope
      • Syntax
      • Using a DSL
      • Popular DSLs
      • A contract between language and domain
      • The language of trust
    • Internal versus External DSLs
      • External DSLs
      • Internal DSLs
      • Clojure libraries
      • The characteristics of a Clojure library
      • The current state of Clojure libraries
    • Database domains
    • The HTML domain
      • Formative
      • Hiccup
      • Mustache
      • Clostache
    • The ECMA/JavaScript domain
      • ClojureScript
      • Comparing ClojureScript and JavaScript
    • The Audio domain
      • Music-as-data
      • Overtone
    • Image domains
    • Summary
  • Chapter 2: Design Concepts with Clojure
    • Every function is a little program
      • A pure function
      • Floor-to-roof development
    • Each function only does one thing
    • Patterns for success
      • DRY
      • KISS
      • YAGNI
      • Writing Clojure
      • Spacing and alignment
      • Syntax
      • Name conventions
      • Collection types
    • Summary
  • Chapter 3: Clojure Editing and Project Creation
    • The origin of Emacs and its usage
    • Installing and setting up Emacs24
    • Setting up Emacs
    • Creating and editing CLJ files in Emacs
    • Running a Clojure REPL inside Emacs
      • The nrepl.el Emacs extension
    • Leiningen and project management
    • Installing Leiningen and starting a project
    • Including Clojure or Java libraries in your project
      • Compiling your project to a Java JAR
    • Leiningen
    • Summary
  • Chapter 5: Collections and Sequencing
    • Collections
      • Collections by example
    • Vectors
      • Vectors by example
    • Lists
      • Lists by example
    • Maps
      • Maps by example
    • Sets
      • Sets by example
    • Sequences
      • Sequences by example
    • :let, :while, and :when
    • Summary
  • Chapter 7: Flow Control, Error Handling, and Math
    • Flow control
    • Object comparison
    • Casting
    • Error handling
    • Arithmetic
      • Addition and subtraction
      • Multiplication
      • Division
      • Remainder and modulus
      • Increment and decrement
      • Greatest and least values
      • Equality
    • Summary
  • Chapter 8: Methods for Abstraction
    • Creating and constructing classes
      • Creating interfaces and implementing them with deftype
      • Using records, protocols, and type extensions
    • Overriding methods with reify and proxy
      • Working with reify
      • Implementing interface methods with proxy
    • Custom symbol definitions with macros
      • Definitions using records
      • Making definitions using proxy
      • Making definitions using deftype
    • Multimethod polymorphism
      • Creating the Bottle and Customer classes
      • Testing the customer-drink methods
    • Relationships with hierarchies
      • Resolving parent relationship conflicts
    • Assertion testing with metadata
    • Input constraints with :pre
    • Output constraints with :post
    • Summary
  • Chapter 9: An Example Twitter DSL
    • Creating Java-based abstractions
      • Making Java objects easier to manipulate
      • Retrieving values in a better way
    • Examples of our Twitter DSL
      • The Retweet bot
      • Creating an event notifier
    • Reading the OAuth configuration
      • Twitter account registration and application keys
      • Adding required dependencies
      • Creating the project and API configuration
      • Reading the Twitter configuration
    • Making our most important macro
      • Building the deftwitter macro
      • Building the twitter-> macro
    • Handling search queries
      • Adding the tdsl.search namespace
      • Search macros and functions
    • Handling tweets
      • Adding the tdsl.tweet namespace
      • Tweet macros and functions
    • Adding user-related features
      • Adding the tdsl.user namespace
      • User macros and functions
      • User details and multimethods
      • Adding logging features
    • Summary
  • Chapter 10: Unit Testing
    • Exploring the clojure.test framework
      • Testing tdsl.core
      • Using the is macro
      • Using the are macro
      • Developing the final test
    • The expectations framework
      • Using the expect macro
      • Search testing
    • The midje framework
      • Using the fact macro
    • The speclj framework
      • Using the describe, it, should, and should= macros
      • Using the should-contain macro
    • Summary
  • Appendix
    • Chapter 1: An Overview of Domain-specific Languages with Clojure
    • Chapter 2: Design Concepts with Clojure
    • Chapter 3: Clojure Editing and Project Creation
    • Chapter 4: Features, Functions, and Macros
    • Chapter 5: Collections and Sequencing
    • Chapter 6: Assignment and Concurrency
    • Chapter 7: Flow Control, Error Handling, and Math
    • Chapter 8: Methods for Abstraction
    • Chapter 9: An Example Twitter DSL
    • Chapter 10: Unit Testing
    • Chapter 11: Clojure DSLs inside Java

Ryan D. Kelker

Ryan D. Kelker is a Clojure enthusiast and works as a freelance—he is willing to take on any project that sounds interesting. He started exploring computers and the Internet at a very early age and he eventually ended up building both machines and software. Starting with MS DOS, batch files, and QBasic, he eventually floated towards Arch Linux and the Clojure language. He has four certifications from both CompTIA and Cisco, and has decided not to pursue any additional certifications. These days, he spend most of his time reading about software development, cyber security, and news surrounding up-and-coming computer languages. While away from the computer, he is usually reading a book or going out to eat with the people he loves the most.
Sorry, we don't have any reviews for this title yet.

Code Downloads

Download the code and support files for this book.


Submit Errata

Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.

Sample chapters

You can view our sample chapters and prefaces of this title on PacktLib or download sample chapters in PDF format.

Frequently bought together

Clojure for Domain-specific Languages +    Getting Started with Oracle BPM Suite 11gR1 – A Hands-On Tutorial =
50% Off
the second eBook
Price for both: €37.65

Buy both these recommended eBooks together and get 50% off the cheapest eBook.

What you will learn from this book

  • Understand the pros and cons of a domain-specific language
  • Learn general programming design concepts
  • Know the benefits of a Lisp-based syntax
  • Edit Clojure files in Emacs
  • Learn to operate a Read-Evaluate-Loop session from within Emacs
  • Build Clojure projects with Leiningen
  • Manipulate and make polymorphic objects in a non-object-oriented language
  • Create a Twitter domain-specific language to understand Clojure, its Java, and Lisp foundation closely.
  • Use your Clojure applications inside of a Java project

In Detail

Clojure is a very new and rapidly growing language that runs on top of the JVM. The language being hosted on the Java platform allows for Clojure applications to use existing Java components. Although there are objects in Clojure, the language is not object oriented.

"Clojure for Domain-specific Languages" is an example-oriented guide to building custom languages. Many of the core components of Clojure are covered to help you understand your options when making a domain-specific language. By the end of this book, you should be able to make an internal DSL. Starting with a comparison of existing DSLs, this book will move on to guide you through general programming, Clojure editing, and project management. The chapters after that are code oriented.

"Clojure for Domain-specific Languages" tries to expose you to as much Clojure code as possible. Many of the examples are executed in a Read-Evaluate-Print-Loop environment, so the reader can also follow along on their own machine. This book uses Leiningen, but no prior knowledge of it is required.

"Clojure for Domain-Specific Languages" aims to make you familiar with the Clojure language and help you learn the tools to make your own language.

Approach

An example-oriented approach to develop custom domain-specific languages.

Who this book is for

If you've already developed a few Clojure applications and wish to expand your knowledge on Clojure or domain-specific languages in general, then this book is for you. If you're an absolute Clojure beginner, then you may only find the detailed examples of the core Clojure components of value. If you've developed DSLs in other languages, this Lisp and Java-based book might surprise you with the power of Clojure.

Code Download and Errata
Packt Anytime, Anywhere
Register Books
Print Upgrades
eBook Downloads
Video Support
Contact Us
Awards Voting Nominations Previous Winners
Judges Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software
Resources
Open Source CMS Hall Of Fame CMS Most Promising Open Source Project Open Source E-Commerce Applications Open Source JavaScript Library Open Source Graphics Software