Closure

Summarized using AI

Lightning Talk: Ruby and the Lisp

Marian Posăceanu • December 06, 2023 • Bucharest, Romania

In Marian Posăceanu's lightning talk 'Ruby and the Lisp' presented at Friendly.rb 2023, he shares his journey as a seasoned Ruby developer and his passion for Lisp, particularly its dialect Clojure. He opens with his history in programming, highlighting his decade-long experience with Ruby, which began with Rails 2, and his exploration of various Ruby frameworks. Key points include:

  • Background in Ruby: Marian started programming in Ruby after working with PHP and CodeIgniter, recognizing the benefits of Ruby and the Rails framework. He has actively engaged with Ruby over the years, including writing papers on genetic algorithms and exploring Sinatra for building APIs.
  • Transition to Lisp: About five years ago, Marian felt a discontent in the Ruby community due to delays in Ruby 3.0 and the growing complexity of Rails with the need for additional tools like Node.js. This pushed him to explore alternatives like Elixir and eventually Lisp.
  • Discovering Clojure: His interest in Lisp grew as he learned about Clojure's powerful metaprogramming capabilities and the concept of code as data. He appreciated Clojure's concurrency features and how they offered a fresh perspective on programming with Ruby.
  • Integration Experiment: Marian then discusses his innovative project of combining Ruby on Rails with Clojure. By leveraging JRuby to run Clojure on the JVM, he created a custom action view template to generate HTML using Clojure, showcasing the possibilities of cross-language integration.
  • Learning Outcomes: Through this experiment, he gained insights into creating custom views, handling boilerplate code, and understanding Clojure's Uber jar concept. He emphasizes the importance of experimentation and joy in programming.
  • Final Thoughts: Marian concludes by encouraging developers to explore different paradigms and enjoy the complexities that languages like Lisp can introduce. His entertaining take on mixing programming paradigms leaves the audience with food for thought about language choices in software development.

Lightning Talk: Ruby and the Lisp
Marian Posăceanu • December 06, 2023 • Bucharest, Romania

Marian is a talented Ruby developer from the seaside of Romania, where he's making the World Economic Forum stay on track while exploring his passions. He shared his passion for lisp at Friendly.rb.

Friendly.rb is an International Ruby Conference hosted in Bucharest at the end of September and focuses on community and creating connections.

https://friendlyrb.com
https://twitter.com/friendlyrb

Friendly.rb 2023

00:00:07.680 And our next speaker, Marian, is a talented Ruby developer from the Romanian seaside.
00:00:09.840 He hails from the city of Constanța, where I went to college.
00:00:14.080 From there, he's currently making the World Economic Forum stay on track while he explores his passions.
00:00:19.000 The passion he is sharing with us today is the alien technology of Lisp.
00:00:26.199 Give a round of applause for Marian.
00:00:32.079 Hello, my name is Marian, and I'm a hacker.
00:00:37.040 Not the kind you're thinking about; I'm not an ethical hacker or a non-ethical hacker.
00:00:42.079 I just hack code, and that usually works most of the time.
00:00:45.000 I'm going to talk a bit about Ruby and Lisp and all its dialects and things like that.
00:00:54.079 But first, I want to share my journey of how I actually got into Lisp, because that's actually the interesting part, from my point of view.
00:01:03.559 So yeah, I'm a senior Ruby developer.
00:01:08.320 I consider myself that because I'm old and I've worked with Ruby for over a decade.
00:01:11.080 I actually like saying that I've been working with Ruby for over a decade because I started somewhere in 2008.
00:01:21.680 I read 'The Pragmatic Programmer' book; I'm guessing you know what I'm talking about.
00:01:30.520 Back then, I was primarily working with PHP and trying to emulate Rails in a small framework called CodeIgniter.
00:01:44.439 I started adding migrations and found myself asking, 'Why aren't you using Rails and Ruby?' So I got my first gig as a junior Ruby developer.
00:01:52.680 I started with Rails 2, and that's how I began my career in Ruby.
00:02:03.440 Of course, I'm not only a Ruby developer; I've worked with Sinatra and experimented with APIs in Grape, which worked fine for a year until I started encountering some issues.
00:02:19.519 I haven't just used Ruby for web applications; I've had a lot of fun with it.
00:02:34.400 That's why, after all this time, I’m still a Ruby developer—because I love the language and the community.
00:02:47.840 For example, during my university years, I wrote a small paper about experimenting with genetic algorithms in Ruby.
00:03:06.360 It was a lot of fun because Ruby, as we all know, has that Global Interpreter Lock, so I had to fork Ruby processes left and right.
00:03:13.400 I know this sounds like a long intermission, but I’ll get to the Lisp part soon; that will be pretty quick.
00:03:29.760 My journey toward Lisp began about five or six years ago when there was some discontent in the Ruby community.
00:03:43.799 If you remember, at one point, we had Ruby 3—supposed to be a performance improvement before the release of Ruby 3.0—but it got delayed.
00:04:01.040 At that time, it felt like Ruby was stuck; Rails was also at version six, and I remember installing it for a new project.
00:04:21.840 But when I noticed I needed Node installed for Rails, I checked the documentation and saw they were trying to keep up with the current state of the frontend using Node.js and React components.
00:04:42.120 It was fine, but it seemed to contradict the idea of being a full-stack framework that easily bootstraps applications without added complexity or external tools.
00:05:07.360 At that point, I thought maybe I should try something else.
00:05:23.920 As I was exploring the internet, Elixir had just been released, and I started getting into it, particularly because its syntax is heavily inspired by Ruby.
00:05:43.560 I liked the parts about Elixir, including the BEAM VM and Erlang.
00:06:02.919 However, something felt missing; I didn't want to switch completely to Elixir and Phoenix.
00:06:17.280 The community was great, and I knew there were many use cases—like WhatsApp using Erlang to process a lot of requests.
00:06:27.680 But for me, the appeal of the BEAM VM was the ability to upgrade code in production without actual deployments.
00:06:40.360 I wanted to integrate that approach at work, but I realized we were running on Heroku, which restarts your dynos every 24 hours, eliminating that key feature.
00:07:05.960 Anyway, I'm getting closer to the present timeline.
00:07:18.120 I’m a Vim guy, and my friend Max, who's an Emacs user, keeps talking about Elisp and how he can configure everything in his text editor.
00:07:37.479 I got interested because I played with it during university, where I used AutoCAD's scripting language, a dialect of Lisp.
00:07:51.640 I remember my teacher joking that if I learned this, it would be the end of all languages.
00:08:02.480 So I started Googling and exploring different Lisp dialects, including Clojure, and watched a lot of Rich Hickey's videos.
00:08:15.240 This was how my interest in Lisp, especially Clojure, began.
00:08:21.600 Here's a small comparison: before diving into Ruby and Lisp, I realized they both have a lot of meta programming capabilities.
00:08:40.720 However, in Lisp, it's much more powerful because code is both data and code, which opens up a world of possibilities.
00:09:02.640 I appreciate Lisp for its unique concepts that challenge your thinking, and it allows you to view Ruby code from a different perspective.
00:09:15.200 What I like most about Lisp is its concurrency and safety features.
00:09:34.720 In Clojure, this is easy to achieve because the language supports Software Transactional Memory (STM), ensuring most of the code is thread-safe.
00:09:50.160 Lisp may seem ancient, but it still resurfaces and remains relevant.
00:10:08.960 Another interesting aspect of Lisp compared to Ruby is its concept of identity versus state—where identity represents a series of values, while state represents a specific value.
00:10:30.640 This distinction helps understand how data structures are persistent in Clojure, pushing you to think differently about Ruby code.
00:10:50.200 Exploring this stuff and reading about it is fascinating.
00:11:06.240 I could go into great detail on any of these points, as they are all very interesting and deep.
00:11:12.600 Now, let's move to the next slide.
00:11:19.720 What is this actually about?
00:11:24.480 I think there was an interview with Linus where he mentioned that he likes Ruby developers because they're strange.
00:11:37.040 That inspired my idea to do something strange with Ruby, so I thought: how about mixing Rails with Clojure?
00:11:54.440 I imagined rendering HTML with Clojure from Rails—completely whacky, but I wanted to try it!
00:12:09.679 The fun of programming often lies outside of work, creating unusual ideas and seeing if they actually work.
00:12:28.320 So, what I did on the Clojure side was to use a library that represents HTML.
00:12:43.240 I then installed Leiningen in its toolset to generate an Uber jar.
00:12:58.720 An Uber jar includes the whole Clojure jar, its dependencies, and your code.
00:13:13.000 I needed this to load the jar and call the hiccup library from Ruby.
00:13:31.960 You may wonder how we mixed these two languages since Clojure runs on the JVM and Ruby runs in C.
00:13:49.760 The answer is quite simple: we used JRuby.
00:14:07.640 A huge shoutout to the team behind JRuby, especially the main contributors.
00:14:15.159 We still use JRuby in production on our end, and it's a great version of Ruby.
00:14:34.080 If you start from scratch, you can leverage the full power of the JVM.
00:14:51.520 There’s also 'Concurrent Ruby' if you wish to explore concurrency directly from Java.
00:15:07.640 I started a Rails 7 application which has undergone about eight iterations.
00:15:24.280 To set this up, I created a new custom action view template ending in Clojure.
00:15:42.720 Using the Uber jar, I added some required glue code to make it work.
00:15:56.760 The code on the right illustrates the connection between the Ruby application and the Clojure library.
00:16:23.919 Instead of using HTML in ERB, we utilized Clojure to generate HTML.
00:16:50.159 This experiment presented various challenges, especially in running Clojure within JRuby.
00:17:04.480 However, overcoming these obstacles has been very rewarding.
00:17:26.640 The end result is a custom action view template that combines Clojure and Ruby.
00:17:44.080 While it's not perfect, it makes for a great programming experiment.
00:18:06.200 The question now is: what can you learn from this experiment?
00:18:26.160 I navigated the intricacies of creating a custom action view, gaining insight into adding boilerplate code.
00:18:45.320 This project allowed me to explore the Uber jar concept and the required toolset.
00:19:07.680 I would recommend some resources, including this excellent book on Clojure.
00:19:16.720 The series covers concurrency, and the principles are enjoyable to learn.
00:19:33.120 Additionally, here's the GitHub repository for the code, if you want to explore all that hacky stuff.
00:19:50.560 There is also a link to the actual Clojure library.
00:20:00.520 Ultimately, it's about having fun while experimenting with various paradigms.
00:20:18.760 We don’t always need to adhere to a single language.
00:20:38.640 Lisp, in particular, can be a valid choice, as it can really challenge your way of thinking.
00:20:58.760 The more you dive into it, the more complexities you uncover.
00:21:15.760 Thank you very much!
00:21:25.480 Let's hope that AI won't turn against us because we didn’t program it in Lisp.
00:21:46.360 Thank you.
00:21:49.360 Thank you, Marian.
00:21:51.840 I tried Clojure once. It wasn't for me.
00:21:54.400 But maybe you're more curious now.
00:21:56.320 So thank you so much, Marian.
00:21:57.760 One more time.
Explore all talks recorded at Friendly.rb 2023
+10