What is the difference between MathLink and WSTP programs? Will the use of MathLink protocol be maintained or not?


1 Answer 1


There is no difference. "WSTP" is just a new name for MathLink.

As part of the renaming they also changed the function names from ML-prefixed ones to WS-prefixed ones. Now Mathematica comes with two developer kits, found in SystemFiles/Links/MathLink and SystemFiles/Links/WSTP. There is no functional difference between these two. The only difference is in the naming.

Note that at the same time when the renaming happened, a new version of MathLink/WSTP was introduced (interface version 4). Interface version 4 does introduce several new things, but it's important to understand that this is completely independent from the renaming. You'll still get the new things if you use the ML-prefixed devkit.

Personally I stick to the ML prefixed version so my code can more easily be ported to be compilable with the devkit that ships with v9.

Update (2017 August, M11.1):

Which one should you choose for a new project, MathLink or WSTP? The documentation states that MathLink is deprecated in favour of WSTP (e.g. here).

Despite this, I recommend people choose MathLink, i.e. use the ML-prefixed functions. The reasons are the following:

  • I am not aware of any contexts where using the WS-prefixed functions has a practical advantage (as of M11.1), but there are several cases of the reverse.
  • LibraryLink still seems to use ML-prefixed variants, and won't work out-of-the-box with the WS-prefixed ones (at least not without any extra work—I never tried to get the WS-prefixed ones working)
  • The CCompilerDriver packages always links to MathLink (not to WSTP). This package is useful both for compiling LibraryLink libraries and for compiling installable MathLink programs. It's especially useful for creating a cross-platform compilation setup.
  • The Raspberry Pi version of Mathematica still includes only the ML-prefixed libraries, but not the WS-prefixed ones (verified in M11.0.1, the latest as of 2017 August). Your code won't compile on this platform unless you use MathLink instead of WSTP.
  • Opening the Mathematica executables (either kernel or front end) with a hex editor reveals that internally they use ML-prefixed names (as of M11.1). This gives me some assurance that MathLink isn't likely to go away in the near future.

Needless to say, this is a personal opinion, and it is directly at odds with what Wolfram says. Follow it at your own risk. I am posting it here because it agrees with what Wolfram does.

  • 2
    $\begingroup$ I might add, WSTP does not appear to be packages with the Raspberry Pi version of Mathematica, and one must use MathLink on this platform. $\endgroup$ Feb 19, 2016 at 3:50
  • $\begingroup$ This is a pretty good answer. I certainly don't feel the need to add my own. Thanks @Szabolcs. Let me add a couple of things here, though... First, you are right about the interface 4 release and the renaming (or, as we refer to it internally, a rebranding). And yes, there was some messiness that happened at the seams. I'm sorry about that. FWIW WSTP/MathLink have moved into my wheel house now. So, feel free to pester me/call me out about the state of WSTP development. In the next comment, I'll discuss briefly what's happened in 11.2 and where things are going. $\endgroup$
    – John Fultz
    Aug 29, 2017 at 15:24
  • $\begingroup$ Much of the improvement for 11.2 in WSTP has to do with internal engineering, and isn't obviously visible. But I'm really much more comfortable with the state of things in 11.2 than in previous releases. I don't think CCompilerDriver has changed, and I wasn't even aware of the RasPi thing (thanks for reporting it!), but I feel we have a pretty solid base to build on. The WSTP and MathLink SDKs are much more unified in how they're created, and I feel quite good in saying that the two are really bug-for-bug compatible. Some of this is accomplished by preprocessor aliasing, so... $\endgroup$
    – John Fultz
    Aug 29, 2017 at 15:29
  • $\begingroup$ ...it may not be the friendliest so working with auto-completing IDEs. But it is working well now, and we've laid the groundwork for removing those aliases from the header file (in fact, I think this is not so much work). As far as exposed functionality between SDKs, I haven't properly analyzed the full public-facing APIs yet. There may yet be some undocumented functionality in MathLink which deserves to become first-class documented functionality in a future WSTP interface. If you have specific suggestions, feel free to call them out for me. $\endgroup$
    – John Fultz
    Aug 29, 2017 at 15:34
  • 1
    $\begingroup$ That having been said, I think it's important to say that it's entirely possible that interface 4 may be the last interface of MathLink we'll ever ship. I don't know that to be true yet, but it is certainly an option on the table. We'll still continue to ship MathLink for quite some time, so old programs will continue to work, and we'll put bug fixes into the MathLink binaries, too. But the SDK may have a significantly shorter lifespan. No final decisions to announce here...just something to consider. $\endgroup$
    – John Fultz
    Aug 29, 2017 at 15:41

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.