Release v0.6.0

µcad

This release is a huge one: µcad is now pronounced mucad and the official file extension is .mu! I have taken on board the user feedback of those who are using non-European keywords.

But beyond that, there is so much more that has changed!

Note: mucad is an official fork of microcad.xyz.

Compiler rewritten

I took some time off over the summer to rework the compiler toolchain. I started the rewrite from the insight that the old architecture was simply not suitable for building language tooling on top of it. The rewrite has also shifted µcad project’s focus. The goal is now to provide have a well-specified language and compiler with API that allow integration into existing CAD kernels, like OCCT.

In the new architecture, each compiler stage (parse, lower, resolve, eval) is now implemented in separate crate and has a defined API.

  • The parse API is used for formatting,
  • The lower API for syntax desugaring and code normalisation,
  • The resolve API is used e.g. for type checking, searching library symbols and code completion.
  • The eval API is used to produce ModelTrees from µcad source files and symbols. The ModelTree is supposed to be passed to a CAD kernel. Right now, µcad has a minimal CSG kernel, but I want to use the ModelTree as a bridge to other CAD kernels.

The driver crate now provides struct Compiler, a high-level API for the µcad compiler, sitting above the 4 compiler stage API. You can feed the Compiler with µcad source as &str or a file path, it will compile everything into a ModelTree. The ModelTree can be passed to a renderer or an exporter to actually generate a geometry from the .mu source.

New language features

No breaking language features have been added during the compiler rewrite, but existing language features have been revisited. For example, defining consts is now possible almost everywhere (workbenches, modules, functions), except within {} scopes and groups.

I have also added some new reserved keywords for future features, including:

  • asset: for including assets such as OpenType fonts.
  • layer: for defining layers.
  • for: for for loops (yes, for for loops).
  • lib: For using external libraries.

The list of keywords can be found here.

µcad libraries

I have also improved the library API. Each µcad library has a mu.toml as manifest that contains metadata for the library. The standard library std is the first official µcad library and is always bundled with the compiler and installed the first time, µcad is used. The µcad standard library is licensed under MIT license.

There is also a prelude for symbols from the std library. This means you can write Circle, translate without including it via use std::geo2d::Circle or use std::ops::translate. All symbols that are part of the prelude are listed here.

Although the library feature is not complete yet, the current state is solid foundation for a future µcad package manager and sharing µcad libraries.

µcad playground

µcad now has a web-viewer that can be used as playground at [https://play.mucad.org]!

The web-viewer itself is based on the WebAssembly API implemented in a wasm crate. The API is still rudimentary, but thanks to that, the web viewer mostly consists of a WASM binary compiled from the Rust code. The rest is only 800 lines of vibe-coded (but well-reviewed) TypeScript and CSS :)

The playground allows you to fiddle with µcad without installing it. If you spot any issues, please share a link and file it here.

Share your designs!

The web-viewer supports generating permalinks in URL fragments and QR codes with embedded small designs up to 2048 bytes. This means you can easily share designs, with a server-less privacy-first approach!

You can test it here and by clicking on the Share button in the viewer.

Please be aware that encoding of the µcad source code for this feature is highly experimental and may change in future versions.

Missing features

Some highly-desired features are currently not (yet) implemented:

  • Rendering text.
  • Importing SVGs and STLs.
  • Calculating bounding boxes and measures of models.
  • Chamfer and fillet.

What’s next?

You also may have noticed that on the new website, the documentation under [https://docs.mucad.org] is still under construction. This is because I need some time and I do not want to use LLMs for writing the documentation. For me, documentation is supposed to be written by humans for humans and is more than LLM slop. So, I ask kindly for your patience, I will upload a first draft of new language reference and standard library documentation in the next weeks, promised!

I plan to release the next version v0.7.0 by the end of November.

Next week, I will be at the [https://rustlab.it] conference to talk about my experiences during the development of µcad.

Stay tuned!