anchor
Blog /  
Clojure vs. Python from a Developer's Side

Clojure vs Python: Differences and Perspectives

February 3, 2022
->
4 min read

Python became the third most popular technology by Stack Overflow Global Developers Survey 2021. Clojure was honored as the highest-paid and the most "joyful" programming language some years earlier.

Both languages enable programmers to build increasingly sophisticated systems. Both facilitate the creation of flexible software that's required for rapidly evolving domains. Finally, both Python and Clojure are blessed with a:

- powerful toolbox
- simplicity
- development speed
- concise and clear code
- a strong culture of sharing best practices
- ever-evolving community

What is common between Clojure and Python? What Lisp features did Python acquire in the context of Data Science? If Lisp is so great, why do we keep needing new approaches? Today I want to share some thoughts regarding the topic.

Clojure phenomenon:"is Clojure an acceptable Lisp"?

Development speed, elegant syntax, Code-as-Data paradigm, access to large existing ecosystems (Java, JS, .NET)... It's all about Clojure. Let's talk a little about how all this was implemented and what preceded it.

Common Lisp and Scheme implementations were very large and complex and were handled by multiple teams. In turn, <medium>it took Rich Hickey about 2 years to create Clojure<medium>. How is this possible? What are the reasons? What problems have been solved?

  • There were <medium>no native (machine) code compilers<medium> within previous Lisp implementations
  • <medium>Porting a new platform<medium> (Linux->Windows, Windows->MacOS, Linux->Embedded) was extremely time-consuming
  • Clojure is <medium>hosted on the Java Virtual Machine<medium> which reduces a huge part of Lisp complexity. JVM enables:

- cross-platform portability

- system API support (it's completely different for Unix, Linux, and Windows)

- performance optimization (JIT compilation), a particularly difficult task because of requiring optimization for a specific machine/processor architecture besides the OS optimization

- organizing multiple libraries

Data Fabric 2022 Tech Trends

Rich Hickey, judging by his interviews, loves to think and more than act. I think this <medium>strong propensity to analyze, explore and systemize<medium> was a reason why he didn't follow the path of building a system from scratch. Instead of this, he preferred <medium>to combine a bundle of ready-made solutions<medium> and add a thin layer of appropriate wrapper for industrial programmers on top (Python went the same way).

So, in a sense, Clojure was designed as a sort of good glue between various ready-made components. But as with every Lisp-family programming language, it is also good for implementing some things from scratch.

Dialectic of Python's pros and cons

I'll <medium>consider Python through the prism of data science<medium> because Python for web and Python for DS are two huge differences in kinds of approaches, frameworks, and tools.

During the general push toward DS, Python was much more popular than Lisp. And it's interesting that <medium>Python for DS acquired Lisp's features<medium>, including interactive REPL-driven development. As an example 一 Google Colab, an interactive Python IDE that allows debugging a piece of code (step through it line by line) and visualizing the results.

Here are some of my findings on <medium>Python's pros and cons in terms of data science<medium>. Some points may be indicated both as Python's strengths and weaknesses.

Python pros

  • its syntax is much more handy for mathematicians and physicists than S-expressions
  • mathematics libraries support (for the above-mentioned reason)
  • mainstream programming approaches
  • Python is a good programming language to learn first
  • Python is unaffected by the so-called Lisp Curse, where many devs create their own methods and solutions diverging from widely-accepted practices. Python programmers tend to use existing libraries
  • lack of fully supported metaprogramming (so there is less temptation to reinvent wheels)

Python cons

  • Python has functional capabilities but it doesn't support the FP paradigm fully
  • metaprogramming is not a concept that is typically associated with Python (despite the fact that it provides some advanced features). Although there are good things about it, lack of fully supported metaprogramming can be considered as a disadvantage

What are the similarities between Python and Clojure?

  • both are developed by BDFL (benevolent dictators for life). By the way, Python's inventor Guido van Rossum announced in 2018 that he'd be stepping down from the position of BDFL of the Python
  • language design is evolving slowly and predictably
  • relatively speaking, there is only one reference implementation and no competing standards (other implementations are suitable only for specific cases and, for the most part, are experimental)
  • well suited for interactive REPL-driven development (this lowers the learning curve)
  • dynamic typing 一 language is very practical for rapid prototyping & fast iteration
  • both languages actively use existing ecosystems (Clojure shares the JVM type system, while Python is based on C/C++)

Wrapping up, or some reason for reflection

Although Сlojure is less popular than Python it's no less promising. Data science was an early selling point of Clojure. Already 10 years ago developers explored and used Clojure concepts, which are great for mathematical calculations. According to the Clojure Survey 2011 42% of interviewed persons were using Clojure for 'math and data analysis' that is a really stunning number as for the pre-'the hype around neural nets' times.

Clojure offers intelligent solutions that are really well-suited for data analytics. <medium>Extreme development speed, metaprogramming, macros, DSL, map/filter/reduce<medium> – all those Clojure benefits are worth trying.

But, the questions of convergence and tooling are still on the agenda.

It's a good tendency. Conclusions 'hammered out on the anvil of discussion, dissent, and debate' lead to wise solutions, aged like fine wine, which in turn lead to improving the language ecosystem.

How to keep with the times and provide a better total experience with Clojureand Python tools? Freshcode welcomes you to talk about it! Please, fill out the form on our website or contact our representative on Linkedin.

{{about-barmin-green="/material/static-element"}}

Shall we discuss
your idea?
Uploading...
fileuploaded.jpg
Upload failed. Max size for files is 10 MB.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
What happens after you fill this form?
We review your inquiry and respond within 24 hours
We hold a discovery call to discuss your needs
We map the delivery flow and manage the paperwork
You receive a tailored budget and timeline estimation