Matlang is a modular, compiler-first reimplementation of a MATLAB-compatible language system.
Matlang is an independent project and is not affiliated with or endorsed by MathWorks. MATLAB is a trademark of The MathWorks, Inc.
Current project intent:
- Keep the project CLI-first while the language, runtime, and compatibility surface continue to grow.
- Ship a practical MATLAB-compatible subset for Release 0.1 rather than a parser-only prototype.
- Keep the repository decomposed for long-running multi-AI and human collaboration.
Primary documents:
docs/architecture/OVERVIEW.mddocs/architecture/RUST_WORKSPACE.mddocs/handoff/CURRENT_STATE.md
Current status:
- The end-to-end pipeline is live: parser -> semantics -> HIR -> optimizer -> codegen -> serialized bytecode artifact/bundle -> interpreter/bytecode execution -> workspace snapshot export.
.\scripts\cargo-msvc.cmd test --workspacepasses in the supported MSVC environment.- The project is still a subset, but it is no longer a minimal bring-up. Large portions of execution, bytecode parity, object support, and builtin coverage are real and regression-tested.
Current default technical direction:
- Implementation language: Rust
- Execution path: parser -> semantics -> interpreter -> bytecode VM -> native backend
- Compatibility strategy: explicit feature matrix with documented divergences
- Helper build scripts:
scripts/cargo-msvc.cmdandscripts/cargo-msvc.ps1
Immediate focus:
- Keep pushing MATLAB fidelity instead of subsystem bring-up: more builtins, edge semantics, and compatibility polish.
- Broaden documented divergences and fixture coverage around the current object/runtime/bytecode surface.
- Deepen backend and interchange layers such as artifact evolution, MAT-file interoperability, and tooling/debuggability.
- Continue broadening command-form, classdef, and library behavior where MATLAB semantics are still incomplete.
Current compatibility highlights:
-
Interpreter and bytecode VM both execute a broad shared fixture corpus with golden parity.
-
The runtime supports meaningful array, cell, struct, logical, text, and object behavior instead of numeric-only execution.
-
The current array runtime also covers folded N-D indexing/assignment behavior when MATLAB uses fewer subscripts than array rank, including growth through the folded trailing dimension.
-
Logical values and constructor helpers now follow a broader MATLAB-compatible slice too, including bare
true/falsevalues, logical array constructors, the currentlike=subset forzeros/ones/eye, the current real-floating-pointlike=subset forInf/NaN, preserved logical class on current empty logical constructor/conversion results, current empty string-array results keeping string class, currentlogical(...)conversion errors forNaNand complex inputs, and currentisreal(...)behavior that keeps explicit complex values nonreal even when their imaginary parts are zero, including current empty explicit-complex arrays and string-array matrix inputs. -
The current shallow reflection/helper slice also keeps improving:
class/isaremain compatibility-layer helpers,isnumericnow treats current integer scalars and integer matrices as numeric while still keeping logical and string values nonnumeric,isfloat/isintegernow cover the current floating-point and integer scalar-or-matrix subset including both empty integer arrays and directint64([])/uint64([])casts keeping their real class identity,isdoubleno longer misclassifies those empty integer arrays as double, empty struct arrays now preserve bothstructidentity and their field-name schema for the currentfieldnames/isfield/rmfield/orderfields/struct2cellsubset, empty object arrays created through the current object-array deletion path now keepclass/isobject/isaidentity and preserve that typed-empty metadata through the current concat helpers too, and the current transpose / reshape / permute / squeeze /flip/rot90/circshift/repelemshape-helper slice now also preserves logical, string, integer, struct, and object empty-array identity instead of collapsing those empties back todouble, while plain[]no longer trips struct, handle, or object reflection predicates by accident, empty string scalars now stay nonempty forisempty("")while empty char arrays still report empty, andisanow recognizes the current built-in category namesnumeric,float, andintegerin addition to direct class-name matches. -
Command-form parsing now covers a broader MATLAB-like quoting slice too: single-quoted values lower as real char vectors, double-quoted text with spaces now splits into multiple char-vector command inputs when it appears standalone or embedded in a larger top-level raw command argument, and grouped raw chunks preserve inner spacing and quoted whitespace like
nested{1, 2}andvalue(1,"two words",3)as one command input. -
Matrix and cell literal parsing now also keeps MATLAB-like signed whitespace column splitting when those literals are nested inside call arguments, so forms like
int64([0 -1])andint64([1 +2])stay two-column literals while grouped arithmetic likeint64([(1 +2)])still stays arithmetic. -
The current
classdefslice includes value and handle objects, method dispatch, method handles, inheritance, package/folder class layouts, and save/load roundtrip for the implemented subset. -
Numeric/library coverage is broad and includes linear algebra, reductions, text helpers, ordering/shape helpers, and a substantial signal/filter slice, including current integer-aware
bounds/range/ direct integer-scalariqr/quantile/prctile/zscore/mad/mode/geomean/harmmean/rms/skewness/kurtosissupport together with the implementedmedian/var/std/"all"/vecdim/ current NaN-handling and multi-output forms, direct integer-scalar support for the current promoted-output floating-point and transcendental unary helper slice such aseps/log10/log2/pow2/exp/log/sin/cosh/sqrt/isfinite/isinf/isnan/sign, direct integer-scalar support for the current promoted-output binary helper slice such asmod/rem/hypot/mag2db/db2mag/pow2db/db2pow, direct integer-scalar support for the current promoted-output complex-helper slice such asangle/real/imag/conj/ unarycomplex(x)/ binarycomplex(x, y), direct integer-scalar support for the current text/formatting helper slice such asnum2str/int2str/mat2str/dec2bin/dec2hex/dec2base, direct integer-scalar support for the current numeric-or-complex vector-entry helper slice such astoeplitz/hankel/vander/polyder/filter/freqz, integer size-vector and integer scalar dimension support for the currentreshapesubset, and current class-preserving integer scalar support forfloor/ceil/fix/round/abs/ unary+/ unary-, current row-wise char-matrix and N-D char-array behavior across the implemented literal/formattedcompose, current logical/integer structural helpers such asdiag/trace/issymmetric/ishermitian/istriu/istril/triu/tril/blkdiagfor the implemented scalar-and-matrix subset including empty-result class preservation where relevant, current integer-awaresort/sortrows/issorted/issortedrowssupport for the implemented scalar-and-matrix subset including preserved integer class onsort/sortrowsoutputs and typed-empty value results, plus direct integer/logical/complex scalar identity through the current reshape/repmat/concat and transpose/flip/rotate/circshift/page-transpose helper slices, doc-alignedjoin/strjoin/strtok/split/splitlines/strsplittext-input handling, documentedstrfind(...,'ForceCellOutput',...)behavior, text set-operation vector validation, multi-patterncontains/startsWith/endsWith, append/strcat, pad, extract/replace/search, path-helper, and struct field-name text-array subsets. -
Signal Processing compatibility now includes a nontrivial SOS/CTF/state-space/
digitalFilterconversion and analysis surface, plus basic plotting behavior for functions such asfreqz,phasez,grpdelay,impz,stepz, andzplane, including the current integer scalar point-count subset for the implementedfreqz-family andfreqsresponse helpers, a firstinvfreqz/invfreqsequation-error subset for[b, a] = invfreqz(h, w, n, m[, wt])and[b, a] = invfreqs(h, w, n, m[, wt]), a broaderlpcsubset that now includes the real-vector default-order formlpc(x)together with the current real matrix column-channellpc(x, p)slice, a firstaryule(x, p)subset for real/complex vector input and current real matrix column-channel input with[a, e, rc]outputs, a broader reflection/prediction conversion seam throughac2rc(r),ac2poly(r),poly2rc(a[, eFinal]), andrc2poly(k[, r0])for the current vector/matrix subsets together with a first realrlevinson(a, eFinal)subset for[r, u, k, eEvolution], direct integer zero-location support for the implementedzp2ss/zp2tfsubset, a first named-window helper slice (hamming,hann,blackman,blackmanharris,barthannwin,bartlett,bohmanwin,chebwin,taylorwin,triang,rectwin,flattopwin,gausswin,kaiser,nuttallwin,parzenwin,tukeywin) together with a firstenbwsubset for direct window vectors, a broaderwindow(fhandle, n, winopt...)gateway subset over those current built-in windows together with docs-aligned requiredwinopthandling forchebwin,kaiser, andtukeywinplus the current two-element numeric-vectorwinoptform fortaylorwin, a firstkaiserordsubset covering current lowpass/highpass/bandpass/stop specs together with[n, Wn, beta, ftype]outputs and the current'cell'form forfir1, a broaderfir1slice covering low/high/bandpass/stop forms together with explicit or named windows, currentscale/noscalehandling, and the currentDC-0/DC-1two-cutoff aliases, a firstfir2subset covering MATLAB-like default-Hammingfir2(n, f, m)together with the documented odd-order Nyquist-passband promotion, current explicit-window forms, currentnpt/lapdense-grid forms, and the current no-auto-extension rule for explicit windows under Nyquist promotion, all on the current normalized piecewise-linear frequency-sampled path, a broader firstfirlsslice covering the default even-symmetry linear-phase formsfirls(n, f, a)andfirls(n, f, a, w)together with the current antisymmetricfirls(..., "h"/"hilbert")/firls(..., w, "h"/"hilbert")andfirls(..., "d"/"differentiator")/firls(..., w, "d"/"differentiator")subsets, weighted bands, and current odd-order Nyquist-passband promotion for the default symmetric path, a firstdesignfiltFIR window-method subset forlowpassfir/highpassfir/bandpassfir/bandstopfirwith currentFilterOrder,CutoffFrequency*,Window,ScalePassband, andSampleRatesupport, a firstdesignfilt('differentiatorfir', ...)least-squares subset with currentFilterOrder, optionalPassbandFrequency/StopbandFrequency,PassbandWeight,StopbandWeight,SampleRate, and explicitDesignMethod="ls"support, a firstdesignfilt('hilbertfir', ...)least-squares subset with currentFilterOrder,TransitionWidth, optionalSampleRate, and explicitDesignMethod="ls"support, a broaderdesignfilt('arbmagfir', ...)slice with directFrequencies/Amplitudes/ optionalWeights, the currentNumBands/BandFrequenciesN/BandAmplitudesN/ optional scalarBandWeightsNform, optionalSampleRate, explicitDesignMethod="ls", plus a first explicitDesignMethod="freqsamp"subset for both the direct-vector and current banded forms with optionalWindow, a firstdesignfilt('fracdelayfir', ...)direct-order subset with currentFilterOrder,FractionalDelay, and optionalSampleRatesupport, a broaderdesignfiltIIR subset forlowpassiir/highpassiir/bandpassiir/bandstopiirthat now covers both the earlier explicit-FilterOrderButterworth/Chebyshev path and a first minimum-order path driven by passband/stopband specs plusDesignMethod="butter"/"cheby1"/"cheby2"on the current implemented subset, a broader publicbilinearsubset for transfer-function, zero-pole-gain, and state-space analog-to-digital conversion with optional prewarping, a first publicimpinvarsubset for transfer-function analog-to-digital conversion with optional repeated-pole tolerance, a broader publiclp2lp/lp2hp/lp2bp/lp2bsstate-space and transfer-function subset for analog lowpass frequency transformations, plus a first analog lowpass prototype-helper slice throughbuttap,cheb1ap, andcheb2ap, a firstbuttersubset covering normalized digital lowpass/highpass/bandpass/bandstop forms plus current analog's'lowpass/highpass/bandpass/bandstop forms with[b, a]and[z, p, k]outputs, a broaderbuttordsubset covering current scalar and two-edge digital plus analog's'lowpass/highpass/bandpass/bandstop order estimation with[n, Wn]outputs for direct round-tripping intobutter, a broadercheb1ordsubset covering current scalar and two-edge digital plus analog's'lowpass/highpass/bandpass/bandstop order estimation with[n, Wp]outputs for direct round-tripping intocheby1, and a broadercheb2ordsubset covering current scalar and two-edge digital plus analog's'lowpass/highpass/bandpass/bandstop order estimation with[n, Ws]outputs for direct round-tripping intocheby2. -
The same design surface now also includes a first
cheby1subset for lowpass/highpass/bandpass/stop digital forms and analog's'lowpass/highpass/bandpass/stop forms with current[b, a]and[z, p, k]outputs. -
That same design surface now also includes a first
cheby2subset for lowpass/highpass/bandpass/stop digital forms and analog's'lowpass/highpass/bandpass/stop forms with current[b, a]and[z, p, k]outputs.
Current usable CLI surface:
matc parse <file.m>matc check <file.m>matc lower <file.m>matc optimize <file.m>matc codegen <file.m>matc run <file.m> [scalar args...]matc run-workspace <file.m> [scalar args...]matc run-bytecode <file.m> [scalar args...]matc package-bytecode <file.m> <artifact.matbc>matc inspect-bytecode <artifact.matbc>matc bundle-bytecode <file.m> <bundle.matpkg>matc inspect-bundle <bundle.matpkg>matc run-artifact <artifact.matbc> [scalar args...]matc run-bundle <bundle.matpkg> [scalar args...]matc export-workspace <input> <snapshot.matws> [scalar args...]matc inspect-workspace <snapshot.matws>
Quick start:
- Run tests in the supported Windows/MSVC environment with
.\scripts\cargo-msvc.cmd test --workspace. - Execute a fixture through the interpreter with
.\scripts\cargo-msvc.cmd run -p matc -- run tests\fixtures\execution\interpreter\builtin_complex_numbers.m. - Execute the same file through the bytecode VM with
.\scripts\cargo-msvc.cmd run -p matc -- run-bytecode tests\fixtures\execution\interpreter\builtin_complex_numbers.m.
Current public-facing project name:
Matlang- CLI binary currently remains
matc
License:
- Apache License 2.0
Contributors must read:
docs/handoff/CURRENT_STATE.mddocs/handoff/FUTURE_ONLY.md- relevant
SPEC.mdandDECISIONS.mdbefore editing a module