Debugging and Profiling Poly/ML Programs: Tools and Techniques

Poly/ML: A Practical Guide to Getting Started

What Poly/ML is

  • Poly/ML — a high-performance implementation of Standard ML (SML) with an optimizing compiler, a C/C++ runtime, a generational garbage collector, and support for threads and a rich basis library.

Why use it

  • Performance: native-code compiler and runtime optimizations.
  • Concurrency: built-in lightweight threads.
  • Interoperability: foreign-function interface to call C libraries.
  • Tooling: debugger, profiler, and utilities to build stand‑alone executables.

Quick installation (common platforms)

  • Linux (Debian/Ubuntu): sudo apt-get install polyml
  • macOS: install via Homebrew/MacPorts or build from source (recommended Homebrew: brew install polyml)
  • Windows: download installer from the Poly/ML releases page or use prebuilt binaries

First steps (fast path)

  1. Create a file hello.sml:

    Code

    print “Hello, Poly/ML! “;
  2. Run interactively:
    • Start REPL: poly
    • Load file inside REPL: use “hello.sml”;
  3. Run a script directly:
    • poly hello.sml
  4. Compile/export a standalone object:
    • Use PolyML.export in a source file then follow polyc or build instructions (see docs) to link into an executable.

Basic REPL tips

  • Evaluate expressions by ending with semicolon: 1 + 2;
  • Set printing depth: PolyML.print_depth 10;
  • Load files: use “file.sml”; or run poly –script file.sml

Building larger projects

  • Use Poly/ML’s make-like system (MLB) or load sources in a Poly/ML session.
  • For creating executables, export main with PolyML.export and link with the Poly/ML runtime (polyc or manual gcc linking).

Useful tools & features

  • Source-level debugger and profiling (time/space).
  • Garbage-collection tuning and heap export/import.
  • Basis library (POSIX, Unix sockets, timers, arrays, vectors, etc.).
  • Foreign-function interface (FFI) for C integration.

Sample minimal project layout

  • src/main.sml (contains main : unit -> unit)
  • src/polyml-export.sml (val () = PolyML.export (“myprog”, main))
  • Build: load sources in poly –script and link produced object.

Where to read next

  • Official Poly/ML documentation (polyml.org) — overview, runtime, compiler, and examples.
  • GitHub repo for sources and releases.

If you want, I can generate a ready-to-run hello project with build commands for your OS (Linux/macOS/Windows) — tell me which OS.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *