Use the language that fits each part of the job.
Conflate is an experimental polyglot language that puts Python, C++, Rust, Java, and Go in one
.confl file. Each block keeps the syntax and libraries of its language. You
choose what crosses a block boundary, and Conflate prepares the entry points and
value bridges.
That makes it possible to use the language that fits each part of a small tool: Python for quick data handling and its large ecosystem, Rust for memory-safe parsing and checked arithmetic, C++ for existing native code, and Java for the libraries your project already uses. Go and optional PHP or JavaScript backends fit the same model. Conflate handles the data exchange so you can work on each part without writing a separate wrapper for it.
The polyglot tour runs all five built-in languages and is a compact way to see the syntax. For a more practical first example, start with the Python and Rust orders example.
| Languages | Integration |
|---|---|
| Python, C++, Rust, Java, Go | Built-in value sharing and cross-language function workers |
| JavaScript / Node.js | Recognized registration with value and function sharing |
| PHP | Optional command-manifest JSON bridge, with value sharing; no cross-language function workers |
| Other runtimes | Command manifests; value sharing requires a bridge for that runtime |
The concept is extensible polyglot programming. Different integrations have different capabilities; adding a compiler path alone does not supply a bridge.
@python(out: seed: int)
seed = 40
local_note = "This stays inside the block"
@cpp(in: seed: int; out: answer: int)
int answer = seed.as<int>() + 2;
@python(in: answer: int)
print(answer) # 42
in names are required inputs; out names are the values a block publishes.
Conflate checks their types at runtime and reports boundary failures at the
source marker. A missing clause means an empty list. Bare @python and @cpp
markers retain the earlier implicit sharing behavior.
Read the language specification, or run
typed-pipeline.confl:
python -m pip install -e .
conflate --doctor
conflate --run-source examples/typed-pipeline.conflconflate --build examples/typed-pipeline.confl -o build/typed-pipeline
conflate --run-build build/typed-pipelineThe build directory contains a source snapshot, manifest, and prepared native artifacts. Building does not execute your program. These are local builds for the current environment, not standalone or cross-platform distribution bundles. Python and Conflate remain required, alongside the native runtimes in use.
The Python and Rust orders example shows the division of labor Conflate is meant for. Python supplies order rows as strings and formats a configurable report. Rust parses quantities and cents, uses checked arithmetic, and rejects malformed, negative, or overflowing rows. That keeps the input handling flexible while putting the arithmetic and failure cases in a small, memory-safe Rust block.
conflate --run-source examples/rust-python-orders.conflThe example notes show the sample output and explain the validation choices.
You need Python 3.11 or newer and a C++20 compiler named g++ or clang++.
Programs using other blocks also need their normal tools: rustc, javac plus
java, or go. Put the commands on your PATH.
git clone https://github.com/Hacker-lot/conflate.git
cd conflate
python -m pip install -e .Then try the included example:
cd examples
conflate -c helloWorld.confl
conflate -r helloWorld.exe- Python, C++, Rust, Java, and Go blocks execute from top to bottom.
- Strings, numbers, booleans, lists, dictionaries, and
Nonecross the boundary. - Simple native variables can return to later language blocks.
- Functions stay callable across blocks. Native workers keep function state until the program exits, and can call back into Python.
- Register another compiler or enable JavaScript by pointing Conflate at Node.js.
- Conflate generates entry points, state plumbing, and build commands.
- Compiled blocks are cached and reused when only input values change.
- The generated executable is a launcher, not a standalone binary. It still needs Python, Conflate, and a C++ compiler on the machine where it runs.
- Native variable discovery is based on straightforward declarations, not full language parsers.
- Automatic integration needs known language conventions. Other tools can run through a command manifest; full value and function sharing needs a bridge.
Conflate is version 0.4.0, and the format may change.
@python
def square(n):
return n * n
@cpp
std::cout << square(12); // 144C++ functions, Java methods, Go functions, Rust functions, and registered
JavaScript functions can return values to Python too. See
examples/functions.confl for a counter that keeps
its state while the program switches languages. Calls use JSON messages, so a
call across languages costs more than a local function call.
conflate --add-language javascript node
conflate --add-language mycpp "C:\Tools\LLVM\bin\clang++.exe"
conflate --list-languagesNow @javascript and @mycpp work in .confl files. No Conflate source edits
are needed. Python, g++/clang++, rustc, javac, go, and Node.js are recognized.
For an unfamiliar compiler, a command manifest
defines how to build and run its source. A compiler executable alone cannot
describe an arbitrary language's values or function signatures.
Read DOCUMENTATION.md for the execution model, supported types, CLI reference, examples, and current limits.
-
polyglot-tour.conflpasses a typed value through Python, C++, Rust, Java, and Go in one source file. -
php-roundtrip.confluses the optional PHP manifest bridge to pass values from Python through PHP and back. -
typed-statistics.conflsends Python data to a C++ loop and publishes only the mean and count for Python to format. -
nested-functions.conflsends one function call through all five built-in languages and back. -
data-pipeline.conflpasses a list through Go, C++, Rust, and Java helpers before Python checks the result. -
persistent-service.conflproves that a C++ static counter survives calls from Java and Python. -
recoverable-errors.conflcatches a Rust failure in Python, then calls the same Java and Rust workers again. -
registered-javascript.confladds Node.js without editing Conflate, then keeps JavaScript function state.
Bug reports and small, focused pull requests are welcome. Start with CONTRIBUTING.md.
Conflate is released under the MIT License.
