[OpenSCAD] Extending OpenSCAD from assembler to C or Perlish language and adding standard library
doug at moens.org
Wed Oct 2 14:13:54 EDT 2019
On Wed, Oct 2, 2019, at 11:33 AM, Steven Dick wrote:
> I've often dreamed of a GUI for OpenSCAD that would work seamlessly
> with the OpenSCAD programming capability.
> I've been afraid that adding mutable variables would make this difficult.
I love the idea of a direct manipulation GUI for making OpenSCAD models. But there's a basic philosophical question to settle first.
OpenSCAD works bottom up and in one direction, starting from the model parameters, applying arbitrary computation (using a Turing-complete language) to produce a CSG tree, which you can visualize.
On the other hand, there are constraint-based CAD programs that represent the connection between the model parameters and the shape using a constraint network, where information flows bidirectionally. You can tweak model parameters and the shape changes, or you can directly manipulate control points on the shape using the GUI, and those changes are back-propagated through the constraint network to update the model parameters.
With a constraint-based modelling system, you can't use a Turing complete language to map the parameters to the shape. Even supporting simple arithmetic equations becomes difficult: you end up using complex, ad-hoc, heuristic based algorithms to back -propagate shape changes back to the model parameters. And then you also create a difficulty for the user, in trying to understand what these opaque heuristic-based algorithms are doing when they back propagate changes.
Building a constraint-based GUI on top of OpenSCAD is a non-starter: what you end up with is not OpenSCAD. However the GUI works, it needs to abide by the rule that changes flow in one direction, from the parameters, to the model. And you can use the full power of a programming language to describe how the parameters generate the shape.
Once we establish that, then mutable variables don't create any additional difficulty. They don't add any expressive power to the language. You can accomplish the same computations by programming in a functional style with immutable variables.
More information about the Discuss