11
$\begingroup$

The relatively new wolframscript now accompanies the traditional math and wolfram binaries. I am guessing (?) that math is effectively a deprecated alias for wolfram, since I can no longer find documentation for math and the binaries are the same size. So I will focus on wolfram vs wolframscript.

It looks to me (from the documentation linked above) that wolframscript offers a superset of the capabilities of wolfram. The only comparison I truly care about right now is wolframscript -file file vs wolfram -script file (and for systems where they differ, such as Windows, WolframKernel -script file). Are these essentially identical? As one example, is there any significance to the fact that the wolframscript documentation does not refer to "script mode" but the wolfram documentation does? (My presumption is no, but I hate to rely on presumption.)

Finally, does any of this link to file naming conventions. It seems that the extensions .m, .wl, and .wls all remain in use, and this use appears inconsistent in the documentation. As a striking example, the "Code from a File" example for wolfram literally mixes up whether the example is working with file.wls or test.wl. What is the semantic information that is intended by the different extensions, if any? (My presumption is that .wls should be reserved for files that are made executable on a platform, but I hate to rely on presumption.)

I am very interested in educated guesses by experienced users, but obviously, pinning this down in the documentation would be ideal.

$\endgroup$
13
$\begingroup$

math/wolfram, MathKernel/WolframKernel are all the same: they are the Mathematica kernel. There is a difference between math and MathKernel on Windows in that the former is a console application (i.e. uses the standard terminal) while the latter is a GUI application, but otherwise they are the same thing.

Mathematica/mathematica is the front end.

wolframscript is not the same thing as math/wolfram. It has different capabilities and it takes different command line options. It invokes math/wolfram in the background. It is also a separate program from Mathematica: you may have several Mathematica installations (e.g. multiple versions), but normally there is only a single wolframscript, which can be configured to use a certain Mathematica.


I believe that wolframscript -file foo.m and wolfram -script foo.m are practically equivalent for most purposes, but there are definitely some differences, and they are not indistinguishable.

For example, $ScriptInputString and $ScriptCommandLine work only with wolframscript. If examining variables related to (batch) input or output (such as $Input or $Output), there will also be differences. I expect these won't affect most scripts.

Personally I still use wolfram -script due to its predictability, and have little experience with wolframscript. wolframscript might not invoke the Mathematica kernel I expect when I use it on our HPC cluster with multiple Mathematica installations. wolframscript has also evolved rapidly, and not everything in its documentation is accurate. For example, one documentation example seems to show that with -file, it returns the result of the last command in the file, but this is not the case unless -print is also provided.

$\endgroup$
2
  • $\begingroup$ One other thing: if I recall correctly, it's a little easier to use wolframscript in a hashbang (like #!/usr/env wolframscript than it is wolfram -script, because the semantics of the hashbang can mess up when you pass arguments to it. $\endgroup$
    – Carl Lange
    Jun 11 '21 at 16:58
  • $\begingroup$ Thanks! According to the documentation, $ScriptCommandLine does currently work with wolfram. $\endgroup$
    – Alan
    Jun 11 '21 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.