Which of these qualities do you strive for when writing code?
- Clarity
- Readability
- Expressiveness
- Power
- Concision
Obviously, all of these are important, but they are often elusive. How can we make something complex more clear? How can we make long, intricate logic readable?
The answer is Domain Specific Languages. And Clojure excels at them. Lisps have traditionally been great at writing languages in. Why? Because it was originally defined in itself. That's right: Lisp was designed to be written in itself. That means from day one, you could use it, with no dependencies, to write languages in.
Languages have this ability to capture an idea in a really elegant way. Humans develop languages naturally. As you gain expertise in a field, you begin to pick up the jargon, the expressions, the turns of phrase. And as you learn to speak it, you learn to think it. The concepts become intuitive. Your language becomes concise, clear, efficient. So why shouldn't our languages let us do that?
Well, I think they should. And I think this feature of Lisp gives it its ultimate power. It's that Lisp knows it's not the best language possible for every use case. But it gives you the tools to build a language that does fit the use case.
How does it do that?
Well, that's what we'll explore in this course. You'll learn:
- The difference between an interpreter and a compiler
- How to write a a simple interpreter that uses Clojure's built-in data structures, like Hiccup
- How to turn any interpreter into a compiler
- How to leverage Clojure's syntax to shortcut your DSL development--and make writing an interpreter even easier
- That interpreters don't need to be complicated--in fact, they're nothing more than a conditional!
- How to write Turing-complete languages
- To write your own Lisp interpreter and compiler in Clojure
- How to add a new syntax to your language
- How to get started with Instaparse
- The basics of setting up a TDD workflow to really get into flow