Number of OSGeo stack software written by C/C++ camp have to run on Microsoft Windows systems. I think I wouldn’t be dead wrong if said that most of hackers from OSGeo Community work on Unix systems (Linux, Mac OS X) but there is large number of users who work on Windows.
Conclusion? Portability. Google is bursting at the seams of the essays about how to write portable code in C or C++ language. I’d add a little poem to the collection.
Principles of Portability
- Obey the standards, because they are not just dumb rules.
- Make a list of compilers that must be supported. Learn about their differences.
- If possible, use GCC 4+ and Visual C++ 7.1+.
- Using old compilers? If possible, use C89 but avoid C99.
- Prefer GCC 4.3 and Visual C++ 8.0+, so you get C++0x support. C++0x “brings C++ more in line with the C99″ – Wikipedia, so portability is much easier.
- Write code in C or in C++, but do not write both at the same time.
- Avoid (direct) use of C POSIX Library.
- Never ever disable any warnings compiler throw. Fix them.
- Be pedantic. Compile in highest strict mode possible.
- If possible, do not use compiler-specific features.
- Do not make platform/architecture specific assumptions about memory addressing, memory layout, etc.
- First understand why, then cast the hack.
- Personal preferences are evil. Make decisions based on reasoning.
- (Re)Use good code that already exist. Boost C++ Libraries won’t bite you!
- KIMS (Keep it modular, stupid) and let modules to loose coupling but keep cohesion in architecture, design as well as in development cycle (releases, inter-modular dependencies).
Or you could move to Java, my students have hardly any problems running GeoServer and uDig on any of the variety of OS and machines they have.
Ian,
Java is implemented in C++ – http://openjdk.java.net/
C/C++ code is portable. C/C++ compiled programs are not portable. Java solves this problem. Java itself is as portable as C++ language. If there is an OS that has no C++ compiler, you can forget about running Java on it – so, where’s the glorious portability of Java?
Portability of Java means you install JVM dedicated for your system and architecture
IMO, it’s not very different to replacing operating system or installing it under VM.
OS1 + Java ~= OS1 + VM + OS2
GeoServer and uDig are only two of large number of products. Are we going to reimplement GDAL, GEOS, PostGIS, etc. in Java? I don’t think so, unless somebody puts zillinons of #pound; on the table.Thus, we have to take care of writing C/C++ codes in portable way.
Java is not a magic cure for all problems of portability. It introduces new problems and brings old ones back.
Simply, Java is not an option. It’s far easier to take care of writing portable code (it is possible, unless hacker is an ignorant), than rewriting existing software to Java.