cd /news/developer-tools/show-hn-typed-polyglot-compiler-for-… · home topics developer-tools article
[ARTICLE · art-137544] src=github.com ↗ pub= topic=developer-tools verified=true sentiment=· neutral

Show HN: Typed polyglot compiler for CLI/API/MCP generation

Morloc, a typed polyglot compiler in beta after roughly ten years of development, composes functions across languages under a common type system and generates CLIs, APIs, and MCP tool definitions from those types and declarative docstrings. The compiler runs natively on Linux, macOS ARM chips, and Windows WSL, and its author says the core feature is slowly stabilizing while regular backwards-incompatible changes continue. The project is seeking community contributors to report bugs and write modules.

read4 min views1 publishedSep 22, 2026
Show HN: Typed polyglot compiler for CLI/API/MCP generation
Image: Michielbdejong (auto-discovered)

Morloc composes functions across languages under a common type system and transforms modules into rich CLIs, APIs, and MCPs.

Write ordinary code in ordinary languages, source it into a Morloc script, and provide a type. These functions are then first class citizens. They can be used freely within a rich functional language. The Morloc compiler generates the CLI, API, MCP model, and usage statements from the types and declarative docstring instructions.

Morloc runs natively on Linux, macOS (new ARM chips), and Windows WSL.

Run this to install the Morloc Installation Manager (mim):

curl -fsSL https://raw.githubusercontent.com/morloc-project/morloc-manager/main/scripts/install.sh | sh
mim new     # bulid the environment
mim shell   # drop into a shell
mim demo    # pull cool morloc demos

The build is native by default, add the --engine docker flag to build in a container (or podman or apptainer). The environment automatically handles dependencies for Morloc builds via the Pixi package manager. See the manual section Getting Started for more info.

You may freeze Morloc environments into Docker images with mim freeze.

Two functions, in two languages, neither aware of the other. A C++ sum:

// foo.hpp
#pragma once
#include <vector>

double sum(const std::vector<double>& vec) {
    double sum = 0.0;
    for (double value : vec) {
        sum += value;
    }
    return sum;
}

and a parallel map in Python:

import multiprocessing as mp

def pmap(f, xs):
    with mp.Pool() as pool:
        results = pool.map(f, xs)
    return results

Neither file imports anything from Morloc. The Morloc module gives each a type and composes them:

-- sums.loc
module m (sum, sumOfSums)

import root-py
import root-cpp

source Py from "foo.py" ("pmap")
source Cpp from "foo.hpp" ("sum")

pmap :: (a -> b) -> [a] -> [b]

--' Add up a list of numbers
sum :: [Real] -> Real

--' Add up a list of lists, summing each in parallel
sumOfSums :: [[Real]] -> Real
sumOfSums = sum . pmap sum

. is function composition, so sumOfSums reads right to left: pmap sum sums each inner list in parallel, and the outer sum adds the results.

$ morloc make sums.loc
$ ./sums sumOfSums '[[1,2],[3,4,5]]'
15

A Python function called a C++ function across a process boundary, and you wrote no binding, no serializer, and no argument parser.

Building the program creats a CLI tool from the given types and docstrings:

$ ./sums -h
Usage: ./sums <nexus_options> <command> <command_options>

Commands:
  sum        Add up a list of numbers
  sumOfSums  Add up a list of lists, summing each in parallel

General Options:
  -h, --help  Print help; -hh adds details and examples, -hhh adds schemas
              (nexus options: -h @)

./sums sum -h goes further and prints the argument types the compiler derived.

It can also serve as an MCP server (./sums --mcp-tools emits JSON Schema tool definitions), an HTTP, TCP, and Unix-socket service, and a module that another Morloc module can import and re-export. None of these are separate builds or a separate descriptions, so none of them can drift from the functions: changing a return type changes all interfaces.

Morloc has been in development for about ten years and is in beta. I use it for my own work and am currently trying to build a community.

The test suite is massive and growing, but many bugs remain. The core feature is slowly stabilizing, but I still make regular backwards incompatible changes. Play with the cutting edge and you might bleed. Track your blood over here: issue tracker.

The hard part is finished. The ongoing work is the long tail of bug fixes and ecosystem development. That is where I need people. Here's what I'm looking for:

  • Report what breaks. Try it out, tell me what breaks
  • Write a module. Take something you already maintain, give it types, and share it. I would be happy to collaborate.
  • Fix the editor tooling. Add support for your favorite editor.
  • Bring a language. Every new language brings fun design questions, I would be happy to work with you in bringing your language into the Morloc ecosystem.
  • Tell me the right way to build a type system. There is a lot of theory to hash through and I've half-assed more than half of it. If you're a theorist, I'd love to hear from you. There's a paper or two buried somewhere in all of this.

If you are interested in playing with Morloc (or want to drown my in money), feel free to contact me at z@morloc.io.

Apache 2.0. See LICENSE.

── more in #developer-tools 4 stories · sorted by recency
── more on @morloc 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-typed-polygl…] indexed:0 read:4min 2026-09-22 ·