Home » Programming Languages » Functional Languages

Julia and The Reincarnation of Lisp

Background

I have programmed exclusively in C for five years so far. I can say from experience, after one and half years in C, I was beginning to understand pointers, malloc() and arrays of pointers to pointers of structs containing pointers. I really mean was beginning to understand, not an expert at all. In K&R2, the authors said that they feel after 10 years in C, they are still learning. They said the exact same thing while writing the first edition of the book. I struggled to think in C for first three years. The fifth year changed that. After five years, C felt so friendly, so easy. If someone told me a problem then C code came out from my hands like a reflex. I could solve problems in C which I never could, never did earlier. Imagine 10+10 more years in C, what it will make you: C Samson? I have, personally, written programs in many languages:

  • Common Lisp
  • Scheme
  • OCaml
  • Haskell
  • Ruby
  • ATS
  • At least 20 others I forgot.

I could never use them professionally on a large scale. Just some toy programs here and there and sometimes bit bigger, like those of Practical Common Lisp, The Gigamonkeys Book. I loved Common Lisp but could never use it in the software industry.

Experience and Desire

When every software company started having Python in their job description, I was still loving Common Lisp and thinking this is from where Python got most of the ideas and hence in future it may overtake Python. It never happened. My heart was broken because Common Lisp is such a fine fine language and it is a joy to work in and hardly anyone uses it in industry. The industry has a lot of code in Java even when it takes much less time to write code in Lisp. What happened to the programmer’s time is more important than the machine’s? Software owes many inventions to Lisp. First garbage collector was written in/for Lisp, same is true for conditionals and tree data structures, to name a few, but it never got its share of popularity. Then I came across Julia. It looked like Ruby to me (in syntax) but it was faster, way faster than any language, it is just bit slower than C and C++. It joined the Petaflop club recently.

3862149396

3862156918

3862152887

(First steps with Julia for numerical computing by Bogumił Kamiński)

Working with so many languages taught me two things:

Tech+Features of a language (usual stuff) and mental model behind the language (not so usual stuff). A Programming Language is a lot about its design and whys.

I was looking for a language with speed of C, with a Free Software license (this is what we used to call them before term Open-Source was coined) and where I could have dynamic typing too. I love read–eval–print loop of Lisp a.k.a REPL. REPL is one of the most amazing experiences of programming (and yes, it was invented in Lisp). The other is Emacs, which I will write about someday. I wanted a language where I could use my mind to solve a problem instead of memory problems and Segfaults. A language that is far simpler than C++ (by all means, C++ is a great language, if I have to create an OS, I would use it. Still, it is a very complex language to work in). Then I came to realize, I was not the only one thinking along those lines. Few Lispers were thinking the same. Then I read Why of Julia:

We want a language that’s open source, with a liberal license. We want the speed of C with the dynamism of Ruby. We want a language that’s homoiconic, with true macros like Lisp, but with obvious, familiar mathematical notation like Matlab. We want something as usable for general programming as Python, as easy for statistics as R, as natural for string processing as Perl, as powerful for linear algebra as Matlab, as good at gluing programs together as the shell. Something that is dirt simple to learn, yet keeps the most serious hackers happy. We want it interactive and we want it compiled.

I felt like it was written for me. Out of all those experiences and experiments over half a decade, I can tell you, Julia is a great language to write programs in, for at least for five years of your life. I am sure, any person who likes to improve his skills, looking for better ideas, better design in software, will love Julia. I am typing this from my home computer running Arch Linux with LXQt. It is amazing to chat on Julia IRC gitter at 10:15 PM.

The Strength of Community

Julia community is quite friendly and helpful. One thing I can’t take off my mind is when I was writing toy programs in Python and Ruby. Python looked much friendlier and Ruby looked alien (think less intuitive) and C hurt the head. I read Why’s Poignant guide to Ruby at that time. After 5 years of coding totally in C and C++, I feel quite comfortable with both, they still surprise me though sometimes. I don’t know why but whenever I looked at Julia code/syntax, it always reminded me of Ruby. The syntax feels the same (means less intuitive). I struggle a bit too. Writing Python code I felt was much easier but that easiness and friendliness and intuitiveness wears-off in a week. At the same time of trying out a 100 different languages and environments, I think this easiness/friendliness or lack of it has not much to do with mastering the language and its design and liking it at heart. It all comes with practice and associating with people who already know the language, you just have to follow their guidance. So, yeah, Julia community is full of helpful people. I am still wondering though how long it will take me to get over this mental obstacle of lack of intuitiveness towards Julia syntax. I only know one way, get immersed in the language and its community and write good code, read reference docs/manuals, read blogs and articles on good coding practices in Julia. You must eat, breathe and sleep with the language and the guidance provided by its community. This is how I became good at programming.

Conclusion

I like Lisp a lot, you will too if you work with it. Lisp could never break out into the mainstream. The languages it influenced (Python, Ruby, Scala, Perl etc.) all became mainstream but Lisp could not. I have even read Kent M Pitman’s long conversations on Scheme Language Standard on comp.lang.scheme newsgroup (try Aioe and Pan Newsreader ) when I was choosing to learn between Scheme and Common Lisp (one such conversation can be found on Google Groups). I read all that out of strong interests, now I realize it was all a part of experience towards a greater understanding of programming languages. I liked Lisp and I wanted performance. I think Julia will be mainstream in a few years and it is the language I was waiting for since the day I wrote my first program. If you like programming even a bit, if it touches your heart, you must code in Julia, must-read its documentation. It is a breath of fresh air after a long time.

Leave a Reply

Your email address will not be published. Required fields are marked *