FreeCAD & Lisp

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
radiohaktive
Posts: 5
Joined: Wed Jun 05, 2013 2:25 pm

FreeCAD & Lisp

Post by radiohaktive »

I am looking to transfer my lisp routines to FreeCAD, how easy or hard is this? I am new to Python but am actively learning.
danielfalck
Posts: 395
Joined: Fri Oct 07, 2011 8:58 pm
Location: Beaverton,Oregon, USA
Contact:

Re: FreeCAD & Lisp

Post by danielfalck »

Python is a very user friendly language. If you learn FreeCAD and it's python bindings, and you have a good grasp on what you want to do with the geometry in your application, you will enjoy it. I think the python bindings in FreeCAD are more powerful than autolisp routines in Autocad/Bricscad because of their connection to the geometry, application, and gui.
radiohaktive
Posts: 5
Joined: Wed Jun 05, 2013 2:25 pm

Re: FreeCAD & Lisp

Post by radiohaktive »

I'm concerned about macros, tho. It's true that Python doesn't support macros? Most of my Lisp routines are used to automate tasks, and I want to make sure Python can handle this.
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: FreeCAD & Lisp

Post by jriegel »

What do you mean with "macro"?
Stop whining - start coding!
radiohaktive
Posts: 5
Joined: Wed Jun 05, 2013 2:25 pm

Re: FreeCAD & Lisp

Post by radiohaktive »

Not CAD macros but code macros like for true and false statements, automation etc. It looks like Python is the way to go though, I should learn it.
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: FreeCAD & Lisp

Post by jriegel »

Oh, I forgot that Lisp is a ancient programming language (1958). You meant a kind of preprocessor!

No modern language has such a thing or need it. In python you do it with functions...
Stop whining - start coding!
radiohaktive
Posts: 5
Joined: Wed Jun 05, 2013 2:25 pm

Re: FreeCAD & Lisp

Post by radiohaktive »

Cool thanks.
drayko
Posts: 25
Joined: Sun Jun 10, 2012 10:43 pm

Re: FreeCAD & Lisp

Post by drayko »

Actually, Clojure is a very modern language, and it most definitely has macros (it is a lisp, lisp is a type of or family of languages), which is one of the more prominent features of the language over other functional or more generally general purpose languages. It allows for a more declarative type of programming, which I think would be suitable for CAD modelling. Not here to ignite any language flame wars, python was/is the best choice for FreeCAD, but maybe I will do Clojure frontend for it some day, if I ever get anywhere with my clojure based programmable CAM solution prototype.

Also, for those no familiar with lisp macros, they are often used for similar purposes as the metaprogramming facilities of python. One usecase (my programmable CAM idea) for macros are internal Domain Specific Languages aka DSLs, which are so common in the lisp way of thinking that they aren't even called DSL too often, since its just a natural way of constructing intuitive APIs.
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: FreeCAD & Lisp

Post by jriegel »

Ok, lets flame ;)

Looking back at 30 years of programming I have a definite strong opinion about that.

1. I tried and hate functional programming. Nice exercise for the brain, but useless for big projects. The only on I was remotely interested in, was Erlang

2. I tried and hate meta-programing. Most libraries using meta-progrming with C++ templates are terrible uncooperative and complicated (e.g. OpenMesh or some of the boost libraries I validated for FreeCAD)

3. Internal DSLs are a bad idea, although we use in FreeCAD a DSL for our python binding generator. But thats a generative approach which generate C++ code you can compile and debug. Thats the right way to do a DSLs.

C++ is the only true programing language! You can unleash undreamed speed in working directly on the memory, registers or raw OS interface. At the same time you have all the high level constructs to master REALLY big projects.

--- end of flame ---

But thankfully every programmers generation has to decide on its own ;)
Stop whining - start coding!
radiohaktive
Posts: 5
Joined: Wed Jun 05, 2013 2:25 pm

Re: FreeCAD & Lisp

Post by radiohaktive »

Interesting thanks for the "macro" view on all this. Certainly it will help.
Post Reply