Blog
Sep 20 2024
MicroStation 2024 - what programming language to choose?
One of the new features in MicroStation 2024 is the support of Python. This news leads to the question, of what languages (and what API), can be used today to develop an own application or macro, and what are their pros and cons?
But, at first, why distinguish between API and language? Often, in the case of MicroStation (as well as other products), there is no (or very little) difference, because the language and API are tight together: When VBA is used, it's used with MicroStation VBA API. But e.g. to develop NET addin, different languages can be used: C#, VB.NET, but more exotic languages are available too (F#, IronPython...). For simplicity, I treat API and language the same, and when more languages can be used with a particular API, I use the most typical or popular.
APIs available in MicroStation 2024 are native (C++), NET (C#), NET/Interop (C#), Python, and VBA.
Every API/language pair offers different features but requires different skills and tools. Because of that, there is no one simple comparison available and there is no one winner.
API | Language | API capabilities | API complexity | Exceptional in | Prerequisites | Good for |
---|---|---|---|---|---|---|
Native | C++ | The primary MicroStation API offers the complete set of features. | High | Deep integration, access to special features | MicroStation SDK, Visual Studio1 | Any development |
NET | C#2 | Close to native API, but some features are missing. | High, but simpler than native API | WPF is great for GUI | MicroStation SDK3, Visual Studio | Any development |
COM Interop | C# | The same as MicroStation VBA. | See VBA | Simple control from another program (e.g. MS Office) | No (everything installed with MicroStation) | Access from other programs and also as a complement to normal NET API |
VBA | VBA | Limited, new features are often not supported. | Low, user friendly | Stability, simple use | No (everything installed with MicroStation) | Macros |
Python | Python | Close to native API, but the first version (MicroStation 20204) does not support everything yet, also bugs exist. | High, similar to native API | Native API features through more user-friendly Python | No (everything installed with MicroStation) | Complex macros |
When the table above does not provide a clear answer, how do you choose what API and language to use in a particular project or is that good to learn?
The basic rule (not only) in software development, but not known to all users, is Choose the right tool for the job. For example, from time to time users ask how to add specific features to their VBA macros and later they complain it is not possible, because not supported by VBA. The problem is not in MicroStation VBA, but in the choice itself: Every project, regardless of its size, requires such analysis to ensure that in the middle of development, it is found that something cannot be done. Of course, the choice is affected by available knowledge, skills, and tools. And maybe the result is "We cannot do that (and we must learn it or hire somebody with required skills)".
Another rule is No size fits all. With increasing project size or complexity, also a probability that one API or tool cannot solve all project requirements. Many mid-size (and bigger) applications are implemented and built using different technologies because they solve specific problems the best. The cost of such solution is an integration, that brings extra complexity, but still can be a better solution than trying to hack a system using not an optimal tool. Tools in MicroStation are often implemented in C++, but GUI is created using WPF, with C++/CLI (a special language, that allows mixing native and managed code) as a glue.
The last rule I'd like to highlight is not the rule per se: To what users a tool is distributed? When the tool is internal, MicroStation VBA or MicroStation Python can be perfectly fine, because it is not important that source codes must be distributed (VBA can be locked, but it solves the problem partially only). To distribute source code (scripts) as a part of boxed software is usually not acceptable. Sometimes authors do not want to share the code, but in my opinion, the much bigger problem is quality and security: It is impossible to ensure functionality when anybody can modify the code.
So, what is my conclusion?
- Learn and use C++ when you choose software development as your career.
- C# is also a good choice but be prepared for surprises when something is not supported. On the other hand, the development process is faster than when C++ is used.
- Python is probably a great "future choice", but now a number of available resources is limited.
- To learn VBA now does not make sense and it is better to choose e.g. C# or Python.
- When you know VBA already, great, but be aware a number of MicroStation features that new features are rarely supported.
- ^ Microsoft Visual Studio Professional or Enterprise are supported by default, but Community edition can be used as well. The version depends on MicroStation version, now it is 2019 or 2022.
- ^ Any language and tool, producing NET Framework 4 assembly, can be used. C# and Visual Studio are the most often used, but VB.NET, F#, or IronPython are other alternatives.
- ^ Technically no SDK is required to developed MicroStation NET addin, because all assemblies are part of MicroStation itself. But without examples and documentation, delivered with SDK, it is impossible to write new code.
Sep 16 2024
Blog restart
One ... two ... three ... and start!