Charles Nutter. How to transfer an ancient monolithic project to JRuby and is it worth it?

    In a couple of days RubyRussia conference will be held in Moscow . Our guest Charles Natter (working on JRuby and JVM support in Red Hat) answered a couple of questions.

    How did you get into the world of programming and ruby?

    In 2004, I was contracted to a government firm as a Java Enterprise Architect. I worked on a project for the US Department of Agriculture, and spent a couple of weeks a month in Washington. One of these trips coincided with RubyConf 2004, and since one of my friends recommended me to pay attention to Ruby long ago, I decided to go to the conference. So I ended up at a Ruby event without having any idea about this language ... but I understood every bit of code, every given example. I was amazed and promised myself to find a way to bring Ruby to my Java world.

    What projects are you working on now?

    I am one of two leaders of the JRuby project. This work includes various related projects, for example, support for native libraries (we support Ruby FFI on JRuby), or transcoding strings (porting similar logic from CRuby). In addition, I work with the community to ensure that our users can always get help from us. In general, the work is always full!

    Which of these projects has the brightest future?

    I think this is JRuby, although it is not the most popular language on the JVM platform.
    At the very least, we contributed to the positive changes in the JVM itself. Largely due to our collaboration with Sun Microsystems and Oracle, the JVM has now become a convenient platform for many dynamic languages, not just Java. I hope that we played a significant role in this change.

    What languages ​​do you write most often? Which one do you like the most and why?

    I mainly write in Ruby and Java, since JRuby is written using both. Each of these languages ​​is well suited for its tasks. Ruby - to create applications that need to evolve and adapt quickly. Java - for writing high-speed, reliable libraries and services. And JRuby combines the best of both worlds!

    Do you like Java programming?

    Yes, especially if you take into account all recently added language enhancements, such as lambdas (closures or blocks in Ruby), and a new syntax for declaring local variables (var) when the static type is unique.

    What do you think about Rust?

    Rust is a great language! In college I used a lot of C ++, but I can definitely say that if I knew Rust at that time, I would prefer to write on it. I especially like the statically-typed ownership model, which allows you to write stable parallel programs, and guarantees secure memory access. I think other languages ​​should adopt this in the future.

    What are your thoughts on Ruby prospects? For many years, many believe that the language and its community "die" ...

    After many years of working on JRuby, I fell in love with the Ruby syntax, and how everything is arranged in it. But, I'm afraid that the problem of performance really exists and is important. JRuby struggles to make parallel threads a reality for Ruby developers, but, until now, the vast majority of Ruby services use several isolated processes, wasting a huge amount of processor and memory resources. I think this is due to the too large and invasive C API for writing Ruby extensions, which does not allow for the introduction of improvements such as parallel streams.
    But I do not lose hope that one day we will still see a change.

    What do you think, which of the not-so-popular Ruby features should gain attention in the future?

    I look forward to strings becoming immutable by default, as it happens in most other languages. Parallel programming would be much easier if more Ruby objects could be made completely immutable (deeply frozen). This may resemble the model used in Rust ... if you are sharing an object in streams, you should select the version of the object that will not be modified exactly. This applies to arrays, hashes, and almost any other mutable object in Ruby: we need to simplify data modification locking.

    I have a big old monolithic Ruby project. I thought - and not whether to transfer it to JRuby. How could this be done, and does it even make sense?

    The first question, in fact, is whether such a step will help you.
    Strong arguments for switching to JRuby could be:

    • Reducing resource costs when there is a drawback, for example, if several applications are hosted on the same server at once
    • Deploying a Ruby application in a JVM-loaded environment that is used in large financial and government organizations
    • The need to access libraries that exist only in Java, or which are easier to port to the JVM than their equivalents in Ruby or C
    • A slight increase in performance in heavy-computing applications (which load the processor) or with a large number of parallel tasks.

    I would say that if an application scales well and doesn't cost you too much, then maybe you shouldn't do anything. But if you decide to get more from Ruby, here's the migration process:

    • Put together all the third-party libraries that your application uses.
    • Select among them those that use C-extensions.
    • For each extension, find the equivalent of JRuby. We have several
    • pages in the JRuby wiki about this. Most popular libraries have JRuby versions. If there are no JRuby versions, then you can use a pure Ruby version (it will be fast enough on JRuby) or JVM libraries (in Java, Scala, Clojure, etc.), which can be used as a replacement.
    • Once all your gems have earned on JRuby - the whole application will work! We pay a lot of attention to compatibility and try to take into account new problems that our users are paying attention to. Therefore, with high probability if you are going to bundle on JRuby - the application will work.

    Well, and then the most difficult thing begins - what to do with the released resources. How many threads to parallelize the application, how to spend the money saved ... :)

    What do students need to know now to become good programmers?

    When I was at university, my computer science courses taught Scheme, a functional language like Lisp, which was great for learning the basics of programming. I still recommend that novice programmers study at least part of the book Structure and Interpretation of Computer Programs, published by the Massachusetts Institute of Technology (MIT). Well, in general, the more different languages ​​you know, the better. It gives new ideas, and allows you to look at the solution of your problems from different angles.

    Where do you get motivated to work? Have you encountered the problem of professional burnout?

    Burnout is a real problem in our industry. Especially working in open source
    brings with it a tremendous amount of stress. I think it happened to everyone ... when there is too much work, you do not have time to do everything, you sacrifice time with family and friends, you forget about your health, in order to fix another regular bug. To fight this, I try to pay attention to my hobbies: playing computer and board games, learning to play the guitar,
    learning foreign languages ​​and traveling the world, meeting new people. A nagging workaholic will always live in me, persuading me to get back to work, but I still try to maintain the right balance.

    What is your opinion about Russia and what do you expect from the upcoming RubyRussia event?

    I love Russia, and all my trips to the conference here over the past few years have been very helpful. This will be my fourth visit, previously I was in St. Petersburg, Moscow and even in Novosibirsk (!!!). I look forward to returning to Moscow and meeting with the Russian Ruby community, which I have heard a lot about.

    Questions prepared by Dmitry Matveyev , PM in the company Evrone . And ask your question will be on October 6. So see you at the conference! All the details on the site .

    You can read the original in English at .

    And many thanks to the companies that support the main Ruby event in Russia:

    General Partner - Toptal
    Gold Partners - Gett and Cookpad
    Silver Partners - Instamart , , JetBrains and Qlean
    Partner after- party - Teachbase
    Bronze Partners - Bookmate and InSales

    Also popular now: