0

I would like to create some libraries in C++, these libraries will be able to model physical phenomena. I would like to build a cross-platform environment where these libraries are updated independent of the GUI, in my case a PC application and a iOS app would be the clients of such libraries.

In terms of performance, easiness to plug C++ code, etc., what would be your recommendation? to generate a C++ classes and call them from other classes with the .mm extension or to generate a framework in c++.

Would you recommend something different to C++ for cross-platform compatibility?

NB: I am not an experienced programmer but trying to get into a decent level.

Thanks, Alejandro

1 Answers1

2

In terms of performance, easiness to plug C++ code, etc., what would be your recommendation? to generate a C++ classes and call them from other classes with the .mm extension or to generate a framework in c++.

It depends on the platforms you are aiming to support, but C++ is pretty well supported, so I think there should be no issues at all. C++ is also pretty low-level, so it will give you all the performance you need.

When it comes to the concept of framework, though, you should beware. Usually, a framework gives you a set of classes which you reuse in several ways. One, possibly the most important way is by subclassing (i.e., you subclass and specify a missing method, or specialize a generic method). You could not really do this, like in: an Objective-C class deriving from a C++ class -- this is not possible (unless you define some kind of wrapper or bridge).

So you would have your C++ framework, that you can extend using C++, and use from other languages, e.g., Objective C.

Would you recommend something different to C++ for cross-platform compatibility?

Again, as above, but C++ is better than other options (Java, e.g., which is not supported on iOS, and less and less supported on MacOS, the major platforms using ObjC). Possibly only C could give you wider portability.

sergio
  • 68,819
  • 11
  • 102
  • 123
  • Sergio, thanks for your prompt answer. So, if I want to program in Xcode for iOS with some codes that I would also use in PC applications, your recommendation would be to generate a framework and include it in Xcode? I am also now clear that C++ (or even C) is the way forward. – Alejandro Primera Jan 12 '13 at 12:43
  • I found this useful link as well with regards to the use of static libraries vs framework. http://stackoverflow.com/questions/6245761/difference-between-framework-and-static-library-in-xcode4-and-how-to-call-them – Alejandro Primera Jan 12 '13 at 14:23
  • Glad to have helped. I think you can use C++ if you are comfortable with it and you will have no problems. Your classes would be packaged as a framework for iOS/Mac and as a static/dynamic library on a PC. Keep in mind that in my answer above, I used the term "framework" in a different way (see here: http://en.wikipedia.org/wiki/Software_framework), not in the cocoa-specific sense of "library packaging". – sergio Jan 12 '13 at 17:29