Skip to content

What Does This Line of Code Do?

ADMIN | 11-08-2011

As all good posts start with a quick to-the-point intro; here goes this one. Can anybody tell me what this line of code does? And what language is it in?

Hexagon pattern 1

As all good posts start with a quick to-the-point intro; here goes this one. Can anybody tell me what this line of code does? And what language is it in?

(do ((i 0 (+ i 1))) ((= i l))
        (set! en (list-ref allEntities i))

Obviously it’s a loop (that part is not hard) and it’s in the Scheme Programming language. Although it’s easy to recognize when you see it, it’s not that trivial to write from scratch. I’ve personally been using Scheme for ten years now (it’s the scripting language of our ACIS kernel) and I still have to go back to reference material in order to write a loop if I’m not using Scheme’s map function.

So why are we discussing this? Well, we’re at a point with the CGM modeling kernel in which we are adding scripting functionality to the kernel and we are in the process of choosing a language. In this case the decision is between Python, JavaScript and yes, Scheme (old habits die hard).

But I have to digress a bit before we discuss the scripting language itself. It’s really not in itself, the problem. Actually, what is the problem? Well, we need easy access to the modeling engine so one can quickly test and code geometric modeling works flows. (Example; build a block and fillet and edge.) We want to do this from a scripting language for the obvious reasons of not re-compiling, etc. However to do this efficiently, it’s the programming interface to the CGM kernel that’s important. In the case of ACIS we have a collection of high level functions we call "Scheme extensions" that have been bound to the Scheme programming language (they’re actually written in C++). These functions sit over the standard ACIS C++ interface and allow us to perform commands such as constructing a block:

(define block (solid:block (position 0 0 0) (position 10 10 10)))

This functional interface has many of the qualities that we originally intended; brief, declarative / procedural, and all inclusive. (Specifically, the viewport and part management gets updated at the end of each call). Now, we could have bound the functions to any scripting language, we just chose Scheme at the time. (We have a functional interface into the modeler, so we picked a functional language). In the end, I’m not saying the scripting language is not important for our purposes . . . we just need to develop the context of how we are scripting; and what extensions we are using.

Today, we’re at the same crossroads with CGM. We’re working on the modeler’s higher level functions; writing them in C++ but we have to choose again, the scripting language of preference. In doing so we made a comparison of the languages in consideration:

script chart

This is far from being an exhaustive comparison but it should include the main points. But back to the beginning of the post. . . how easily can one write a for loop? What language has the broadest understanding by our user customer base? What language supports on-the-fly, easy, command line typing? (And in what programming paradigm would you use to do this? Functional, procedural or OO?) In what language can you easily read a script someone else wrote two years ago? At the end of the day, these are the key questions.

Your thoughts? What language would you choose?

 

You might also like...

5 Min read
3D Modeling
What is digital manufacturing? Here’s a simple digital manufacturing definition: the process of using computer systems...
5 Min read
CGM Modeler
Software components are like the stage crew at a big concert performance: the audience doesn’t see them, but their...
Application Lifecycle Management Flow
4 Min read
CGM Modeler
When you hear the term, Application Lifecycle Management (ALM), you likely think about the process that a software...
9 Min read
CGM Modeler
SLS in Additive Manufacturing is used to convert 3D CAD designs into physical parts, in a matter of hours.
8 Min read
CGM Modeler
There’s a lot of confusion around what the terms additive manufacturing and 3D printing mean.
4 Min read
3D Modeling
Additive manufacturing, often referred to as 3D printing, is a computer-controlled process for creating 3D objects.
5 Min read
CGM Modeler
Computational Fluid Dynamics (CFD) is a type of analysis that provides insight into solving complex problems, and...
2 Min read
CGM Modeler
WRL files are an extension of the Virtual Reality Modeling Language (VRML) format . VRML file types enable browser...
Voxel model example
3 Min read
CGM Modeler
Voxels are to 3D what pixels are to 2D. Firstly -- let’s examine what pixels actually are. Everything you see on your...
Point_cloud_torus
2 Min read
CGM Modeler
Point-cloud modeling is typically used in the process of 3D scanning objects. Rather than defining surfaces through...
Polygonal Modeling
2 Min read
CGM Modeler
Polygonal (or polyhedral) modeling is the most common type of modeling for video games and animation studios. This type...
aerodynamics-CFD
9 Min read
CGM Modeler
Computational fluid dynamics (CFD) is a science that uses data structures to solve issues of fluid flow -- like...
BREP Model example
2 Min read
CGM Modeler
BRep modeling, or Boundary Representation modeling, is, in CAD applications, the most common type of modeling. BRep is...
Feature Recognition Zoomed
5 Min read
CGM Modeler
IN THIS ARTICLE: What is FEA (Finite Element Analysis) Principles of Finite Element Analysis and Simulation Software A...
3YourMind and Spatial
3 Min read
3D Modeling
As manufacturers begin to rely more and more on additive manufacturing (AM), moving from a few select piece parts that...
Voxeldance and Spatial
2 Min read
3D InterOp
To the uninitiated, 3D printing may seem a simple process — download your CAD file and hit print. But the world of...
BIM_word_cloud_web
2 Min read
3D Modeling
The construction industry has long taken advantage of prebuilt components, from prehung doors to prefabbed roof...
Clash-Detection-fig-1
4 Min read
3D Modeling
A major benefit of constructing a building virtually is the cost savings gained by identifying errors in the design...