discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

The OpenSCAD Language

DM
Doug Moen
Mon, May 6, 2019 4:45 PM

Curv is in the early adopter phase (it's not finished yet). There are no precompiled binaries. You can compile the source on MacOS or Linux yourself. No Windows port exists because nobody has volunteered for that.

We are going to address the deployment problem later this year by porting Curv to run in a web browser.

To align a corner of a cube with the origin, you are supposed to use the align operator, but that isn't implemented yet. So for now you are stuck with:

cube 10 >> translate[5,5,5]

to simulate cube(10) in OpenSCAD.

Note that in Curv, all of the geometric primitives are written in Curv. The align operator is probably 12 lines of Curv code, it just needs to be written.

On Mon, May 6, 2019, at 11:40 AM, Rogier Wolff wrote:

On Mon, May 06, 2019 at 10:59:04AM -0400, Doug Moen wrote:

OpenSCAD:
cube(45, center=true);

Curv:
cube 45

OK ! I want to switch. Where do I download it?

-> https://github.com/curv3d/curv

It is not fair to compare the nondefault in one language with the
default on the other.

Openscad
cube (45);

curv:
cube 45 dontcenter=true
^^^^^^^^^^^^^^
don't know how to write that in curv yet.

Roger. 

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.


OpenSCAD mailing list
Discuss@lists.openscad.org
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

Curv is in the early adopter phase (it's not finished yet). There are no precompiled binaries. You can compile the source on MacOS or Linux yourself. No Windows port exists because nobody has volunteered for that. We are going to address the deployment problem later this year by porting Curv to run in a web browser. To align a corner of a cube with the origin, you are supposed to use the `align` operator, but that isn't implemented yet. So for now you are stuck with: cube 10 >> translate[5,5,5] to simulate `cube(10)` in OpenSCAD. Note that in Curv, all of the geometric primitives are written in Curv. The `align` operator is probably 12 lines of Curv code, it just needs to be written. On Mon, May 6, 2019, at 11:40 AM, Rogier Wolff wrote: > On Mon, May 06, 2019 at 10:59:04AM -0400, Doug Moen wrote: > > OpenSCAD: > > cube(45, center=true); > > > > Curv: > > cube 45 > > OK ! I want to switch. Where do I download it? > > -> https://github.com/curv3d/curv > > It is not fair to compare the nondefault in one language with the > default on the other. > > Openscad > cube (45); > > curv: > cube 45 dontcenter=true > ^^^^^^^^^^^^^^ > don't know how to write that in curv yet. > > > Roger. > > -- > ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** > ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** > The plan was simple, like my brother-in-law Phil. But unlike > Phil, this plan just might work. > > _______________________________________________ > OpenSCAD mailing list > Discuss@lists.openscad.org > http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org >
CA
Carsten Arnholm
Mon, May 6, 2019 5:21 PM

On 06.05.2019 16:59, Doug Moen wrote:

OpenSCAD is not a functional language. Functional programming is
all about programming with functions. But functions are not
values in OpenSCAD. It would be fair to call OpenSCAD a
domain-specific, declarative language.

Whatever you call it is not important, I was simply loosely referring to
what has been said at various times when e.g. explaining why variables
are constant in OpenSCAD.
https://en.wikipedia.org/wiki/Functional_programming

The main point as I see it is being able to do things like assign and
re-assign variables and use them for anything, including holding shapes.
Also, I prefer not to be limited to recursion when iteration is natural.
It is all about choice.  Being able to declare user defined datatypes
(classes) in the script language is another thing I want to have, so I
enabled it. The list goes on.

It is untrue that functional languages "by definition" disallow
the feature that Troberg wants: "I can't assign an object to a
variable and then ask that variable about the object (location,
size, rotation et cetera)."

The main point is you can't do that in OpenSCAD, not which paradigm you
classify the language to.

It would be possible, in principle, to extend OpenSCAD to support
the same features. But it would be a big, disruptive change to the
language, and that conflicts with OpenSCAD's conservative approach
to change. OpenSCAD is almost 10 years old and the project has
emphasized stability, incremental change and backwards compatibility.

That is indeed a good principle to work from, given the large user base.
However, to have alternatives is also a good thing, so I am offering one.

However, AngelCAD is just CSG embedded in a general purpose
imperative language.

You could say a Ford is just a car :-)

There is a lot of verbosity and boilerplate,

This is not a competition in writing a trivial example using the least
amount of bytes, at least not the way I see it. I am more interested in
the examples that are somewhat more complex.  The cases you list don't
do the same things either. If you want a minimal,complete example that
generates and exports a cube it can be written as

void main() { cube(45).write_xcsg(GetInputFullPath()); }

AngelCAD:
shape@ main_shape()
{
cube@ cu = cube(size:45, center:true);
return cu;
}

You can write the above in various ways,  all below are valid and doing
the same thing

// 1
shape@ main_shape()
{
return cube(45);
}

// 2
shape@ main_shape()
{
cube cu(45);
return cu;
}

// 3
shape@ main_shape()
{
auto cu = cube(45);
return cu;
}

But, this is not a competition in writing trivial code with the least
amount of bytes. With support for different programming styles in the
same language, one can select the most natural approach in each case. I
am more interested in readability and performance than sheer compactness
of trivial cases.

The motivation behind AngelCAD is to offer flexibility, expressiveness
and speed. It is also about offering a choice, if you like it you can
use it.

Carsten Arnholm

On 06.05.2019 16:59, Doug Moen wrote: > OpenSCAD is not a functional language. Functional programming is > all about programming with functions. But functions are not > values in OpenSCAD. It would be fair to call OpenSCAD a > domain-specific, declarative language. Whatever you call it is not important, I was simply loosely referring to what has been said at various times when e.g. explaining why variables are constant in OpenSCAD. https://en.wikipedia.org/wiki/Functional_programming The main point as I see it is being able to do things like assign and re-assign variables and use them for anything, including holding shapes. Also, I prefer not to be limited to recursion when iteration is natural. It is all about choice. Being able to declare user defined datatypes (classes) in the script language is another thing I want to have, so I enabled it. The list goes on. > It is untrue that functional languages "by definition" disallow > the feature that Troberg wants: "I can't assign an object to a > variable and then ask that variable about the object (location, > size, rotation et cetera)." The main point is you can't do that in OpenSCAD, not which paradigm you classify the language to. > It would be possible, in principle, to extend OpenSCAD to support > the same features. But it would be a big, disruptive change to the > language, and that conflicts with OpenSCAD's conservative approach > to change. OpenSCAD is almost 10 years old and the project has > emphasized stability, incremental change and backwards compatibility. That is indeed a good principle to work from, given the large user base. However, to have alternatives is also a good thing, so I am offering one. > However, AngelCAD is just CSG embedded in a general purpose > imperative language. You could say a Ford is just a car :-) > There is a lot of verbosity and boilerplate, This is not a competition in writing a trivial example using the least amount of bytes, at least not the way I see it. I am more interested in the examples that are somewhat more complex. The cases you list don't do the same things either. If you want a minimal,complete example that generates and exports a cube it can be written as void main() { cube(45).write_xcsg(GetInputFullPath()); } > AngelCAD: > shape@ main_shape() > { > cube@ cu = cube(size:45, center:true); > return cu; > } You can write the above in various ways, all below are valid and doing the same thing // 1 shape@ main_shape() { return cube(45); } // 2 shape@ main_shape() { cube cu(45); return cu; } // 3 shape@ main_shape() { auto cu = cube(45); return cu; } But, this is not a competition in writing trivial code with the least amount of bytes. With support for different programming styles in the same language, one can select the most natural approach in each case. I am more interested in readability and performance than sheer compactness of trivial cases. The motivation behind AngelCAD is to offer flexibility, expressiveness and speed. It is also about offering a choice, if you like it you can use it. Carsten Arnholm
RW
Rogier Wolff
Mon, May 6, 2019 5:30 PM

On Mon, May 06, 2019 at 12:45:06PM -0400, Doug Moen wrote:

 cube 10 >> translate[5,5,5]

So
cube 10

is (behind the scenes) the intersection between
|x| - s/2
|y| - s/2
and
|z| - s/2

wher s is the size (10 in the example cube)?
Or can that intersection be written differently?

Roger.

P.S. Curv built in one go on my home machine once I started following
the instructions.
PPS: Curv built in two goes on my work machine once I installed ttb-dev.
Thank you for not using autoconf!

--
** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 **
**    Delftechpark 11 2628 XJ  Delft, The Netherlands.  KVK: 27239233    **
The plan was simple, like my brother-in-law Phil. But unlike
Phil, this plan just might work.

On Mon, May 06, 2019 at 12:45:06PM -0400, Doug Moen wrote: > cube 10 >> translate[5,5,5] So cube 10 is (behind the scenes) the intersection between |x| - s/2 |y| - s/2 and |z| - s/2 wher s is the size (10 in the example cube)? Or can that intersection be written differently? Roger. P.S. Curv built in one go on my home machine once I started following the instructions. PPS: Curv built in two goes on my work machine once I installed ttb-dev. Thank you for not using autoconf! -- ** R.E.Wolff@BitWizard.nl ** https://www.BitWizard.nl/ ** +31-15-2049110 ** ** Delftechpark 11 2628 XJ Delft, The Netherlands. KVK: 27239233 ** The plan was simple, like my brother-in-law Phil. But unlike Phil, this plan just might work.