Which programming languages and platforms does Stan support?

Updated

Stan provides official interfaces for Python, Julia, R, and the Unix shell, and it runs on laptops, clusters, and cloud environments. If you already work in one of those languages, you can call Stan from it rather than switching tools. The same probabilistic programming language sits underneath every interface, so a model written once can be driven from any of them.

Language interfaces

Interface Language Typical use
PyStan Python Data science and machine learning workflows already in Python
CmdStanPy Python Scripted, command-line-style runs from Python
CmdStanR R R users who want the CmdStan backend
RStan R Tight integration with R modeling and plotting
Stan.jl Julia Julia users needing Bayesian inference
CmdStan Unix shell Direct execution, automation, and pipelines

The page lists "interfaces for Python, Julia, R, and the Unix shell," so those four environments are the supported entry points. CmdStan is the underlying shell-level program; the Python and R interfaces wrap it.

Where Stan runs

Stan is described as cross-platform and scalable, suitable for:

  • Laptops — local development and small models
  • Clusters — larger models or heavier sampling workloads
  • Cloud — the same code without local hardware limits

Because the modeling language is shared, moving from a laptop to a cluster or cloud does not require rewriting the model, only changing how you invoke it.

What this means in practice

A Stan program is a separate .stan file. For example, a Bernoulli model looks like this:

data {
  int<lower=0> N;
  array[N] int<lower=0, upper=1> y;
}
parameters {
  real<lower=0, upper=1> theta;
}
model {
  // uniform prior on interval 0,1
  theta ~ beta(1, 1);
  y ~ bernoulli(theta);
}

You write this once, then compile and run it through whichever interface matches your environment. The interface handles passing data in and getting samples back; the model file stays the same.

Supporting tools

Beyond the language interfaces, Stan has "a rich ecosystem of tools for validation and visualization." These support checking that a model fit correctly and communicating results, which matters when you need to justify decisions rather than just produce numbers.

Choosing your entry point

  • Already use Python? Start with PyStan or CmdStanPy.
  • Already use R? Start with RStan or CmdStanR.
  • Already use Julia? Start with Stan.jl.
  • Prefer scripts, pipelines, or automation? Use CmdStan from the Unix shell.

If you are unsure, pick the interface for the language you already know best — the model syntax is identical across all of them, so the choice does not lock you in.

Getting help

The Stan forums cover "all user levels and topics, from installing software, to writing Stan programs, to advanced Bayesian modeling techniques." Documentation, tutorials, and case studies are available for learning, and the Prior Choice Recommendations wiki page offers guidance on priors. Developers can use the Stan Developer Wiki, the Developers category on the forums, and the Slack channel at mc-stan.slack.com for informal discussion.