Seeking strategies to deploy a function securely without a front end

Not a full answer, but a little too long for a comment.

You may need to pay a close attention to licensing. If the results of your computation are used on a single machine (e.g. somehow saved to a database or used further in the computation), you may only need a professional single-machine license. If they are going to be used by other employees / machines in the company directly, you may need a WebMathematica lincense.

Assuming the first case, I'd use JLink rather than script mode, and call Mathematica from Java (or .Net/Link, if you prefer that). This will be more robust and allow to:

  • automatically transfer common data formats from and to Mathematica (that includes type-checking on both parts, plus it is reasonably fast since Mathlink is used behind the scenes)
  • manage Mathematica kernels, including error-handling, re-starting kernels in the case of a crash, etc.
  • easier integrate it into the infrastructure of the company, and make the natural - looking .Net or Java API for the IT department of the company.
  • easily prototype things in Mathematica, since JLink allows one to work with individual instances (as mentioned in JLink's documentation, it makes Mathematica a prototyping environment for Java) - and I believe the same for .Net/Link too.

As for keeping the code proprietary, you could use either Encode or create an .mx file (with DumpSave), plus set the relevant attributes (Locked, ReadProtected), but no protection will give you a 100 % guarantee. You could also combine Encode and DumpSave etc, which should give you a reasonable level of protection. You could also write some Mathematica code obfuscator, or use some existing ones (not sure if they exist).

In terms of the project's organization, I can only give an idea how it could look like for Java (I have no experience for the .Net). For Java, you can package your final project as a single .jar file. Inside, it will contain your Java code (compiled) and your encoded compressed Mathematica code. You can make settings customization (such as location of Mathematica installation etc) a part of your Java API. So, all that the programmers of that company would have to do is to add this .jar to the classpath for their project (to the set of libraries they use), and also the JLink.jar - and they can start using it. This is all very standard in the Java world, so you win big in terms of the easy setup. In addition, you win in terms of development, since WolframWorkbench, being built on top of Eclipse (one of the most popular Java IDE), is optimised for the hybrid Java / Mathematica project development.


webMathematica is probably the most secure solution. Unless someone hacks your sever there is no way to get to the source of your program.

Using webMathematica you could easily use standard Web services. Check out the documentation So e.g., you can create a macro in Excel and then it looks like web services from Excel

In this way you use standard web technology and keep all your Mathematica source code central in one server. It may take quite a while to get familiar with webMathematica, but simple things can be done quite quickly.


Contrary to what most people say (including people working at Wolfram), you do not need Mathematica to run Wolfram Language scripts. What you need is a MathKernel and the wolframscript interface. You install the former by installing the freely available Wolfram CDF Player, the latter is also freely available from Wolfram website. Once you have installed both, it works like any other scripting language; go to a command-line and run your script: wolframscript -f yourScript.wl

I wonder if at least Stephen Wolfram is aware of this, because people working at Wolfram customer service are not.

I think they should let the world know that the Wolfram Language is free, instead of keeping it as a secret. By insisting on the fact that you need to buy Mathematica they are keeping developers away from the Wolfram Language.

The wolfram-geany project goes in this direction.