Live Editor at MathWorks

I was an EDG Intern at MathWorks during winter of 2021. My manager led the Desktop Experience team and I was responsible for developing a MATLAB plugin that improves the coding experience.

Learn more about the Live Editor

Result

I successfully implemented features for a section management plugin prototype in MATLAB, extending its features to different file types. A plugin based on this prototype will likely be released in the main product in the future to improve the scripting experience.

I defined requirements with my manager and implemented the plugin with advice from different members of the Live Editor team. I then pitched the plugin to multiple feature teams at MATLAB in preparation for a production version of this plugin being shipped.

Contents

These were the main stages in the implementation process for my feature

Product Background

The script editor is an essential part of MATLAB. It allows users to write code for algorithms in an organized way, while providing the ability to run the code in the command window. Over the years, MATLAB has introduced new ways to improve the script-writing experience. These include function and class definition files, live scripts, and features for manipulating sections of a script.

It was the latter two items that inspired the plugin prototype I inherited. In each script file, an outline of the 'sections' can be defined using the headings in a script. Users are also able to select lines of a script to perform actions on, such as commenting, copying, and pasting. My manager had the idea of combining these two concepts, leading to a plugin that allows users to manipulate lines in a live script on a section-level.

The plugin, dubber the Surfer, had features similar to the slide preview browser in Microsoft PowerPoint. Users are able to navigate and perform actions by selecting 'sections' of a live script. Building upon the concept of sections, I also inherited another prototype plugin dubbed the Commander that allows code to be written and tested in isolation before being added to the current script.

Product Requirements

Before starting to code, I had meetings with different feature owners to discuss potential directions for this plugin. Although the Surfer already has section manipulation features, they were restricted to only Live Scripts. However, all files created through the editor had the concept of 'sections.' So I was tasked with extending the Surfer to all different editor file types, adapting the plugin behavior for each file type.

I discussed with my mentors and other members of the team to confirm feature behaviors. After that, I started implementing the new behaviors into both the Surfer and the Commander.

Implementation

Having explored the codebase, I implemented the features by adding a file type checker that makes use of existing APIs and plugins. Then, I was able to adjust the behavior of both plugins depending on the file type while reusing as many existing functions as possible to manipulate the editor code.

I used JavaScript and the function calls of various MATLAB libraries to implement the feature. I learnt a lot about how plugins in MATLAB are integrated into the product, and working my way through such an established product and inherited code.

I provided a test environment for my manager to verify the functionality of the features, addressing any issues he raised.

Challenges

One of the main challenges in my project was providing different behaviors for the different actions while maintaining code readibility. To achieve that, I used a wrapper plugin to implement each function.

Another challenge I ran into was the difference in architecture between the editor when editing Live Scripts and the editor with other script files. For Live Scripts, an entire editor window is created, while for other scripts the script editor is reloaded but other parts of the window were not destroyed, leading to errors when multiple Surfer listeners perform the same action.

To solve this problem, the HTML component for the Surfer was moved into the script editor, so the plugin does get destroyed and reinitialised when a new script is created.

Conclusion

The company culture at MathWorks is great. If someone was not able to answer my question they would introduce me to someone that could, usually being the feature owner. I learned a lot during this internship, especially about when to ask questions and being able to pitch your project to an unfamiliar audience at any time.

The remote aspect of the internship was the main reason I was able to take this opportunity and it was a great experience. I enjoyed the flexibility and my mentors were very willing to help me with my questions. I'm looking forward to see what direction the Desktop Experience team takes with this plugin and hope to see this feature implemented in the future. With this internship, I've gained more experience to adjust to new codebases and communicating in a virtual environment.