VB vs C++ for NXOpen

Hi all,

My company has a lot of custom buttons in NX10 that are all written in VB.

I am now writing and performing upkeep for all buttons/functions that are intended for my dept.

I have a working knowledge of VB and C++ and I was just wondering what people think about the 2 languages for NXOpen? I have noticed that there is probably 10 times more online literature and examples in VB for NXOpen but as a language I prefer C++

Is there a benefit/drawback to trying to move to C++ for our custom user functions and buttons beyond just using the language you prefer?

Any thoughts would be much appreciated, especially from anyone who writes C++ NXOpen code

Nick

Well for one thing C++ cannot be compiled as journal. Not sure if you knew that already. If However, you have the option to compile your code then there are quite a few advantages to C++. From the Docs, here are some:

"
Some of the benefits of Open C++ are:

• Open C++ uses standard C++ syntax, which often results in more concise and readable application code.

• Open C++ objects are referenced via pointers to C++ objects rather than tags, which is a more natural and expressive programming style.

• Open C++ reports errors via the C++ Exception mechanism, which allows you to localize your error handling in a few places and avoids having to explicitly check error codes returned from individual function calls.

• Open C++ is strongly typed, which means that any attempt to invoke a function on an inappropriate NX object is caught by the C++ compiler rather than resulting in a run-time error.

• Open C++ takes advantage of C++ encapsulation to make it easier for you to identify the set of functions relevant to a particular type of NX object.

• Open C++ provides a framework for defining new classes of objects using standard C++ inheritance, enabling your derived class to override virtual methods that allow the user to define what NX operations such as Update mean for the new object.

• Open C++ can be used in combination with traditional Open C function calls, allowing objects created in Open C++ to be accessed in Open C, and vice versa.

• Open C++ provides context-managed creation of NX objects by specifying the owning part in every create method.

• Open C++ unifies the evaluation and inquiry of curves and edges, allowing you to write code without special case branches for wireframe curves and solid edges.

• Open C++ provides ease of editing objects without the inconvenience of inquiring if the object is a prototype or an occurrence.

Open C++ sits on top of the Open C library and provides a relatively thin C++ interface layer on top of traditional Open C. Open C++ actually consists of two libraries: the openpp library provides access to NX objects and functionality, while the vmathpp library contains a vector math package that provides general purpose mathematical operations.

Open C++ applications can be written as either internal or external applications. An internal application is a shared library on UNIX or a Dynamic Linked Library on Windows NT and can be executed during an interactive NX session. An external application is an executable file that executes stand-alone, outside an NX session.
"

Now some down sides to using C++ (just my opinions):

VB is user friendly and easier to edit. If for whatever reason somebody besides yourself is required to make amendments to your C++ code, and they only know VB (usually the case), then it will be that much harder to edit the code for there purposes.

I prefer C++ myself. However I don't write in C++ just for that reason. Most of my co-workers are not programmers, but have dabbled in VB at some point in there career (usually the case if you are using Office applications). So, if I am on vacation, and my coworkers need to change some source code, they won't be able to figure out. Just something to keep in mind.

I would recommend using C++ for NX/Open programming only if you already know the language pretty well and don't know any other language. It's a hugely complex language that gives you all kinds of freedom to shoot yourself in the foot.

I think VB is pretty good. It has most of the benefits claimed for C++ (like encapsulation, strong typing, exceptions). If you just don't like the syntax of VB, you can try C#, which is (some would say) C++ with all the legacy junk removed.

Open C++ uses standard C++ syntax, which often results in more concise and readable application code.

Concise -- maybe. Readable -- no way, unless you're already familiar with C++.

Open C++ objects are referenced via pointers to C++ objects rather than tags, which is a more natural and expressive programming style.

I don't think there is anything "natural" about pointers. VB uses object variables. Only old NX/Open.UF functions use tags.

Open C++ reports errors via the C++ Exception mechanism

VB also uses structured exception handling.

Open C++ is strongly typed,

Very few people would regard C++ as strongly typed. VB is strongly typed unless you turn off the strong typing.

Open C++ takes advantage of C++ encapsulation

VB is also object-oriented

Open C++ provides a framework for defining new classes of objects using standard C++ inheritance

VB supports inheritance, too, though not multiple inheritance. But you can't inherit from most NX classes, anyway.

Open C++ can be used in combination with traditional Open C function calls, allowing objects created in Open C++ to be accessed in Open C, and vice versa.

Same is true of VB. That's what the NXOpen.UF class is for.

Open C++ provides context-managed creation of NX objects by specifying the owning part in every create method.

That's certainly a difference. I'm not convinced that it's a benefit, though.

I write most of my code in either C# or VB. I don't use C++ very much because I think it's far too complex and weird. But, generally speaking, the best language for you is the one you're most familiar with.

VB (and C#) give you access to the SNAP library, which makes simple tasks simple.