How do I use live script (*.mlx) files in source control?
Show older comments
I would like to use the live script files with source control, what is the workflow for that?
Accepted Answer
More Answers (4)
Teemu Sillanpää
on 22 Mar 2018
8 votes
So with the change from readable content (text) to binary, live scripts / to achieve .m files with documentation built in feature is totally useless in normal working environment (>1 user).
Markus Leuthold
on 1 Apr 2019
6 votes
This is going into a completely wrong direction. Source code files must be text files. The toolchain does not only consist of Matlab, but many other such aus Github etc... which become unusable with these mlx files.
Unfortunately, there are already new features which are only available in the Live editor, but not in the classic editor or command window, such as tab completion via functionSignatures.json
2 Comments
Walter Roberson
on 1 Apr 2019
I used to rail against web pages with images because "Source code files must be text files!", and you couldn't copy and paste the representation of images. I lost that fight, Tools evolved.
I also appear to have lost the fight against CSS...
Michael Abboud
on 29 Jun 2021
Hi Markus, I'm a developer on the MATLAB Editor team and I'm glad to share that this Auto Completion functionality from the Live Editor is now available in plain text (.m) MATLAB files in the R2021b pre-release of the MATLAB Editor!
Many of the other coding tools from the Live Editor (Block selection, Refactoring, etc.) are also now available in plain text (.m) MATLAB files – along with a refreshed look and feel – starting with the R2021b pre-release which launched last week.
We think this is a big step forward, and we're excited for you to give it a try! If you're able to install a new version of MATLAB, I'd encourage you to try out the R2021b pre-release and send us feedback:
Richard Crozier
on 21 Mar 2018
Edited: Richard Crozier
on 21 Mar 2018
4 votes
No you cannot use live scripts with any of the major version control systems such as svn, git or mercurial. They are a binary format and not compatible with these text difference based systems. Versioning the files will be possible in a very basic sense but none of the standard diffing and merging commands will work effectively, and none of the standard GUI tools for comparing versions will work as the files will simply appear as binary blobs.
You may be able to set up your source control system on one or two machines to work as specified in the Matlab docs, but no remote services such as Github or Bitbucket will support this.
Jan Kappen
on 22 Jun 2021
Edited: Jan Kappen
on 22 Jun 2021
2 votes
Any updates on that? Workarounds? Plugins for Github or GitLab? Mathworks is effectively destroying any kind of collaboration, --automatic testing-- (wrong, see below) and code reviewing.
I'd stick to .m files if the editor wasn't that bad :(
Even juypter notebook files are in text format... The Notebook file format — nbformat 5.1 documentation
12 Comments
Steven Lord
on 22 Jun 2021
Plugins for Github or GitLab?
Mathworks is effectively destroying any kind of collaboration, automatic testing and code reviewing.
How so?
Using the third general source control topic on this documentation page you can use the MATLAB Comparison Tool on Live Scripts, MAT-files, or Simulink models as long as your source control tool allows you to specify tools to use to diff and merge files with certain extensions.
Jan Kappen
on 22 Jun 2021
Please ignore "automatic testing" in my rather provocant statement, that is not true, apologizes. CI & automated tests works well. Github Actions are the right direction, unfortunately, my company uses Bitbucket and Gitlab - no way to change that. Runners for CI work on local machines so better than nothing.
The part about collaboration and code review however remains true. Most of my developer colleagues (partially including myself) prefer not to use the Matlab GUI for code reviews (or anything else). This kind of work is done in the web interface where the pull request are shown or in good text editors that properly support git, pull requests, all kind of different languages, such as VSCode. There is no way to comment .mlx files line by line, or see incremental changes per commit online. One always has to checkout the whole commit and call the Matlab comparison tools (which have non-obvious interfaces and limited functionality - compare it with GitLens in VSCode and you know what I'm talking about ;)
Colleagues without having Matlab installed (or when no flex license is free) have no chance to do code reviews. That's certainly not the way to go.
What about supporting VSCode plugins like Add feature to support .mlx file(a matlab live script file) · Issue #115 · Gimly/vscode-matlab (github.com)? (I'm not the maintainer)
Thanks!
Walter Roberson
on 22 Jun 2021
Your company should stop using .mlx files if you have those needs. If that forces you to move to a different programming language, then that forces you to move to a different programming language.
.mlx files will never be plain-text files. If, hypothetically, Mathworks were to create similar functionality in plain-text files, then they will not use the .mlx file extension for such a hypothetical file.
I repeat: As long as .mlx files exist, they will always be a zipped structure of XML... exactly like .xlsx files are and ECMA-376 (ISO/IEC 29500) and Open Document Format (ODF) are. No amount of plugins or UI improvements will ever change that, so if your workflow requires that you use plain-text files, then .mlx files will always be incompatible with that.
Jan Kappen
on 23 Jun 2021
I'm afraid we indeed will stop using .mlx files though the idea is good. It's a too big source of error and slows down the development process, just as easy as that.
I'd like to continue using .m files, but the editor (auto completion, look & feel) is worse than the live editor. That means, I'd have to code in the live editor and save it as .m file to convert it to .mlx next time I (or my other 50 colleagues working with Matlab) want to make bigger changes where refactoring and auto completion features are needed. That's not a working workflow. Maybe commit hooks or one of these packages to convert .mlx to markdown can help: livescript2markdown: MATLAB's live scripts to markdown - File Exchange - MATLAB Central (mathworks.com) Live Script To Markdown Converter - File Exchange - MATLAB Central (mathworks.com)
Btw, as several people already mentioned the same issue in this thread, my needs are not that uncommon - in fact the majority of review workflows in software development I'm aware of are using web interfaces. And I wonder which company has not the same or at least similar requirements as ours has. These requirements automatically occur when a code review workflow combined with GIT (does not "like" binary data) is established. Which is standard.
Jupyter Notebooks work very similar as Livescripts, they contain code, text, pictures, latex and meta data and can be a) textually compared, b) rendered in GitHub, GitLab and Bitbucket, so it seems to be possible. I understand that .ipynb files are json, but as you state, .mlx is basically xml (zipped), so there should be ways to at least render them on the fly.
A comparison with .xlsx is not appropiate here imo. Microsoft has its own style of versioning and reviewing files via O365 and OneDrive/SharePoint. These files are simply not meant to be pushed to an VCS. On the other hand, Matlab .mlx files contain code. Code that often lived in .m files before. This should be reviewable outside Matlab.
I'm not asking to change the file format at all, I'm asking for helper to get around the fact that they cannot be rendered outside of Matlab.
Thanks.
Walter Roberson
on 23 Jun 2021
xlsx files can certainly contain code. Macros are code. People write big complex spreadsheets in xlsx. No substantive difference. If an organization is willing to put a xlsx file under version control, then it should be willing to put an mlx file under version control.
Jan Kappen
on 23 Jun 2021
Walter, while the .xlsx paragraph was obviously not the main point (the main point is: binary files don't belong to standard VCS like git, it's that simple, and Mathworks should think about that) I don't think any company puts .xlsx files under git version control, at least if they have a choice. .m files were good for version control, .mlx are not.
Any idea if features from .mlx editor (I don't care about the embedded plots, I mean refactoring and auto completion) will be usable for .m files in the future?
Walter Roberson
on 24 Jun 2021
And I am saying that MATLB used a standard binary container format -- standard as in International Standard -- that is used for spreadsheets, word processors, image handling, scientific data. They did not "roll their own": they used a common standard. You would think that version control systems would have caught up to that container format by now.
Michael Abboud
on 29 Jun 2021
Hi all, I'm a developer on the MATLAB Editor team and wanted to share a few thoughts on this topic.
First off, I'm really excited to share that many of the coding tools from the Live Editor (Auto Completion, Refactoring, etc.) are now available in plain text (.m) MATLAB files – along with a refreshed look and feel – starting with the R2021b pre-release which launched last week. We think this is a big step forward, and we're excited for you to give it a try! If you're able to install a new version of MATLAB, I'd encourage you to try out the R2021b pre-release and send us feedback:
On the topic of plain text (.m) vs Live Editor (.mlx) files, we know that different tools work well for different folks. We're committed to making the Live Editor features work more seamlessly with source control – and we're also committed to providing an enhanced experience with plain text MATLAB files. We're working hard on both of these fronts, so stay tuned for future updates!
Jan Kappen
on 30 Jun 2021
I've receied the prerelease notification yesterday and was more than happy to read that the live editor features were ported back to .m files, this is awesome, thank you!
Thank you also for your last paragraph, it's good for us to know that work is being done and that a potential gap in means of source control is identified.
So thanks!
Jan Kappen
on 22 Jul 2023
I have the feeling that the most recent decisions (Matlab Jupyter Kernel, export to ipynb, web GUI for Desktop App) go into a right direction. Good.
Hamid Farshi
on 6 Jul 2024
Starting with MATLAB R2024b if you use the "new MATLAB Desktop", you have the option of saving your MLX to M based live script. You can also change your settings so that all of your new live scripts would be M based .
Jan Kappen
on 6 Jul 2024
Yep, already checked that out, it's nice!
Categories
Find more on Environment and Settings in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!