Slashdot Mirror


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?"

131 of 531 comments (clear)

  1. A little known library is SFL by Hougaard · · Score: 3, Informative

    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..

  2. GNU Compiler + CommonC++ by lkaos · · Score: 2, Troll

    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));
    1. Re:GNU Compiler + CommonC++ by dyfet · · Score: 2, Informative

      GNU Common C++ certainly does abstract network I/O (sockets) as well as threads, serial I/O, XML parsing, and logging. There is also a supplimental RTP stack for it (ccRTP). It compiles native under win32 as well as under posix targets. It recently has had a very extensive rewrite, and is still recovering from that.

    2. Re:GNU Compiler + CommonC++ by Earlybird · · Score: 2
      NT's POSIX subsystem is for running POSIX.1 binaries. Access to this subsystem is not provided to Win32 executables, which run under the Win32 subsystem.

      Since the two are completely isolated from each other, POSIX programs cannot make use of common Win32 services like networking, graphics, DCOM etc. All subsystems are implemented on top of the native, undocumented NT APIs (ntdll.dll).

      Similarly, NT has an OS/2 subsystem which is capable of running OS/2 console programs. The original idea was that NT could expose different, swappable "personalities", of which Win32 is but one, but of course that potential has never been realized.

      For more information, see Understanding Windows NT POSIX Compatibility.

  3. ACE ADAPTIVE Communication Environment by n-tone · · Score: 4, Informative

    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.

    1. Re:ACE ADAPTIVE Communication Environment by dkixk · · Score: 2, Informative

      I'll second the recommendation of ACE. In addition to ACE, The ACE ORB (TAO), Zen, their real-time ORB, and Jaws, An Application Framework for High Performance Web Systems, are all worth a look. This stuff has been around for quite some time and has been ported to nearly every compiler-platform imaginable.

    2. Re:ACE ADAPTIVE Communication Environment by irix · · Score: 4, Informative

      I (and my company) also use this library extensively in a number of C++ projects to do multithreading, socket communications and memory maps, just to name a few things.

      It is open source, so it has the advantage that you can fix or patch bugs easily, and extend it if you want to.

      Even if you don't use the cross-platform part of ACE a lot, the C++ abstractions for some common UNIX paradigms are great to have - for example you can turn a class into a thread, etc.

      --

      Do you even know anything about perl? -- AC Replying to Tom Christiansen post.
  4. Question by SimonK · · Score: 5, Insightful

    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.

    1. Re:Question by PD · · Score: 2

      Damned idiot moderators, this was a perfectly good comment, with a good suggestion, AND a truthful statement about Python and Java.

      Moderation is not the place to put across your personal opinions.

  5. Err, you told us didn't you? by mainframe_uk · · Score: 5, Insightful

    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.

    1. Re:Err, you told us didn't you? by Surak · · Score: 2, Informative

      Right. Serial port stuff is another issue. Most of the serial port stuff that I've seen written was either written years ago, or based off of stuff that was written years ago. What you'd have to do, more than likely is either find a serial port library that wraps around OS functionality, or write one yourself.

      'nix and NT handle serial ports very differently, and I doubt that such a library exists. Writing one should not be too difficult because serial port stuff is really basic anyways...you have data going in and data going out, it doesn't get more complicated than that. :)

    2. Re:Err, you told us didn't you? by larien · · Score: 3, Informative
      Even if the serial stuff was written years ago, is that such a problem? What difference is there between a serial port 10 years ago and a serial port now? My guess is not a lot, other than perhaps faster baud rates, but I don't think even that has changed in about 5 years (how long have we had UART 16550?).

      Worst case scenario, put all the serial code into one file and use functions like open_serial_socket(), read_serial_data which call the underlying OS functions. When you move to Unix, swap out the file for the new version.

    3. Re:Err, you told us didn't you? by statusbar · · Score: 2

      Some libraries compiled for Win98 serial ports will not work with Win2000 serial ports. The API sucks and is overly complex (hey, it is micro$oft!) - also, the API does not deal with 16550 directly. AND-, at 115kbaud, the NT serial driver WILL lose data bytes, even on a dual pentium. So you gotta EXPECT dropped bytes. No one usually notices this because they are usually using PPP which handles the re-send for you.

      But it IS easy to write your own anyways on both platforms. No big deal. RTFM

      --jeff

      --jeff

      --
      ipv6 is my vpn
    4. Re:Err, you told us didn't you? by strobert · · Score: 2

      For serial port (and network and threading for that matter. look at: http://www.ysl.org

      okay, so I am biased (one of the authors), but the serial code works well on both linux and winNT (haven't tried the serial code on another unix). Has been use for commercial use to communicated with embedded hardware controlling oil drilling equipment.

      If you grab it, definently use the cvs access (haven't done a release in a while as all active users go for the revs in CVS)

      and it is OpenSource

  6. Usr Open source tools by Lumpy · · Score: 4, Informative

    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.
  7. wxWindows by Anonymous Coward · · Score: 3, Informative

    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.

    1. Re:wxWindows by joerg · · Score: 4, Informative

      wxWindows has Networking support (socket I/O, ipc,... whatever you want), thread support, a rich feature set for GUIs and much more (unfortunately there is no support for Serial I/O).

      You might even consider to drop QT in favor of wxWindows.

      It is availabe for Windows, XWindows (GTK based), Mac and some other platforms. It is released under the LGPL.

    2. Re:wxWindows by erlando · · Score: 3, Informative

      And it has the IMO great advantage over Qt in that it uses native widgets where possible. Qt draws its own widgets afaik.

      Also the Qt-license is very restrictive. wxWindows has a license explicitly allowing the library to be used for commercial purposes.

      wxWindows runs on Windows, MacOS (9 and X), GTK(+). Work is underway to implement a universal version of the library to be run on embedded platforms.

      wxWindows is open-source. Patches and contributions are highly encouraged. Also the mailing-lists are very active with several of the main developers taking part in the discussion.

      --
      Remember, there are no stupid questions. But there are a lot of inquisitive idiots.
    3. Re:wxWindows by rs_nuke · · Score: 3, Insightful

      A year back when trying to find out if I should choose QT or wxWindows, I noticed very poor reliablity with QT, I did experience several cores just by compiling the samples that came with QT on all *nix plateforms. (Solaris,HP-UX,IRIX,DUX) I remember my Solaris box often cored after playing with QT widgets... However, QT was _rock_solid_ on Linux, and windows.

      wxWindows is far more a complete set GUI and more including I/O, networking, ODBC (database)! The nices part about wxWindows is the native look, of other *nix apps, on the unix world, which come with Motif R1.2 or better, using the Motif build of wxWindows gives a nice native look, and smaller executables! By linking with already found Motif libraries DSOs! I recalled some sample QT examples were like several megabytes! On non-x86 *nix boxes.

      For someone that has been working with wxWindows, and tried QT, by far, I think wxWindows wins hands down. I don't know why it isn't as "famous" as QT.

      My .02cents...

    4. Re:wxWindows by Spy+Hunter · · Score: 2
      I was not too pleased with Qt on Windows. The gui seemed very slugish.

      I have not noticed anything like that. I thought the advantage of Opera was that it was supposed to be lightning fast, faster than IE. Also, QT's platform consistency is great.

      About reuse, well, TrollTech already spent time doing QT's widgets, so you might as well use them.

      --
      main(c,r){for(r=32;r;) printf(++c>31?c=!r--,"\n":c<r?" ":~c&r?" `":" #");}
  8. At least use the STL.. by reachinmark · · Score: 3, Informative
    We have our own API that we used to support on both unix and NT. It was originally developed on IRIX, and we made extensive use of the C++ Standard Template Library which made things a bit easier when porting to NT.

    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).

  9. NSPR by machingo · · Score: 5, Informative

    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.

  10. Apache Portable Runtime by bob@dB.org · · Score: 2, Informative

    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
    1. Re:Apache Portable Runtime by ttfkam · · Score: 2

      Not really... Netscape Portable Runtime is at version 4.1. The APR came about with the development of Apache 2.0 (still not out of beta yet). NSPR had been tested and used since before Mozilla started development. It's been the cross-platform glue that put Netscape Communicator on so many different kinds of computer.

      Not to slight the APR, it's a well engineering library. However I still think that the ASF would have been better served by reusing (and improving) the NSPR than making their own.

      So much for code reuse in free software... :-/

      --

      - I don't need to go outside, my CRT tan'll do me just fine.
  11. qt 3.0 have it all by eske · · Score: 2, Informative

    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
  12. Rogue Wave by sql*kitten · · Score: 4, Informative

    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.

    1. Re:Rogue Wave by King+Of+Chat · · Score: 2

      Didn't they get the old zApp class libraries (mostly GUI) as well? They don't seem to be pushing C++ stuff much on their website (traitors!) so I can't tell.

      A few years ago I used zApp. I coded up about 250,000 lines of C++ on OS/2 2.1, then ported it to 16 bit Windows. The port took less than a week - IIRC, there was about 50 lines of platform specific stuff. Mind you, OS2 and Windoze aren't that different and I am a genius.

      The old Tools/threads/stuff.h++ stuff sounds like what's needed for the non GUI stuff.

      --
      This sig made only from recycled ASCII
    2. Re:Rogue Wave by Teancom · · Score: 3, Informative

      We have used .h++ for years around here for our main inhouse app. We decided just yesterday to remove all remaining dependencies and go to straight stl. Why? Because .h++ is not source-code compatabile with SourcePro, they provide no migration path, or even a "porting howto" (all according to our account rep). So we are faced with either spending the time and energy porting from .h++ to SourcePro, or spending the exact same amount of time and energy porting to the stl, with the side benefit of making our app linux compatable.

      Which reminds me, their linux port *SUCKS*. The latest and greatest .h++ will run on Redhat6.2, with gcc 2.95.2, the stock kernel, and *thats* *it* (not even perfectly, there are serious bugs). Any other platform (we've tried mandrake 7.2,8.0,8.1;debian2.1,2.2;redhat 7.0,7.2) will segfault/core dump. Their next release, due January, will run on redhat 7.1. I have no doubt that it will fail to run on anything else. So it really falls down wrt cross-platform compatability.

      So, to summarize, if you happen to be running one of the "tier-one" plarforms, their libs are pretty decent. Anything else, even if it's listed as "compatable", and you'll be screwed.

      (as a quick example of what I'm talking about, our app has different defaults depending on what it was called as, tc vs. frpt vs. etc, and it does a simple check of ARGV[0] to see if it .contains the various names. It doesn't work on linux. Flat-out returns the wrong value. And that's on redhat6.2. Any attempt to use their string class will immediately seg-fault. I'm seriously disappointed, in case you couldn't tell.)

  13. Re:NT vs Unix. by ZxCv · · Score: 2

    My guess (and what my impression was reading the post) is that the submitter has to use NT, presumably because whatever systems it has to run on currently run NT.

    Just be glad its not the other way around and they're not migrating from Unix to NT.

    --

    Perl - $Just @when->$you ${thought} s/yn/tax/ &couldn\'t %get $worse;
  14. This is wrong by Nicolas+MONNET · · Score: 3, Offtopic

    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.

    1. Re:This is wrong by aozilla · · Score: 2

      Writing cross platform GUI applications is hard.

      Hmm, I find that quite interesting. I am currently writing a linux program in GTK+. I downloaded the source code into Windows, compiled, ran, and... it crashed...

      Then I changed two places where I was calling free(), and changed it to g_free(). Recompiled, and the app runs perfectly on Windows and Linux.

      --
      ok then your [sic] infringing on my copyright! Could you as [sic] me next time before STEALING my comments for your own?
  15. Kylix? by Ubi_NL · · Score: 2, Interesting

    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.
    1. Re:Kylix? by Surak · · Score: 2

      Not necessarily. If you use ONLY Delphi/Kylix libraries, that's probably true. As soon as you make a raw Win32 API call, forget it. Dollars to donuts says the thing won't compile under Kylix. I have no practical experience trying to get Delphi apps to compile on Kylix (yet), but based on what I know about writing other stuff cross-platform, and combining that with my knowledge of Delphi, that's my story and I'm sticking too it. :)

    2. Re:Kylix? by DarkEdgeX · · Score: 2

      The thing is, almost all the features desired are already handled in the class framework for Delphi (the exception being Serial communications, which really are quite simple under Win32, which leaves writing your own cross-platform class(es) to handle it, or finding someone elses and porting them or using them). About the only time you'd ever use a Win32 API call is for a feature that wasn't implemented that you needed, and that's what {$IFDEF ...} is for.

      --
      All I know about Bush is I had a good job when Clinton was president.
    3. Re:Kylix? by uradu · · Score: 2

      That's true about Win32 calls, but that's not as big a problem as it might appear. Especially for business-type apps that don't need exotic hardware access, the VLC wrapps the OS quite nicely. And chances are that someone wrote a component to do what you need, and that this component will show up in Kylix sooner or later. I'm pretty sure many of the Delphi serial port components will be available under Kylix, if they're not already. The socket components already are.

      The biggest argument against Kylix would be that it compiles only x86 executables. Rumors are that other platforms will be supported in the future (esp. MacOS X), but Borland doesn't comment on rumors. If however x86 Linux is all you need, you should very seriously consider Delphi/Kylix.

      -

    4. Re:Kylix? by DarkEdgeX · · Score: 2

      Whichever person with moderator points modded this Off-Topic, please shoot yourself, and spare us more of your idiotic moderation skills. Suggesting Kylix is a completely fair stance.

      --
      All I know about Bush is I had a good job when Clinton was president.
  16. Can it be browser based? by Ami+Ganguli · · Score: 5, Insightful

    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
  17. A more comprehensive approach by Anonymous+Brave+Guy · · Score: 5, Insightful

    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.
    1. Re:A more comprehensive approach by p3d0 · · Score: 2

      Absolutely right. Otherwise, you're at the mercy of an unknown factor. This is what software engineering is all about.

      Make sure your interface is designed to place the least possible requirements on the underlying library, or else you may find it difficult to substitute another later. It would be wise to look at a few libraries (say, Qt, Gnome, and Windows' own) and concentrate on their differences, just to get an idea of the range of possibilities. Then design your interface in such a way that it doesn't rule any of them out unless it really needs to.

      I know it sounds like you're designing your own GUI library from scratch, but that's not the case. You're simply expressing your GUI needs in terms of an interface which can be implemented easily in terms of existing GUI libraries.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    2. Re:A more comprehensive approach by interiot · · Score: 3, Insightful

      So, write your own cross-platform library since none available is taylored to your own needs. ?

    3. Re:A more comprehensive approach by Thomas+Charron · · Score: 2

      No. Abstracting your code provides you many things. Only ONE of which being the ability to cross compile easily. It also allows you to cross compile using DIFFERENT libraries on the SAME OS. Or even provide different networking capabilities. It makes alot of sense, really..

      --
      -- I'm the root of all that's evil, but you can call me cookie..
    4. Re:A more comprehensive approach by Anonymous+Brave+Guy · · Score: 2
      So, write your own cross-platform library since none available is taylored to your own needs?

      Not at all. Just isolate any use you make of libraries you don't control and/or may have to change (i.e., pretty much anything your team isn't writing itself and that isn't a standard part of your implementation language). You only need to define the interfaces; the implementations may well be trivial if you've got a good library or two to support you.

      The isolation layer is a sound investment. It costs almost nothing in real terms. Where it does cost significantly -- if your implementation isn't trivial on a given platform -- you'll still be very glad you isolated that code later. It would have been much more expensive to implement whatever it is throughout your whole codebase when your "portable" library turned out to be anything but.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
    5. Re:A more comprehensive approach by Anonymous+Brave+Guy · · Score: 2
      I'm getting really sick of these idiots who haven't done a Computer Science or Software Engineering degree at college running around thinking that they know how to make good software.

      How ironic. I'm getting really sick of those idiots who teach Computer Science or Software Engineering courses running around thinking that they know how to make good software. ;-)

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  18. And why can't you use Java? by Anonymous Coward · · Score: 5, Informative
    You clearly point out that you have prior experience with Java. Java meets all of the requirements you listed:
    • Cross Platform
    • Portability without changing a line of code (or recompiling for that matter)
    • Multi-threading
    • Serial I/O
    • Network I/O

    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?

    1. Re:And why can't you use Java? by onion2k · · Score: 2



      Exactly the same arguements could be used for Perl..

    2. Re:And why can't you use Java? by OblongPlatypus · · Score: 3

      Isn't multithreading still fairly shoddy in Perl 5? They say it'll be great in Perl 6, but at the rate things are going these days, Perl 6 is still a long way off.

      --
      -- If no truths are spoken then no lies can hide --
    3. Re:And why can't you use Java? by mvw · · Score: 4, Interesting
      Java meets all of the requirements you listed:
      • Cross Platform
      Which means it will run with all promised features only on Win32, with some drawbacks under Solaris, with other drawbacks under Linux (where it has a strange status between supported and unsupported) and is not supported at all under *BSD. The situation for Mac is not known to me, Jave seems to be available lately.
      • Portability without changing a line of code (or recompiling for that matter)
      Both is not true in general. Only non GUI programs, using only established APIs have a change to run without modification, so much for source compatibility. For byte code it turned out, that while the byte code it self might be stable, other stuff changed so much over time, that you are forced to recompile old classes (I had this experience with many security related APIs).
      • Multi-threading
      Multi-threading is still a complicated matter under Java, perhaps it is a bit easier because one just deals with one implementation per plattform in general.

      But implementation is still different. Under Win32 you get preemptive multitasking, under other implementations (like Solaris up to certain revision) you have only cooperative multitasking. So you are still forced to stray yield() or sleep() into your loops.

      I found debugging multithreaded apps under Java complicated as well, not too much help from the JBuilder IDE I used, and I was not able to detect certain stall conditions with JProbe's threadalizer. (Blame it on me or the tool :) I had to work things out with classic printf style debugging that gave me a hint, what thread was doing what.

      • Network I/O

      Berkley sockets are quite standard, be it UNIX or Win32 (WinSocks) that is not that hard.

      • In addition, you can get security, high availabilty, and scaleability with far less effort and platform-dependence than a C/C++ solution.
      I think that statement is bullshit. It largely depends on the experience of your programmer what is easier to use.

      In my experience Java is still unforgiving. Good code runs well, but you will feel it if you run sloppy or bad code, be it speed or memory wise. Under C/C++ there is a certain margin of tolerance in that area. Alas you have to grok pointers, which seems to be seen as a problem todays.

      On the good side Java has some large standardized libraries and nice development tools. I also believe that the average Java code is more modern, because it uses these modern libs.

      Both approaches C++/QT/NSPR whatever or Java might lead to a working solution. Each has its strongnesses and weaknesses. (And there is other stuff, like functional languages :)

      Again I would take the experience of the crew as the deciding factor.

      Regards,
      Marc

    4. Re:And why can't you use Java? by Teferi · · Score: 2

      Eh, a JDK exists for FreeBSD, and if that isn't good enough, the Linux one'll run just fine. There's even a port for it.

      --
      -- Veni, vidi, dormivi
    5. Re:And why can't you use Java? by Fnkmaster · · Score: 2

      Sorry, dude, Linux is fully supported and the Linux JDK is distributed by Sun. You must be thinking of 2 or 3 years ago when the Blackdown JDK was originally built with support from Sun but by outside developers. Who still work on the JDK as far as I know, but there is an in-house team at Sun as well (and I haven't seen any of the parallel track Blackdown-Sun releases since JDK 1.2.2).

    6. Re:And why can't you use Java? by duffbeer703 · · Score: 2

      I think you are exaggerating the faults of Java more than a bit.

      I use a Java GUI (swing) program and a several java server applications on AIX, Solaris and Windows NT every day, they perform pretty well.

      --
      Conformity is the jailer of freedom and enemy of growth. -JFK
    7. Re:And why can't you use Java? by Hard_Code · · Score: 2
      Which means it will run with all promised features only on Win32, with some drawbacks under Solaris, with other drawbacks under Linux (where it has a strange status between supported and unsupported) and is not supported at all under *BSD. The situation for Mac is not known to me, Jave seems to be available lately.

      What "promised features"? Are you aware of how many companies actually rely on Java for really critical stuff, and use it accross platforms? We have production systems that run a whole slew of Java software on AIX (yes, IBM AIX!), Windows, and Solaris (client applications, servlet engines w/ servlets/jsp, backended by Java CORBA objects and JDBC database connections). Mac OS has finally caught up with the rest of the world and produced a Java 2 VM. Microsoft is "dropping" Java support, but that doesn't mean a damn thing because we run Sun's reference VM anyway. Is using QT really that less difficult than a Java GUI in the first place?

      Both is not true in general. Only non GUI programs, using only established APIs have a change to run without modification, so much for source compatibility. For byte code it turned out, that while the byte code it self might be stable, other stuff changed so much over time, that you are forced to recompile old classes (I had this experience with many security related APIs).

      Where's your evidence? The only time I've seen incompatibilities is when Mac OS added an extra Help menu (oh horrors). Seriously, have you looked at Java since the mid nineties? APIs changing is a *version* issue, not a *platform* issue, and is an identical problem encountered by C and C++ programs (what version of libc, what version of GCC, etc. etc.).
      Multi-threading is still a complicated matter under Java, perhaps it is a bit easier because one just deals with one implementation per plattform in general.
      But implementation is still different. Under Win32 you get preemptive multitasking, under other implementations (like Solaris up to certain revision) you have only cooperative multitasking. So you are still forced to stray yield() or sleep() into your loops.

      I found debugging multithreaded apps under Java complicated as well, not too much help from the JBuilder IDE I used, and I was not able to detect certain stall conditions with JProbe's threadalizer. (Blame it on me or the tool :) I had to work things out with classic printf style debugging that gave me a hint, what thread was doing what.

      Multithreading is "complicated" period. A native language would painfully expose you to all those incompatibilities *anyway*, so I don't see how the case is any different. Do you have any arguments to lodge that aren't moreso applicable to native languages (yeah, writing conditional code for different native threading models for Windows, Linux, BSD, Solaris, etc. on top of the complexity of multithreading in the first place is *exactly* what I want *choke*).

      Berkley sockets are quite standard, be it UNIX or Win32 (WinSocks) that is not that hard.

      And they are just as "not that hard" in Java. Your point?

      I think that statement is bullshit. It largely depends on the experience of your programmer what is easier to use.


      Java security policy files. You set it, you forget it. Your code WILL NOT access resources you have not given it permission to. One the other hand, native code is notorious for security holes, accidental or otherwise. High availability is partly dependent on robustness of security. "Scaleability" is probably a lark, but as the poster says, you probably will get it with less effort given that you're not hardware bound.

      So, in conclusion Java *does* meet all the requirements he posted. Perhaps C or C++ meets some more and some less than others but that wasn't the argument. C/C++ wins in performance, and integration with other native libraries. I can't think of anything else though.
      --

      It's 10 PM. Do you know if you're un-American?
    8. Re:And why can't you use Java? by aozilla · · Score: 2

      Forget java, use wine.

      • Cross Platform
      • Portability without changing a line of code (or recompiling for that matter)
      • Muti-threading
      • Serial I/O
      • Network I/O

      Plus, unlike java, you're not running an emulator.

      --
      ok then your [sic] infringing on my copyright! Could you as [sic] me next time before STEALING my comments for your own?
    9. Re:And why can't you use Java? by Wraithlyn · · Score: 2
      "C/C++ wins in performance"

      I'm not contesting this, but I would like to add something. Modern HotSpot VMs are getting REALLY good. For those who don't know, HotSpot starts executing Java in interpreted mode immediately, to eliminate the costly startup time of a full blown pre-compiler like JIT. Then HotSpot dynamically analyzes the runtime characteristics of the program, and determines what sections of code are run most frequently. These sections ("hot spots") are then compiled (with advanced optimizations) to native code. They have also made major inroads with incremental garbage collection, short-lived object efficiency, thread synchronization, and a host of other goodies. Sun has been dedicating major resources to this type of research for years. Java has really hit its stride with 1.3, I can't wait for 1.4. (Primary focus in 1.4 is on stability and scalibility, as opposed to new features)

      Don't get me wrong... I'm not saying the next Quake engine will be written in Java. I believe low level real time stuff will always be the domain of native C/++, ASM, etc.. but the performance difference between high level C and high level Java is FAR less that most of you would probably believe. I think the biggest caveat to Java is the huge runtime footprint, but that's the tradeoff of having such a feature rich, OS independant platform.

      Here is Sun's white paper on HotSpot, it's very well written.

      --
      "Mind, as manifested by the capacity to make choices, is to some extent present in every electron." -Freeman Dyson
    10. Re:And why can't you use Java? by mvw · · Score: 2
      Eh, a JDK exists for FreeBSD, and if that isn't good enough, the Linux one'll run just fine.

      Yes, all exist. But the native 1.2 and 1.3.1 ports are still of beta quality.

      And last time I checked it, the linux port too had problems running the Hot Spot VM. Part of this was due to the different thread implementations between Linux and FreeBSD. I'm not sure, if this has been fixed in the meantime. Could be, could be not.

      For production use, one needs a rock solid implementation and the speed one gets. Thus having resort to the classic VM is a major drawback.

      The situation under Linux regarding stability is better than under BSD. However the various JDK releases each have their own bugs and drawbacks and strangenesses. My personal experience is that while Linux got some support here from Sun, it typically lacks behind the Windows version in quality. This gets more obvious if you look at the situation for extensions, like Java3D, which lack behind in version often too.

      Not that it is technically impossible to come up with similiar nice Unix versions, but it has not happened yet. And it is clear why. The present dominant client system is Win32 and Sun concentrates its efforts here.

      Some experimental stuff I did (e.g. Java3D distribution via Java Web Start) did not work out under Linux while it did under Win32 due to fundamental problems with shared library loading and Linux glibc madness.

      A lesser evil is the appearance of the GUI/Swing applications under X11 in general. It simply looks uglier than under Windows. I'm not sure why exactly, it could be the fonts.

      All this adds up to my opinion that the only real nice Java implementation for building clients at present is the Win32 one. I don't like this, but such it is.

      Regards,
      Marc

    11. Re:And why can't you use Java? by mvw · · Score: 2
      You are right that Sun features the JDK/JRE for Linux as well on its download page.

      But if you look closer you will notice differences in the effort Sun puts in for the various plattforms. It is more obvious if you look at availibilty of the additional packages, like this one.

      First comes Windows, be it 95,98,ME,NT,2000 or XP. You noticed the special XP 1.3.1 release? And it makes pretty much sense for them - enterprises typically use Unix for the server side and Win32 for client boxes, so the Java clients there need attention.

      Next one seems to me Solaris. At least in the Java parts I work with, I see more activity for Solaris than for Linux. However I can't speak of the quality here, as I rarely use the Solaris box we have.

      Last comes Linux, x86 Linux. And it is not clear to me what Linux they use as reference, as Linux distributions differ. Had some strange problems here.

      I would like to hear other Slashdotter's opionion on this.

      Regards,
      Marc

    12. Re:And why can't you use Java? by mvw · · Score: 2
      But you noted that I did not only criticize some of the hype arguments ("write once, run everywhere", or "Java is better than C++"), but that I said some nice things as well? (modern libs, nice tools). :)

      And I didn't say that Java programs are not able to do their job - what I said was that programming a non trivial Java app is not as easy as some Java advocates tell.

      There are some very nice examples of good Java apps. The clients I like most are JBuilder and Together, both IDEs.

      But take JBuilder as example, this program is crafted very well and even if it is said to be a pure Java app you will find three seperate distributions one the installation CD (one Win32, one Solaris, one Linux :)

      Regarding server programming: one of the interesting uses of Java here is to enable to get applications written at all. :) How many programmers for example have experience in C on a S/390 mainframe or have access to such a box to learn? In that case developing the app e.g. under NT first and then moving it over to the mainframe and tweaking it there is considerably easier.

      Regards,
      Marc

    13. Re:And why can't you use Java? by mvw · · Score: 2
      What "promised features"?

      The ones I need are:

      • smooth and stable execution under Win32 and Linux, perhaps Solaris one day
      • flawless access to the OODB we use and
      • some goodies like Java3D and web deployment, (right now Java Web Start)
      • If the development environment (Editor, Debugger, Profiler, Testing, Architecture, Configuration Management) would work under Win32 and Linux equally well, it would be a plus
      The experience so far with all points (except security related stuff) was, that it either was less hassle under Win32 to achieve than under Linux, or it didn't work under Linux for various reasons. There is definitly a difference in maturity of both plattforms at this time. I would love to see it the other way, but I have to acknowledge reality.

      Are you aware of how many companies actually rely on Java for really critical stuff, and use it accross platforms?

      Sure. Java has its strong sides and its weak sides. J2EE reputation eg is excellent.

      We have production systems that run a whole slew of Java software on AIX (yes, IBM AIX!), Windows, and Solaris (client applications, servlet engines w/ servlets/jsp, backended by Java CORBA objects and JDBC database connections)

      Again, I don't said, Java is worthless junk. I however wrote down my opinion on some of its hyped ascpects.

      Is using QT really that less difficult than a Java GUI in the first place?

      I believe QT will give more trouble programming it (less mature development tools for example, smaller development community) but it will save some gray hairs if the application is demanding regarding performance and memory.

      Where's your evidence? The only time I've seen incompatibilities is when Mac OS added an extra Help menu (oh horrors).

      I wrote some not too complicated data visualization applets which at some time stopped to compile cleanly (ok, apis get deprecated at some point), did behave differently under different VMs and plattforms in some unexpected areas (eg like scrollbar behaviour) and at some time didn't work correctly anymore because the changed security model prevented correct access to the applet's data resources.

      Seriously, have you looked at Java since the mid nineties?

      I only paused between mid 1998 and mid 2000, otherwise I developped fulltime under Java as well.

      APIs changing is a *version* issue, not a *platform* issue, and is an identical problem encountered by C and C++ programs (what version of libc, what version of GCC, etc. etc.).

      True, but Java is always not only "Java the language" but also had a "Java the platform" aspect. And it turned out that is not as downward compatible as initially promised. A change 1.3.x to a 1.4 VM for example should not require recompilation or even recoding of a once running application. Guess what will happen once 1.4 final shows up? :)

      And Java multiplattform is certainly not "write once, run everywhere".

      Multithreading is "complicated" period. A native language would painfully expose you to all those incompatibilities *anyway*, so I don't see how the case is any different.

      My point was that using Java here makes things a bit easier (you don't have to choose some lib like QT, NSPR or whatever, you know you do it with your Java implementation) but not really easier, because MT is complicated. Sounds simliliar to your statement.

      Java security policy files. You set it, you forget it. Your code WILL NOT access resources you have not given it permission to.

      That's theory. The Java interpreter and its byte code verifier are prone to implementation errors like any other product. There exist exploits as well. Not to speak of native libs who work in the background. (eg 1.4 on Win32 will improve Swing performance by resorting to Direct X use)

      So, in conclusion Java *does* meet all the requirements he posted. Perhaps C or C++ meets some more and some less than others but that wasn't the argument.

      Fine, but that is what i said as well. Java is an option. However it is not automatically the better option. If you have a bunch of fairly experienced Java hackers go for it.

      Regards,
      Marc

    14. Re:And why can't you use Java? by mvw · · Score: 2
      The difference in performance between the early VMs and todays Hot Spot VMs is impressive, yes.

      Those code optimizations at run time are however not a Hot Spot only domain, I have heard recent Intel C++ compilers offer similiar optimizations.

      I agree as well that Hot Spot + Moore's law have made some Java apps possible, that were unthinkable a few years ago. I have seen some very nice "demos" (demos in the sense of stunning/teasing graphics + sound bits) written in Java lately.

  19. Re:You have the answer by jawtheshark · · Score: 3, Informative

    Crippled? Hmmm, I don't know if that is true. Java in itself is an elegant language which has some limitations due to trying to support such a wide range of platforms transparently. You have to know what you are doing, that is all...but that counts for any language.
    Java code runs fast (really fast) in a lot of cases, mostly the only thing that "feels" slow is the GUI. You can really enhance responsiveness by including intelligent Threading. You can also avoid creating of throwaway objects, thus limiting Garbage collection.
    For the GUI, just don't use Swing if you don't need to... AWT is enough for simple frontends, yes it is not perfect, but it is faster. I suppose it is even possible to write your own native implementation linking to, for example, QT libraries or W32 libraries. Not portable, lot of work, but speed ensure.
    Some people tend to forget: using a vitual machine inherently takes some performance, but that is the price to pay for excellent multi-platform support. Note that it's still is better to do test on all the platforms you want to support, but the implementation is done once. Especially when using applications (not applets, because of browsers (non)support ), mult-platform Java applications tend to work astonishingly well in my experience.

    --
    Ahhh...the great dumpster continuum. Many a free computer will be found there. -- sowth (748135)
  20. Cross-Platform Tools by tom581 · · Score: 2

    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!

  21. Threading/Serial/Network by NitsujTPU · · Score: 2

    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.

  22. Re:You have the answer by dda · · Score: 2, Informative

    I've worked on several projects using the Java platform, where the portability was one of the the major issue.
    I could also tell you that the major part of these applications were in a banking environment, where reliability and security were, of course, vital.
    It included Threading, I/O , GUI, ...
    The problem with Java is quite offen not the language itself, but the programmers which are not able to understand the basic
    O.O. principles, and to keep the logic as simple as possible.
    Furthermore, Java performances have been really improved since the version 1.0

  23. From someone who has used ACE professionally by Christopher+Bibbs · · Score: 4, Insightful

    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.

    1. Re:From someone who has used ACE professionally by RalphTWaP · · Score: 5, Insightful

      Absolutely,

      As someone using ACE at the moment (well, in another screen). I can say that I've never found a more well-constructed cross-platform middleware package. You can find it here. In addition, the DOC group's TAO package provides a CORBA implementation on top of ACE that works really well for... well, those CORBA things *grins*.

      One drawback when using any middleware package that I've seen is that you have to buy in pretty heavily to the package, somewhat adopting the development philosophy of the package's designers. With ACE that hasn't been as much of a problem (For instance, it provides a method of dispatching QT events) mostly because the underlying design is heavily pattern based.

      On other fronts, I also continually find the Boost libraries to be very useful. They can be found here.

      Probably the last thing to consider is that if you vary your development platform, you are likely going to be changing your C/C++ implementation--and they are not all created equal. Personally, I've found that the cross-platform availability and easy integration of the Dinkumware C/C++ libraries are pretty much worth the middle-of-the-road costs involved. Dinkum's located here.

  24. SWIG by SimHacker · · Score: 2
    Check out SWIG, the Simplified Wrapper and Interface Generator.

    "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
  25. Re:You have the answer by tjansen · · Score: 2, Troll

    And I still don't get why those people who insist on Java programming cannot see how screwed up Java is. Just look at any of the well-known Java projects (JUnit, the Jakarta stuff) and watch how insane programming in Java is. "We don't have method pointers, so we use the method name and reflection". "We do not have preprocessors or macros, so we cut&paste the code and modify each copy a little bit". "We are too lazy to write the long static method invocations, so we just inherit from the class that contains the methods that we need". "Lets make everything a bean, use reflection to access it and separate the code in 5 layers - ok, we write 10 times the code of a simple solution, but look how easy it is to do this change"... I admit that C++ is harder to learn, just because of its pure size, but it really pays off because it contains so many features that are really make your life easier without using all the ugly cludges that the Java guys must do (unfortunately I am one of them and do this 8hrs/d).

  26. Use XPCOM + XUL by rfmobile · · Score: 2, Interesting

    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.

  27. Re:You have the answer by tbone1 · · Score: 3, Interesting
    Unless the specs are that it is to be written in C/C++.

    And this is all too common, I'm afraid. I once had to implement a massive, heavy-fines-for-errors project that needed to compare massive associative arrays in C instead of Perl. Why? Because the boss didn't like Perl.

    --

    The Independent: Reverend Spooner Arrested in Friar Tuck Incident - ISIHAC, Historical Headlines
  28. Re:You have the answer by statusbar · · Score: 3, Interesting

    Actually, no, but he DOES already have the answer.

    QT 3.0 supplies everything he needs for platform independent sockets, threads as well as the gui. Serial port access is easy enough on both platforms to do yourself.

    My only suggestion is to have a spare linux box with a cron job that checks out the latest sources from cvs, compiles, and emails you the error messages. Then he will be notified as soon as he checks in some sources that only compile on the lame VC++ compiler. I do that all the time and it is much easier to fix the portability problems as you go instead of in one big chunk at the end.

    --jeff

    --
    ipv6 is my vpn
  29. Re:Just use the gcc, g++ by statusbar · · Score: 2

    Correct, but there is another gotcha.

    The current cygwin g++ compiler is not compiled itself with the appropriate flags to generate thread safe RTTI and exception handling code.

    threads + cygwin + g++ + ::operator new = memory corruption and crashes

    unless you use -fno-rtti -fno-exceptions

    Yes, this sucks.

    --jeff

    --
    ipv6 is my vpn
  30. If you haven't tried to port it, it's not portable by Dr.+Manhattan · · Score: 2
    I wrote a non-GUI background app for my company that runs on about six flavors of Unix and VMS as well. I ported about 60% of it to Windows as a knock-off project to help solve a customer problem. Writing portable code is possible, but difficult.

    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:

    /* AIX documentation is incorrect and its threads don't follow the standard, we have to explicitly declare that the threads aren't detached and can be joined. Worse, they use the nonstandard "PTHREAD_CREATE_UNDETACHED" constant instead of the standard "PTHREAD_CREATE_JOINABLE". */

    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!
  31. Use the NSPR - Netscape Portable Runtime by DrXym · · Score: 2

    This is a cross-platform C lib and networking runtime. It's production quality and free. See mozilla.org for more info.

  32. STL? Yeah, right... by Dr.+Manhattan · · Score: 2
    Our group inherited some code that used the STL throughout. The authors thought they were doing things portably, but they just wrote a Solaris version and never tried any other platforms.

    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!
  33. portable CORBA and threading: omniORB by matthew_gream · · Score: 3, Informative

    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
  34. Re:Ummm... POSIX? BSD Sockets? by Sir+Runcible+Spoon · · Score: 2, Insightful
    It does. However, things that run in the POSIX subsystem are unable to use those nice POSIX calls to access anything that is outside the POSIX subsystem. This typically includes everything, even bog standard features of the OS. When I was trying to port a UNIX app to NT some years ago, POSIX did not include some basic things like signals and common socket stuff, it certainly didn't give you any graphics. Consequently the POSIX subsystem at that time didn't provide them or even the WIN32 equivalent.


    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/cygutils /V1.1/cygipc/ to do ipc).

  35. Why make it cross-platform? by BillyGoatThree · · Score: 2

    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
    1. Re:Why make it cross-platform? by ameoba · · Score: 2

      Here's one.. write the original app for Linux (or BSD or whatever) and then use VMWare or something when it needs to be deployed on NT/2k. You get the benefits of being able to run on multiple platforms and only writing the code once, while only slightly extending the testing cycle.

      I guess you could work the other way, and start writing for NT, and making sure it runs under WINE, but since this is slashdot, I fig'd targeting Linux would work best (IE get modded up to a point where anybody will read it).

      --
      my sig's at the bottom of the page.
  36. Beware SWIG by slim · · Score: 2

    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."

  37. From someone who also has used ACE professionally by Svartalf · · Score: 2

    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
  38. wrong question. by ethereal · · Score: 2

    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

  39. Common Lisp and Smalltalk - actually portable... by RevAaron · · Score: 2

    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
  40. Java, baby by twdorris · · Score: 5, Informative

    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.

  41. either Java or .net by pvera · · Score: 2, Funny

    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
  42. Depends... by Svartalf · · Score: 3, Informative

    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
    1. Re:Depends... by Camel+Pilot · · Score: 2

      FWIW I have a firewire interface written in Perl that talks to Opto22 Brains.

      A while back we delivered a submersible safety system to the Navy based on Opto22 hardware. The system used a central Linux server querying 5 remotely mounted Opto22 Brain boards over ethernet. The nice thing about Opto is that they have modules to interface to just about any instrument/controller/device.

      The Perl firewire module is based on the C++ code available from the company.

  43. Re:exactly wrong by tjansen · · Score: 2

    Depends on how you use MI. There are certainly bad uses of MI, like you can misuse almost every feature. But there are also good ones, and he mentioned one of them: "interfaces with default implementations". They won't be more difficult to read than a UML diagram with regular interfaces, only with less duplicated code.

  44. Doesn't have to be... by Svartalf · · Score: 2

    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
  45. Re:This community needs to embrace Java by mvw · · Score: 2
    Java performance is an argument of the past. The improvements made in the VM, hotspot, and good coding pactices have alleviated the performance issues.

    Java has not much margin compared to C++. You have to code quite good Java.

    Yes, the VM got faster. It is not the VM that is to blame all the time, expect for those occasions when native libs want to shovel data into the VM and back.
    Trust on the garbage collection leads to memory bloat. The high level leads to the construction of deep nested objects that cost much time and memory to construct.
    Not that it is different under C++, but people stick closer to the metal there.

    Like you wrote, it depends largely if the developer is able to handle the tool.

    Regards,
    Marc

  46. Use a different language by YoJ · · Score: 2
    Of course it may not be up to you which language to write the software in, but if it is, then seriously consider using another language. C++ is a fun language, but isn't particularly suited for threaded programming nor for high portability. And for most programming tasks, correctness is much more important than raw execution speed. With this in mind, I would suggest using a language other than C++.


    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.

  47. Cygwin? by Dr.+Evil · · Score: 2

    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.

  48. Re:You have the answer by bug1 · · Score: 2, Informative

    I didnt give a reason as i didnt think i would be questioned.

    Its interpreted.. or rather run time compiled, call it what you will it will _never_ be as fast as c.

    It requires a virtual machine, so it will always be more bloated than c.

    As the "portability" that you and others in this thread mention, gcc is portable. if you want portable code dont make it closed source.

    There are "feature-rich" libraries that can be linked to in c also.

    Java's only good point is its easy to program in, its the modern day equivalent of basic, or visual basic. Once you become a more advanced programmer, the benefit of being easy to programming in is of reduced benefit.

    Sun will never let java be really free.. they want to control it just as badly as any other large mega-corporation would, its just about money for them.

  49. Yup, only way to code for the future. by Medievalist · · Score: 4, Insightful

    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

  50. Re:You have the answer by Novus · · Score: 2, Interesting
    Oh dear. What a load of FUD. I hope I'm not feeding a troll here.

    Its interpreted.. or rather run time compiled, call it what you will it will _never_ be as fast as c.

    Just-in-time compilation is roughly equivalent to compiling, then executing; this is hardly an uncommon scenario with C programs, is it?

    It requires a virtual machine, so it will always be more bloated than c.

    Again, this is untrue. Java can easily be compiled to native code.

    As the "portability" that you and others in this thread mention, gcc is portable. if you want portable code dont make it closed source.

    Closed source is admittedly harded to port, but GCC isn't enough to provide a homogenous environment. E.g. GUI libraries vary a lot between e.g. Windows, Unix and Mac. These are highly cross-platform in Java.

    There are "feature-rich" libraries that can be linked to in c also.

    This part is quite true. However, the standard Java libraries are more feature-rich than the corresponding standard C libraries.

    Java's only good point is its easy to program in, its the modern day equivalent of basic, or visual basic. Once you become a more advanced programmer, the benefit of being easy to programming in is of reduced benefit.

    Ease of use is an advantage to experienced programmers, too (as anyone who's spent ages chasing memory leaks can attest)!

    Sun will never let java be really free.. they want to control it just as badly as any other large mega-corporation would, its just about money for them.

    Actually, considering the existence of third-party implementations like Kaffe, Sun probably can't close Java completely even if they want to!

  51. ObjectSpace C++ Toolkits by staplin · · Score: 2

    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.

    1. Re:ObjectSpace C++ Toolkits by elflord · · Score: 2

      But why use STL if you're already using Qt ? Qt already includes several container classes, and their cost per instance is considerably smaller than that of STL

    2. Re:ObjectSpace C++ Toolkits by staplin · · Score: 2

      My main point was that ObjectSpace provides the toolkits for doing multithreading and communications I/O.

      For example (IIRC), you can instantiate threads like this:

      Thread t1 = new Thread("WorkerThread", &MyWorkerClass::run);

      And things like sockets also have a nice OO abstraction that hides the platform (or posix) details.

      I haven't used Qt, so I didn't know about the container classes, however, the other uses of ObjectSpace seem to fit the needs of this project quite nicely. Though, if no STL was going to be used anywhere else, this would add quite a bit of overhead.

  52. Re:SWIG ... or sip by elflord · · Score: 2

    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.

  53. STL and boost by yamla · · Score: 2

    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.
  54. An idea... by Fnkmaster · · Score: 2
    If you (or the client) are determined to go pure C/C++, Qt already provides almost everything you are asking about, except serial port support. So you have two choices: Go with Qt all the way and find a third party library or isolate dependencies to make your own mini-library to handle serial port access. Or go with one of the other perhaps more comprehensive toolkits mentioned here (ACE, etc.) which I know little about.


    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.

  55. Qt already does everything you need... by cduffy · · Score: 2

    ...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).

  56. Why? by Svartalf · · Score: 2

    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
  57. Don't know about serial ports... by JohnZed · · Score: 2

    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

  58. Could be a _customer_ requirement... by Svartalf · · Score: 2

    Ever thought about that one, hm?

    --
    I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
  59. learn QT as it does most of that by josepha48 · · Score: 2

    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!

  60. Re:ACE Hints / Tips by PureFiction · · Score: 2

    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.

  61. Use CVS for cross platform source control by Lumpish+Scholar · · Score: 2

    I work on a medium-sized (~50-100K LOC) cross platform commercial application.

    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++ :-( 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).

    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
  62. I'm not Java bashing, but Java may be a bad choice by Svartalf · · Score: 2

    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
  63. I happen to have done extensive projects w/VC++ by Svartalf · · Score: 2

    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
  64. Don't bet on it. by Svartalf · · Score: 2

    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
  65. ACE/TAO for massively cross platform applications by Ricdude · · Score: 2

    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
  66. Mozilla's Article is Old and Wrong by ChaoticCoyote · · Score: 2

    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++.

  67. Not so for some things... by Svartalf · · Score: 2



    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
  68. anything other than java... Why? by llamalicious · · Score: 2, Insightful

    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.

  69. Re:Qt 3.0 for Win32? by Dr.+Sp0ng · · Score: 2

    Uhhh, Qt is still at version 2.3.0 for Windows.

    That's funny, because I get paid to develop an app for Linux and Windows which uses Qt 3.0. AFAIK Trolltech hasn't released a free version of 3.0 for Windows yet (although they should soon), but the commercial Windows version was released at the same time the X11 version was.

  70. Who needs speed of C in age of PHP? by brlewis · · Score: 2

    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.)

  71. Common C++ not ready for prime time by Earlybird · · Score: 2
    At least when I tried it a few months ago, CommonC++ did not compile correctly under Windows. Its configure script did not even work out of the box, failing to detect Cygwin and Visual C++. It compiles fine on Linux, but the Win32 support seems to have been neglected for a while.

    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.

  72. Dinkumware STL / VC++ 6 by Anonymous+Brave+Guy · · Score: 2

    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.
  73. DJGPP may be your answer. by Codifex+Maximus · · Score: 2

    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.
  74. POSIX is it all (cygwin) by anshil · · Score: 2

    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.
  75. The C++ STL, generics and Java by Anonymous+Brave+Guy · · Score: 2
    Isn't the STL, and the generic programming it introduces, one of the main features lacking in Java? Or will Java catch up in that area?

    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.
    1. Re:The C++ STL, generics and Java by Anonymous+Brave+Guy · · Score: 2
      By "major functional languages" I presume you're referring to LISP?

      I was actually thinking of things like ML. Where the standard algorithms in C++ take a predicate, which is currently awkward at best since C++ cannot define simple functions anonymously and in-place, you can just pass a (comparison/equality/whatever) function in to an algorithm written in ML, quite naturally. C++ would do well to learn from this.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  76. Re:... by spitzak · · Score: 2
    Damn right. Management is lying to you, pretending to obey your request that this be done on Unix.

    Insist that there be at least one production machine running Unix right now so that you can test the cross-platform capability. Do all your development on that machine.

    If you start out this way doing it cross platform is not too much difficulty. You have to write every bit for both platforms at once. Otherwise you will have a porting nightmare later (this can also happen if you write for Unix and try to port to NT). Try to encapsulate the differences to as small a part as possible. Put the differences in header files, try to use macros or anything there so no ifdefs are needed in any of your source files.

    I recommend using Qt and the cygwin header files (like libstd) on NT. Use the Unix versions of all calls. Try to avoid needing the cygwin libraries, though, they are slow.

    Things like threads are not too much difficultly if you limit yourself to the common abilities of both systems. You don't want the weird features of pthreads (or Win32 threads) anyways. You can put a lot of macros in the header files so there is no time wasted. Linux supports recursive locks even though pthreads does not, it is a good idea to use these to match how Win32 works. Look in the linux pthread.h header file.

    Absolutely do not release anything unless you have a working executable with identical behavior on both platforms.

  77. Re:Just use the gcc, g++ by statusbar · · Score: 2

    Yes. One other gotcha with cygwin is that the cygwin DLL is licensed under the GPL - not the LGPL. So you can not distribute any closed source software that uses cygwin.

    --jeff

    --
    ipv6 is my vpn
  78. Uh, no... by Svartalf · · Score: 2

    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
  79. Paying for software by dwsauder · · Score: 2, Interesting

    Why should Trolltech give their software away for free? How are they supposed to feed their families?

  80. Cool. by Svartalf · · Score: 2

    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
  81. contract by geekoid · · Score: 2

    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 /. http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect
  82. possible, but one warning by aozilla · · Score: 2

    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?
  83. Re:Not so old! by ChaoticCoyote · · Score: 2

    I did read the revision history, and my statements still stand. The document is based on false assumptions, poor knowledge of C++, and an inattention to detail.

    That given, I wonder why the Mozilla folk didn't simply stick to C and be done with it. Why use C++ at all if you won't use so many of its features?

  84. That's Firewire... by Svartalf · · Score: 2

    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.

    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 .so's project) to make a driver for the RS-485 multidrop B2 interface driver that we were using.

    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
  85. Perl. by mattr · · Score: 2
    The short answer to you questions is: Probably Perl. I think it matches your tentative decisions and is the only reasonable answer to your timeframe.

    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.