My experience with Clojurescript and React Native

Tienson Qin
4 min readAug 6, 2016

--

Edit:

I’ve released Lymchat as open source, https://github.com/tiensonqin/lymchat

IOS app link:

https://itunes.apple.com/us/app/lym/id1134985541?ls=1&mt=8

When I started learning Clojure two years ago, never thought I could write an ios app by it.

If you are curious, it’s called Lymchat, you can learn languages, find local people, talk to people with same interests.

Lymchat, learn different cultures.

I’m not familiar with javascript, so when I need to write some web apps,
I went to look at Clojurescript, It works like this:

I thought ok, looks good.

Several months ago I quit my job to travel, you know, I call it “immutable gap year”. When i came back, I thought why not write an app to find local people, explore different cultures?

When I decided to do it, I actually thought about swift/obj-c for one second, I went away just because drag ‘n drop is too magical for me.

After browsing the react native documentation and the versatile UIExplorer, I decide to go with it.

Then it’s the language battle, Clojurescript vs Purescript vs Elm vs Javascript, I choose clojurescript for now because the tooling:

David Nolen: A Tool For Thought

For me debugging and profiling, advanced optimization, IDE support, rich tooling across all desirable JavaScript targets are equally important considerations to weigh against static guarantees when choosing the programming language for clients.

So, awesome choice! Actually even now, I’m still trembling with fright when I have bad dreams about this:

Maybe i’m digging too deep a hole in the beach, but if you ask me what’s my experience about React Native with Clojurescript, it looks like this:

It’s riding in the mud, a little tough, but enjoyable!

The enjoyable part

Learn once, write everywhere.

All the api service, ios app, web page and admin panel are written by Clojure[script]. So I can save huge time by sharing most of the logic and components.

Figwheel.

I won’t do any clojurescript web or mobile development without it. Hot reloading, much better error report. Thank you, Bruce Hauman!

Re-natal.

Re-Natal is a simple command-line utility that automates most of the process of setting up a React Native app running on ClojureScript with Reagent an re-frame.

Thanks for mfikes, decker405, drapanjanas, mjmeintjes and pesterhazy now we can use figwheel with react native in clojurescript.

Fast development.

Flexbox, interactive repl, source maps…

Rich libraries, diligent community.

Realm, webrtc, gifted-chat, vector icons, fs, linear gradient …, thank you, RN community!

Performance is actually good.

I’ve worried about the Listview performance issue, turns out not a big problem for me now.

Seamless bridging with native.

Bad news is you still need to write a little native code. You don’t want put your access token in the bundle. Good news is it’s really easy.

The tough part

React Native: Unable to resolve module ‘some-module’ #4968

“Solution”:

npm cache clean && watchman watch-del-all && rm -rf node_modules && npm install && npm start -- --reset-cache

Clojurescript re-natal: You have to restart repl when importing new react native modules or pictures.

This is really a big distraction.

Finally, thank you for reading this post. If you are interested in Lymchat or clojurescript with react native, you can find me in twitter: tiensonqin or email: tiensonqin@gmail.com.

Reviewed by Paulus Esterhazy.

--

--

Tienson Qin
Tienson Qin

Written by Tienson Qin

Spurs fan, Father, Clojure, Clojurescript

Responses (3)