Talks

IRB Reboot: Modernize Implementation and Features

IRB was written at 20 years ago and contains Ruby code parser by pure Ruby. The parser is contributing greatly to some Ruby tools over
many years but the maintenance cost for new Ruby syntax continues to increase. IRB must parse Ruby code certainly for when should evaluate the code. I provide a solution for it. Ruby 1.9 or later has two big new features for this problem, `Ripper` and `RubyVM::InstructionSequence.compile`. The two features provide whether code piece continues by tokens information and syntax check.

After IRB implementation was modernized, I added some new features to IRB. IRB imports RDoc features as a library, such as show documentation with auto-complete, auto-complete for meta-programmed namespaces.

RubyKaigi 2018 https://rubykaigi.org/2018/presentations/aycabta

RubyKaigi 2018

00:00:00.030 Hello everyone, today I will be discussing how to modernize the implementation and features of IRB.
00:00:11.300 Firstly, this morning the weather was cloudy and rainy, but today it is a beautiful day outside. The birds are singing, and flowers are blooming. It’s a lovely day to talk about IRB.
00:00:25.640 Let me introduce myself. My name is Sakura Itoyanagi, and my GitHub ID is AYcabta. I am part of the maintenance team for IRB.
00:00:38.550 My company is Space Pirates, and one of my hobbies is climbing. I plan to climb Mount Zaō, which is the highest mountain in Miyagi, and it’s one of the closest places to the stars. However, it’s quite far from here.
00:01:01.199 Instead, I visited a gorge near the Tohoku University. The gorge is a narrow river between the escarpments, and the university's official website provides a map of fossil digging points.
00:01:20.070 There are a dozen fossil digging points in this area. I visited some of them, and at one point, I encountered a 4-meter waterfall, while another was over 10 meters high. It's quite a beautiful sight.
00:01:39.710 During my time there, I camped while cooking rice and miso soup over a bonfire. One morning while cooking, I received notice about a Ruby event happening today, so I quickly packed my things and headed for the event.
00:02:12.870 I traveled to the event via a highway bus, joining the Ruby party just in time. This party, which I attended three days ago, was a challenging experience for me.
00:02:41.010 At the event, I didn’t find a fossil, but I encountered many sweet, sugary sediment layers instead. It was exciting, and I enjoyed the various geological features.
00:03:03.980 Now, let's transition to the main topic of the day: modernizing the implementation and features of IRB. In recent years, there has been much discussion concerning IRB and its features.
00:03:46.319 For example, Kase-san, who has been presenting for years, discussed the evolution of Ruby, and mentioned how its initial design had similarities to shell scripting.
00:04:06.150 He also elaborated on the evolution across various versions of Ruby and how certain features have transitioned from Ruby’s design to its implementation over the years.
00:04:50.220 During Ruby's 20th anniversary, significant conversations arose around the development of IRB, and it was suggested that we should catch up on these advancements.
00:05:06.390 In this session, I’d like to share the patches I contributed to IRB. The first one, ticket number 1683, focused on improving IRB's integration with Ripper.
00:05:37.200 The second patch, ticket number 1787, aimed to show documentation during code compilation. I will detail how these patches enhance IRB.
00:06:12.620 Reflecting on last year, I noted that Ruby's syntax is complex and can feel overwhelming. This complexity presents challenges when using IRB, especially for new users who find its spaghetti-like syntax difficult to navigate.
00:07:05.760 While Ruby is known for being user-friendly, the syntax can present a learning curve. I identified numerous bugs in the existing implementation, and my solution was to replace some components with those from standard libraries.
00:07:43.580 My intentions were to create a more manageable implementation of IRB that would adhere to Ruby's syntax more closely, aiming for improved ease of use for developers.
00:08:43.740 The enhancements include better handling of syntax errors and improved prompts for various code scenarios, such as unclosed literals and nested structures.
00:09:36.710 Additionally, I implemented features for displaying contributions like trumpet and prompt symbols, indicating code continuation states effectively.
00:10:40.100 For example, I constructed a means of tracking nesting levels through specific keywords in Ruby, ensuring that users receive immediate feedback on their code's structure.
00:11:22.950 Each time the nesting level changes, the user receives a corresponding prompt. This level of responsiveness provides clarity and can help users avoid errors during coding.
00:12:11.200 In one of the recent updates, I introduced a way to simplify the loading of documentation files into Ruby, making them more intuitive for users who rely on it.
00:12:50.840 To benefit users further, I aim to enhance the visibility of documentation through clear commands and efficient display methods—ensuring it's accessible when needed.
00:13:37.080 In a broader scope, I believe it's crucial to improve the overall documentation design within Ruby. Incorporating user-friendly designs can enhance the experience and ease of use for our community.
00:14:52.920 Encouraging the removal of the no-document option in future releases could truly enhance the accessibility of the documentation and the overall Ruby experience.
00:15:42.350 In summary, Ruby's syntax intricacies, engagement with documentation, and community suggestions are vital to its evolution. Thus, we must continue advocating for improvements in our tools and resources.
00:16:33.630 I appreciate your attention and look forward to any questions or discussions regarding the modernization of IRB.
00:17:00.060 Feel free to engage; I'm here to address any inquiries. I also appreciate the feedback and support from everyone as we work together to enhance Ruby's capabilities.
00:17:55.650 Thank you!