Competitive Cross-Platform Development? 411
Avalonia asks: "I work for a software company in the oil and gas exploration industry with a software development team of seven. Our software and development environment is cross-platform on Solaris, Irix, Linux and Windows. Most of our customers are on Solaris and Irix 64-bit systems, but Linux and Windows are increasingly important. Our environment is based around an elaborate command-line system of Makefiles controlling four different compilers (gcc 3.1, Sun Forte, Irix MIPSpro and Visual C++ 7). Needless to say, maintaining this system and producing modern multi-threaded C++ that will go through the four build systems is time-consuming in the extreme. A large proportion of our time is spent finding C++ code that just works rather than being creative and competitive with new functionality. What tools and strategies can we use to increase our productivity and regain our competitive advantage, without going for Windows only?"
"Our recent single-platform competitors (Windows only) can seriously outrun us in terms of productivity by using a single modern IDE development environment - such as C++ builder or Visual Studio - although we can scale onto larger multiprocessor Unix systems. With Windows 64-bit imminent we may lose our 'big-iron' scalability advantage. Java is not currently an option for the high-performance numerical and immersive graphical aspect of our applications."
try (Score:3, Insightful)
I think it runs on several of the environments you mention. And I think there are C++ plugins for it.
BC
gcc cross platform? (Score:5, Insightful)
Hrm, this seems too simple an answer, there must be something wrong with it
Re:gcc cross platform? (Score:2)
Haven't checked recently, but is CygWin still being maintained? If it is, then you have GCC available on all four of your platforms, along with the same development libraries and headers.
You may lose some of your "Big Iron" support since you are using GLIBC instead of the native libraries. (but I'm not an expert in this to know what kind of performance hit you may take).
Re:gcc cross platform? (Score:4, Informative)
Re:gcc cross platform? (Score:3, Interesting)
Actually they use an old version of someone else's libraries, I think the Dinkam libraries.
Anyway, I haven't run into any problems with GCC/G++ and GLibC in a while. I think version 3 of the GCC fixed a lot of the standards-related issues, and GCC compiled code is plenty fast. It runs circles around the VC++ compiler.
Re:gcc cross platform? (Score:5, Informative)
We compile using gcc for unix (linux mostly) and Windows using mingw. We cross compile everything from linux and this all works from one Makefile. Recently we even managed to get the NullSoft NSIS installer working under Wine so we can make the install package under linux too.
Once we got all this ironed out we don't really have to worry which platform we are working on - "it all just works". Any developer can compile for every platform too.
We split the design into a server part and a client part. The server part doesn't do anything fancy but the client part of course interfaces with the user. We had flirtations with wxWindows [*]and GTK[*] as cross platform GUIs but in the end we decided to use SDL. SDL is very simple but it really works excellently - our application looks identical down to the last pixel on Windows and Linux. Of course we had to write our own windowing system but that is what C++ is for isn't it
[*] In our experience GTK doesn't work very well under windows, wxWindows is just too different on Windows/Unix and we couldn't (then) afford the licence fee for QT for commercial products. SDL seemed just the answer for us.
Re:gcc cross platform? (Score:4, Informative)
gcc on MIPS-IRIX is just awful. gcc is the least common denominator in terms of performance and just as bad as the others w.r.t. compilerisms and peculiarties. it just so happens that if you ported your code to gcc, it would _compile_ everywhere and run in a degraded state on non-linux-x86 platforms.
so to review:
On Solaris - the sun compiler smokes gcc for c, c++, and fortran code
On IRIX - the SGI C++ compiler is almost a reference for how a good C++ compiler should be done. Oh yeah, its code generation is ideal on MIPS architectures (big surprise). can gcc even emit MIPS4 code yet ?
On Windows - well, msvc is a pretty performant compiler.
Re:gcc cross platform? (Score:2)
I can't speak for the other platforms.
Re:gcc cross platform? (Score:5, Informative)
This message is outdated, possibly reflecting experience with older GCC versions. GCC 3.x is in many ways closer to ISO C++ conformance than MSVC, and it has a new x86 backend that is a big improvement over what we had before.
Sun's C++ compiler generates faster code than GCC for some cases, but slower for other cases. Sun tuned their compiler for the standard benchmarks, you will not see the gains they advertise for other platforms. In the recent pase, Sun regularly has broken binary compatibility in patch releases, leading to no end of problems for us in supporting customers.
If you need Fortran, gcc's Fortran is not great. Also, the ia64 support is immature, you will not get fast code out of gcc for that platform.
Sun, HP, and MSVC are all riddled with compiler bugs of various types; GCC's bugginess is now somewhere in the middle of the pack.
Finally, differences between compilers can often be greatly reduced by simplifying the coding of inner loops. With code that has been given this treatment, we find that Intel's compiler is only about 5% better than gcc on our large codes.
But if you do cross-platform C++, GCC can be a very good choice, as you have one set of front-end compiler bugs to work around instead of five or six.
Gcc? (Score:4, Insightful)
Re:Gcc? Speed. (Score:5, Informative)
Re:Gcc? Speed. (Score:2)
It's amazing how many things you find this way. It actually a good way to find many bugs as well. Since we've been doing this a while we also decided to avoid a lot of the "newer" C++ features and that really helped both speed and portability. (Since not all compilers did STL well for some time)
Re:Gcc? Speed. (Score:2)
Re:Gcc? Speed. (Score:4, Interesting)
You're joking, right? Perhaps I'm a little behind the times, but I was under the impression that GCC used a register based architecture where VC++ uses a stack based architecture. While GCC might spit out some average performing code with the default options, using -O3 will produce very fast running code. I've compared the performance of code compiled with GCC vs. the same program written in assembler, and at its best, GCC is only 50% slower than hand coded assembly, which is very good considering that some very well respected compilers will produce code that is 10 times slower than hand coded assembly.
I've also looked at the assembly language output of VC++, and it's a joke. VC++ often inserts large sections of extraneous instructions into the code. I've managed to follow function calls in VC++, and it is not uncommon for a function call to have prolog and epilog code of several dozen instructions. Interestingly, GCC uses a register based schema, and I can actually follow the code pretty easily, in spite of the fact that it uses the AT&T syntax. GCC just produces cleaner code.
Re:Gcc? Speed. (Score:3, Interesting)
in my experience.
Mingw32 is the target of choice if you don't want
to license Cygwin.
Re:Gcc? (Score:3, Interesting)
- using GCC on Windows is not a problem anymore. I do it often, with no problems, and then you should keep in mind that I'm not very good at this stuff on any platform.
Re:Gcc? (Score:4, Informative)
GCC 3.2 performs MUCH better.
GCC (Score:3, Informative)
Don't write Makefiles yourself. Instead write a script that translates simple build rules (foo.cpp -> foo.o -> foo.exe) into a custom Makefile for each platform. I went this route after battling for years with complex Makefile rules that never quite worked.
Re:GCC (Score:3, Informative)
Don't write Makefiles yourself. Instead write a script that translates simple build rules (foo.cpp -> foo.o -> foo.exe) into a custom Makefile for each platform. I went this route after battling for years with complex Makefile rules that never quite worked.
I'm starting to look into using Cons [dsmit.com] for a cross-platform C/C++ makefile alternative. I haven't used it in a large project yet, but I can definitely get up and running faster than with Make.
GCC/DJGPP (Score:2, Informative)
GCC [gnu.org]
DJGPP [delorie.com]
Re:GCC/DJGPP (Score:2)
...write portable code? (Score:5, Funny)
Re:...write portable code? (Score:2)
Re:...write portable code? (Score:2)
yes, but it might be *very*, *very*, impossible to get manage than non-portable code. Well, there's more experienced minds in here, but I would say atleast maximing the percentage of platform independant code is the path to go. Hehehe, giving advices is just so easy - and fun! :)
Go client/server? (Score:5, Informative)
Communication between the two is probably best through SOAP, although to be honest I've not looked into this area for a long time. The GUI can still be built from Java (I believe Java has some reasonably fast OpenGL wrappers now), or look into wxWindows [wxwindows.org] using the existing C++ resource.
Dave
I've done this! (Score:5, Informative)
If I had to do it again I would do the same thing except I would use python as the 'main, relatively slow, easy to code and maintain' language.
Hajo
Re:I've done this! (Score:2)
Re:I've done this! (Score:2)
Not true: wxPython [wxpython.org]. Sure, it doesn't come bundled with official Python distributions, but wxPython is cross-platform and quite capable, and blows the socks off Tk.
Re:I've done this! (Score:2)
Has anyone else had these problems? I'm thinking it was due to Fink as I've had other subtle problems with Python since I installed it.
Re:I've done this! (Score:2)
But wxPython works very well for win32-linux cross-platform development.
Python, Java, wxWindows (Score:4, Informative)
If you have to use C++, then wxWindows is a great environment: it works on lots of platforms and has extensive support for platform-independent I/O, threading, and networking.
WxWindows and GCC maybe? (Score:5, Informative)
I don't know what you need, but WxWindows and GCC cross-compiling (see mingw32 faq [mingw.org], for instance) might be what you need?
WxWindows also have good bindings to python and perl etc. for more rapid crossplatform development.
Huh? (Score:2)
All Windows productivity oxymoron jokes aside, how do you go from most of your users being on Solaris and Irix to thinking about going Windows only?
Erg...I just saw the second part of the article, after the ad. That was annoying. Maybe it's time to sign up for a subscription.
Primary platform? (Score:4, Insightful)
Another thing would be to standardize on say, gcc. since the source is available, you can do whatever tweaks you need to to get around any performance issues (I know, easier said than done). Then standardize on things like configure.
Without joining any holy wars about language... (Score:4, Interesting)
I would suggest first using gcc on all UN*X platforms, and also trying out something like ant [apache.org] instead of the various forms of make you're dealing with now.
Also, have you considered using a library like Qt [trolltech.com] to handle most of the porting details? It's not free, but it is good if you can deal with it's oddities (I personally consider preprocessing to be evil).
Good luck.
Look several topics down. Design Patterns covers (Score:2, Insightful)
Unfortunately if you are already doing this then you are probably screwed unless someone releases
So many compilers - so little time. (Score:2, Insightful)
Couldn't you just use gcc across all systems? There are also plenty of opensource IDEs around. We use
Eclipse [eclipse.org] along with ClearCase. Very good for cross platform.
Re:So many compilers - so little time. (Score:2)
Re:So many compilers - so little time. (Score:2)
Re:So many compilers - so little time. (Score:2)
Not if you care about performance. Code compiled with a vendor-written compiler like Forte or MIPSpro can be over twice as fast as gcc's. At present, for example, gcc cannot optimize for the MIPS processor family, but SGI's compiler is finely tuned (remember SGI's bread-and-butter is fast compilation).
Remember, gcc is the lowest common denominator. It'll compile you code sure, but that's all it will do, even with -O2. It might do a little better on Linux/x86 because it is the primary compiler on that platform, but I'd be very surprised if VC++ generated code doesn't outperform it, even allowing for the additional overhead of Win32.
This isn't a criticism of gcc, since performance wasn't its design objective, but it does ably illustrate that Open Source isn't always the solution, and commercial software is often better.
ant instead of make? (Score:2, Informative)
Apache Ant [apache.org]
Single compiler _interface_ (Score:2)
With more fundamental issues like differences in the code accepted by different compilers, you can use #ifdefs in the code, which is not elegant but probably much better than makefile hacking.
Some suggested switching to gcc on all platforms, but then others said it might produce slower code. Well, you won't know until you benchmark. It's possible (just) that you might decide to compile most of your object files with gcc, to eliminate most of the compiler-specific hackery, and just compile those parts of the program that are speed-critical using the native compiler. This assumes that the object formats used by gcc and the native compiler are compatible, but in principle there's no reason they shouldn't be. (Perhaps not in practice, but give it a try.)
Numerics in Fortran, Front-end in Java (Score:2, Interesting)
It's very simple. (Score:3, Funny)
Just add more people to your team! Double! Tripple! GO WILD WITH NEW RECRUITS!
Sheeesh, some people never learn...
C++ = Object Orientation? (Score:2, Informative)
Sure you are going to have incompatible concepts across platforms (e.g. Windows doesn't support just unlinking an inode), but I'm sure you can find a happy subset without making too much compromise.
I know Alias|Wavefront uses a very similar concept for their Studio and Maya products. (studio looks and behaves identically on all platforms - so it *is* possible).
I'd be interested in knowning... (Score:5, Insightful)
Even if you feel that Java doesn't cut it for everything, apply the 80/20 rule. 80% of your non-performance critical code in Java, and the later 10& in C/C++. This solution would at least *reduce* your multi-platform woes. You might try posting this on JavaGaming [javagaming.org]. The guys over there are wizards at making Java perform with intensive graphics. (No surprise considering that some of the industries greatest performance experts hang out there.) They can also help you find the APIs you need. I'd really take a second look before you toss Java out as an option.
Re:I'd be interested in knowning... (Score:2)
I like coding in java, you might even say "I want to believe" (in my best X-files voice) but how? People point to stuff like JBuilder, or other commercially built applications by big businesses. Nada. And no, I am not talking about my own applications either, although they be slow, they too...
So give me one good example and tell me how to run it, and I will believe. Noone has, yet.
No problem (Score:5, Insightful)
Step 2. Visit http://www.datadino.com [datadino.com] and click on "Webstart Now!".
Step 3. Right click and save Meat Fighter [bellatlantic.net]. Find where you saved the JAR file and double click.
Step 4. Right click and save Duke Nukes Stuff [dnsalias.com]. Double click on the JAR.
Step 5. Visit jGoodies [jgoodies.com] and try their wide variety of products.
If you are under Linux, I'm afraid the games probably won't perform well. (Little issue with getting X to be configured to handle high speed direct-framebuffer graphics). However, DataDino should work, although you may need to get the installer instead of using the super-cool WebStart link (Mozilla problem only!). If you don't have a database to use, visit the "Supported Databases" page and download the test HSQLDB database.
The plain and simple fact is that Java is fighting two issues:
1. Poorly written apps that give all Java apps a bad name. (For example, "genius" A decides to load a table before releasing the event thread. Table takes 5 minutes to load and user gets annoyed. The solution would have been to load the table in a separate thread so that the user can see and interact with the table items as they are being loaded.)
2. Perceived performance vs. actual performance. People see Swing and the default look and feel and instantly "feel" that the app is slower than windows. Nothing could be farther from the truth. In all reality, it is probably running faster than the Windows app, it just doesn't seem right. This is caused by the Java L&F being way too "flat". Your brain doesn't quite connect the buttons and other objects as being solid objects to be manipulated.
Re:No problem (Score:2)
But I will tell you beforehand, I am not totally buying that explanation (#2)- it would mean that almost every java developer, including old professionals would suck, since I've seen quite a few java apps.
And your point 1. is nothing I recognize at all... but maybe I am just lucky.
Explaination (Score:3, Insightful)
After you visit jGoodies, you should understand more of what I mean.
As for Point #1. I don't know enough about MFC to be 100% sure, but I believe that Windows automatically handles repainting when you are populating complex objects such as tables. (e.g. You'll tend to notice large tables in SQL Server Enterprise Manager paint nothing in the table as you scroll. Instead, you can watch the text filled in after the fact.) Swing (the Java GUI toolkit) requires the programmer to make these optimizations. Why? Because that's who *should* be doing it.
What if for some reason, I want to design a scrollable table that is fast enough when pulling data over dial-up connections? Under Java, I might design it so that the data doesn't display until the user stops scrolling, or I might display partial data. Under MFC, do I have much choice? Not without jumping through a great deal of hoops.
Notice how Microsoft writes new components every time they have a new piece of software (e.g. Office toolbars, Outlook shortcut bar, etc.). They do this to improve performance in their programs. Java programmers shouldn't have to rewrite GUI components, just data models. However, few and far between is the programmer who actually does this.
BTW, another spot you might want to visit is
Swing Sightings [sun.com]. You can find links to all kinds of well written Java programs.
If you'd like to try a Java program that uses native components instead of Java Swing, try Eclipse [eclipse.com]. While I personally don't like it, it should help you understand the perceived problem a little more.
Re:I'd be interested in knowning... (Score:2, Funny)
And throw the remaining 10% out?
Re:I'd be interested in knowning... (Score:2)
The performance of Swing still lags behind native code. We have some Java tools for in house use, I can't bear to make them greater than 30% of the screen size because the refresh rate is too painful.
Maybe there's some aggressive coding techniques that would accelerate things, but if you're not a game developer, your boss won't consider GUI optimization time well spent. The Qt or wx libraries (or even Microsoft Visual Basic(tm)) will give you a snappy feeling application after a few minutes of assisted layout.
JNI is your friend (Score:5, Insightful)
Java isn't an all or nothing deal. You could write your app in Java and then convert the parts that really need performance into C and call it via JNI. Then you only have to deal with keeping a much smaller C library portable.
Re:JNI is your friend (Score:2, Insightful)
Not only that, there may be some merit for the "graphical aspect" of his argument, BUT the "high-performance numerical" part of his argument doesn't hold water.
Java gets a bad rap for being "inefficient". The problem with java, isn't that it is slow, it is that it is so easy to learn that you have people programming in the language that have no business writing computer programs. I have proven time and time again to my peers that I can write code that is AS efficient or in some cases more efficient than comparative C++ programs. The thing is, I'm a java expert, and I know how to tweak things for performance. Any language can be inefficient if the person writing the code doesn't know what they are doing. And quite frankly, very few programmers I've met are at that level.
Re:JNI is your friend (Score:2)
Hint: Your supposed to factor the entire loop out, not just the function calls.
Re:JNI is your friend (Score:2)
Hint: "Your" is actually spelled "You're" - short for "You are", jackass.
Re:JNI is your friend (Score:2)
Simple. Because Java isn't slow and it's better supported under Windows than most Unix scripting languages. Most scripting languages ARE quite slow when it comes down to it. That's fine when we're talking non-performance critical web-apps, but if you are actually talking real-time systems, Java will keep your non-critical code from eating up all the CPU that the critical code needs.
Besides, I'm betting that any project done in Java will end using very little JNI to improve performance.
Use ACE (Score:3, Informative)
Re:Use ACE (Score:2, Informative)
ACE (or Rogue Wave) and gmake (Score:2, Interesting)
I've done this... it works...
Bridge pattern (Score:2)
The GOF book gives an example of using the Bridge pattern to provide a platform-independent interface to a GUI api.
Disclaimer: I don't have any real-world experience with the Bridge pattern, so I can't say how easy it is to make work, or how it performs in performance critical situations.
Hmm... (Score:3, Interesting)
However, java is exactly what you need. You can scale it across processors on the big iron or run it on the desktop without recompiling.
Have you considered only writing your display logic in C++ and using java for the backend number crunching? For raw floating point math, I've read that java is barely slower than native code at this point. It's my understanding that talking to the OS so you can get to the hardware is where you take the major performance hits using java. If you could do your raw crunching in multi-threaded java code, you could then deliver the data through one of many different mechanisms to your display logic and have that be the only code that you need to port from OS to OS...
Another thing you could possibly look at is licensing 3rd party libraries made for cross-platform development. From your post, the only thing I know you're definitely having trouble porting is thread-related code. I'm sure there are multi-platform threading libraries for C++ out there somewhere.
Qt (Score:5, Interesting)
Have you looked at Qt [trolltech.com]? It supports all the platforms you are developing for. It is primarily a platform independent GUI toolkit, but it also got a lot of other stuff like container classes (if you for some reason won't use stl), thread support, sql classes, xml classes and socket classes, all which are platform independent. It is not only just a portable GUI toolkit, I think it is the best GUI toolkit there is. I recommend it even if you're writing for Windows only. If you think of Qt more as a platform than a GUI toolkit, writing applications that run on multiple platforms (with native speed) may be easier than you think. (I'm not an employee of trolltech, although I am wearing a Qt t-shirt as I write this :)
Commercial support: Qt, MKS (Score:2)
MKS Toolkit does a terrific job of integrating a Unix ksh-based CLI with WinNT/2K/XP, and couples closely with IBM DB/2 so that you can run DB/2 UDB scripts as you can under AIX. It is expensive, but worth it if you can afford it.
Qt is a very, very nice cross-platform development library. Another option you could look at used to be Neuron Data's Elements Environment, but they renamed the company (www.blazesoft.com) and I don't know if they still sell EE as a seperate product (Advisor is a repackaging of their rule-base software, which was built on EE.)
There are also the ever-present Rogue Wave class libraries, but I don't think they'll address your GUI requirements. However, if you use it to split out the core application functionality from the presentation (GUI), it might be helpful.
A solid set of macros with compiler/platform detection directives can help a great deal for porting code, though many people prefer to use sed or perl scripts instead (ala config.) Macros have the advantage of dealing with portability more consistently, and localize the changes for platforms to the headers and migration binding code (usually done as a base library.)
Using cross-platform libraries such as xml.apache.org libraries, IBM's ICU (Unicode support), et. al. can also make your code much more portable without requiring extra work after the initial coding.
There are also various open source projects that provide portable thread libraries, portable GUI toolkits, etc.
GCC (Score:2)
I've had some experience doing just that. To date, Qt [trolltech.com] is the most mature of those and will give you uniform access to GUI, networking, threading and even database access for Win32, Unices (including Linux) and MacOS.
If you aren't so worried about GUIs but need to output multimedia contents portably, SDL [libsdl.org] is a viable alternative. The portability of some of the more esoteric components is dubious but SDL has the distinct advantage of being completely free.
As for performance concerns some people have raised about archaic versions of GCC, don't let that stop you-- even if you don't use GCC 3.2 (which produces very good code) the subtle improvement is speed is very rarely worth the greatly increased complexity in development and maintenance.
Besides, with recent GCCs I'm hard-pressed to actually find any significant difference between code generated by it and other compilers (for IA32, anyways, and with all relevant optimizations turned on).
-- MG
Two tips (Score:2)
Nowadays, Qt doesn't just handle GUIs. It also includes networking and threading abstractions, with really nice object oriented interfaces to them.
- Second, think about what IDE features you're looking for. If it's a GUI builder (which seems doubtful, considering that you probably spend a lot more time writing visualization algorithms than dialog boxes), then you could use Qt Designer.
But, if you're more generally interested in project management, integrated debugging, and source browsing, I'd suggest you take a look at Visual SlickEdit (http://www.slickedit.com), which integrates all those features into an amazing, cross-platform IDE/editor.
Good luck!
--JRZ
Java for GUI, C++ for profiled code (Score:2)
Give it a try, that way you can use only one IDE for all of your code (NetBeans, Forte, JBuilder, Visual Age, are all good tools).
X-Platform Strategy C++ (Score:2)
I'm guessing you'll get plenty of suggestions to change your language, which is certainly something to consider if you have that option.
But if you're like me, you don't have that option. You've got a load of C++ that's not simply going to magically transform into Python or Java overnight.
I would suggest the hard road. Boil down supported standard features in the compilers that you can use and tell people to stick to that list unless they can make a case that all of the compilers now support the new feature that they want to use.
Although I feel it is dated now, Netscape used to publish such a guide [mozilla.org] for their developers.
For example, in our early days, we would not permit namespaces or RTTI.
Now, as compilers have gotten more supportive of the ISO C++ standard, we permit those features in our codebase.
But we haven't yet decided to open the floodgates on exception handling, although it's supported pretty broadly.
Finally, you really need an automated build system that runs the latest repository snapshots through the compilers on all the platforms and throws the results up on a web page, like Tinderbox.
That will tend to enforce good standards as developers will see that their check-in attempts fly through with green and no warnings, or get dirty yellow about warnings, or red with downright errors during the build.
Ask the experts! (Score:2, Informative)
Yeah, they had to make their own toolkit (XUL), but I don't know if you need one (it wasn't totally clear from the question).
In particular, check out this helpful document the mozilla team made about writing portable C++ code [mozilla.org].
We don' need no stinkin' tools (Score:2, Interesting)
Program with Java, build with Ant. (Score:3, Interesting)
I'm not going to expound on using Java, since it is fairly ubiquitous these days and if it would work for you, I'm sure you would have already considered it.
Hi Rob (Score:2)
Have you considered java? Sounds insane, I know but Java3D seems to be coming of age and I've seen some pretty impressive large data visualisation demos written in it. It saves you a lot of headaches with cross platform development issues.
I realise that most people think of Java only as a server side technology but Sun has been putting a lot of effort into making it more appealing to the scientific programming community. You should really give it another chance.
Yours truly,
You know who, eh? :-)
You may be surprised... (Score:2)
I have a few words / acronyms...
1. JIT. As in Just-In-Time compilation. Meaning Java software approaches native speed as time goes on.
2. JNI. As in Java Native Interface. Ok, so you have a couple C++ libraries that really have to be as fast as they possibly can be, without necessarily incurring the wrath of the platform demon by being written in assembly. That doesn't mean that the 90% of your code that doesn't vastly effect the performance of your system ALSO has to be written in C++.
3. Silicon. As in what chips are made of. Including chips that run Java. Though these are really targetted at the embedded market, to have your coffee machine run Java or whatever, a high-performance version is available. It plugs into your PCI bus. And runs Java there instead of in the main processor.
Oh, not exactly on-topic, but insert obligatory note of how
Have you tried Java? (Score:2, Interesting)
Go out and download and install Java's sdk [sun.com]. Also, take a look at jama [nist.gov].
Java is not currently an option (Score:3, Insightful)
So what you're saying is:
You've coded it in Java, used native methods where applicable, optimized it, ran it, and it was too slow on every single hardware configuration known to man.
Or are you just guessing?
If you posted on Slashdot hoping we'd help you, give us the details. How "not an option" is it?
My 2 cents (Score:2)
Using TCL you'll have a very compact and clean code.
Java is *so* hard! (Score:2, Funny)
cmake and cygwin (Score:3, Interesting)
as far as tools go, look at cygwin [cygwin.com]. My company uses gnumakefiles on NT and UNIX, with generalized Makefiles for each project, and platform specific build rules in universal gmake include heeaders. We use ACE for a lot of the cross platform C++ stuff, a lot of our things are servers so we avoid the cross platform GUI stuff.
Probatus Spectra SDK (Score:2)
You might want to take a look at Probatus Spectra SDK [spectrasdk.com]. It provides many standard and advanced functionalities, as well as many helpful high-level frameworks for networking, globalization, and so on. A comprehensive cross-platform compatibility layer is an integral feature of the SDK.
You mentioned that you need especially threading. Probatus Spectra SDK provides a very nice cross-platform API for threading. For example, it cross-implements the conditional variables in Unix threads and thread events in Windows.
It also has an excellent build system based on a framework of makefiles that hides all platform-dependent issues.
The currently supported platforms are Linux, Solaris (Forte compiler), HP-UX, IBM AIX, Tru-64 and MS Windows (VC++ and Borland C++ Builder compilers). Both 32- and 64-bit platforms are supported for Solaris,
FLTK and Boost (Score:2)
FLTK - http://www.fltk.org/ - light-weight
cross-platform C++ GUI toolkit with
OpenGL support, etc.
Boost - Portable, peer-reviewed C++ libraries
including threading support, etc.
Better compiler... (Score:2)
I tried Intel's compiler for the first time today on Windows, and it's far superior to the one that comes with VC 6.0... it integrates nicely with the IDE (remember, the IDE is just an IDE, the compiler is a command-line utility) and -- in my case (fourier transforms, MP3 decoding) it produces code that is a LOT faster (though compile time is slower, output is larger...)
Point being, there is no reason (ever) to tie yourself to visual studio. It's a glorified text editor, really, and as long as you keep it that way (stay away from MFC et al) then it won't introduce any problems with cross-platform programming. I personally run a couple of (private) cross-platform projects, and the best advice is to treat code as code. Don't rely on any of VS's magic, just use it as an environment that lets you edit text and compile with the push of the F7 key.
RogueWave (Score:2, Informative)
Abstractions, abstractions, abstractions. (Score:4, Interesting)
This stuff is done for real. At IBM I worked on a very large project that compiled on AIX (several distinct versions that we were sensitive to) Solaris, Windows NT, Linux, HPUX, and supposedly OS/400 although I never actually built the OS/400 piece nor have I seen it operate. First things first, you need good coding conventions, don't let some punk break them either. Secondly you have to design some abstractions and build some foundation classes; or buy a really good set or downlaod some good free ones, I've heard positive things about ACE. This is mostly a problem with windows any more, back a few years you might support win16, win32, PM, and UNIX now it's pretty much just POSIX and Windows. You need to abstract the machine stuff out. Threads, possibly strings and such (Unicode vs. non-unicode..) possibly basic types (big endian vs. little) networking code.. A rule of thumb is that on this kind of project you should never talk to the OS directly without something in between, it's a huge effort to make that OS abstraction layer or learn the ins and outs of an off the shelf one but it's worth it, even if you pay with a little performance. Nothing sucks more than coding away on AIX building some cool classes and adding some cool new stuff, then checking it in and finding that it doesn't compile on any other platforms.. and you've got to figure that crap out ASAP to make a deadline. If you build one from scratch, as IBM usually does or did, you can tune some things for your application; your OS abstraction layer can be a great "helper" or "utility" layer.
Typically well coded C and C++ can go from compiler to compiler pretty easily. Then you can use Pro64 on Mips, ACC on sparc, Intel C on Windows for performance critical portions of code. You have to be smart about it though and use some good conventions. The biggest rule would be avoid MS Visual Studio which is by far the most non-standard setup out there and if you do use it don't use their projects unless you have to. Some good make files with some good rules can help make this pretty easy. I don't know why more people don't do it but look at the Linux kernel's rules file. I have a Rules.make that I've built up and it includes things like different options for debug builds, profiled builds, and optimized builds, sets up some common rules for compiling C++ code and C code and what have you. My makefile include that file and then they are usually pretty short, generally not much more than a list of .cxx files and a library name.
Then it's easy to make sweeping changes too. I think a good build
system, one that will last should usually take a day or two to kind of
put together pretty early on in a project, unless you can carp some
good stuff from another project. The goal is a flexable and reliable
build system that you don't have to worry about. Far too often people
start cobbeling a build system together and then after 6-9 months it's
broken and britle and hard to change because so many things have been
changed and added through out the project. Put some effort in up
front, consolidate your rules in to one place, use some environment
variables to control some build switches. Use some shell scripts to
figure out various things, not hundreds of lines of Bourne shell code,
just little bits. Do this until AAP is ready and rocking and then use
that. Also, if it needs to be said, use GNU Make; it runs damn near
everywhere and it's pretty good at what it does the 15 minutes it
takes to learn it will save you hours and even days worth of time in
the long run.
I'm a huge advocate of a solid and strong build. Mozilla is a project that festered for weeks or maybe even months becuase you couldn't build the damn thing when it went open source. Building code is something that can be done so well by tools that if you're worried about it then you need to fix the build. Building software is hardwork so take the pieces you can out of the equation, the build is the first one.
Next, I assume you've abstracted out the GUI from the meat. If not, make this job one if you wish to have any chance in hell against your one platform competitors or even your mulitplatform competitors when you get down to it. View/Data Model and client/server: learn it, live it, love it. Or switch to a web based interface, lot's of people do it.
While we're on abstraction. If you guys are really serious then you're probably going to have machine specific components. Look at /usr/src/linux/include and /usr/src/linux/arch for a starting point of
reference. I would envision a project like this have a set of small Mips,
Wintel, Linux-x86, etc. directories. Everything else can probably be
compiled with GCC and then in those directories you'd have your
assembly and machine specific compiled code.
Lastly, you want to have a staged check in process. People hate not being able to commit code but at the same time you don't want them to commit code for real until it compiles on all of your platforms. Honestly, I don't know of a really good way to do this. Set up a build lab, do nightlies against the real code. Do nightlies against the "staged" code. Then have some kind of weekly merge meeting. That's how I've seen it, it's time consuming and somewhat painful. You bite off too much and you're spending a shitload of time merging stuff.
Re:Might I suggest... (Score:5, Insightful)
Re:Might I suggest... (Score:2, Interesting)
Platform independent, it's highly creative, and damn if you can't prototype stuff quickly.
P.S. And you can actually understand the code months after you wrote it.
Re:Might I suggest... (Score:3, Insightful)
I would sugest the same thing though. Write your whole app in Python. That's your base. Port each function that needs to be ported to C++. At the end you'll have something much more maintainable.
Re:Might I suggest... (Score:2, Funny)
Re:Might I suggest... (Score:2)
Of course I've never done any graphical programming in Perl (besides Perl/CGI) so I could be wrong depending on the nature of the GUI.
Re:Might I suggest... (Score:2, Insightful)
if all you have is a hammer, eventually everything begins to look like a nail.
Re:Might I *STILL* suggest... (Score:5, Interesting)
As for graphics, there is a QT binding for perl [infonium.com] that will allow you to do cross platform GUI work (and it looks nice, too)
As for speed, making C/C++ plugins for perl is not hard, and if you can break out your high-speed numerical pieces into small bits of code, it's relatively easy to call them from perl.
That said, perl isn't that slow. After you break out a few critical routines into their own XSUB modules, I bet you'd be surprised how fast perl is.
Also, perl 5.8 has very good threading support [perl.org], and it isn't a global mutex around the interpreter like it is with some other interpreted languages.
Re:Might I suggest... (Score:2, Informative)
Re: (Score:2, Funny)
Re:Might I suggest.... (Score:2)
Re:Might I suggest.... (Score:2)
So can we also assume you won't help hunting the deer that have completely overwhelmed the upper midwest due to 'conservation'?
http://datcp.state.wi.us/ah/agriculture/animals/di sease/chronic/faqs.html
Hmm Under "Symptoms", one is said to be "depression". How many of our tax dollars went towards analysis of deer psychology?
Damn bleeding heart liberals.
Re:Select another language (Score:2, Informative)
Leaving you to do interesting stuff _with_ the C++ components, but without having to formulate everything in C++.
Just preempting the "you did not read the post"-posts
Re:www.paulgraham.com (Score:3, Informative)
I don't care so much about Java, but with Python, it's just that a lot of its cool features are also in Lisp, like functions-as-data, classes with metaclasses and the ability to define and change them at runtime, dynamic typing, docstrings, the REPL/interactive prompt, keyword and "rest" arguments to functions, ability to fix bugs without having to stop the running program, ... However, it lacks, for example, macros (don't even try to compare the power and beauty of Lisp macros to the C preprocessor!) and good native code compilers, optional type checking and a variety of free and proprietary implementations all adhering to the same standard.
As for syntax: Both Lisp and Python have the problem that people, esp. newbies, hate their syntax (the parentheses in Lisp and the significant whitespace in Python). Most people eventually get over it and even get to like it. Just because a language doesn't look like C doesn't make it bad.
You are right about the lack of easy-to-find, ready-to-use libraries for common tasks, however (not about the "standardized" part, however. Last I looked there was no Python standard.) There are some projects to change that, for example CLOCC [sourceforge.net], but there's still a long way to go.
IMHO, the single greatest problem Lisp has is non-technical. It is the (wrong) perception that the only data type in Lisp are lists, that there is no OO, or even iteration, that it is interpreted and slow, and generally dead. I'm not interested in forcing anyone to use Lisp, but I for one do like it, and if you are looking for a cool language to learn next, I'd say you definitely should have a look at it.
Re:Qt (or maybe Java) (Score:2)
Re:I do the same (Score:2, Informative)
Check out
http://www.mozilla.org/projects/nspr/about-n
Erm.... No, sorry. (Score:2)
I seriously question whether your claim is true.
I work on a serious cross-platform app at present. We build on something like 15 different platforms, from the latest Metrowerks CodeWarrior on the Mac and VS.NET on Windoze to antiquated HP-UX things and God knows how many Solaris builds.
Today, I wrote a singly linked list class. I wanted it to be generic, so I defined it all using macros. Am I insane? Not at all. Several of our compilers don't support even basic templates properly, and if you look up STL in the help, you'll find no match. You can't get more modern compilers on some of these platforms, and even if we could, we're supplying to other development companies and are constrained to make our code work on whatever compilers they develop with.
I could have written everything much more cleanly using templates, in much less time, or even faster still just used std::list, but then it wouldn't have built on something like half of our compilers. These things get confused when you combine overloading and overriding sometimes (what's the using keyword, anyway?) so more advanced techniques are right out of the Window.
Boost is a fabulous thing. I sincerely hope that several parts of it make the next C++ standard, and fix up some of the glaring gaps in the current one. But while it's intended to be written in standard C++, and as time goes by it will become more widely useful, you could never call the sort of code they use "portable" in an industrial engineering sense at present. Portable amongst recent compilers on popular platforms, yes, but outside that scope, it's an academic toy that is of no practical use.
Re:Visual C++ Everett (Score:3, Interesting)
There will always be compatibility issues... VC.NET is a lot better than VC6 but there are holes, like MS' continued habit of putting underscores in front of 'unix compatible' names (snprintf for example), and calling other things completely differntly (eg. strcasecmp).