Changing to Clojure mid-flight by Marcus Rydberg

September 23, 2021

In the presentation Changing to Clojure mid-flight by Marcus Rydberg, he shares his background as a programmer, including his experience of switching from Java to Clojure due to JavaScript fatigue. He discusses the challenges of applying functional programming in a team setting using JavaScript and the benefits he discovered in Clojure, such as its immutability, concurrency, and simplified syntax. Marcus also talks about the unexpected costs of managing a team and the importance of optimizing infrastructure when transitioning to a new language. He shares his experience of using the front-end library re-frame in ClojureScript and the benefits of using the same language for front and back-end development. Marcus reflects on the importance of making distinctions in programming and the influence of the Lisp language on his thinking. He also discusses the criticism he received for switching to Clojure and the benefits he encountered in terms of reduced cognitive load and improved code readability. Throughout the presentation, Marcus emphasizes the importance of finding joy in the programming process and the power of using the right tool for the job.

Changing to Clojure mid-flight: A comprehensive overview

Discovering the path to Clojure

Marcus Rydberg’s journey begins with a familiar tale: a developer frustrated with the constant churn and complexity of JavaScript. Having started programming at a young age, Marcus sold his first piece of software, a content management system in Java, when he was just 15. His early career saw him co-founding companies where he focused on process improvement and combating sepsis in hospitals. However, despite his achievements, he began to feel the weight of JavaScript fatigue — a weariness many developers can relate to.

The relentless pace of change in JavaScript, coupled with the challenges of applying functional programming principles at scale, led Marcus to explore alternatives. After researching various options, he and his team decided to take the bold step of switching to Clojure. This decision was not made lightly; it came at a time when the team was preparing for a major rewrite and the COVID-19 pandemic was disrupting their plans. Yet, despite the hurdles, the switch to Clojure proved to be a resounding success.

 

The motivation behind the Switch

The decision to switch from JavaScript to Clojure was driven by several factors. Marcus found that while functional programming was possible in JavaScript, doing it at scale required significant effort and energy. Influential articles, testimonials from other successful teams, and a desire to build a high-performing team further fueled his motivation. He was particularly inspired by stories from programmers at companies like Netflix, who had successfully made similar transitions.

Marcus also highlighted the challenges of dealing with state in JavaScript, particularly in Angular 1, and how this contributed to his growing fatigue with the language. As someone who had transitioned from a solo developer to leading a team, Marcus realized that managing a team while keeping their service alive was no longer enjoyable. This realization led him to explore Clojure, a language known for its immutability, concurrency, and overall fun factor.

 

The benefits of Clojure

From the moment Marcus and his team started working with Clojure, they noticed significant improvements. Clojure’s minimalistic syntax, particularly its use of parentheses, led to a decrease in cognitive load, making it easier for developers to distinguish between code and data. The language’s functional paradigm also played a crucial role in helping the team figure out higher abstractions and reduce unnecessary complexity, or what Marcus refers to as “craft.”

One of the standout benefits of Clojure was its ability to unify the front and back-end development processes. Marcus discussed his experience with re-frame, a front-end library in ClojureScript, which offers a simpler approach to state management compared to frameworks like Redux. He was particularly impressed with re-frame’s separation of event names from event handlers and effect names from effect handlers, which contributed to the team’s productivity and code quality.

 

Lessons learned

Throughout the transition, Marcus and his team learned valuable lessons. One key takeaway was the importance of optimizing infrastructure before making a switch. In their case, starting with the backend would have maximized team utilization and minimized disruption. Marcus also emphasized the benefits of report-driven development in Clojure, which reduces the time between idea and implementation and brings developers closer to the problem at hand.

Despite some initial challenges, such as adapting to Clojure’s raw tooling and libraries, the switch to Clojure ultimately led to a more enjoyable and efficient development process. The language’s concise nature and the thoughtful design of its data structures and syntax contributed to reduced cognitive load and improved team morale.

 

The joy of Clojure

Marcus concluded his talk by reflecting on the joy that Clojure brings to his daily work. The language’s functional aspects, such as proper state management and pure functions, not only contribute to more stable and maintainable code but also make the coding experience more enjoyable. He shared testimonials from team members and customers who praised the stability and success of their software projects since making the switch.

In a world where programming often feels like a constant battle to stay ahead of the curve, Marcus’s experience with Clojure serves as a refreshing reminder that there is value in finding the right tool for the job. It’s a story of transformation, not just in the technology stack, but in the approach to software development as a whole. For those considering a similar journey, Marcus’s advice is clear: don’t be afraid to take the leap. The rewards, as he and his team discovered, can be well worth the effort.

 

Additional resources

Check out more from the MeetUp Func Prog Sweden. Func Prog Sweden is the community for anyone interested in functional programming. At the MeetUps the community explore different functional languages like Erlang, Elixir, Haskell, Scala, Clojure, OCaml, F# and more.