Skip to content

Instantly share code, notes, and snippets.

@randylien
Forked from KevinGreene/clojure_thoughts.md
Created January 19, 2016 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save randylien/48068b1666bfe8a75402 to your computer and use it in GitHub Desktop.
Save randylien/48068b1666bfe8a75402 to your computer and use it in GitHub Desktop.
Thoughts on Clojure after introductory talk

Hey all,

Thanks for coming out and talking about Clojure and ClojureScript! I'm not going to be posting the source code for the project, as I'm still not 100% if it will end up monetized at all, but it will probably make it's way to GitHub eventually.

If you want to learn more about Clojure, ClojureScript, and how they can help you, you have a ton of options:

Intro:

Living Clojure by Carin Meier - http://www.amazon.com/Living-Clojure-Carin-Meier/dp/1491909048 - Also available at GRPL

Clojure from the Ground Up - https://aphyr.com/posts/301-clojure-from-the-ground-up-welcome

Clojure for the Brave and True - http://www.braveclojure.com/

Programming Clojure - http://www.amazon.com/Programming-Clojure-Stuart-Halloway/dp/1934356867 - This is what I actually used to start my experience

Bug me on the Grand Rapids Slack or Meetup, at really anytime. I'm always happy to teach / share / learn. Sign up here slackin-grandrapids.herokuapp.com

If you're like me and prefer working on a specific project or library of a language, then you are in luck! Clojure has a ton of options to get started with right away. But before that can happen you need a build tool.

First, I would 100% suggest installing leiningen - http://leiningen.org/. This is the primary build tool people use to develop Clojure and ClojureScript applications. While others exist,

If you want to play around with it as a scripting language and have a Mac, I'd check out Planck - https://github.com/mfikes/planck. In addition to launching a REPL to play around with, it's great for scripting things. For example, I use it to generate CSVs here - https://github.com/KevinGreene/utopia/blob/master/generators/powers.cljs.

Sadly, it is only available for OS X right now.

Lastly, there is Boot. Honestly if you are new I wouldn't suggest it, unless you really, really want to use it as a scripting language but don't have a Mac. Boot can be found here - http://boot-clj.com/.

A quick note on editors - There are a ton of options, but the three clear choices to me are Emacs, Cursive (an IntelliJ plugin) and LightTable.

If you want an editor that will just get out of the way but work great with Clojure, LightTable is the right choice - http://lighttable.com/. It really helped me play around with Clojure when many other places were suggesting Emacs as the only way.

Cursive is excellent if you are already familiar with IntelliJ - https://cursive-ide.com/. You can use a non-commercial license, no purchase necessary.

Finally, Emacs is definitely, 100% my preferred editor, but can take a bit of getting used to. I'd recommend Spacemacs - https://github.com/syl20bnr/spacemacs - if you're a vim user, Prelude (My choice) - https://github.com/bbatsov/prelude - if you're looking to dive into the full experience, and emacs-live - https://github.com/overtone/emacs-live - if you're looking to try out Emacs, but want a sensible but minimal setup.

You certainly can use Vim, Atom, Sublime, or whatever else, but the three above tend to be the most popular choices. Whatever editor you choose, consider looking into REPL support (where you evaluate code inline) and Paredit (sometimes known as structural editing). Both make Clojure development significantly more enjoyable.

The fun stuff! Either because you're diving head in, or you are ready after reading some things in the first post, you want to start actually working on a project. A web app is often what people want to tackle first, but I'd encourage you to consider something else. While web applications are fun and applicable, in general they are relatively complex compared to other Clojure applications. So first, some other suggestions:

Quil - quil.info - A very fun and intuitive drawing library based on processing. Works in both Clojure and ClojureScript environments! I'd highly suggest checking out the winners of Clojure Cup 2016, http://landofquil.we-do-fp.berlin/. Fun and interactive walkthrough, no installation required.

Overtone - https://github.com/overtone/overtone - A popular music library for Clojure, and the motivation behind emacs-live. I found it a bit hard to get started, mainly because I wasn't interested in dub-steppy music, and don't know much about midi. If you want to check out a small understandable project, I wrote an arpegiator with a few people from my company, located here - https://github.com/Spantree/arpejiator

Incanter - http://incanter.org/ - A great statistical and graphing library. To be honest, this one is a little more nebulous to get started with. I've done workshops on it in the past, and you can check them out here - https://github.com/KevinGreene/exploring-data. Right now it's in a transition phase. If anyone is interested in this, let me know and I can talk more about it / give suggestions, as much of the documentation is woefully out of date.

tools.cli - https://github.com/clojure/tools.cli - Build CLI tools with Clojure!

Perhaps you're a web developer through and through, or you just appreciated my demos that much. In that case, I'd say what you should do depends on what part of the dev process appeals to you most - the entire system, or just the event driven nature of the front end?

If it's the entire system (or if you're on the fence), I'd strongly suggest checking out Luminus - http://www.luminusweb.net/. I cannot recommend the tutorial enough, located here - http://www.luminusweb.net/docs/guestbook.md. Even though it doesn't look like it, the parts on the right are entirely sequential, and if you follow them one by one you will have a surprisingly excellent understanding of a standard Clojure web application. In particular, the ClojureScript section will cover Reagent, the library that re-frame is based on.

If you really like the elm architecture, I'd suggest using re-frame, which is the library that provides the dispatch and subscribe methods I talked about. Before you go deep with that, though, I'd recommend trying out the library it's based on, Reagent - http://reagent-project.github.io/. The GitHub page is a nice concise walkthrough, complete with a ToDo app. After you've built a simple thing with Reagent, I'd suggest moving to re-frame - https://github.com/Day8/re-frame. Even if you don't like that style, I'd highly recommend reading the entire README and reading https://github.com/Day8/re-frame/wiki/Creating%20Reagent%20Components, which give great justification and explanation for what Reagent is, what re-frame is, and why they are both great. Really great documentation, and I'd encourage you to check out other things on the wiki as well.

"No!", you say. You'd rather do the more cutting edge stuff. Native Clojure applications on your laptops and phones. Well, if you're really new to Clojure, I'd say that's a bit overly ambitious, and you're likely to struggle more than you'd like. But, if you really want to give it a shot, have at it.

I'm much less confident suggesting something that worked for me here, as I honestly haven't done much. If you want to check out React Native, http://cljsrn.org/ appears to have a ton of documentation. Re-natal would be my first choice, based solely on the support and documentation for re-frame.

On Electron, https://github.com/ducky427/electron-template worked for me right out of the box, but I just printed "Hello World", nothing more.

Good luck, and let me know if you ever have any questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment