I had passed the phone screen for a chance to work as a ClojureScript developer for a startup in manhattan, and they emailed me a coding challenge. Basically, they wanted me to make a glorified do-to list using reagent and re-frame. This post is to document the feedback from the reviewer of my code and think out loud about what he / she meant by it and what I can do to avoid the same issues the future.
0 Comments
Kind of embarrassing, but I just discovered these things today! I'm a long time javascript developer whose just trying to get into ClojureScript by create a template built on Reagent and Re-Frame. I am very much used to HTML (or JSX, but still- very similar to HTML). Sometimes I have an idea in my head that I'm thinking about in terms of HTML. Other times I find a cool snippet of code (such as this codepen) that you want to copy into your project. Here's an easy way to do it!
Giving someone a snippet of code for them to copy into their editor and run is cool, but giving them live code that they can run right there in their browser is like wow. These days I'm all about JavaScript and ClojureScript, and in this post I'll show you how to embed them. Let's go!
I grew up on "Algol" style languages like Java, C++, and ActionScript 3 where one of the first things you learn about is the concept of a class, a blueprint for an object. I guess I'm too young to remember a lisp world without Clojure so at first I was amazed that you could even have a programming language that didn't based its foundational architectural patterns around classes or object use classes! I just today was working on a project and found it refreshingly simple to just write some functions in a namespace so I could require and call them from another file. In this post we'll take a look at how to we import functions in a ClojureScript project using the build tool leiningen without classes or objects.
The beauty of Clojure's non-OOP style is that the functions are not tied to some blueprint that needs to be instantiated. Instead, once they are included, required, or loaded, etc. the functions are just there, able to be called at some later point in the code. Because of this, Idiomatic Clojure lends itself well to functions that are pure and can be called in complete isolation. It should be noted that load-file works for both Clojure and ClojureScript!
|
AuthorThe posts on this site are written and maintained by Jim Lynch. About Jim...
Categories
All
Archives
March 2023
|