Group Abstract Group Abstract

Message Boards Message Boards

What's the difference between *.m and *.wl file format?

POSTED BY: Raspi Rascal
5 Replies

I usually write packages in a .nb file and change "AutoGeneratedPackage" to "Automatic" in the Option Inspector. Notebook Options->File Options->AutoGeneratedPackage.

This lets me use the formatting features of .nb files and generate the package file automatically when it is saved.

Regards,

Neil

POSTED BY: Neil Singer

.m and .wl are one and the same. The only practical difference is that .wl won't be recognized by Mathematica pre-version-10.0.

One advantage you will get from .wl is that it is unique to Mathematica (while .m is also used by MATLAB, in case you have that installed).

Personally, I still use .m.

POSTED BY: Szabolcs Horvát

The .m suffix is the old way of saving package files, and is used only for backwards compatibility. Use .wl for new stuff.

If you only write use-once code, then there is no need for making packages. I suppose that the majority of Mathematica users use the language as an interactive calculator, and so would never need to build a package. However, if you write code that will be used again, then making a package has advantages. It is the closest thing in Wolfram Language to source code files, such as .c or .swift files.

If you open a .wl and a .nb file in a text editor, you will see another difference. The .nb file has a lot of information on creation dates, modifications, etc. that are useful for a notebook file, but not so much for computer source code. For this reason, source management systems, such as GitHub, are much more effective with .wl files.

Maeder's book is older than Wellin's book, and his emphasis is on package development, as opposed to Wellin's book, which emphasizes programming using Wolfram Language. Maeder's book assumes that you already know much of what Wellin is presenting, although a lot of stuff in the newer book did not exist in versions 1 or 2 of Mathematica which is the time frame of the older books. There is still a lot of useful stuff in Maeder's books, but you need to "translate" it into the world of Mathematica 11 or 12.

In my own work, I do explorations using notebooks. I typically produce what are now called computational notebooks using just .nb files. However, when a project warrants it, I will make a package so that 1) the code is better organized, and 2) it can be reused in other projects.

You can do almost everything you need to do to make packages from within Mathematica or Wolfram|One itself, except preparation of fancy documentation like you see int he documentation center. For that you will need Wolfram Workbench, which adds an extra level of complexity into the process.

My suggestion is that you use the File menu to start a package project. It makes things easier to manage. You can convert a .nb file to a .wl file, but you need to know what you are doing. In my case, when I am ready to make a package with some code I have created in a notebook (.nb), I start a new package file and cut and paste the code.

Hope this helps.

I suppose that the majority of Mathematica users use the language as an interactive calculator, and so would never need to build a package.

Great post, thanks so much for it! Yes, this helps a lot.

So there is no difference in form, content, application, or concept between a .m and .wl file? I am also going to suppose that the creation/handling of packages by end users was more a common thing in the past than it is nowadays? Looking at literature, libraries, archives, repositories, directories (also on HDD, see your Mma install dir), there seems to exist so many more .m files than .wl files.

I browsed through the contents of .wl files from my Mma install dir: some of them contained packages, others contained code for a single function. And the code tended to have more framework-related functionality than expanding the end user's session with added mathematical functions. The code/content of those files looked less structured to me, providing maybe auxiliary functionality to the overall system, not to the end user's end in the end. Well, that was my impression, and i could be wrong.

Both file types contain source code in input form, with no information on cell properties as seen in .nb files.

I cannot find any official online tutorials or documentation treating the .m .wl difference topic, so maybe we should not bother either?

POSTED BY: Raspi Rascal
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard