Fornjot

early-stage b-rep CAD kernel, written in Rust

Advantages of Code-CAD

I'm a software developer. I've learned to prefer clear code, written in a programming language, to complex graphical user interfaces that control opaque data formats. Applied to CAD, this approach is called Code-CAD or Programmatic CAD. Let's talk about some of the advantages of Code-CAD, as I see them.

Source of Truth

Let's start with something that may be easy to overlook: If code is the source of truth for your model, you can inspect and manipulate this source of truth directly.

With typical CAD software, the model is defined by a data format that you are walled off from. Most likely, you never interact with it directly. Your interaction is filtered through a complicated graphical user interface (GUI).

If that interface is well-made and bug-free, you might not perceive this as a disadvantage. But if you use a graphical application extensively, you will more than likely, sooner or later, run into a bug that messes up your data in a way that the software may or may not be able to recover from.

With Code-CAD, you change the code directly. If you mess it up, you can fix it again.

Inherent Advantages of Programming

Simply by using a programming language, you get some inherent advantages:

A sufficiently advanced GUI-based CAD program can also provide all of these things. However, the developers of that program might not have gotten around to develop what you need yet. And even if they have, they could have used that time to develop something else that would have been just as useful.

Many CAD programs can be extended with plugins, which provides the full power of a programming language in a different way. But there will always be a disconnect between GUI-based CAD modeling and writing a plugin. On the other hand, if you've been writing code anyway, just to create your model, then writing some slightly more complicated code poses less of a hurdle.

Using Tools Made for Text

The large majority of programming languages are represented (and hence written) as simple text. By using such a language, you can tap into a vast ecosystem of tools that have been developed to deal with text:

Again, a sufficiently advanced GUI-based CAD program can provide you with all of these capabilities. But the developers have to put in the effort to make it happen. And their solutions might not compare favorably to the standard tools from the software development world, which have been refined over years and decades.

The Disadvantage

There is one glaring disadvantage, of course: To use Code-CAD, you have to know how to write code. And while that is a very useful skill to have in general, not everyone wants to invest the effort into learning that.

This is somewhat offset by the fact that learning a non-trivial GUI-based CAD application is also not easy. But if you're already proficient in a CAD program that you're reasonably happy with, learning a completely new skill to switch to something else might not be the best use of your time.

And that's fine. The best solution to a problem depends not only on the problem itself, but also on its context. Your context is going to be different from mine, so what's the best solution for me, might not even be a good one for you.

A Hybrid Approach

There are other disadvantages to Code-CAD, of course. Making a sketch and applying some constraints can be very easy with a nice GUI, while having to type it all out would be very tedious.

For that reason, I think the ideal CAD program would use a hybrid approach: Being code-first for all the reasons presented above, but letting you edit that code through graphical tools, where it makes sense. I'm not aware of any system that works like that, at least to the extent that is possible in principle. I believe that creating such a system would be a worthwhile effort.