Portable Coding and Cross-Platform Libraries?
Bradee-oh! queries: "My brother and I were just commissioned to develop a large energy management system for a few big college campuses in the area. It will be written in C/C++. We know that in 6 months, when a preliminary test system will be installed, it will be running on NT/2000 servers. The software will be tested on NT for up to 12 months and a final version will run on NT a year after that. We also know that around that time, it will shift to *nix servers, and we're expected to account for that in development. The question is, what sorts of cross platform libraries will make this as painless as possible? I've never made it a point to code for 2 platforms at once in any language other that Java. Aside from the GUI, which we've already agreed to use QT 3.0 for, we specifically are looking for cross-platform libraries for multi-threading, serial port I/O, and network I/O."
"Ideal libraries would be open source and free, though those aren't as important as tested/stable/reliable. What are your recommendations? Anyone have experience writing for multiple platforms at once with threading, serial I/O, and network I/O all in mind? The ideal scenario would be to recompile on the new platform without changing a line of code - will this type of portability be possible?"
You have the answer : Java has all what you need.
From www.imatix.com (The makers of the Xitami webserver).
SFL is a great library for doing portable low-level stuff such as network etc..
The GNU Compiler (gcc/g++) runs on so many platforms so it should solve a lot of portability issues. CommonC++ is a GNU library for threading and I also believe it can handle network IO.
Now, I always heard that NT is supposedly Posix compliant so it might not be terribly difficult...
int func(int a);
func((b += 3, b));
ACE is an open-source framework that provides many components and patterns for developing high-performance, distributed real-time and embedded systems. ACE provides powerful, yet efficient abstractions for sockets, demultiplexing loops, threads, synchronization primitives.
I've never tested this framework but it seems very good. I know several companies which use it and which are happy with it.
i think there is a port for windows also of gcc and maybe g++ (not very sure).
you may wanna check this side right here(djgpp)
If it would be possible, this would be a natural for Boarland's Delphi & Kylix. Kylix compile Linux executables which will also run on the *BSDs. Delphi does Windows. With both, you write one code set and compile for the platform.
Do you have a compelling reason not to use Java in this case ? It would seem to provide everything you require.
Even just writing portable C++ code can be tricky, especially if one of the target platforms is Microsoft.
QT covers the multi-threading and network stuff so you're down to just serial port stuff aren't you. If you use QT properly then you should be fairly ok.
Your choice of Qt is a good start, but be sure to use GCC, all open source libs that exist on both sides, and adhere as closely to the ANSI standard as you can. If you do the footwork now and gather the libs and other files needed now for both sides AND keep cross compiling on both platforms as you go.
Dont think you can make it under NT and then 2 years later that it will compile on *Nix magically, you need to test every step of the way.
Oh and be sure you have the libs that are identical for both platforms and freeze them before you start. nothing kills a cross platform project faster then changing libs and finding later that the libs you built for on platform X are no-longer compatable with platformY's libs.
Do not look at laser with remaining good eye.
Lookup ACE on yahoo, adaptive communication environment (or something like that).
Got all sorts of CP junk
The question is begging, and I'm surprised a troll hasn't nailed it yet. Why start on NT and port to Unix, especially in light of MS's recent vow to hide security holes instead of fix them?
For an energy management system, security should always be a prime factor in any design. I'm not trying to smash down NT as an insecure system, but given the sheer number of factors you simply may not be able to account for, is this tactic wise?
I'm curious to know how long the security debate was in choosing NT devel first over Unix.
- billn
Java sounds like a much better choice given the planned OS switch.
.NET should be ported to *nix by then (hasn't the IL part of it already been done?) so I'd seriously consider that too.
Alternatively
wxWindows (http://www.wxWindows.org) supports quite a few platforms, is open-source, has been developing since 1992, and might be probably exactly what you're looking for.
Perhaps you should take a step back and ask "Why is this needing to be cross platform in the first place?"
There are cross platform libraries around. You may wish to just roll your own, but I would suggest constantly testing against your *nix machines throughout development to ensure compatibility.
One thing you *don't* want to do is start testing against other OSs six months into development. Do it every day, and develop a regression test suite.
Ash OS durbatulk, ash OS gimbatul, ash OS thrakatulk, agh burzum-ishi krimpatul! Uzg-MS-ishi amal fauthut burgulli.
I realise that the STL isn't on the same level of cross-platform libraries that you were referring to, but it does aleviate some problems - and it's damn efficient too. Stream's, the way the STL uses them, can be quite an effective way of abstracting I/O.
The biggest two problems we had was threading, and serial I/O. Threading, thanks to NT's posix libraries, wasn't that much of a pain - but we did need to write our own thread interface classes, one NT specific and one unix specific. Serial I/O was a little more tricky, but both came down to the same basic approach of treating the serial ports as files.
I think the conclusion we came to was that it was a good idea to highlight the major differences first, and create your own wrapper classes around the OS specific methods. This way your main program is platform independant, and porting is kept to the wrapper classes.
And of course, if you use the Cygwin environment, you shouldn't have any problems at all porting to another GCC platform.
Only one warning: watch out for tricky C++ template uses, not all compilers support all features (e.g. Visual C++ lacks partial template specialisation amongst other useful features).
Check Netscape Portable Runtime, (just one of the many projects that are part of Mozilla. This library provide cross-platform threading, IPC, network/file IO, and dynamic linking, among other things.
Insist on coding to the target platform. The target platform appears to be *nix, so insist on coding to that.
This sounds like a decision made by somebody who doesn't know what they're doing (when they're not looking I like to call them stupid but you don't have to.) It is part of the job description for software engineer, even if it isn't specified in any contract, that you are responsible for advising management whenever they exhibit dimwitted behavior.
Life is too short to be bending over backwards to accommodate another's failings.
Is this truly the only Earth I can live on?
would be a good place to start for the threading and networking parts. from what i've seen, it looks like a well engeneered package (and you'll have a hard time finding a better tested library :-).
http://apr.apache.org/
Acts@core.mailboks.com Acrux@core.mailboks.com Adam@core.mailboks.com Adar@core.mailboks.com Ada@core.mailboks.com
NSPR is used in the Mozilla browser for x-platform threads and network/file I/O. It should basically cover all your needs, besides serial port I/O i guess.
You may have a look at their homepage: http://www.mozilla.org/projects/nspr/
Well if you are using qt for GUI why not use the
qt 3.0 network tools.
se the doc for qt 3.0 http://doc.trolltech.com/3.0/
I know that there is no IO mod but g++ have som you can use!
What rimes on recursion What rimes on recursion What rimes on recursion What rimes on recursion
Mozilla.org uses NSPR (Netscape Portable Runtime)
From the about page
NSPR provides platform independence for non-GUI operating system facilities. These facilities include threads, thread synchronization, normal file and network I/O, interval timing and calendar time, basic memory management (malloc and free) and shared library linking.
You can find more information here http://www.mozilla.org/projects/nspr/index.html
You need SourcePro from Rogue Wave, formerly Threads.h++ etc. It provides a high level, easy to use C++ API for cross platform application development. Even if you're not going cross platform, the Rogue Wave stuff is excellent, provides loads of useful classes for threading, database access, network protocol handling and more.
subj. is very powerful library, we use it for very large projects in our company and I also know that Israely Army is using it very extensively, it gives you totally portable IPC, Networking and a few less important services as well
Writing cross platform GUI applications is hard. Writing cross platform GUI applications with multithreading and network stuff is very hard, but most of all hard to get right.
Hard = difficult = long = costly.
The question is, is the cost worth it? This application, from what you're telling us, is going to run on a few dozen computers at most. It's not a general purpose app, there is no added value in providing cross platform support.
Why switch platforms in the end? It doesn't make any sense.
But to answer your question, if Windows is really a transitional system, I would just develop on *nix, and run it on Windows with Cygwin. Might be even simpler to use XFree/Cygwin.
I was under the -- perhaps misguided -- impression that Win NT offers a POSIX subsystem. Combined with Qt (which does threads, IIRC), the serial port access is covered by POSIX, and network APIs are like UNIX (give or take a WSAStartup()/WSACleanup()).
Why not write the whole thing in Delphi, which is -apparently- source-code compatible with Kylix. All you need to do then is recompile...
If an experiment works, something has gone wrong.
I'm not sure what you mean by "Energy Management System", but if the interface isn't heavily interactive, I'd go with a browser front-end. If you can, use Mozilla and XUL. It allows you to build really nice interfaces easily.
Browser-based apps aren't going to replace everything. Highly interactive things like word-processors, spreadsheets, etc. aren't suitable for browsers, but if the interface is form-based I think it's the way to go.
The obvious advantage in your case is that the interface code is painlessly cross-platform. You still have to worry about lower level stuff, but that's much easier to do properly if you eliminate the GUI.
It is tempting, if the only tool you have is a hammer, to treat everything as if it were a nail. - Abraham Maslow
We have a cross-platform multithreaded C++ application, and invested quite a bit of research to get it working on FreeBSD, Unix and WinNT (2K)
+ +/ )
Basically, you will need these libraries:
STL - STLPort ( www.stlport.org )
Threads - QPThreads ( http://freshmeat.net/projects/qpthreadlibraryforc
That will give you a cross-platform STL, threading, and synchronisation primitives.
Some people within our project use the ACE library for multi-threading. Personally I have no expericene with the ACS library. They've used it for its portability. At the time some software was being developed it was not clear weather the software had to run on Linux or VxWorks, hence ACE. Quick search on google gave me: http://www.cs.wustl.edu/~schmidt/ACE.html
While cross-platform libraries will help, some things just work differently on different platforms, and you're unlikely to find a library covering everything so that all it takes is a rebuild to port.
As an alternative strategy, and one that's often easier in practice, I suggest you adopt the old programming rule of thumb: isolate anything platform specific in your code. If you're developing using C++, for example, define interfaces (probably via abstract base classes or in terms of templates) that represent the low-level functionality for serial comms, threading or whatever. Write all your higher level code in terms of those interfaces.
Then you just need to write the implementation behind them for each platform. This may be as simple as writing a few inline forwarding functions if your platform provides native APIs to do what you want. (Obviously I'm including any platform-specific or cross-platform libraries you have in the term "APIs", not just OS-provided functionality.) If, for any particular platform or library, there isn't a direct API to do what your interface requires, you can write a more complex routine in your implementation using the APIs that are available. It will still be isolated from the rest of your code, and nothing higher-level should need changing (or, hopefully, even rebuilding).
If you adopt this approach, the vast majority of your code will probably be 100% portable, because all it depends on is your own "middle level" APIs. Those can be implemented in whatever way is most convenient on a given platform, which might still include writing them in terms of a cross-platform library. The key thing is that most of your code isn't tied to anything platform-specific at all this way, and as such is immediately portable anywhere as long as your middle-level interfaces are sensible -- which they will be, of course, since you wrote them. ;-)
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
Uh, yeah, this sounds like a *real* question: I want to develop a GUI application for *NIX, but I want to develop it on Win2k.
In addition, you can get security, high availabilty, and scaleability with far less effort and platform-dependence than a C/C++ solution.
Are you being forced to use C/C++ simply because of QT? Have you considered using QT in conjunction with Trolltech's QT AWT?
... yet you don't know how to deal with this problem. Impressive.
I don't have a great deal of personal experience with this, but at the last place I worked they had used Rogue Wave's Stingray Objective Toolkit as a cross-platform library for NT and Solaris.
I've heard bad things about it; I've heard good things about it. I couldn't comment either way.
I can't find it on their site now that I look, but I did find this: SourcePro, which looks similar. They change the names of the products on a regular basis.
It seems to me that you're looking to prototype on the NT platform, and construct the production environment on Unix. Tcl/TK is a wonderful tool that promotes rapid application development, and multi-platform (nt,unix, mac, etc). Whether you're aware of it or not, all of the major industry players have been using Tcl/tk in their products, Oracle with oratclsh, IBM with wscp (their tcl/tk interface to websphere), Vignette with the tcl/tk interface. Also, considering that Ajuba has placed TclPro in the open-source community, you can DL the Unix & NT version's for free. The really nice features of TclPro, is that it contains the tclcompiler (to byte-compile your tcl/tk code), and the tclwrapper (to wrap your code into a binary executable). Most of Tcl/Tk's libraries are cross-platform, though there are specific's to both arena's, (i.e. IPC on Unix & Registry calls on NT).
I'd suggest you start with modeling the product in Tcl/TK on the NT platform, ensuring you don't reference any NT specifics. Once you're happy with the model. Copy the code to your Unix system, confirm it still runs, then compile it up into a binary executable for distribution. BTW, there's some nice GUI IDE tools available for Tcl/Tk, I'm rather fond of SpecTcl, a GUI for building graphical user interfaces, that will also produce java & html output.
Good Luck!
I came across this win32 pthread library the other day. I haven't used it, or really read anything about it, but it's from Cygnus, so I imagine it is at least semi-decent. Good luck.
http://sources.redhat.com/pthreads-win32/
Aside from not being C, Java is the best choice for the following reasons -
1. Superior Portability
2. Stability
3. Easiest way to multi-thread.
4. Good database connectivity.
Some people said that Java is slow. But it is actually not if you are programming with good design and skills.
Have a look at ACE. It provides all you'll need - and probably a lot more!
For a simple, free, portable threading library, also have a look at OmniThread.
This article is another attempt to subversively convert more straight Slashdot readers into slashbots - homo toyboys, kept around for CmdrTaco's sexual forfillment. Let's examine the article and see why this insidious Open Sauce movement must be stopped at all costs: "My brother and I were just commissioned to develop a large energy management system" In other words, Cowboikneel and CmdrTaco get tired after too little anal sex and need a more effective system to manage their energy. This is no doubt due to them both being fat homosexual geeks. The only cure is to go outside, breathe the fresh air, excercise regularly, and stop taking men up the ass. "Aside from the GUI, which we've already agreed to use QT 3.0 for" Ever since qt was released under the GPL (Gay Penetration License), CmdrTaco's toy boys have been using qt more and more. qt, or Queer Technology as it is now known, was strictly forbidden before, as it did not allow RMS to have Gay Penetration with his Free Software ("Software" is a term for underwear designed for easy removal). It is a major loss for the straight community that qt has now 'come out' under the GPL. We must strive to find a straight replacement. "we specifically are looking for cross-platform libraries for multi-threading, serial port I/O, and network I/O." cross-platform, as I've already documented elsewhere is a term used to describe any object which will fit in CmdrTaco's, Cowboikneel's, and Homos's ass. It is truly a disgusting phrase. multi-threading refers to the homosexual practice of inserting more than one object up a gay lover's anus. The anus has to support multithreading for this to be possible. Cowboikneel has always supported this, due to the enhanced size of his O-ring. CmdrTaco has not always supported multithreading, but after being impaled on Homos's huge cock multiple times, he has now managed to support it. 'serial port I/O' refers to the sick practice of in-line Gay Penetration. Because of the nature of this task, each lover must hold a Gay Penetration License. in-line Gay Penetration means Homos taking CmdrTaco who in turn takes Cowboikneel, who continues the line of homosexuality. Many homos will join the line. The record line length is two hundread and fifty seven lovers! RMS and ESR were involved, of course, as well as many other prominent Open Sauce leaders. The nature of 'network I/O' is not known to me at this time. Although the intelligence gathering methods used to undermine the homopocalipse revolution are very advanced, no one has dared to enter a orgy in which 'network I/O' is going on and thus cannot give us more information as to the nature of this dark and sinister threat to our sexuality. Anyone who holds information on this matter is encouraged to let us know, even if it means putting their anal virginity at stake. This threat is of the highest importance and we must learn more about it. In conclusion, The homopocalipse, which was once thought to be merely a figment of RMS's imagination, is now very very real. We must work persistently and diligently if we are to destroy this threat once and for all. Until such a time as a straight man may once again walk with pride, and not fear being taken up the arse by rabid slashbots, armed with cross-platform dildos, we must excercise caution. Do not trust anyone. Do not believe what you read on slashdot. Treat everything and everyone with suspicion. I must go now, I fear the slashbots have discovered the hiding place from which I am transmitting this warning. If I do not make it out of here and to safety, please continue my work. Do not rest until slashdot is free of RMS and his homosexual minions. I will go now.
You may know about libSDL on Linux, which has been used in many Linux games. Loki has also succesfully ported across several Windows games to it. Don't be fooled by the name "Simple DirectMedia Library": Simple doesn't imply 'restricted', and 'DirectMedia' doesn't mean that only abstracts multimedia capabilities.
libSDL is a cross-platform library which supports not only video and audio, but also threads and timers. There are also plenty of support libraries for it -- including a cross-platform networking library that works on Linux, Windows, MacOS and BeOS. There's plenty of example programs for you to work with, it's open-source, and perhaps most importantly, it is mature and tested. The only downfall of it is that you'll have to track down the documentation for it, but there are plenty of SDL gurus around if you know where to look (the SDL mailing list is a great start). The SDL homepage itself also has links to other similar ambitious libraries, such as clanlib, if you don't like it. I definitely recommend that you check it out.
- #ozone
Apart from the useful advice offered re portable libraries, gcc etc, make sure you do *daily* builds on each target platform from day 1 of implementation. Don't rely on a big bang port in 12 months time.
Great Windows SFTP Server!
Have a look at nutcracker. It's changed it's name recently but the product's been around forever. It will give you a consistant API for Windows/*IX development in C/C++/Fortran/Ada/COBOL
This article is another attempt to subversively convert more straight Slashdot readers into slashbots - homo toyboys, kept around for CmdrTaco's sexual forfillment. Let's examine the article and see why this insidious Open Sauce movement must be stopped at all costs:
"My brother and I were just commissioned to develop a large energy management system"
In other words, Cowboikneel and CmdrTaco get tired after too little anal sex and need a more effective system to manage their energy. This is no doubt due to them both being fat homosexual geeks. The only cure is to go outside, breathe the fresh air, excercise regularly, and stop taking men up the ass.
"Aside from the GUI, which we've already agreed to use QT 3.0 for"
Ever since qt was released under the GPL (Gay Penetration License), CmdrTaco's toy boys have been using qt more and more. qt, or Queer Technology as it is now known, was strictly forbidden before, as it did not allow RMS to have Gay Penetration with his Free Software ("Software" is a term for underwear designed for easy removal). It is a major loss for the straight community that qt has now 'come out' under the GPL. We must strive to find a straight replacement.
"we specifically are looking for cross-platform libraries for multi-threading, serial port I/O, and network I/O."
cross-platform, as I've already documented elsewhere is a term used to describe any object which will fit in CmdrTaco's, Cowboikneel's, and Homos's ass. It is truly a disgusting phrase.
multi-threading refers to the homosexual practice of inserting more than one object up a gay lover's anus. The anus has to support multithreading for this to be possible. Cowboikneel has always supported this, due to the enhanced size of his O-ring. CmdrTaco has not always supported multithreading, but after being impaled on Homos's huge cock multiple times, he has now managed to support it.
'serial port I/O' refers to the sick practice of in-line Gay Penetration. Because of the nature of this task, each lover must hold a Gay Penetration License. in-line Gay Penetration means Homos taking CmdrTaco who in turn takes Cowboikneel, who continues the line of homosexuality. Many homos will join the line. The record line length is two hundread and fifty seven lovers! RMS and ESR were involved, of course, as well as many other prominent Open Sauce leaders.
The nature of 'network I/O' is not known to me at this time. Although the intelligence gathering methods used to undermine the homopocalipse revolution are very advanced, no one has dared to enter a orgy in which 'network I/O' is going on and thus cannot give us more information as to the nature of this dark and sinister threat to our sexuality. Anyone who holds information on this matter is encouraged to let us know, even if it means putting their anal virginity at stake. This threat is of the highest importance and we must learn more about it.
In conclusion, The homopocalipse, which was once thought to be merely a figment of RMS's imagination, is now very very real. We must work persistently and diligently if we are to destroy this threat once and for all. Until such a time as a straight man may once again walk with pride, and not fear being taken up the arse by rabid slashbots, armed with cross-platform dildos, we must excercise caution. Do not trust anyone. Do not believe what you read on slashdot. Treat everything and everyone with suspicion. I must go now, I fear the slashbots have discovered the hiding place from which I am transmitting this warning. If I do not make it out of here and to safety, please continue my work. Do not rest until slashdot is free of RMS and his homosexual minions. I will go now.
Threading - It has been my experience that since various operating systems handle threads differently, your thread behavior will be slightly different on each OS, however, the threading code will remain the same. This code should be portable with no problems as long as you do it in a standard (ANSI, ISO that is) kind of way. The only problems that may come up are timing issues, but these are easily solvable (like a day of labor for a real brain stinger), and rarely come up as long as you didn't do anything unorthodox.
Network - Again, as long as you don't do anything funky, and just use portable ansi/iso code, socket programming shouldn't pose a problem. Dont' go below port 1024 if your program won't run with root permissions, as many *nix's will only let root access those ports.
Serial - Ok, this could be a nightmare, find a good library.
Dude, you bill according to labor.
Life is too short to attempt to convert teenage geek idealism into calories and cocaine. Hello - it's only a program; no one is awarding medals for pedestrian custom apps.
This article is another attempt to subversively convert more straight Slashdot readers into slashbots - homo toyboys, kept around for CmdrTaco's sexual forfillment. Let's examine the article and see why this insidious Open Sauce movement must be stopped at all costs:
"My brother and I were just commissioned to develop a large energy management system"
In other words, Cowboikneel and CmdrTaco get tired after too little anal sex and need a more effective system to manage their energy. This is no doubt due to them both being fat homosexual geeks. The only cure is to go outside, breathe the fresh air, excercise regularly, and stop taking men up the ass.
"Aside from the GUI, which we've already agreed to use QT 3.0 for"
Ever since qt was released under the GPL (Gay Penetration License), CmdrTaco's toy boys have been using qt more and more. qt, or Queer Technology as it is now known, was strictly forbidden before, as it did not allow RMS to have Gay Penetration with his Free Software ("Software" is a term for underwear designed for easy removal). It is a major loss for the straight community that qt has now 'come out' under the GPL. We must strive to find a straight replacement.
"we specifically are looking for cross-platform libraries for multi-threading, serial port I/O, and network I/O."
cross-platform, as I've already documented elsewhere is a term used to describe any object which will fit in CmdrTaco's, Cowboikneel's, and Homos's ass. It is truly a disgusting phrase.
multi-threading refers to the homosexual practice of inserting more than one object up a gay lover's anus. The anus has to support multithreading for this to be possible. Cowboikneel has always supported this, due to the enhanced size of his O-ring. CmdrTaco has not always supported multithreading, but after being impaled on Homos's huge cock multiple times, he has now managed to support it.
'serial port I/O' refers to the sick practice of in-line Gay Penetration. Because of the nature of this task, each lover must hold a Gay Penetration License. in-line Gay Penetration means Homos taking CmdrTaco who in turn takes Cowboikneel, who continues the line of homosexuality. Many homos will join the line. The record line length is two hundread and fifty seven lovers! RMS and ESR were involved, of course, as well as many other prominent Open Sauce leaders.
The nature of 'network I/O' is not known to me at this time. Although the intelligence gathering methods used to undermine the homopocalipse revolution are very advanced, no one has dared to enter a orgy in which 'network I/O' is going on and thus cannot give us more information as to the nature of this dark and sinister threat to our sexuality. Anyone who holds information on this matter is encouraged to let us know, even if it means putting their anal virginity at stake. This threat is of the highest importance and we must learn more about it.
In conclusion, The homopocalipse, which was once thought to be merely a figment of RMS's imagination, is now very very real. We must work persistently and diligently if we are to destroy this threat once and for all. Until such a time as a straight man may once again walk with pride, and not fear being taken up the arse by rabid slashbots, armed with cross-platform dildos, we must excercise caution. Do not trust anyone. Do not believe what you read on slashdot. Treat everything and everyone with suspicion. I must go now, I fear the slashbots have discovered the hiding place from which I am transmitting this warning. If I do not make it out of here and to safety, please continue my work. Do not rest until slashdot is free of RMS and his homosexual minions. I will go now.
It is quirky, a pain in the rear, time consuming, but less so than other cross-platform libraries.
I've used it in projects that required common threading, interprocess communication, and a few other things across NT, Solaris, HP-UX, AIX, and Linux. I point out all of the UNIX-like platforms as seperate entities because they all have enough quirks that you can't expect any given library to work across the board.
Oh, and to everyone that has been promoting ideas like "just use gcc" or "just use straight c++", maybe you've never worked on a large scale, long term project, but gcc is not the best option for an app that needs to be highly optimized and writting everything in c++ from scratch is a waste of time (that's why we have libraries in the first place). I'm not flaming here, just pointing out that you need to look at the bigger picture.
"Combine Kylix with Borland Delphi 6,(TM) to develop cross-platform Linux/Windows applications." - Borland.
"Shoot some fish!" - Happyworm.
Go on, shoot some fish!
Use Common C++ for the cross-platform serial I/O, network I/O and threading support. I strongly suggest you use G++/cygwin rather than MS VC++ as the latter has all sorts of minor incompatibilities. G++ does too, but at least it's cross-platform. If you do decide to go with VC++, there's a few tricks you can use to make it closer to standard C++, such as #defining for="if (0) {} else for" (do it in the project pre-processor definitions if you don't want to #include it everywhere) which fixes the for-loop control variable scope problem in VC++. Any point where you do anything remotely Windows-centric when you're coding, at the very least put a comment, or put a #ifdef LINUX (or whatever) and flag an error when you try to compile on the other system, or better, figure out how to do it on the Linux system and write that in the #ifdef.
It's very important to keep in mind that the system will be ported, and soon, otherwise it'll be a huge project to convert it when the time comes. It is probably worth doing things slightly less efficiently from the win32 perspective (use G++) so that the system can be easily ported later.
Good luck!
"SWIG is a software development tool that connects programs written in C, C++, and Objective-C with a variety of high-level programming languages. SWIG is primarily used with common scripting languages such as Perl, Python, Tcl/Tk, Ruby, Guile and MzScheme."
You can write your code as portable C++ classes, and then use SWIG to automatically read in the header file, and write out all the glue code to plug your C++ classes (or C libraries) into the scripting language of your choice.
-Don
Take a look and feel free: http://www.PieMenu.com
Good morning! Write your program as a XUL application! Say what? Yeah, that's XUL (pronounced zool) ...
The folks that earlier suggested NSPR are on the right track but they stopped short of taking advantage of the cross-platform GUI aspects of mozilla. Design you UI using XML - that's XUL.
Write modular components in C++ using XPCOM - a
cross platform variant of COM.
Compile and deploy to just about any platform that mozilla runs on - and *that* my friend is a lot!
The bulk of your app can be defined using a few
text files (XUL compatible XML tags with some Javascript). You might not even need to write *any* C++ code.
Besides the docs available directly on mozilla.org,
here's a link to some stuff I wrote:
http://www-106.ibm.com/developerworks/webservices/ library/co-xpcom/
Enjoy.
If you find you need more than Qt offers for network i/o, treading and stuff like that, consider the ACE libraries:
http://www.cs.wustl.edu/~schmidt/ACE.html
They are free, proven to be extremely portable, and can come with a full-featured Corba implementation.
See also POSA2 book for background info:
http://www.cs.wustl.edu/~schmidt/POSA/
Of course, check out boost for another well-tested + well-maintained cross-platform C++ library:
http://www.boost.org/
This is better/more modern C++, but there may not be much space for it between Qt and ACE.
Now for the serial port... dunno, but shouldn't be too difficult to encapsulate that. You may find useful info at:
http://www.lvr.com/
Good Luck - Ivan
One good thing is that NT is in the loosest sense POSIX compliant. That means, all the stuff like sockets, etc, work almost as you'd expect from Unix.
Use something like QT for GUI, or glut if it's a predominantly 3D interface, and you'll have something that starts of being fairly platform independant.
Use STL instead of MFC for storage. You may have to roll your own file loading/saving stuff, but don't try and reverse engineer the MFC stuff afterwards - it's not worth the hassle.
I started off writing a network-based game targetted for Windows as while back. Pretty much everything was standard POSIX with OpenGL as the user interface. Before I started in earnest on the UI, everything ran under Unix - in fact, I wrote plug-in UI modules, as I eventually planned to back-port to Linux. That never happened, but I did have a text console UI. This made debugging very easy, as you can run lots of clients at once.
If you're after socket stuff, check out the source for Xpilot. Not C++ style code, but it uses a library that you can look at to see some implementation differences between Unix and Windows.
Definitely do daily builds on both platforms, gcc is good for cross platform use. You can even set up your Unix box to cross-compile your Windows binaries. If you target POSIX, you shold be able to isolate all the Windows/Unix stuff behind an abstraction layer early on and forget about it.
Good luck!
I am no programmer but dont delphi and kylix have an interchangable code base?
Couldnt you write on delphi then recompile in kylix with little change to the source code?
Just a thought!
Gecko19scl
I havent lost my mind i know exactly where i left it!
Use the MPMC ( Multi Platform / Multi Compiler )Rule from day 1 on. It will save you pain later. Even if you cant develop the whole thing on two platforms at once, write a small command-line app that does some test cases and includes all of your back-end sourcees and make sure it compiles on more than one platform and make sure you start using more than one compiler from the beginning. Especially for command-line apps its not much pain in the beginning, but it saves you plenty later. It also forces you to clearly divide between back- and frontend( Which has saved precious programmers lives more than once
For libraries check ACE and BOOST.
Other people already said that QT offers multi platform network and threading support.
And this seems to be a multi plattform (linux/win32) library for serial port io.
HTH,
j.
For threading:
use the boost library, Boost.Threads
For network:
Use ACE
Port io is trickier; i am aware of a couple of free libraries for NT, which are rumoured to make things more like unix, butI have never really used them. look on google for dlportio and giveio.
The most important thing is that you use the GNU tools on the windows side, as there are quite a few differences between Visual C and GCC dialects
Check out CYGWIN. I don't know about the network, but it attempts to implement a POSIX-layoer on top of windows....
The Qt library offers cross-platform facilities not only for the GUI, but also for the network and threading code. The only thing missing is the serial port: this could be a bit difficult to do. To have an idea of the problems involved you may look at the Wine page: they have a lot of trouble emulating the Windows serial ports behaviour under Linux.
I'm sorry...I really hate to be negative, but these requirements are really stupid.
I mean, really stupid.
Let me get this straight, here...You want to develop this app on NT, test it on NT, and migrate it to Unix after all this is complete? I certainly hope this isn't doing anything important, `cause that baby's gonna crash-and-burn like a mofo. when you bring up your Unix boxes for the first time.
First...get a clue. Cross platform development for the GUI is going to fucking suck. No, I take that back...Cross platform development alone is going to fucking suck. The GUI won't help, either. You can use third-party libraries, but that's code that you haven't written (which means you know very little about it). Not good.
Second...you're a fool if you think that you can build and test this on NT, and just port it to Unix a year later. If this is going to end up on Unix boxes, then that's what it needs to be built and tested on, from the ground up.
Third...grow some balls, and tell the people that want phases 1 & 2 on NT to fuck off. The right way (and the smart way) to do this is develop the app for Unix, test on Unix, and roll out on Unix. Testing on NT, and then porting to Unix 6 months later will do two things...Make you look staggeringly stupid when it doesn't work, and help you to understand that it's a terrible idea (TM) to build and test Unix apps on NT(!).
I know I'm repeating myself, here...but the nature of the question really leads me to believe that this needs to be rammed down your throat. If it's for Unix, build it on Unix, and test it on Unix. If it's for NT, build it on NT, and test it on NT. Build two separate apps, if you have to. I guarantee that it'll be smaller, better, faster, and cheaper than the spaghetti mess that you'll end up with at the end of your proposed project.
But hey...it'll be portable spaghetti.
--Life may have no meaning, or, even worse, it may have a meaning of which you disapprove.
And why did you discount java? Unless you're forced to use C/C++, you can code it in java, which provides well tested libraries... You can even compile it to native code if speed is such an issue...
This is really wort considering, I've been experimenting with XUL a little and i have only good things to say about it so far!
Check wxWindows out http://www.wxwindows.org/, cross platform gui, i/o. Works under *nix, win32, os/2, macos etc
I'm using ACE for this purpose, and it really works.
Use STL whereever you can.
Use Boost, www.boost.org, for platform independant threading. BTW, this threading platform code will probably make it in the next version of C++ since boost is run by member of the c++ comitee.
Use a good design. Code the logic in a platform independant way and abstract what is platform dependant.
Pat
ZooLib allows one to write a single set of C++ sources which can be compiled into native executables for Mac OS, Windows, BeOS, or POSIX-compliant systems that use the X Window system (such as Linux).
- freshmeat.net/projects/zoolib
-- bartman
You are so right. I've been programming java on and off for 6 years (on again at the moment, server side, marketing decision...)
My main problem with java is not the speed of execution (although that's still a problem). It's the ton's of superfluous shitty code that seems to get generated in any java project.
The flaws you mention aren't even the main ones IMHO - lack of MI (no, interfaces are *not* as good, eg EJB programming wouldn't be quite so cumbersome if the methods one needed to overload had default implementations) and templates is even more irritating. Then there is the stupid overuse of try/catch blocks because the style encourages this, leads to local error handling code all over the place and defeats the whole purpose of exception. The lack of enums is unforgivable too, aargh... And then Swing - good god, what a piece of shit. Try FLTK instead, to reduce code size by factor of 4 and increase speed by factor of 100.
Glad I'm not the only one who feels this way..
http://rareformnewmedia.com/
i'd recommend wxwindows (http://www.wxwindows.org)
it's a cross-platform c++ gui toolkit (other language bindings exist), which acts as a wrapper around the native toolkits (mfc on windows, gtk/motif on unices, platinum on mac, etc.).
it also provides a couple of other nice, platform-independent classes for string-handling (yet again?!), networking, odbc, etc...
if you use it, be sure to check out the cvs version. it's reliable enough and has a lot of features that can't be found in the tarball.
I m just starting to discover a little perl called rebol, now that stuff support tons of network protocol natively and run on dozens of platforms, i don t know about serial i/o but the rest look absolutely astonishing. maybe it's worth a look.
Back in the early nineties when no such thing existed (or at least that was findable), the company I work for wrote such a beast as the library of which you speak. It provided; sockets, threads, forks, mutexes, shared memory, config file handling, to name a few. The reason for the library at the time was that the client was dos and the server was *nix but we wanted the layer on top of this library to be source code identical.
We still use it today. It is good (and better than it was then) and very helpful. However we have started using ACE (as mentioned by some other posters) and it is also good. Much more extensive than our system and if we were starting now we would certainly not write our lib but use ACE from the get go.
So there you go. I reckon go with ACE.
"The first thing to do when you find yourself in a hole is stop digging."
Virtually all UNIX platforms out there are compliant to some POSIX standards to some degree. Linux is, and Windows NT and derivatives are.
With POSIX and ANSI C, you should get 95% of the portability issues out of the way. Keep the 5% remaining in architecture-specific files through a common API, and you're done.
The Linux Kernel is a prime example of ANSI C code which works on a multitude of very different hardware platfoms.
Thank you Linus.
Use Smalltalk! THE most ported language!! :) Just kidding ;)
Perhaps a better idea is to develop on Unix and port to NT. NuTCracker provides a porting environment that supplies the proper POSIX environment on NT, complete with sh, make, etc. This works very nicely with C (we've done it) but I have no exp. with C++.
For Network IO, try CORBA. omniORB from AT&T is a nice implementation, and Mico is reasonable as well. It'll be standard, the IDL's are nice, and it'll work cross-platform and between platform (i.e. NT client, *nix server, etc.)
Forget the NT portability requirements and write it for Unix. If you absolutely must run it under NT then perhaps Cygwin would be an alternative.
One thing you don't mention is whether you're writing a GUI or not, in which case I'd write a wrapper gui rather than an integrated GUI with IPC to deal with I/O. As others have mentionned serial I/O is a pain in da arse under Windows (it's a security issue, doncha know) but I'm not sure how cygwin deals with this issue.
Recommendation number one. Convince them to install Unix/Linux/Gnu/RMSIAI.
:wq
Python can also speed up application development, letting you prototype stuff without recompiling. You can compile fragments of Python code straight into your C code when you have got it working. You can make use of Python's httpd module, xml parsing module, etc, etc, etc. There is a lot on offer there.
And.. best of all, Python doesn't suffer from any form of restrictive licensing either! We use Python extensively in our commercial applications and it does make a difference to development time.
hi!
i'd recommend wxWindows (http://www.wxwindows.org). that's a free (GPL, i think) cross-platform toolkit, or rather, a set of wrapper and supplementary classes.
meaning, it'll use mfc on windows for displaying your application, gtk or motif on unices, etc, etc...
the supplementary classes contain some network stuff, odbc client classes, yet another string class, config classes (using files or the windows registry), etc, etc.
the documentation isn't that terrific, though, so there's a lot of guessing. and i'd download the cvs version, as that is pretty stable and contains a lot of features you'll be missing in the stable tarball.
The key thing is that you must develop for at least three platforms from the start. My initial work was on Solaris, Linux, and VMS. This allows you to find (most of) the inconsistencies early and design around them before they get too embedded in the project to ever change.
You also need to identify what things are very likely to change across platforms (in my case it was threads, networking, and file I/O) and abstract those out from the start. Write wrapper functions and use them. Actually, I wish I had wrappered more of the output functions; as it is, the app's a little too dependent on ASCII. Given a few wrapper functions I could easily have supported EBCDIC and Unicode; now it'd be a bear to add that.
Stick with anything ANSI, and POSIX is good. C++ still hasn't finalized everywhere, not like ANSI C. If you write in ANSI C it works darn near everywhere. Windows doesn't do POSIX threads natively, but if you aren't doing anything really weird, wrapper functions can handle that. (All I needed was threads with default stack sizes, and mutexes.)
Not that all the Unixes are the same. AIX in particular has some non-standard silliness in its implementation of pthreads. A comment from my code:
A few #ifdefs can take care of things like that. But really, really, really: Port from the start!
For the GUI part of it, make a separate front-end app. Use something portable for that; a library or Java or whatever. Speed is hardly ever a problem for GUI front-ends. Just make it simple and reuse as much code as you can between platforms.
PHEM - party like it's 1997-2003!
This is a cross-platform C lib and networking runtime. It's production quality and free. See mozilla.org for more info.
Try POSIX
At work we've been using for a couple of years ACE with excellent results. It's prepared from the ground up to deal with networking, multithreading, concurrency, etc, it's extensively cross-platform, open-source, cost-free, there's QT support ( although I've never used that part ), etc.
I don't agree with some of the comments that say that it's cumbersome and difficult. It's extremely simple to use, and because of the massive use of patternas, you can concentrate in what is your application supposed to do instead of "How can I spawn three thread that communicates with each other, one services a FIFO queue, the other connects t a server and the last one serves a TCP socket?". ACE handles all of that for you.
We work with Solaris, pSOS, Win32 and vxWorks, and our code compiles in each one of these platforms without a glitch.
http://www.cs.wustl.edu/~schmidt/ACE.html
Porting it to HP-UX was a headache; the STL's on the platforms differed in a multitude of subtle ways. AIX has been even harder (there may be something good about AIX, but I haven't run into it yet).
The STL seems to be about where C was when the ANSI spec first came out. It took several years before code was really portable...
PHEM - party like it's 1997-2003!
How do the software mongers in telco
industry do crossplatform communications?
The put a very thin #define wrapper around
POSIX calls.
You pay them for their interface which
you could have done yourself in very short
order.
And then you keep paying them subscription
and they keep doing as little as just wrapping
POSIX in thin #define macros.
And the 'interface' that you buy from them
is mostly deprecated and worthless.
But your managers don't know this and they buy
it anyway.
POSIX is what it is despite what the
software mongering telco stack people tell you.
They have no stack, they use whatever is
there and wrap it in #defines.
And you pay them the 1/2 million dollar
license hoping to be bought out before
anyone else figures out the fraud.
I've seen it over and over and over.
The obvious solution to these weird requirements is Java. Often, Java apps are developed on NT and deployed on Unix. If it is necessary to interface with C libraries, just use the JNI. Since it takes so much longer to program in C/C++, there would have to be a compelling reason not to use Java.
I see this all the time. What does it mean? It's either one or the other.
That's like saying "awk/perl" or "vi/emacs".
Since you're coding this thing in C++, then you have a prime opportunity to use generic programming techniques like abstraction, encapsulation and template program to hide all platform specific code.
For instance, rather than coding using the native windowing system, wrap and generalize the window functionality in such a way that you can code your client code using a generic object. You might have objects such as:
class generic_window
contains class generic_window_impl pointer
class win32_window : public generic_window_impl
class xwin_window : public generic_window_impl
The client would create an instance of generic_window, which would set it's member implementation object to the correct native window manager based on what platform you were on. Then you can generalize the callback functions, by providing a callback_register() function in the generic_window class that takes a generic_callback class as it's parameter. The generic callback would be a "functor" object that gets called by the native window object when it receives a native window message.
Basically, just create your own generic libraries! But if you're a good c++ programmer, then you already know this.
Otherwise, definitely use STL for all your data containers and searching algorithms. Use the Boost library (www.boost.org) for other useful generic classes and algorithms.
I don't think 6 months is enough to make a completely generic product, but if you constantly remind yourself to program generically, even if you're only providing windows functionality at first, your porting efforts will be MUCH easier a year from now. Encapsulate ALL platform specific code.
+1 Insightful, -1 Troll. What can I say, I'm an Insightful Troll.
There is MainSoft, which has worked in the past with Microsoft to port the Win32 API to various *nix platforms.s wf" target="_blank">flash intro</a>, hmm.. reminds me of those teleshopping ads...., funny but informative. For best effect open it to full screen.
<p>IIRC, IE for Solaris was created using this.
<p>Have a look at this <a href="http://www.mainsoft.com/flashdemo/mainsoft.
<p>Also look at <a href="http://www.wxwindows.org/">WxWindows</a>. They say it supports network programming, well atleast it's free.
<p><b>Caveat: </b>Mainsoft is $$$_expensive_.
To me, makes sense to write it as Unix-like and ignore NT as much as possible. I would suggest using Cygwin on top of NT/2000 (a unix compatibility layer, more or less), which includes standard GNU tools. There are some licensing issues with proprietary apps and linking against libcygwin.a (ie, you have to buy a licence), but it may be worth your while to pursue it. Or, try convincing the company to install Interix on their NT/2000 machines - it's basically Microsoft's own version of a Unix subsystem, and it's not horribly expensive (MSRP is US$100).
For portable CORBA and threading support, try omniORB (http://www.uk.research.att.com/omniORB/omniORB.ht ml). We use it for seamless portability between NT4.0 & Solaris components and its very effective.
-- Matthew - matthew.gream@pobox.com, http://matthewgream.net
We have a set of C++ toolkits which should do a lot of what you need, and support a variety of platforms, OSs, and compilers. They've been around for a long time, are very stable (they have been used in mission-critical software) and are a lot cheaper than Rogue Wave's tools. Go to ObjectSpace for more.
There was a rumour that MS didn't want anyone to use the POSIX subsystem. It seemed to be there simply to get a tick against the "Does it comply with the POSIX standard?" checkbox on corporate/governmental buyers requirements list. Once the sale is made, the POSIX subsystem is of no further use.
We eventually ported to the WIN32 subsystem using a toolkit called NuTCracker. It sort-of worked, but we eventually ended up doing a native port by abstracting out all the OS sprecific stuff.
There are other options to be considered. There is UWIN - http://www.research.att.com/sw/tools/uwin/. There is also the CYGWIN stuff (which seems to include OpenGL) which you can get at http://sources.redhat.com/cygwin/ (you might also need the extra CYGIPC at http://www.neuro.gatech.edu/users/cwilson/cygutil
I happen to agree with the corebreech's statement. You do have a responsibility to inform your customer of their poor design decisions. After showing the original post to two other software engineers at the company I code for, we all agreed that "...here comes another failed software project... i.e. train wrecking waiting to happen."
At the very least, I would suggest doing a cost benefit analysis to compare development cost on the target platform vs. the cost of developing a cross-platform version on NT & Unix. Include cost of libraries, testing, hardware and increased skill sets and I bet you will find it much cheaper to develop for your final target *nix. Most managers in my experience are brain-dead when it comes to software development, but money talks.
Good Luck
NT servers seem to crash often. Can you tell us what colleges, so I can avoid having my children wandering around halls whose lights are controlled by NT? I'd also like to donate some candles to those colleges.
This may have been a troll, but its the funniest goddamn troll I've seen in a long time. I nearly wept. It was better than Cats.
When I need to code cross platform I start with a cross compiler and two targets. That way I know with every build whether I'm getting platform specific and it's easy to isolate the platform specific stuff.
Check out Metrowerks compilers for cross platform stuff.
Alot of people have already mentioned some great points and specifics about threads, I/O and other platform specific issues to consider.
If I was in the position to build such an application I would ask myself the following questions. I'm assuming the application is hitting an existing server which has proprietary API.
Since there's very little details about what kinds of system the application will hit, it's all guess work at this point. But, if I had to come up with a flexible architecture for an energy/utility grid for a couple universities, I would consider doing the following.
Of course this is all hypothetical and could just be garbage.
My suggestion: Prototype in python if at all
possible. Say "This is just a prototype so we
can check out the screens with the users". Get
as much going as possible. Make sure performance
is ok. Then say "Suprise, We're done. And so
is the port."
I have gone through this myself very often and there are two REALLY good libraries. Ok they are not C++ based, but I really like them.
The first is NSPR (Netscape Portable Runtime). I used this in a few projects and NSPR worked wonders. The other one is APR (Apache Runtime). I am working on an Open Source C++ Apache server framework and have to say I love it. I am so interested in the APR solution because it uses resource pools, which mean that I do not have to worry about every pointer being freed. The resource pools handle this automatically.
If you want more information about APR stuff feel free to email me. Just take the obfuscated email address apart.
"You can't make a race horse of a pig"
"No," said Samuel, "but you can make very fast pig"
is your best bet, that is if you can wait. And even know it will be a 1.0 on the *nix side, by the time you are done developing it their should be a update or a upgrade. You should be able just to copy the src over and build on the win32 system without any problems.
I will bend your mind with my spoon
You need to test everything, all the time. Unit testing is going to be SO critical for you. You need to set up a test center with a set of machines running each OS you will be porting to. You might even want to hire a good tester, I'm sure you could find an out of work one around somewhere.
Object Pascal. It's what my company uses for cross platform development.
Try Visual MainWin from Mainsoft . This tool claims to make porting from Win32 to Unix (including Linux) very easy with little or no code change. It is said that M$ provided Windows code to Mainsoft to develop this tool. This tool is not open source though. Also, I haven't personally used this tool but will like to hear experiences of those who have.
- J
The Apache Portable Runtime has good cross-platform I/O, threading and networking support. Plus you know it will have been tested in a demanding environment (Apache!)
Why not just start out on Unix? I mean, think about what you are saying. Develop on NT, test on NT for 12 months, run on NT for 12 months...then switch to Unix. Why not drop the superfluous OS and go straight to Unix? If UI is an issue, build a portable UI (in Java or whatever) they can run wherever they want.
324006
Your question doesn't explain why the system has to run on NT first, and then later switch to *nix. Also, you said you'd already agreed to use some specific package for the GUI. Why?
I'd guess that, like many on many projects, the technical questions won't be as hard to answer as the questions about the exact requirements.
But, whatever technical strategy you adopt, be sure to test, on both platforms, early and often. Some sort of automated test suites would be ideal.
I am developing a cross-platform OpenGL scientific vis application in linux, and using the Qt library, I can cvs checkout my code on my WindowsXP laptop under Cygwin and create an executable without changing a line of code. You do have to buy the Qt license, but I have found the cross-platform ease to be worth it. My app uses networking, but no threading or serial communications. You don't really have to use Cygwin --- Qt's make system can generate msvc project files, but I am just more at home with the command-line.
SWIG looks like it'll be great when it's done.
However I recently downloaded the SWIG based OpenSSL Python bindings (mtcrypto) and on my first attempt the build failed because the SWIG syntax had changed between releases. I would advocate not using SWIG for anything important until it stabilises.
The SWIG homepage appears to back me up here: "
SWIG is currently in a state of redevelopment in which substantial parts of the system are being reimplemented. This work can be found in the SWIG1.3 series of releases. If you are concerned about stability or are a first-time user, you may want to download some variant of SWIG1.1 instead. Caveat--SWIG1.1 may not be compatible with recent releases of certain scripting languages such as Perl 5.6 and Guile."
If you're asking such questions, and you've made such commitments, you're fu*ked.
Do you really need to do this in C/C++? How much UI does it have? Does it run as some kind of server process? Unless people know all these kind of things about your project (and you didn't say much at all), you can pretty much discount what they say as it will just be speculation.
The quickest UI's to develop are web based ones (they're often the most simple).
For back end stuff, look at something like perl.
Complicated UI's, Java/Swing - at this stage I'd say you're committing to doing something too complex.
My guess is, you'll put a lot of work in on this (more than you think), you may get something written that does the job, you won't be happy with what you've done, but you will learn a lot (mostly non-technical about how you approach such a project).
Try to have fun though.
Anything that involves stateless transaction processing where it does not matter if a process crashes - Java is fine. If you need a long-lived scientific application doing quantitative analysis - Java simply is not good enough (too much memory, too slow).
why not GTK/GLIB? 1.3.x is coming along quiet nicely... native windows/*nix ports... developed by the community, for the community ..not by a single company sure redhat support GTK+/Gnome, but hey dont own it.Its always been under LGPL/GPL, none of this QPL-hybrid shit.
Trolltech still fully control QT on non-linux platforms...why cant QT be open on every platform?
I'll never trust trolltech.
Indeed.
And TAO that sits atop ACE, providing a real-time capable CORBA ORB atop it can't be beat either. Its use is less quirky than ACE and made possible a massively distributable financial and access control system that is in use at DFW International Airport and other locations. This system runs on both NT and Linux, with exception handling, etc. across both platforms working well.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
You are so right. I've been programming java on and off for 6 years (on again at the moment, server side, marketing decision...)
hmm... let's see, Java was first shown at a trade show in 1995 by Bill Joy and James Gosling. It was at least another year till applets started appearing on the net.
Since its only 2001, you mean to tell me you worked for Sun's Java development team?
Bullshit - just like your opinion that Mutilple inheritance is a good thing.
Look, MI might be good if you're some 31337 haX0r who's code will never have to be looked at, but if you get paid to code(God help us) then you would realize that the clusterfuck of MI eponentially decreases the maintainability of a project.
Do me a favor, try charting out some of the objects through a UML diagram on a project that uses diamond shaped.. excuse multiple inheritance. Unless you wrote it, you'd be rotating the printout in all directions and scratching your head trying to make sense of it.
I definately agree. Use Kylix I programmed with Delphi for 4+ years full time. I was a wonderful system. I have been programming with Java/JSP/jakarta-struts for about 14 months now and it is by far the most primative environment I have developed in for years. Developing GUI's and Database applications take about 10x longer. Also if you are familar with Java then Kylix would be a snap, if you used Object Pascal. It is a very beautiful language. There is also the C++ version of Kylix. It's gui system also uses QT at its base ! Why did I stop programming in Delphi ? It was more a decision to leave my old job, than to switch languages. I wanted to expand my experience. I could produce pretty complex database applications,20 + tables, reports, help files, with a good look and feel in just 3 to 4 months of development.
Rob
(while (= lisp stupid_language)(No Java/VB faggot is going to be able to do even the simplest arithmetic (+ (they'll get confused))))
(Lost In Stupid Parentheses)
Get wrox's book on Java Servers. They have a good implementation of socket pools for databases. I've used a similiar pool and pool manager in production and it worked great. It will take care of bad connections. Also wrap the result set too, catch all the exceptions in that wrapper so you don't have to constantly be typing try..catch everywhere. Great for websites IMO especially if you use them with servlets. You can typically only keep 3-8 sockets around for hundreds of users.
Yes but every time I try to see it your way, I get a headache.
The correct question: "why are our requirements so f***ed up?"
Seriously - there is absolutely no reason to develop on NT, test on NT, and deploy on Unix, and there are a number of good reasons not to follow that path. If you're going to deploy on Unix, you can develop the system on Unix using cheap hardware and more-or-less free Linux or *BSD development systems. You are setting yourself up for about twice as much work as you need to be - just develop the thing on Linux or *BSD to begin with, stick with standard Unix portability guidelines (there are a couple of good *nix portability guides out there from O'Reilly, although at the moment I can't remember the associated cover animals), and call it good. Don't add extra portability into the plan that doesn't really buy you anything.
I could understand if you foresee a future need to port back to Windows, but absent such a requirement at the present, I really think you want to plan the easiest development plan that's consistent with your current deployment requirements. Just ditch the whole NT thing entirely, or if it's a matter of "well, we already bought you these NT boxes to use", then reformat them and install Linux or *BSD on them. Even in the worst case, moving *nix code to Windows will be less painful than moving Windows code to *nix - Unix is designed for portability somewhat, Windows is specifically designed to make it harder to port applications to other platforms. That is not where you want to start out from.
Also, if you do have to do the Windows thing, don't test on NT, test on 2000. In the 2-year timeframe that you're aiming for, nobody's going to want to actually run on NT. So if Windows must be in the picture, then develop on 2000, test on 2000, and deploy on 2000. Again, save yourself from some headaches that aren't necessary.
Your right to not believe: Americans United for Separation of Church and
A lot of people have been suggesting Java, and just as many have been debunking it.
I know this is a C/C++/Perl/Java bigot crowd, so I'll keep this short.
What about Common Lisp or Smalltalk? Both are quite portable, and reasonably fast. Common Lisp can even be fully compiled to machine code. They both fill all of the other requirements.
Two notable implementations of CL are CMUCL (Free) and Allegro CL (free trial, commercial- but solid).
As far as Smalltalk, the notable implementations for your project are VisualWorks and IBM's VisualAge for Smalltalk. Couple summers ago I worked at a shop which was heavily into VA/ST, and it was a pretty awesome system. Core of their business, and we're talking about a pretty big insurance company.
Working toward a usable PDA environment in the spirit of Newton OS: Dynapad
Seriously. Most folks on here think Java sucks, but that's typically because they haven't actually *used* it. I think perl sucks, simply because I haven't used it and don't know it well enough to be efficient at it. That's all too common. But take a closer look at Java... It's cross platform, multithreaded, scaleable ('cept that pesky GC thing, which can be handled reasonably enough with intelligent coding), and does all the stuff you're looking to do.
I used to code exclusively in assembly, then C, then C++, and now Java. Trust me, Java is a stable alternative that will solve MANY of these cross platform issues for you, if not all.
As an example, I have written a datalogger for my car. I coded everything under Linux using vi. It's a Swing based app that's multithreaded and uses the serial port to communicate with the car's computer. I never gave a second thought to cross platform support. I just coded to the Java APIs.
One day, a friend of mine wanted to run the thing on his laptop...which had Windows 98 on it. Sure enough, I put the files onto his laptop and it ran perfectly. This was not modified in any way and didn't even get recompiled! I just put the jar files from my Linux box onto this Windows laptop and away it went. I told him this "should" work, and sure enough, it did.
As for scaleability, I have also helped design a VERY large scale middleware Java RMI server architecture for a VERY large shipping company (it's a public company...you know them...I'm positive you've used them). This handles all user-based load from their VERY large website. We're talking millions of transactions a day here, not thousands. With proper attention to garbage collection, multithreading, and a distributed architecture, this system runs without flaw, 24/7.
So Java works in real world examples, it really does. Plus, it promotes code reuse so well, that I can't imagine suggesting any other solution for your problem.
You're right don't use java for heavy computations. But Java is great for the middle tier. One solution is to join them via sockets. Dump the computional code into C and pass params and results back via sockets. IMO it works great.
Yes but every time I try to see it your way, I get a headache.
Code in Objective-C and use GNUStep over linux and win32.
The way I see it you are going to be using either Java or a .net language. Microsoft's roadmap for .net includes a CLR that runs on Unix.
Pedro
----
The Insomniac Coder
If the issue is that they don't want to tie up "expensive Unix servers" for development, then for Ghu's sake slap a copy of Linux onto 1+ of the Intel boxen and develop on that using existing Unix tools; it would at least be closer to the target than Windows... If they think that GUI development can't be done "properly" on Unix (entirely possible mindset given the description), this would be an opportunity to show them otherwise with a start-to-finish *ix development cycle.
If they're doing a lot of I/O device control directly with the app (Uh, this is an energy management system- which, by definition is going to be tickling things like Opto-22 panels, reading from sensors, etc...) then Java's only truely useful as a UI choice as they're going to have to come up with native interface code to drive the Opto-22 stuff.
They not only have to do network programming and serial comms, they have to deal with industrial I/O that may/may not have a serial interface. If it does all have serial interfaces, they're going to have to come up with APIs for those devices- which isn't always easy.
Java meets only part of the criteria- the ones they needed help with answers on. It doesn't magically meet the other criteria- what are they working with and what does the customer want. I suspect that Java doesn't make the grade here for some reason. I code in Java as well as C, C++, and Forth. I'd be using Forth or C/C++ for this sort of thing with maybe a CORBA driven UI coded in Java unless the customer requirements insisted on C/C++ for everything. Then I'd be using C/C++ because it's close enough to cross-platform to matter little if you pay close attention to your code. I know, I've been doing this sort of thing professionally for 7 years now.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
I've used Python for this kind of thing. We are using Zope as the GUI to control test fixtures. This has been tremendously successful. Python handles little things like "\" verses "/" as well as socket issues.
http://www.cs.wustl.edu/~schmidt/ACE.html
Jim
Stop the Java bashing. After reading through most of the comments here, I'm convinced that the problems are not with Java, but with the skill / experience of those commenting. Most of the complaints are just bad practices that real Java developers know how to avoid. As is the case in most languages.
.Net crap that Microsoft is pushing.
Java performance is an argument of the past. The improvements made in the VM, hotspot, and good coding pactices have alleviated the performance issues.
The company I work at is a pure Java IT shop in the utilities industry. We must handle millions of transaction and run on multiple platforms. Java has performed great! And, we have been able to leverage tons of work done by others (Apache's Jakarta to mention one).
Also, Java allows developers to release programs that can be used in the massive Windows market and not exclude all others. I have seen some amazing UIs done with Swing. The complaints that I have seen here, I attribute to lack of experience.
Don't forget that Java is also a thorn in Microsoft's side also. It is the best (the only?) potential competitor to this
There was a time in the recent past when most development jobs I could get would only consider Microsoft platform and C++. Now the choices are Java and open standards (XML, Http, Ftp, etc.). Java played a large part in bringing about this shift.
Keep in mind that NT's posix libraries used to perform an order of magnitude worse than Win32 calls. Thats still the case. $M does that on purpose so developers choose speed over portablility.
Yes but every time I try to see it your way, I get a headache.
ACE_loves_to_use_long_class_names. These guys don't just take a shit like everyone else - they have an ACE_excrement_reactor_sphinter_contractor pattern.
Just don't use VC++'s "features" such as many of the wizards. Don't use MFC for UI development- use something like Fltk, WX, etc. And, don't use COM/DCOM if at all possible, using CORBA or XPCOM when you need something like that.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
Cross platform GUIs have several problems. First, they generally do not support the native human interface guidelines of each platform. Even if they do, your application tends to behave like only one platform. So, if your intended "final" platform is *nix, then find a GUI that allows you to create a *nix interface.
Secondly, cross platform GUIs are usually a layer between some native GUI library and you. This involves overhead in speed and size. If you are considering C or C++, it is possible that speed and size are important to you.
-- Stephen.
POSIX support can be buggy (surprise) on NT and many function calls have "undefined" behavior according to the spec, but it IS the most ubiquitus API out there.
You can grab it from here. Its got a non-standard compilation method, but for anyone with half a brain, it shouldnt be too hard. And it supports all unicies and win32. They've also chosen to expose a unix style API for their OS abstraction layer, which is perfect.
Hope it helps.
The first for the GUI part and the second for the
:-/
serial (not very robust in Win32 until a couple
of months AFAIK), network, IPC stuff
I made my own research time ago and I wish I could have a work like the one you are comissioned to test them and to switch job
I algo found interesting the Apache Portable
runtime (pure C) and some libraries used by
Apple in their open source Quick time streaming server.
This has worked very well for projects which I have worked on. We used ACE and RogueWave (don't ever use RogueWave) to provide platform independant server/backend code in C/C++. Then we used Java to provide a front end. This allows for User interfaces to run on either NT or Unix fairly easily while letting you stay away from GUI constructs in your backend code. This allows for using C/C++ closer to the ansi standards.
Try the ACE package. It is a cross platform library for C/C++. It works pretty well but there are some issues. Some of the threading sync objects have inconsistent behavior on different platforms. But you can work around these difficulties.
l
http://ace.cs.wustl.edu/~schmidt/ACE-papers.htm
Look at the ACE tookit at http://www.cs.wustl.edu/~schmidt/ACE.html.
It has cross platform support for: networking, threading, IPC, file API, etc.
It will be written in C/C++.
What is this "C/C++" language I keep hearing about? I've never worked with it. Is it similar to C or is it like C++? Where is the specification for "C/C++"? Where can I find more information about this unknown language?
I find it amazing that programmers spend so much time looking for good libraries, but don't stop to think about their choice of language and spend the same amount of time looking for a good language to use.
Others have said it already, but I'd like to add my vote for ACE. I work on air-traffic control equipment at a major defense contractor, and ACE is used extensively and successfully here. It is stable, reliable, mature, and comprehensive. It is very well designed, IMHO. It is widely used by the government and the aerospace industry. It is also open-source, and has excellent support from it's creators.
One of the standout features of ACE is that is not only a set of OS-neutral wrappers; although it can be used successfully for that purpose alone. The creator of ACE, Doug Schmidt, is a respected member of the Software Patterns community (he has helped write and/or edited several of the seminal patterns books). ACE is designed to implement many of the patterns that recur in networked programs, saving the programmer from reimplementing and debugging those patterns for the nth time. For example, if your application is an event-driven server that must demultiplex input and output on multiple files and ports, it's a prime candidate for the Reactor pattern. Rather than write and debug a reactor on your own, you can just use an ACE Reactor and save yourself the trouble.
The patterns discovered and/or used in ACE are thoroughly documented in Schmidt's book, Pattern-Oriented Software Architecture: Patterns for Concurrent and Networked Objects.
No, I'm not associated with ACE or Schmidt in any way. I'm just a contented user.
--
CPAN rules. - Guido van Rossum
Since it is going to a native UNIX environment, what about using Cygwin? Has anybody used this in a production environment which demands high-reliability?
For a GUI you could always use a web browser. I expect remote administration is probably a plus if it is going to eventually be running on a UNIX box... not that X doesn't provide similar functionality.
Of course the usual caution must apply that what the customer plans 1.5 years from now (i.e. going to UNIX) is not necessarily what they'll do... you could very well be stuck with Cygwin forever.
I've been using PACE/ACE for a number of years now for manufacturing control systems. The libraries are solid, and well tested ... and provide good portability to a dozen platforms. Ace provides some great high-level C++ abstractions, and PACE is a solid set of C interfaces to common OS stuff. I have a few systems based on Ace/Pace that have uptimes > 1 year ... and ramp up to the library was short. I would stay away from their container classes, and use STLPort instead.
mx
Far be it for me to mention something that you have to pay for, but ILOG (www.ilog.com) sells C++ (and Java) libraries that allow cross platform GUI applications with optimisation, scheduling, networking and database access. It may cost money but its shit hot!
If you want a cross platform set of libraries, then your application code must never use a system call. Anywhere that you would use a system call, you must instead call your library function. Then you port your library from OS to OS. One problem is getting the function signature correct. What if all of the sudden you need another variable passed? You want to minimize changes to your application code. There are techniques for this, but I'll let others discuss them if they want.
I am not sure exactly what kind of energy management system you are developing but you had better take a long hard look at reliability.
Another thing to consider is how you are going to plug it into the local hydro grids system which is probably using fairly standard protocols.
Finally, from what I have seen, an energy management system is going to be doing alot of number crunching.
For these reasons alone I would forget the cross platform development and go with *nix right off the bat. Whoever came up with the NT idea in the first place?
Any fool can make a rule, and any fool will mind it
Consider ACE: http://siesta.cs.wustl.edu/~schmidt/ACE.html
It's open source, more portable than just about anything else, and used in industry.
- Bjarne Bjarne Stroustrup, http://www.research.att.com/~bs
ABG is right, and you should isolate core functionality from data access and user interface - this is critical to portability and leads to evolution of strong, mature systems.
You will note that many business systems written in COBOL as "code monoliths" now require extremely expensive support in the form of CICS compatibility and cumbersome, user-unfriendly security layers. And their interfaces are still "green-screen" or, in many cases, have actually lost function and ease of use through poor GUI integration.
Meanwhile, many scientific systems written in a modular fashion live on despite having their underlying hardware replaced and their user interfaces re-written repeatedly. I'm sure there are systems that started on PDP-11s, are now running on Alpha VAXen, and are planning ports to linux clusters. Some will have been fitted with very pretty web interfaces.
Write your core modules, where the work is done, in ANSI C. Write your data access routines in the most portable language available on your preferred platform, and keep the code entirely distinct from the core functionality and user interface. If you're already invested in something like Rdb, Oracle, MySQL, whatever, then leverage the expertise and investment you already have but make sure your API is callable from C. Don't be afraid to use a fast, simple data store like Berkeley DB or plain old flat files - cheaper is better. But be sure to define a data access API in any case (such as Replace_Leaf_Record() and Create_New_Root(), for example) and keep the code cleanly separated into modules.
Provide a "raw text" interface, written in C, and keep that as the base functionality canon. Use it to test the GUI, which you can write in Java or C++ or Eiffel or whatever (I'd say use your favorite, since you'll get prettier results if you enjoy using the language). Make sure the API for the GUI is entirely documented in the core code itself so that it can be seamlessly replaced when the fabled post-GUI interface finally appears.
--Charlie
ObjectSpace provides a good, cross platform STL implementation, with toolkits that build upon it. ObjectSpace's C++ Toolkits cover multithreading with mutexes, semaphores, reference counting, communication with streams, pipes, sockets and files. They also provide some useful tools in terms of time and regexp.
It's been a few years since I've used them, but I used them on solaris and hpux with both the proprietary compilers and gcc, and I know their headers had provisions for the MS compiler.
Euh... I hope you know about this, but if you are planing to use c/c++ I take you might play with strucures and the what not... well I sure hope you know that Windows runs on CISC processors and they are small ENDIAN, and the UNIX, such as Solaris, runs on RISC processors (unless they use it on a pc) and Risc machines are BIG ENDIAN ...
Well this means that they don;t understand each other, and that all the ordering bits are reversed from one to another... I am saying this because us UNIX guys have a problem with the NT guys (other team at work) that they do not know about i and send us structures that have not been putted in network order!! so we have to make hack workarounds!!!
cheers,
be...
I have spent a few years cross developing on IRIX, Solaris, HP-Unix, and NT/2000.
We used Ansi C/C++ (I know, C++ and Ansi don't mix) and except for machine specific sections (such as serial communications) it worked great. But we didn't do much GUI.
There are cross platform GUI's like MainWin's if you can determine your target *nix machine. That is important. Else, you can simply abstract your GUI from everything else and create a facade/proxy pattern. Good luck!
Loading...
Actually it sounds like he was running on a win9x machine. Unfortunately the way win9x is implemented, the OS will not release memory for a thread until the owning process is finished/killed. Since the JAVA spec requires the VM to use the native OS threads if they exist, all JVM implemented under win98 have the thread memory problem. The only way around it is to do what the original poster did. Keep thread references around and keep reusing them.
Whoever says JAVA is platform independent is sadly mistaken.
Sip has NO documentation, but it has the advantage that it's used for the Python Qt bindings. It's reasonably easy to use, though it really could do with some documentation.
Assuming you are writing in C++, which seems likely given that you are using Qt.
First, make sure you are using the STL. Others have pointed this out already and they are right. Second, Qt provides much of what you want. It is pretty good that way. Third, check out http://www.boost.org/ which has several other very useful libraries.
Oceania has always been at war with Eastasia.
what build tool do you use? do you have
nightly builds on all the target platforms? how is this
set up and arranged? what tools do you use?
I like anything that forces/allows you to fix things as you go rather than wait for the end.
You're already using Qt3.0 for the GUI. Qt3.0 also has perfectly good cross-platform network and threading classes, so why not use those?
I've just completed a complex multi-threaded client-server application, using Qt for both the client and the (non-GUI) servers. 'Porting' the client from Linux to Windows consisted of adding one #include to one file and compiling under Visual C++.
The only thing stock Qt3 is missing is serial port access, and writing a cross-platform shim around that would be no more than a days work.
Qt is based around a central select loop. Trying to borg in another app framework will get painful.
If you haven't already done so, get a good book on the STL and acquire a basic understanding of all the amazing stuff that's in there. I find the syntax of using list, map and the iterators a bit perplexing at times, but it is definitely worth the trouble.
I also highly recommend the Common C++ libraries.
I won't go near Windows stuff, so I developed
my code under Linux (using that library), and
then handed my source (along with the Windows
version of CommonC++ to a guy who is forced to
use Windows, and basically a recompile was all
that was neccessary.
(Actually, since I was working with an _early_
version of Common C++, there were a few things to
fix, but the project was successful.)
If you don't care about bloat, use ACE. I don't think it does serial port I/O however. If you do
care about bloat, use win32-pthreads for threading.
The socket API is pretty much portable. Write a
couple of tiny wrapper functions to smooth over
serial port I/O.
But you really don't want your GUI and application
logic to use the same thread model. Put the
application in another process, and communicate
over sockets. (Not performance sensistive, so
there's no good reason not to make it network-
transparent.) Don't let QT dictate the threading
of your application.
-I like my women like I like my tea: green-
This is so utterly wrong, in factual terms that
the mind boggles to consider a soul so reckless
in it's disregard for truth.
-I like my women like I like my tea: green-
We had to resort to writing our own database access drivers because of the piss poor performance of RW's DBTools. The RWDBTools stuff seems to perform millions of object copies behind the scenes for no good reason. Our homegrown DB API, although crude, is 5 times faster.
Incidentally, I really like Qt, and it's great for commercial projects but as a Free library apps you really want to be cross-platform but can't afford to pay their Windows licensing fees for, I have become increasingly fond of wxWindows.
It has it's quirks, yes, but its greatest stregth IMHO is a very nice, well supported Python API. I swear it's at least 3-4 times faster to build a GUI in wxPython than in anything I've seen in C++, even using GUI RAD tools (which only get you so far before you start having to hack at source). Just my opinion, anyway.
...except maybe the serial IO. It certainly handles threading and network IO correctly, and serial IO isn't a hard thing to encapsulate and not much code to write twice (I don't know what the Win32 network interface looks like, so I can't comment much more about it).
Before looking into additional tools, look closer at what you're already using.
(On a personal note, btw, I don't use C++/Qt -- I prefer to use Python, which provides a sufficiently uniform interface for my needs, with its Gtk bindings, which are available on both the platforms you mention. Since these decisions are already made for your project, however, I'm not going to try to push them here).
IMHO, one of the best choices. Core Ada is fully portable, GUI can be written using Qt, GTK bindings or even JGNAT (the compiler creating Java classes from Ada source).
At lest it guarantees reliability and good built- in multithreading support.
And their roadmap for COM included COM on Solaris
and AIX. Hehehehehe. There's one born every minute.
-I like my women like I like my tea: green-
Why does it have to be done in C++?
How about Ruby?
http://www.ruby-lang.org
(or even Python)
NT's Built-in POSIX has essentially been replaced by Microsoft Interix -- it lets you access Win32 and was in the past Single Unix Spec certified, so the API should be pretty complete.
(Also, unlike Cygwin and UWin, it runs as subsystem rather than a library.)
OpenGL, OpenAL, Boost++, and sometimes PLib
Julien.
Boost starts the thread when a thread object is _constructed_. This is a design problem in my opinion because sometimes you wish to instantiate an object but not activate it immediately (or not at all). Another beef with Boost threads - they do not have a timeout on their join() operation. It blocks forever. It's hard to control thread pools without such timeouts.
You claim that the poster's claimns are utterly wrong. PROVE IT.
My own personal experience indicates that he's much, much closer to the truth than you'd like to admit.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
Uhhh, Qt is still at version 2.3.0 for Windows. I don't know if the changes will affect you. It's still mostly source compatible, but not 100%. Be sure to read the changes.
But Qt 3.0 has fairly good cross-platform threading and networking libraries, in addition to its GUI stuff. See http://doc.trolltech.com/3.0/network.html for networking docs and http://doc.trolltech.com/3.0/threads.html for threading docs. Since you're already learning the "Qt way," you might as well use it for these features too.
--JRZ
Native Win32-PE/x86Linux-ELF , GUI, Networking, data base, OOP (build your "buisness" logic framework and access native api's on each OS)?, fast compiler, fast executables, *great* IDE, copy and compile on the other platform.
I mean, your requierments read like Borland's marketting stuff on Kylix/Delphi
ACE+TAO should meet all of your requirements (and more!) Check it out: http://www.cs.wustl.edu/~schmidt It is *WIDELY* used and well supported. jrn
Ever thought about that one, hm?
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
Of course, you would have to do major re-thinking, and make compromises in some places; but how about perl?
It is fully portable, fast enough for most apps, bug free; and, you will complete the job 3 times as fast if reasonably fluent in perl.
You might want to try Omnis Studio. It's a little different, but it's been working cross-platform since the mid-1980's.
QT has a socket code, I think it has thread code, and much else. If you have already decidede to use QT as the GUI, I'd suggest using them for everything else. It should be cross platform compile okay.
Only 'flamers' flame!
I have used ACE and TAO (the ACE CORBA ORB) for a number of projects.
It works great and is incredibly portable. My only advice is to be sure to get familiar with the configuration of the entire package, like features and options and components before you settle on a given configuration for use in your project.
ACE+TAO are designed to run on a large number of platforms, and support C++ without exceptions, explicit STL template definition, and a number of other features which are really handy for some environments, but dont serve a default installation well.
Some of these options affect the way your code interacts with the library, and require you to write and/or compile your code accordingly. Obviously you do not want to get half way into a project and realize you need to change some configuration options, and then go back into your code and make the requisite changes to support these modified configurations. (This isnt a big deal, as everything is pretty well encapsulated, but it can cause headaches)
I'll give you a few examples of things that I ran across.
1. CORBA. I had used the TAO orb to compile IDL without native exceptions, producing stubs and skeletons that used a CORBA::Environment arguments in all methods to provide the hooks necessary to handle exceptions without using c++ exceptions. Later I switched to native c++ exceptions, and had to modify the function declarations and definitions to remove this now unnecessary CORBA::Environment argument.
2. I had built ACE with the 'no implicit templates' option, which required that all member templates be explicitly defined in the sources files where they were used for linking correctly. Later I switched to gcc 3.0.2 and started using implicit templates. I had to recompile ACE with this new configuration, and also modify my code to remove all of the explicit template definitions that I had added.
3. I had initially been building ACE + TAO with all components and features enabled. This led to very, very long compile times (I am talking 8+ hours on a dual PIII 550 w/ 512M of RAM!) It turns out a vast majority of the stuff being built I didnt need, like a number of the CoS services, the realtime CORBA stuff, and some of the ATM and other networking features. I was able to tweak a few settings in the configuration / build files and this cut my build times down to about an hour. This is a BIG time saver.
I work on a medium-sized (~50-100K LOC) cross platform commercial application.
:-( was very unhappy about Unix-like end-of-line sequences. We check out on each platform, and keep them in sync more or less "by hand" (carrying files or patches from one to the other).
The original developer (1.0 was Windows-only) wanted to use SourceSafe; it's a Windows-based source control system, but he'd heard there was also Unix support. I'd tried to use it on my previous project; true for small values of "support".
We use CVS, checking out onto Windows or onto Unix, hosted on Unix. It just plain works.
FYI, we could not find any way to check out one copy of the source on one platform and build on the other. Visual C++
P.S.: I have no personal experience with ACE but have also heard good things about it. Commercial support is available from Riverace, if that's an issue.
Stupid job ads, weird spam, occasional insight at
You could just ditch the C/C++ effort and pick up something like Kylix. Yes, it is pascal but you can seriously do pretty much anything in it that you could do in C without much difficulty. That and hte professional version would have most of the networking and gui libraries you need, already cross platform. Want it to work in linux? Load up the project and compile. Just my $.02.
Java, as it currently is used, is likely to be a poor choice of a tool for this task.
An energy management system more often than not has to deal with industrial I/O systems such as an Opto-22 interface or a ModBus interface. This often requires system level coding resources Java doesn't provide in any way, shape, or form (because it's not part of it's model of how things should be). To claim that you can code those portions in C or C++ and interface them is silly- it's inserting needless complexity (in the form of having to support two differing languages and having to maintain interfaces suitable for JNI.) for no good reason. If you have to resort to using C or C++ for something, it's more often than not better to code the whole thing in one of those languages.
Coding the UI in Java is an arguable task. On the one hand, you've got the nice API designed for doing UI coding. On the other hand, you're back to adding needless complexities into the system in the form of multiple languages and RPC interfaces unless you're using CORBA between the UI and the energy management system engine. Again, you may be better off, based on my personal experience as a software engineer of 12+ years of experience in the industry as a whole, to code the thing entirely in the base language- it'd be simpler for the whole source tree.
And this doesn't even get into what the customer wants. If they want C/C++, then they get it.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
The biggest problem with working with c++ and visualc++ is the for loop. The solution is to put the following at the beginning of all your programs.
#define for if( true ) for
And the code's collecting some 10-30K per day at a major international airport in parking and ground trans fees. Part of the system runs on NT (Not MY choice) and part of it runs on an embedded platform running Linux. Same codebase, some 200-500kloc of complext client-server code that compiles cleanly w/no warnings or errors on either GCC or VC++.
Its all in what you do/don't do coding-wise. And, I'd probably have a few horror stories to swap w/the people on comp.lang.c++.moderated over VC++ because I DO this sort of thing for a living and have done so for 6-7 years now.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
This really doensn't answer your cross platform library question, as there have already been a number of good answers to that (I'd suggest checking out NSPR; it's open source, free, heavily tested/stable (Mozilla/Netscape/Netscape's server products/etc. use it), and does all of the cross platform stuff you need, and does it on 30-some odd platforms.
As for cross platform programming practices, check out Mozilla's C++ Portability Guide. Porting the browser to 28 different operating systems, each with their own compilers and each of those compilers with their own quirks has given the Mozilla build engineering team some insight into what to do and what not to do when writing portable code.
This document tells you what those do's and don'ts are, and (more importantly) why.
I'll bet the customer knows about/knows C/C++ and understands that they can get systems (key word there...) programmers using that language.
Java isn't a great systems language- it's a great applications language and doesn't pretend to be anything more. You can do systems programming in an applications language, but the results are often less than stellar and a rough beast to maintain.
This is systems level programming and you need more than an applications tool to do the work right.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
We use the same C++ foundation classes in ACE on WinNT, Win2k, Solaris, IRIX, HP-UX, and Linux. ACE is also supported on VxWorks, AIX, and a dozen other weird variants of *nix. It's a comprehensive real-time, networking, threading, and platform abstraction library. The stuff works great. Makes all platforms act the same. Takes a little work to get it compiled at first, though.
Expect to spend some time getting used to the toolkit, which ever one that winds up being. Every minute you spend initially studying example code, and learning the toolkit's way of approaching problems, is one less minute you will spend trying to beat their classes into doing something they weren't necessarily intended to do.
Unless you know what you're getting into up front, keep separate make strategies for Win and Unix. If you're feeling perky after a while, you may be able to migrate your windows build to the same makefiles as unix, but it'll take some work (and probably the cygwin toolset)
How's my programming? Call 1-800-DEV-NULL
The Mozilla "C++ portability guide" is long out-od-date, having been written in early 1998 before the C++ Standard was even official. The Mozilla document makes many uneducated assertions that would lead to poor programming practices.
Any article that suggest the use of macros over templates is clearly no written by anyone who has worked with C++ in the last couple of years.I've been writing, publishing and preaching portable C++ for more than a decade, and I have substantial code bases that compile and run, with MINIMAL conditional compilation, on multiple platforms (hardware and software). What the Mozilla document advocates isn't portable C++, because they threw out almost everything that *is* C++.
All about me
Some definitions:
Systems programming: Driving hardware with software and/or providing interfaces to system resource (i.e. Your OS itself). This includes industrial I/O stuff like you'd see with an energy management system. It's often timing critical with delays causing no end to problems with things working let alone working right.
Applications programming: Just about everything else.
Just because Java does a bang-up job of doing one, doesn't mean it works well for the other. For an energy management system, down to even the UI, the results must always be predictable and consistent for it to be of any use. For the UI, there's some slack for things like GC causing a second or so delay- and at seemingly random intervals. Java's a decent candidate for that. The flipside is that the controls underneath the UI don't want, don't need, can ill afford random delays like that because you could get into oscillations of operation that burn up any advantage you had by the management system in the first place.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
NO is the answer.
But to be serious - it depends on what you're doing. If you don't plan on getting too close to any actual devices or hardware, you'll do OK.
But you'll experience excruciating pain, if you try to do any serious network i/o (Java currently DOESN'T HAVE NONBLOCKING SOCKETS) or do anything that requires special access to hardware (JNI is about as much fun to debug as a kick in the crotch).
Remember kiddies, Java is NOT the One True Language.
1. This is engineering; the solution should be developed as a whole - ie. the hardware and software should be selected from the best available to solve the problem. The solution should then be developed, tested and deployed without changing the game halfway through.
2. Too often developers and their companies see themselves as subservient to their clients. This is the wrong attitude - development should be done as a partnership between client and supplier with both equal. Both client and supplier are much better for it if the supplier is honest with the client. The client is employing you for your skills and knowledge - if they don't at least consider your recommendations, then they are wasting their money.
The client may have good reasons for choosing Windows - but testing on Windows and then changing to Unix is quite clearly a recipe for disaster.
Sorry, but I can see right now that this is very likely to be a project that is going to go wrong. The system has to be tested as a whole - that means using the same users, hardware and software throughout development, testing, deployment and into maintenance.
Are you being simlpy forced to write code outside of Java because your employer/underwriter believes Java will be too slow for implementation, please remind them that the speed of Java applications with a good JVM and JITC can be as fast as C++ with well written code.
If that's their major concern, I would recommend building it in Java from the start.
Use Python. My bro wrote an Othello game for the SGI/Python, ported it to Windows with a single color change. Damn near wet myself seeing the same thing on two *radically* different systems.
Write your app in python, but extend it with C/C++ libraries. Extending with C is easy, use SWIG, which rocks, ignore previous poster. From download to running application in 5 languages was literally fifteen minutes (gd library, Python and Java).
Likewise, embedding is easy: write your application in C/C++ *which calls Python*, then replace Python on an as-needed basis. Develop quickly using an interactive language, then replace them once the algorithms get solid and boring.
This technique gives you a substantial, clean library system; interactivity; portability; etc. It's also easy to replace sections or the whole thing if the PHBs get on your case.
Python rocks!
There are *sooo* many commercial providers of precisely this kind of software, why re-invent it from scratch?!?
One of the few people here on slashdot who isn't stupid.
...out there and here.
Stupid is as stupid likes and uses.
You could argue that perhaps ml is the last advanced language, but few use it.
The last advanced language that people widely adopted would be C++. Java is a kindergarten caricature of C++, designed for kindergarten programmers.
Unfortunately, it's what I'm paid to write in. I wonder how much damage my brain is taking, though. I really would like to get back to C++ and civilization.
The Tcl C library has rock-solid support for serial and network I/O for both Unix and Windows. You language buffs may recall that John Ousterhout first created the Tool Command Language (TCL) as a C library supporting electronic CAD applications. You can check out the interface for I/O channels in the online man pages.
Tcl's thread support is a little more limited. There is a thread extension which is supposed to be pretty good. (I haven't personally used it.) But unless your application is running on multiprocessors, you probably don't need threads and should consider an event-based model. (see "Why Threads Are A Bad Idea" PowerPoint only, sorry.) Events are just plain easier to program and support than threads. And Tcl's event support is excellent.
As a side benefit, you'd get a free scripting environment to prototype your application's communications subsystem.
Wxwindows is a set of cross platform GUI, DB, Networking, IO classes and sound. It runs under windows, Unix, Linux and many others. Look at http://www.wxwindows.org. I have used it in many different applications.
---- aut viam inveniam aut faciam
Yes, you can compile Java into machine code, but guess what, laserbrain? None of the AWT stuff has been adapted to be used natively. And I doubt you have the skill to help them out either. You're probably one of those people who will drool and whine until someone else with some talent does it for you.
Yes you can use JNI, but JNI is about as much fun as a kick in the crotch. I've seen C code run perfectly fine, when used in other C code, but act completely squirrelly when loaded into a JVM.
Hardware is cheap, and if you don't really need to access anything other than a windowing toolkit and main memory, go ahead and use Java. You might have to screw with the gc, if it starts collecting at odd times. If you need to get down to the bare metal, well, see the JNI piece above.
Java is no more or less well organized than C or C++. If anything, it's less consistent than C. Why were arrays made 1st class objects, and not other primitive data types, for instance?
You gotta give Gosling credit for duping people like you. The Force has a strong effect on the weak mind. These aren't the droids you're looking for...
In the 1980s, the speed and compactness you could get out of C was worth the extra coding time. But with today's hardware, languages are coming out of the woodwork that are much less efficient, but still successful. For example, a number of successful web sites have been written in PHP. Not as slow as ASP, but still a horribly slow language. Yet those sites are still successful, because the hardware can handle it. FWIW, my JVM-based implementation of BRL was 3-4x faster than PHP in a simple benchmark. (Incidentally, developers don't need to know C or Java to learn BRL. See the learnbrl.war demo/tutorial.)
As a whole, the CommonC++ design is pretty messy, relying on massive amounts of kludgy ifdefs and macros in the header files. I believe they are working on cleaning it up.
Other libraries I would consider:
ACE: threads, synchronization, sockets. ACE's design is not very object-oriented, but its probably the most extensively portability layer you will find.
IOLib, portable I/O (also includes identical ports for C and Objective-C).
ZThread for threads.
Nescape Portable Runtime (NSPR), a C library: sockets/IPC, threads, synchronization primitives, layered I/O, ADTs/algorithms, portable shared libraries, logging, etc.
there is a cross-platform C library there, or two, SFL and SMT, that they use to create a reference Web Server, Xitami. Bulletproof stuff, tried and tested in many commercial deployments.
Which means I'm not about to touch it with a 10' pole, until someone else has banged on it and driven most of the squirrells away.
Which begs the question, why didn't Java have this in the first place? And it took them *this* long to figure out they needed async I/O? I'm not impressed with the level of sophistication of the Java community.
Congratulations! You "get" it!!!!
The browser is the user interface solution !!!
If we could just get the browser makers to
implement a standard (and robust!!!) javascript,
everything would be even easier.
you da man!!!
Not the nobbled Dinkumware version. Oddly, it's neither PJ Plaugers fault nor Microsoft's fault that they had to use an old version.
Speaking as an occasional participant in that group, I very much doubt anyone there would disagree with you. Those guys are well aware of both cross-platform issues and the deficiencies in VC++ 6.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
He's also right in telling you to fuck yourself.
Dinkumware did write the standard library implementation (including the STL stuff) supplied with VC++ 6. However, the version supplied was actually written before the C++ standard was finalised, and is considerably older than the compiler itself. This results in a number of annoying warnings during builds, and some equally annoying omissions (the auto_ptr implementation is seriously crippled, for example, because they don't have the templated constructor, since that wasn't in the spec pre-standard).
Dinkumware have, of course, revised and updated their library a lot since then. While they do advertise bug fixes (e.g., PJ Plauger himself is a regular on the C++ newsgroups and has posted the fix for getline), they are not just going to give away a whole new version of their library for free -- they've got to make their money somewhere! IMHO, Microsoft should have done the decent thing and shipped the bug fixes and major updates in one of the VC++ service packs, but that would have cost them money, so instead we have to wait for VS.NET, which includes a much improved C++ standard library implementation.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
I know that DJGPP is a mighty fine way of getting GNU stuff onto Windows systems and back for portability. Just avoid using any of the MS API's and the MSFC code.
I *think* that most of the programs developed for GNU environments will compile correctly with DJGPP.
They even include a Borland style IDE with DJGPP.
Codifex Maximus ~ In search of... a shorter sig.
write a "meta" ABC(abstract base class) and base your different serial classes off of those, that way you are forced to keep your interfaces in sink.
Win32 serial is done w/ CreateFile, ReadFile, WriteFile.
linux is done using open and other posix style api's
Hi there,
My company is building a system with basically the same requirements as yours, but for a different market.
We do a LOT of heavy IO (both on the network and on disk) and need to handle tons of threads simultaneously.
Our solution is 100% Java (on the GUI side we use the Java Swing classes, which unlike the old AWT trully is WYSIWYG on all platforms).
Our system has been tested on these platforms without absolutely any modifications whatsoever:
- Windows 95, 98, Me, 2000 Pro, 2000 Server
- Solaris
- Linux
We soon plan to test it on the new Macs as well, as well as some other platforms (HP/UX, AIX, etc).
Most amazing, we re-wrote from scratch the critical loops of our code in highly optimized C routines just for benchmarking, and the Java solution was on average between 4% and 7% slower, which is great, considering we're running debug code.
On the whole, our experience with Java has been great, both on the server and the client side (although sometimes we wish the JTable component was easier to deal with).
Hope this helps.
p.s.: Sorry about not providing more details, but we're under a NDA...
The platform indendant standard does it. Altough windows is one of the few systems that doesn't complain it, you can get by using cygwin:
http://sources.redhat.com/cygwin/
(I know Windows NT got the POSIX Certifacte, but only because they implemented just enough to pass the preknown tests, that does by far not mean that it will function)
If you programm in the cygwin environment using exclusivly the cygwin library interface your code should run pretty well on all other POSIX platforms. (including linux, solaris, *bsd, etc.)
--
Karma 50, and all I got was this lousy T-Shirt.
Yes and yes. However, some caution is in order here.
It is a common misconception that the STL, templates and generic programming are synonymous, that one is only good with the others. This is not true. Generic programming is the concept, the programming style. C++ supports generic programming through its template facilities, but other languages (e.g., functional languages) manage perfectly well without a formal template mechanism. The STL is a very clever library based on generic programming principles, and the C++ standard library contains a large amount of material based on it, and unfortunately also commonly known as the "STL", though it is not entirely Stepanov's original idea. Also unfortunately, C++'s language facilities aren't quite up to making the most of it yet -- templates are a good start, but a couple of major omissions are still crippling for now. Hopefully the next revision of the C++ standard will incorporate things like in-place definition of anonymous functions, to fulfil the currently wasted potential of the standard algorithms.
Sadly, Sun's Java team seem to be amongst the uninformed here. The Java Generics proposal, which you can download via this link if you're interested, basically describes a heavily cut-down version of C++ templates. The usual Java approach has been adopted: take what is commonly used, quietly ignore anything else, add a little here and there but not much of substance. If memory serves, the more glaring omissions include numeric template parameters. Useful techniques from the C++ world such as traits and template metaprogramming appear to be hard or impossible to implement with the current Java generics proposals. As a result, Java's "generics" will probably be good for writing template containers -- itself a great improvement over the status quo -- but not very useful for much else.
It's a step in the right direction, certainly, but in spite of the hype, Java is still way behind the field on this one. The major functional programming languages are probably in the lead, and C++ is still the next most serious contender I know of by quite some distance.
If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
boost has a cross-platform threading library. also, at least some of the boost libraries will probably make it into the next C++ standard so they're a good wagon to hang your hat on, so to speak :)
stay frosty and alert
I'm a professional developer who has been involved with high availability server architectures for the last two years. The group I was a part of was considering the exact same question, finding a cross platform library that supports a variety of sys call abstractions, when a friend who worked on Sun's Streaming Media server told us that they had used Netscape Portable Runtime (NSPR). Since then I've used NSPR extensively for my work, as well as my hobbies. During the last two years it has grown into a very mature library.
n dex.html
NSPR has a simple unix-like API which supports a large number of system calls, including threads, process initialization, locks, conditional variables, monitors, file and network I/O, pipes, timers and time functions, memory management, string operations, floating point routines, long long integers, dynamic linking, IPC, Multi-wait I/O, environmental variables, logging, semaphores, and error handling.
Porting between platforms is nearly seamless (at least for the platforms I've tried). It works well with autoconf and gcc, M$ Visual Studio 6.0, cygwin, and Sun's C compiler (probably others but this is all I?ve used). I've used it personally on FreeBSD, Solaris, Linux, WinNT, and Win2k, and been very satisfied. Also, unlike some of the more notoriously slow Mozilla technologies, such as XUL, NSPR has decently low memory and processor overhead.
Check out for a project overview
http://mozilla.org/projects/nspr/
and the reference for a list of technical capablities
http://mozilla.org/projects/nspr/reference/html/i
Hi,
From reading your post I'm under the impression that the reason your cross platform developing is so that the system can run under existing hardware at the college.
Try doing a business proposal that outlines the costs of cross developing (2*testing, 2 sets of code etc) vs buying a few nix servers to drop in place.
Hardware is cheap - coding and development are expensive. You can pick up a great server these days (raid 5, 2-4 cpu's, good MBd,etc) for only $3-4k.
You will also completely eliminate the migration process you'd otherwise need in going from NT to nix. You can also pitch this as part of the colleges normal server upgrade routine.
There is no way what you're doing could be cheaper than this. You will basically be throwing all that coding you are doing for NT in the trash - what a waste of your time & your clients money.
Most of the posts are at least as much about the posters as your project, interesting though. My only advice is stay away from anything 'new' where your credibility is on the line.
Mostly it depends on your confidence in completion and deadline -- what you can do quickly you can redo, and modify. I didnt see you respond to the contraints put on you by your customer, unless that is flexible the java question is moot.
It does seem much more straightforward to design for the new platform not the old. Be careful that you dont fall into having to validate cross platform confidence you dont possess.
Work from your strengths : dont promise the moon if the sky will do. It would look really bad to be justifying the legacy bugs from the old system on the new hardware.
You've obviously not done a lot of systems programming or you've not tried to broaden your horizons. I've written code for systems that do things like drive Opto-22 I/O, etc. and they all are cross platform (Unix and NT) with minimal differences between the actual code bodies doing the work. If you have to do a lot of differing coding for the differing platforms, you're doing something wrong with your abstractions.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
Why should Trolltech give their software away for free? How are they supposed to feed their families?
But to say "deficiencies" is to put it lightly.
:-Â )
It, for example, allows you to do evil things like modify variables labeled as "const" among other things. I had the damnedest time getting the contractors I was responsible for to get themselves out of THAT habit of Windows programming.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
Its the compiler, stupid.
#ifedf
Solaris
else
Win32
#endif.
I get paid 100 an hour to design cross platform code. who would of thought I could of just asked /. to do my work for me.
He could of at least posted a list of places he's checked.
The Kruger Dunning explains most post on
I develop large client applications which run on various unix platforms and windows NT amoung others.
We do all our development on linux and just build and release on the other architectures.
We've found that gcc's cross compile works really well and we build our NT releases from linux.
Ohh and with regard to the IO and threading etc. Read the Qt docco theres heaps of good cross platform classes in there. Qt 3.0 will do almost everything you seem to want to do.
The ideal scenario would be to recompile on the new platform without changing a line of code - will this type of portability be possible?
It certainly is possible, though you'll almost certainly want to have separate Makefiles for the two platforms. You also have to either use ifdefs, platform specific static libraries, or platform specific shared libraries/dlls.
My one suggestion is that you at the least compile on both platforms early and often. I say at the least, because you'd be better off doing at least some unit testing and QA on both platforms. You will run into problems if you don't, and you probably will run into problems even if you do. This is even true in java, trust me, I know from experience that some platforms are going to have bugs even if you do everything by the book. And other times you'll notice bugs in one platform that are bugs in the other platform, but just don't show up in your tests.
ok then your [sic] infringing on my copyright! Could you as [sic] me next time before STEALING my comments for your own?
TAO -The Ace ORB is a good one aswell, and probably is the best bang for the buck performance and costwise.
'Nuff said.
Unlimited growth == Cancer.
The MKS Toolkit Nutcracker library is stable, proven, and has support for most Unix APIs. I've used it to enable lots of software packages to be portable from Unix to Windows. It comes with all of the scripting and compile tools that you'd need - except Visual C++ which you need to use cc.
You said:
"Oh, and to everyone that has been promoting
ideas like "just use gcc" or "just use
straight c++", maybe you've never worked on a
large scale, long term project, but gcc is not
the best option for an app that needs to be
highly optimized and writting everything in
c++ from scratch is a waste of time
Now, may I pick your mind to what is best - in your opinion, of course - for large scale, long term project?
Thanks in advance !
Muchas Gracias, Señor Edward Snowden !
Writing Generic C++ could solve alot of your problems, but for certain things MS has done a good job with MFC. The company I work for writes code in Visual Studio using MFC and then uses a third party prorgram to compile the windows projects into solaris executables, etc. You can check it out here. http://www.bristol.com/crossplatform/index.html there are other progs available I'm sure but we get good results from this one. I have used it myself and get good results from it. I develop on windows2000 and eventually deploy to solaris8.
Okay, I used to code a lot of Java, and I'm now back to c++. I will tell you that I like coding in c++ as much as I like the design of the Java language. In terms of design, Java has made c# a necessity, and program languages once being the core busines of that small company, I think MS has pretty good reasons to Imitate And Extend (tm).
If you looked closely at how Java is build, you'd probably notice the tons of AbstractFoo.class classes, which contain default implementations for certain interfaces. So if we subclass from that, we don't have to write a single byte extra for any subclassing class, avoiding any code duplication. Implement once, then inherit. Ofcourse you can't design your applications and classes in the same way you design your c++ classes, but a) it's certainly possible, and b) without writing duplicate code, and c) using no difficult syntactical constructs and keeping the design clean.
Templates are nifty but invite coding and compiler bugs. A much nicer solution is the Object single inheritance dependency tree which allows for complete polymorphic behaviour through interfaces, without having to worry about all kinds of casts and vtable jumps. The internals of the compiler can be as clean as you can possibly want them because the inheritance model allows for pure specialisation (is a), and no generalisation (has a), except through extension (implementing interfaces)..
To add some juice to the discussion, there are modelling problems that even c++ can not handle correctly, because the language wasn't build to handle it. For example, consider a geometric construct object 'circle' and 'ellipse'. Objviously, the two objects are related, but how would you describe their relationship ? Mathematically, a circle is special case of an ellipse (you only have one radius), but in c++ you would quite possibly derive ellipse from circle, since it has 2 radii. Now, what happens as soon as you have an ellipse that happens to be a circle (both radii are equal)? Presto, you have a faulting software model of the mathematical model.
Conclusion: use the right tool for the right job. Java is crossplatform, stable, well thought-out, manageable, and quite capable to do anything. C++ (including stl) is fast, ugly, all over the place. STL is certainly not that portable as everybody would like, and templates are usually not supported completely. Yet our software team (including me) is currently rewriting parts of the Java core in c++ to benefit from templates and multiple inheritance and it's speed wherever we can. We have various reasons to do this, one being that the c++ standard language constructs and libraries do not offer the ease of use that we need and that a Java-like inheritance scheme offers. Internally, we use c++ to the max, but our outside sdk shell is completely like Java behaves. It's robust, transparent, fast and nicely designed. It is assured to pay off in the future, when we write our applications.
With great power comes great electricity bills.
Link fix XPCOM Intro
Fully object oriented, if youre platform has a Validated Ada95 compiler, your software will compile and run across platforms.
Just like Java, only it compiles to a native executable and runs about 20 times faster.
Not to mention the oodles of reliability and maintenance features built right into the language.
And the Interfaces.C libs make interfacing with C++ a cinch.
I write cross platform apps with C++ all the time, but for building portable and reliable libraries, nothing has come close to Ada95.
Blah, blah, blahhhhh... Just my personal opinion. It really has saved me alot of time and hassle though.
Good luck on your project.
http://www.adapower.com
comp.lang.ada
Mcdoobie
Many of these suggestions are good, but remember to consider the specific needs of your application first, and don't choose something just because it is cool, open-source, free, cross-platform, has a nice acronym, ...
ZThreads is a very very nice C++ portable threading library. http://zthread.sourceforge.net
Some time back there was a complete cross-platform environment called Galaxy. It won lots of accolades and awards and was praised by quite a few developers. I guess it was killed (almost) by the arrival of Java, though it still seems to be alive.
rmathew.com
Please read the following which appears at the end of the guide.
Revision History.
* 0.5 Initial Revision. 3-27-1998 David Williams
* 0.6 Added "C++ Style casts" and "mutable" entries. 12-24-1998 Ramiro Estrugo
* 0.7 Added "nsCOMPtr" entry and mozillaZine resource link. 12-02-1999 Ramiro Estrugo
* 0.8 Added "reserved words" entry. 2-01-2001 Scott Collins
Also, beware that a stong faction within the mozilla team wanted to code in C rather than C++ because of all the less-than-compatible implementations in C++ that existed. Templates are still broke on some versions of C++. There are folks running mozilla ported to C front for crying out loud. The objective here was to cover as many platforms as possible - not just the top four or five.
Flat out Cross platform development sucks. And sucks royally. As an example you can write fantasticly great code on IRIX systems that works on an Octane but cores on an O2. Both running the same IRIX. The code works nowhere except Octane systems.
// I don't like this but it will be fixed tomorrow
I've been writing very large apps that deploy on many *nix's, NT, W9X/NT, Linux for 9 years. In that time I've come to the conculusion that there is no true ANSI standard C or even more remotely C++ and STL.
All of the compilers are different and have their different bugs and implementations of C/C++.
gcc seems to be the most truthful to the "standard" but even that lacks in spots that will bite your butt on other platforms.
I've written code that has compiled on 13 platforms that dies on the 14th too many times to remember.
My personal favorite was the (then) DEC Alpha C++ compiler that puked on
because the single quote wasn't closed. To this day I shun quotes in my comments.
Other all time favorites:
All compilers except Solaris allow for loops that declare variables inside the if statements even though according to ANSI the defintion of "int i" is ambigious. Lord knows finding and fixing that one cost more than a few dollars in 2MM lines of code.
MSVC. if there is a more stupidly liberal compiler out there, I'd like to run into it and develop on that pig only. (I'll take job offers at my email)
All *nix compliers I've used for Motif allow
Arguments args[2]
XvSetArg(....0)
XvSetArg(....1)
XvSetArg(....2)
XvSetArg(....3)
except gcc. That one tossed Linux into a problem for a day or so 'til we found it.
If you think gcc is the solution, be advised that it allowed the 'setarg(2)' without a problem, it was the 'setarg(4)' that it puked on. It's all a matter of how much buffer is allocated by the compiler by default.
When writing templates about the only complier that has a remote clue of how to do it correctly is HP. Everything else is a poor implementation/fake of templates.
AFAICT, the only way to truely do cross platform development is to write the code, compile and TEST on every platform you want to ship on and, experience the pain, and then relieve the pain/problems.
Even if you have 15 years of C/C++ experience you still will get bit on the butt when you least expect it.
There are no easy solutions. There is only hardship. Heck, that's why we are called "Software Engineers" not "Software Scientists". Us "Engineers"/"Hackers" know we are perfect, the "Scientists" truly belive they are and will always be perfect.
Shark
Fins Up, and to the Left... Any dive you come up from with air in reserve was a great dive. Nothing but bubbles left o
Okay, so maybe Python isn't exactly C++ or C, but you can link to C code with python if necessary. I know this isn't exactly a cross-platform library, but Python is said to take a lot of hassle out of porting.
http://python.org
develop a large energy management system
Developing this for NT will definitely reduce energy costs for the college since the systems will be down most of the time thus, with proper management, reduce power costs for the college.
Why make work for yourself? Here's the easy solution: develop it on linux+XFree86 in the first place - surely you can cadge a cheap/free box from somewhere - and access it from Windows
workstations using Hummingbird Exceed or some other X server.
Run, not walk, to freshmeat.net and inquire for "perltidy".
And it is unlikely to be used in every situation- there's on-board, ethernet, and RS-485 multidrop based Opto-22. This doesn't even get into the varying embedded solutions from other suppliers that drive the passive module backplane for an Opto-22.
.so's project) to make a driver for the RS-485 multidrop B2 interface driver that we were using.
And, that's just Opto-22 stuff, there's all this other lovely stuff that needs driving. In most cases, they have a C or C++ API that snaps right in. For Perl, you had to build the module from that source- and you'd have to pretty much do that for every device you're trying to drive. For me and C++, I had to do very little (pretty much add it to my
And, not to question your choices, but Perl for a systems program (which is what you're describing) on a Naval vessel safety system? Man, you're more confident in Perl and your abilities in it than I would be.
I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
This is simply not true...nobody is translating mozilla to C and running it, and there is no faction within the mozilla community which is pushing to use C. Long ago there were a number of C-only advocates working at Netscape (jwz as an example) but they are no longer there.
The C++ portability guidelines are just that: _portability_ _guidelines_. The primary goal is to make it work on as many compilers as possible, and they are guidelines not rules. There are some platforms which, to this day, do not support anything beyond the simplest C++ templates.
Mozilla makes extensive use of templates with their nsCOMPtr class, but this particular class has been well tested on many platforms, and has many conditional #ifdef's which handle the broken compilers. But this is one major class for which the usefulness outweighed the maintenance costs. If the Mozilla team had to maintain 100 different constantly-changing template classes on 20 different compilers each with their own quirks, it would be a nightmare.
You are wrong about the lack of multiple inheritance in Java. It's there; you simply have to use Java interfaces to get it.
You are also wrong about cut&paste programming. That's a problem due to bad programming, not due to an inherent flaw in Java. A good programmer will abstract out the common code into a separate method. In fact, it's ridiculously easy to do, and your point about forced redundancy in Java programming are completely off base.
http://developer.java.sun.com/developer/technicalA rticles/Networking/timeouts/
You don't really understand what nonblocking sockets are, do you? Obviously, the Java community is a little fuzzy on the concept, as the document above will definitely tell you. Java as a language isn't that bad, but they had some real morons at the keyboard when they pounded out some of their util classes.
I'll give you timeouts for server sockets. Which isn't the same as setting O_NONBLOCK on the socket, but hey, I'll take even that much. It's better than nothing. I just want to get my job done before the end of the day.
Show me where you can set timeouts on client sockets. That's right, you can't. At least not before you connect, which drastically reduces the usefulness of setting timeouts. They tell you to put the socket in a thread, and then do some waiting/synchronization with that thread. A brain-damaged way of going about it, if you ask me. But I guess you like damaging your brain. You obviously don't know any better.
Fortunately, they're fixing it all in JDK 1.4, with the java.nio.* package, but I suppose that's beyond your comprehension level too. You might try looking at it sometime - it'll hurt your brain, but hey, you might actually learn something.
Expensive as hell, you have to pay to Rogue Wave for every license you ship of your own software...
Perl *is* C and it constitutes the most robust (secure against buffer attacks too) cross platform library you could ask for. You can also do all the things you need to do (and it will work even better on Unix so you can look forward to that). Networking, I/O, forking servers, it is all already done for you and tested in the CPAN (search.cpan.org). It will save you time and make the six month timeframe realistic for you (can't see it happening with C/C++ or Java frankly). It can do Qt, Tk and other GUI toolkits and can handle C and C++ like a charm. Unlike Java, which babysits you so you don't make mistakes, Perl's theme is "There's More Than One Way To Do It" (TMTOWTDI) which may be refreshing. You can still write everything in C/C++ but first get yourself a Perl architecture on top of it.
It is faster to program in Perl and you will be able to use C/C++ for the parts in which you need speed. You can even type C inline in you Perl program and it will compile it for you automatically.
You will be able to take advantage of lots of easy to find algorithms and can prototype a network-aware system extremely quickly. One event loop architecture for client apps called POE may be interesting for you.
To be fair, you could also do it in Java. Though I don't think it magically solves cross-platform issues, it costs more money, and there is a limited number of situations in which you really need to build a Java system. This system might be one of those however. It is usually a matter of what your team knows (although you get more power faster out of Perl). Then I expect you would skip Qt, and stop all the C/C++ work you are doing. If you have a Java team ready you might want to use Java then. Until the next version of Perl it is faster, though Perl usually uses precompiled C/C++ code for time-dependent things.
I am a Perl programmer and have managed Java e-commerce site development in the past (on WebLogic and Tomcat). It depends on the experience of your team as to whether you pick Perl or Java. If you want to build an animated client that talks to servers, or do large corporate multi-tier intranets, maybe Java is best. But I don't see you doing that in your time frame and I don't see it as being important to you. And of course you can make Perl-based clients, either encapsulated in an exe file or very thin and based on top of a local Perl installation.
You will probably be able to prototype the full functionality in straight Perl, optimizing later with into C/C++ on a per package (module) basis. So you need to first design yourself a clean, modular architecture of black boxes. I'd recommend doing use-case design to help discover all human-machine interaction and identify priorities; this will help you with risk management too and is applicable to any language.
You might even want to use CORBA or something similar so that these modules are providing networked services and can be changed to whatever language or system you like without fear. It seems likely that the most important thing to your client will be not the language but the ability to see a prototype, know it is extensible and scalable, and be able to get all the functionality (plus the feature creep functionality) for minimum cost.
Also Perl can run Java! And it can use commands like catch-throw and switch-case because Perl is an extensible, postmodern language that is getting very scarily powerful. In case you haven't noticed I'd recommend Perl in particular because of your timeframe, your leaning toward C/C++/Qt, and probably many other needs you will begin to appreciate such as glue to current systems, talking to devices, other information services, and so on. I have not been impressed with Java performance either engineering wise or in terms of cost, but if you have a trained team with plenty of time, lots of money, and a need for very high traffic transaction systems, Java and something like WebLogic is probably best. But you are not the phone company and I think the answer is obvious. Time to upgrade to Perl!
Some references are perl.com, perlmonks.org, and cpan.org. I think you will be pleasantly surprised. Just to reinforce the message, Java is still a totally valid option and probably most people will say Java, and something that is only Java and nothing else does have a beautiful elegance to it. I think though that you will probably save a lot of time and get tons more efficiencies from available code, being able to use different languages, being able to prototype more quickly, and being able to start *now* when it is still a reasonable amount of time instead of doing more technology surveys. You might want to post your question to both perlmonks.org and a Java site and see what people say, it might be interesting.