Gladiator is a code editor that was built completely in Ruby. It supports syntax highlighting for over 30 programming languages, split pane, file name lookup, a variety of keyboard shortcuts, undo/redo, find and replace, line jumping, monitoring external file system changes, ignoring uneditable files, expanding to fill the screen, running Ruby code, remembering the last open files, and multi-project support. In fact, I have been using Gladiator for all my code editing needs since May of 2020.
In this talk, I will present Gladiator's features, and then dig into the implementation of every feature in Ruby, covering things like the Model-View-Controller and Model-View-Presenter architectural patterns, how to build custom widgets, how to implement file editing commands, and how to support undo/redo.
Attendees should walk out of this talk with rudimentary knowledge of how to build a code editor in Ruby.
1. How I Built My Code
Editor in Ruby
Andy Maleh
Senior Developer
Lexop
2. How Did I Build My Code Editor in Ruby?
● I used Ruby as Programming Language (using JRuby)
● I applied Object Oriented Design (with abstractions like File and Dir)
● I applied Architectural Patterns (like MVC and MVP)
● I applied Design Patterns (like Command, Composite, Adapter & Observer)
● I used Domain Specific Languages (like Glimmer GUI DSL)
3. How Did I Build My Code Editor in Ruby?
● I decomposed Software Modules (AKA Components AKA Custom Widgets)
● I reused Ruby Gems (like glimmer-dsl-swt, filewatcher, and clipboard)
● And, that's all folks! You can go home now!
● Just kidding! That was just a preview of the talk. Hang on for more.
4. About Myself
● Bachelor of Science in Computer Science from McGill University, Montreal
● Master of Science in Software Engineering from DePaul University, Chicago
● RubyConf 2008 + MagicRuby 2011 + MountainWest RubyConf 2011 +
RailsConf 2012/2014 Speaker
● Fukuoka Ruby 2022 Special Award Winner
● Senior Full-Stack Developer at Lexop
5. Why Build a Code Editor in Ruby?
● Ruby is a great language:
○ Object Oriented
○ Dynamically Typed
○ Inspired by Lisp, Smalltalk, Perl, Python, and Basic
○ Supports Meta-Programming and Embedded DSLs
○ Highly Expressive and Maintainable Code
○ Very Productive (e.g. Rails)
6. Why Build a Code Editor in Ruby?
● I am a senior software engineer:
○ Proficient in Requirements Engineering
○ Proficient in Object Oriented Programming
○ Proficient in Architectural Patterns (e.g. MVC)
○ Proficient in Design Patterns
○ Proficient in Domain Specific Languages
○ Proficient in Writing Highly Maintainable Code
○ Proficient in Automated Testing
11. Software Development Process
● Avoid using any editor other than built-in VIM while building Gladiator
● Start small and add features incrementally to Gladiator
● Eat own dog food by using Gladiator to build more Gladiator features
12. Software Development Process
● Glimmer Process is simply made up of 7 guidelines to pick and choose as
necessary until software development needs are satisfied. Not all guidelines
need to be incorporated into every project, but it is still important to think
through every one of them before ruling any out. Guidelines can be followed
in any order.
○ Requirements Gathering
○ Software Architecture and Design Diagrams
○ Initial Release Plan
○ Small Releases
○ Usability Testing
○ Automated Tests
○ Refactoring
13. Implementation of Gladiator Features
● File Tree Navigation
● File Lookup by Name
● Text Editor With Syntax Highlighting for Over 30 Programming Languages
● Tabs
● Find and Replace
14. Implementation of Gladiator Features
● Keyboard Shortcuts
● Undo/Redo via Command Pattern (and Adapter Pattern)
● Split Pane
● Menus
● Run Ruby Code
15. Implementation of Gladiator Features
● Watching external file/directory changes
● Remembering Last Open Files
● Ignoring Irrelevant Paths
16. Future Features
● File content search (right now I use grep for that)
● Themes (right now there is internal support for theme that is not exposed)
● Extensions (right now, code is open source, so people can fork to extend)
● Better Windows and Linux support (I mostly use on the Mac)