Click here to Skip to main content
15,168,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am looking at writing a program for engineering calculations run on either Windows or OS X. I intend it to be used/accessed in MS Word with modules being defined and run from there. The code for calculations could be extensive but I need the interface to be seamless with Word so when the calculations are finished a complete report is ready.

What programming language(s) do you think would make this job the most efficient and good for a UI?
Updated 29-Aug-15 7:57am
PIEBALDconsult 29-Aug-15 12:58pm
Richard MacCutchan 30-Aug-15 4:26am
Language rarely has an effect on efficiency. It is the way the code is written that matters. For Windows you probably need to consider C#, with possibly a mathematical DLL in C++ for the complex calculations. I'm not sure about OSX but I think there is a port of .NET that runs on it.
Sergey Alexandrovich Kryukov 30-Aug-15 11:41am
Yes, .NET can be used with Mono. I've done one compatibility project with Windows and Mac OS X. It's not always easy, and is especially ugly thing for Mac OS X, but mostly because of different UI style of Mac (such as common menu object on top), so the Windows-compatible product looks totally foreign on Mac (but working); and you probably know that Mac is very hostile to "foreigners" (in contrast to say, most modern Linux distro, where such cross-platform Mono products work just fine).

Even with Mac OS X, Mono project can be developed with Mac-native UI library through such product as MonobjC (take a look, it's very interesting), or combine Mono-style and Mac style UI, but then there is no talking about Windows compatibility.

I wrote this mostly as an addition to my very detailed Solution 1. I'll credit your comment...


1 solution

This is not about language, but about technology.

Why? First of all, you need to realize one important thing you don't seem to realize: no executable module can run natively on both Windows and Mac OS X. Key word here is natively. I mean, you need to understand how programming of native code is done: you can develop some program and compile/link it, get binary code written in CPU instructions, executable module. Then, having some OS, in its core installation, without any additional layers, you can take your compiled code and copy on this system. It will work only if the code is targeted to a compatible OS.

For example, you can develop Windows code which will run on several different Windows versions. But not on Mac OS X. And visa versa. Even of you target identical CPU and those are exact the same CPU uses on both OS. In this aspect, these OS have nothing in common. The code will need recompilation. And even then it cannot be incompatible, due to different platform API. Only the simplest console-only code could be recompiled directly for two platforms to run natively. And yet, cross-platform development, being problematic, is still possible. You need some abstraction layers on both systems, some platforms developed separately and ported on both systems. Your code should be developed for this abstraction layer, not specifically for core OS.

See also the comment to the question by Richard MacCutchan.
So, we need to discuss some non-native approach to cross-platform programming.

Non-native: P-code

First of all, let's explore non-native possibilities. I would classify them into two major approaches: system working with p-code ("byte code") and systems working with scripting (interpretive) languages. You can find the information on the systems based on p-code here:[^].

By far, two most widely used systems are JVM and CLR. JVM is implemented for nearly all modern OS, and CLR is represented by .NET and Mono for Windows, and Mono for Mac OS X. The flagship languages are Java and C#, but there is a big set of different languages giving equivalent p-code, Java byte code for JVM or CIL of CLR. Please see:[^],[^],[^];[^],[^],[^],[^].

The issues of compatibilities between implementations of these platforms for different OS could be a topic of endless dis discussions, but generally, if you write your code in cross-platform manner, not directly using any OS-specific features, you will get the programs which can be directly executed on different OS, without recompilation.

Non-native: scripting

Now, let's discuss the technologies using scripting based on interpreted languages:[^].
As you can see, there are too many of them, to many to review any here. Except just one: JavaScript. Why? As you should understand, the abstraction layer in this case would be some run-time engine interpreting and executing the code. There is just one engine used on all general-purpose OS: JavaScript engine embedded on browsers. Can you do general software development bases on this? Yes, of course. One common misconception is that JavaScript and the browser itself is only for Web. This is not so: you can develop and run code totally independent from Web. After all, look at a couple of examples in two my articles:
Tetris on Canvas[^],
JavaScript Calculator[^].

The "Web factor" is the most powerful factor which lead to the states of affairs where JavaScript is the most stable and standardized language in this class of products:[^].

Two interesting examples not based on just the common-use browsers are, say, Chrome OS and Apache Cordova:[^] (sorry that this example is unrelated to both Windows and Mac),[^],[^].

One of the limitation is file storage I/O, but this problem is solvable:[^],[^].

Native: recompilation, OS and UI abstraction-layer libraries

And finally, let's quickly explore the compiled language compiling in native code. The abstraction layer in this case will be some OS abstraction layer, which mostly should cover one thing most problematic in terms of compatibility: the UI. This abstraction layer can be just the library with the same API implemented on both OS.

Again, its impossible to discuss all possibilities, but I would emphasize just two: Free Pascal and C++.

Free Pascal is open-source and can be developed with the IDE implemented on many platforms, Lazarus. And Lazarus comes with excellent cross-platform UI library. Please see:[^],[^].

This is my favorite example of such cross-platform product, still in beta and active development. You can enjoy it even now; it's actually very useful:[^],[^].

And, finally, about the cross-platform development in C++; please see my past answers:
Visual Studio Application for Target OS Windows and Linux[^],
How to Compile Visual studio C++ to linux and os-mac[^],
What`s the Problem with this Plot Program win32[^],
writing c/c++ visual programs (cross-platform) with which IDE and compiler?[^.

Good luck,

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900