Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- Be respectful, on topic and if you see a problem, Flag it.
If you would like to contact our Community Manager personally, feel free to send a private message or an email.
Why OnShape defines a new program language - FeatureScript?
my_cad
Member Posts: 2 ✭
Hi,
Why OnShape defines a new program language? Why not use the formal script language like JS? Seems FeaureScript is not easy to learn for both programmer and engineer. And FeatureScript can not be used out of Onshape. If using JS, at least, some people can easy to start. I would like to know the reason. Thanks!
Why OnShape defines a new program language? Why not use the formal script language like JS? Seems FeaureScript is not easy to learn for both programmer and engineer. And FeatureScript can not be used out of Onshape. If using JS, at least, some people can easy to start. I would like to know the reason. Thanks!
Tagged:
1
Comments
1. Determinism -- regeneration has to happen exactly the same way every time. So we'd have to strip down any existing language to remove external interfaces, randomness, date/time functionality, as well as subtler things like unsorted map iteration and uncontrolled side effects. (See also https://cad.onshape.com/FsDoc/intro.html)
2. Control -- the ability to make decisions regarding the language (e.g., the design of the importing/module/versioning system, error handling) has proven very valuable, as we didn't know all the issues and design decisions we'd run into at the start.
3. Operator overloading -- for working with units and vectors (which are essential to CAD) to have readable syntax, you have to overload operators, which JS does not support. Python and Lua (other languages we considered) do, but Python is more complex than we'd like and relatively few people are familiar with Lua, negating one of the primary benefits.
4. Rollback -- we have to be able to undo portions of the execution efficiently, which makes adapting an existing execution engine very difficult.
What we have found is that it takes most people a couple of full days of working with FS to become familiar with syntax and semantics. After that, writing FS gets much easier and remaining issues are typically around geometry and library familiarity (which wouldn't be any easier in another language).