Slashdot Mirror


Write Portable Code

Simon P. Chappell writes "Much as a certain large software company located in the North-West of the United States of America might wish otherwise, there are many different operating systems and platforms in use in the world today. Software these days needs to able to operate in a disparate environment, either by communicating with these other platforms or by running on them or, increasingly, doing both. The Information Systems industry is making good progress with the communication half of the problem (even if a lot of it seems to involve large amounts of XML), but it is still struggling with the issues inherent with writing portable code. Brian Hook's contribution to all of this is Write Portable Code , which according to it's subtitle is an introduction to developing software for multiple platforms." Read on for the rest of Simon's review. Write Portable Code author Brian Hook pages 248 (14 page index) publisher No Starch Press rating 8/10 reviewer Simon P. Chappell ISBN 1593270569 summary I recommend this book to anyone working with portable code.

This is a book for computer programmers who write software designed to run on multiple platforms. It's also for programmers who suspect that their software may need to run on different platforms. This brings the book onto the radar for free and open source software authors, as they seek to create software that does not trap their end users into using specific operating systems. The Structure

There is a good progression shown in the eighteen chapters of the book. The first couple of chapters introduce the reader to portability concepts and then to some of the specific portability features of ANSI C and C++ that are used throughout the rest of the book.

The middle chapters of the book, cover individual portability topics. Some of these topics are the obvious ones, like Floating Point numbers, Networking, Operating System, File System and Dynamic Libraries. Other topics are less intuitively associated with portability, but when you read the chapter, it's inclusion is both obvious and necessary. These subjects include Source Code Management, Compilers, Scalability and Data. There is more to portability than many of us might suspect.

The last two chapters look at some alternative ways of getting portability. Scripting languages are discussed and the pros and cons of each ones portability is weighed. Lastly the use of cross-platform libraries and toolkits is addressed. Quite apropos given that the book's author is also the author of a cross platform library.

As an example of the thoughtful approach taken in this book, lets' take a look at the chapter on scripting languages. It's about the shortest chapter in the book, but representative of the approach that Mr. Hook brings to his work. This chapter takes a very honest look at the portability and cross-platform aspects of using scripting languages. There are advantages and disadvantages to the use of scripting languages. The advantages include everything that is a disadvantage of low-level languages like C/C++. Scripting languages do not require you to worry about about memory allocation, bindings, System API calls or any of the other bugbears of a low-level language programmer's life. The disadvantages of scripting languages naturally include performance, given their interpreted natures, a general lack of tools, such as development environments or IDEs and their tendency to sit high above the operating system with a corresponding detachment from low-level facilities and services of that same operating system. Mr. Hook's choice of scripting languages to consider was interesting. I expected Ruby and Python; both popular and capable in their own right. The inclusion of JavaScript/ECMAScript was also not too unexpected, now that standalone versions are bubbling up and becoming available. The real surprise, albeit a pleasant one, was the inclusion of Lua; a scripting language designed for platform portability and which seems to have managed to fully mature without making a blip on most geeks radar screens.

I like that Mr. Hook has experience writing portable software. This matched with his authorship of the Portable Open Source Harness (POSH) portability library and his contributions to the Simple Audio Library (SAL) gives a great deal of credence to his writing.

This is a solid "doing" book. Mr. Hook is under no illusion that he's writing an introduction to programming. This book has a consistent purpose to take experienced programmers and fully equip them to deal with portability and it does not deviate from this in the slightest.

The layout of the book is first rate, with clear typography, comfortable spacing, clear diagrams and tables and nicely highlighted callouts. I did not notice any obvious typos or glitches in the book. While the look of a book is not the author's fault if it is below par, a well presented book can enhance the reading and learning experience.

The examples are as realistic as possible. While some of the examples to teach principles might be simpler, they are typically backed up with examples from either the POSH or SAL projects, showing real world portability coding. The level of C/C++ required to understand the examples is higher than many books that I've read. That's not to say that the code seems obfuscated, but it's code that is taking into account aspects of the real world and is, by necessity, not simple. A further positive quality of the code examples is that they're very well explained; well enough that an inexperienced programmer with determination could follow them and come to an understanding.

Appendix B contains a summary of all of the portability rules presented through the book. There are twenty rules and each is reprised with a small explanation/reminder of it's application. An example: Rule 4 - "Never read or write structures monolithically from or to memory. Always read and write structures one element at a time, so that endian, alignment, and size differences are factored out."

If you're looking for more of a fluffy "about" book, then this is not it. This is not a complaint, rather I offer it as something to consider, before you buy what you might otherwise think is a beginner's book.

I must reiterate the non-trivial C/C++ example code the book contains. This book is for serious programmers and is not afraid to role up it's sleeves and cut real code.

This is a very well written and very readable book. There are many aspects to the subject matter of portability and Mr. Hook addresses more of them than many of us had previously suspected existed and addresses them with firm authority. I recommend this book to anyone working with portable code."

You can purchase Write Portable Code from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

397 comments

  1. Portable Code by Microlith · · Score: 5, Funny

    Truly portable code is like flipping someone the bird.

    No matter what country (OS) you're working in, everyone understands it!

    1. Re:Portable Code by johnw · · Score: 3, Funny

      A universally comprehensible message - except that I have no idea what "flipping someone the bird" means.

    2. Re:Portable Code by Arandir · · Score: 1

      Not at all. When I was in Germany no one understood "flipping the bird". It was a totally innocuous gesture. Instead they had their own rude signal, which meant nothing to me. I suspect the "bird" is limited to England and it's former colonies.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    3. Re:Portable Code by moranar · · Score: 2, Informative
      --
      "I think it would be a good idea!"
      Gandhi, about Internet Security
    4. Re:Portable Code by milimetric · · Score: 1

      not true. Check out the film Opportunity Knocks with Dana Carvey and also check out how people flip each other off in Russia and England.

    5. Re:Portable Code by hachete · · Score: 0, Offtopic

      Is it penguin bowling? Geddit?

      --
      Patriotism is a virtue of the vicious
    6. Re:Portable Code by cyborg_zx · · Score: 0

      I believe it means to make a fist at a person to whom you wish to 'flip the bird' then to rapidly extend the middle finger of the hand. This constitutes the flipping action. What birds have to do with it I do not know. Once held for a few moments the finger may be returned to the fist position and then the fist may be retracted.

      May also be accompanied with a upward thrusting motion of the arm similar to an upper-cut in boxing. This is used to enforce the gesture to more strongly make your dislike of the person known.

    7. Re:Portable Code by Eric+Pierce · · Score: 1

      Count Japan as another country that wouldn't have a clue to this gesture (or the vernacular you used).

    8. Re:Portable Code by Martin+G.+1984 · · Score: 1

      Where exactly have you been? Everyone I know understands it. And what was the other gesture?

    9. Re:Portable Code by milimetric · · Score: 1

      actually, in england they flip two fingers. I heard, but not confirmed that the reason people flip the middle finger is because the french were once excused from having their middle fingers cut off by the british after being defeated in battle. As a gesture of disrespect, the french turned round and flipped off the british with their middle fingers. Is this true?

    10. Re:Portable Code by drinkypoo · · Score: 1

      When oh when will people learn to check the straight dope?

      --
      "You're right," Fisheye says. "I should have set it on 'whip' or 'chop.'"
    11. Re:Portable Code by Anonymous Coward · · Score: 0

      in Nazi Germany, Bird Flips YOU

    12. Re:Portable Code by Hugonz · · Score: 1

      Except in the US, they don't include any balls.

    13. Re:Portable Code by Analog+Squirrel · · Score: 1
      --
      I'd rather be flying
    14. Re:Portable Code by Arandir · · Score: 1

      Just in front of Linderhof there is a statue grandly and proudly "flipping the bird" to all visitors. I took a picture of that statue because I thought it was so funny, but all the Germans I was travelling with couldn't understand why I thought it was so funny.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    15. Re:Portable Code by Anonymous Coward · · Score: 0

      In the UK two fingers is more common but recently one finger seems to be gaining popularity most likely due to hip-hop and other US imports. Here in Glasgow, at least, 2 fingers is thought of as "fuck you" whereas the middle finger is "up yours".

    16. Re:Portable Code by Lord+Omlette · · Score: 1

      .,|,, >_< ,,|,.

      Sorry, but you were asking for it...

      --
      [o]_O
    17. Re:Portable Code by Microlith · · Score: 1

      Japan knows the gesture, same connotation too.

    18. Re:Portable Code by Anonymous Coward · · Score: 0

      "Truly portable code is... No matter what country (OS) you're working in, everyone understands it!" - by Microlith (54737) on Wednesday November 09, @01:39PM

      Closest things I know of personally is/are:

      Delphi/Kylix (for Win32 &/or Linux (via Qt))

      OR

      RealBasic 2005 (for MacOS X, Win32, & Linux (via GTK))

      For personal computers OS cross-platform ability.

      * :)

      (Said it a 100x here by now, & will stand by those as my testimonials of what the closest things I know of with the best performance (especially math & strings, which EVERY PROGRAM DOES no less, in Delphi/Kylix), & multi-platform coding possible...)

      APK

    19. Re:Portable Code by Hal_Porter · · Score: 1

      In Pachinko parlors (those games with the shiny steel balls, sort of like a Japanese pinball), this gesture is used as a greeting when you enter. Make sure you bring a good supply of large ball bearings and show them to the proprietor - easily recognised as a large tatooed man in sunglasses - before doing so.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    20. Re:Portable Code by Britney · · Score: 1

      I know what the phrase describes.

      And I know what it looks like.

      But what's the significance?

      Everytime I drive anywhere, someone is apparently anxious to communicate the number 4 to me in binary using a 5-bit finger/thumb arrangement.

      What's that all about?

      --

      --
      (if you're still looking for the point, it was back there, in the post. </sig>)
    21. Re:Portable Code by ClosedSource · · Score: 1

      My interpretation is that the quality and usefulness of universally portable code will make all its users feel like someone is flipping them off.

    22. Re:Portable Code by pyrrhonist · · Score: 1
      Everytime I drive anywhere, someone is apparently anxious to communicate the number 4 to me in binary using a 5-bit finger/thumb arrangement.

      132! *screech* *crash*

      --
      Show me on the doll where his noodly appendage touched you.
    23. Re:Portable Code by Deaths+Hand · · Score: 1

      I don't know about the use of the single middle finger, but sticking two fingers up comes from when the English and French fought each other around the time of the battle of Agincourt, in the 15th century.

      It stems from the fact that the English archers used longbows (as opposed to the French crossbows). To draw the bow of the longbow back, the two fingers nearest the thumb are used. Hence, if the French ever captured an English archer, they would chop off these two fingers. So during a battle, the English archers would stick these two fingers up at the French, to show they still had their fingers. The rude gesture evolved from there.

    24. Re:Portable Code by Xiaran · · Score: 1

      I am currently in Germany and there is a large advertising billboard with a hand flipping the bird on Kaiserstrausse in Frankfurt... up near the stration. Amuses me everyday on my way to work. Obviously Im easily amused.

    25. Re:Portable Code by milimetric · · Score: 1

      actually, one of the sibling posts disagrees: Straight Dope

  2. All my code is portable! by Anonymous Coward · · Score: 2, Funny

    Thank the ghods for the USB memory keyfob!

    moderation suggestions:
    +1 funny -1 offtop +1 informative -1 flamebait

  3. Java ??? by djbckr · · Score: 3, Funny

    Hey, just write whatever it is in Java. You know, "write once, run anywhere". Simple!!!
    Yes, this is a joke.

    1. Re:Java ??? by Anonymous Coward · · Score: 0

      I dunno, our software engineers follow this mantra, and none of our customers seem to be complaining. And believe me, they complain louly when they don't like something ;)

    2. Re:Java ??? by OakDragon · · Score: 3, Funny

      You can always use my model: "write anywhere, run once!"

    3. Re:Java ??? by Anonymous Coward · · Score: 0

      Good Java programmers can make their programs portable very easily. The problem is that there are a lot of shitty programmers that don't follow coding conventions and that don't use the API properly. I can't count the number of times I've seen idiots writing huge methods for something that could be done with one line if they had only read the API....

    4. Re:Java ??? by Amouth · · Score: 1

      mix that with the fact that java doesn't run well for most things that people try and use it for.. i am sorry but without inter proccess comunication it is usless to me.

      --
      '...if only "Jumping to a Conclusion" was an event in the Olympics.'
    5. Re:Java ??? by jalet · · Score: 4, Insightful

      > Good Java programmers... use Python instead.

      --
      Votez ecolo : Chiez dans l'urne !
    6. Re:Java ??? by AKAImBatman · · Score: 2, Interesting

      mix that with the fact that java doesn't run well for most things that people try and use it for..

      Most people seem to be doing server side development with it. Works fine. :-)

      i am sorry but without inter proccess comunication it is usless to me.

      You mean like TCP/IP, CORBA, RMI, SOAP, XML-RPC, etc.? You need to be more specific if you're going to complain. BTW, there are libraries for SMB Remote IPC and POSIX IPC, but using either of them won't result in very portable code under ANY language.

      Which raises the question, what exactly are you doing that you need native IPC?

    7. Re:Java ??? by zootm · · Score: 1

      Or Boo.

      Don't kill me.

    8. Re:Java ??? by jonadab · · Score: 1

      Indeed, and this will become even more true in the coming months, because Python will run on Parrot, so that way you'll be able to use modules off the CPAN...

      --
      Cut that out, or I will ship you to Norilsk in a box.
    9. Re:Java ??? by kberg108 · · Score: 1, Interesting

      Not that I disagree with your main point as I love coding in Java. But none of those are inter process communications. Inter process communication would be send/receiving signals from other processes running on the machine. Because the jvm is a "self contained machine" it's processes do not send and/or receive signals with other processes on the machine. Now if you launch an external process from within the jvm then you can send and receive signals from that process (see java runtime exec call) within java but not out side of it. Of course this discussion brings up a very good point that is really at the heart of jvm based apps vs native apps. Many people, my self included, feel that inter process communication creates more problems than it solves. I feel that well defined entry and exit points (XML, properties file, API, SOAP, servlet, etc) to an application is the proper way to communicate with any app but then again this would require programmers to agree on stuff which is about as impossible as getting politicians to agree to something. :) We've made pogress but were still not there.

      --
      I like things that are sweet and not things that are lame. --
    10. Re:Java ??? by AKAImBatman · · Score: 1

      Is that all you're waiting for? We've had that for years.

    11. Re:Java ??? by Anonymous Coward · · Score: 0

      My favorite quote about portability came from Bjarne Stroustrup during a presentation he gave here at JPL last year.

      Java is portable. Almost as portable as C++.
      -Bjarne Stroustrup @ JPL 20040521

    12. Re:Java ??? by AKAImBatman · · Score: 1

      But none of those are inter process communications.

      They're not? Guess I should have my Geek Card revoked then.

      IPC is a pretty broad term. :-)

      Oh, I almost fotgot. IIRC, Java allows you to snag shared memory blocks in byte buffers via memory mapping. That's probably the type of IPC you're thinking of.

    13. Re:Java ??? by LDoggg_ · · Score: 1

      I haven't had much need for this, but can this be done cross-platform with any language? When I think of IPC, I think of things like game trainers that manipulate seperate running game processes. And it may be just bad luck or an unrelated issue, but I've never gotten it to work in wine on linux.

      Also, are C# and CLR able to do IPC? Seems like running things in protected memory space without pointer arithmetic would not lend itself well to this.

      --

      "If they have both, tell them we use Linux. And if they have that, tell them the computers are down." -Dave Chapelle
    14. Re:Java ??? by ckaminski · · Score: 1

      While I agree with your "well-defined entry/exit point" argument, any program that gets its comms on by trading signals back and forth is A) not portable and B) not well designed. Named Pipes, sockets, all are more programmable, understandable, reactive interfaces that pose no issues with reentrancy or platform incompatibilities, such as Windows, which has CRAP for interprocess signals.

      Java has NO problems with IPC.

    15. Re:Java ??? by Anonymous Coward · · Score: 0

      Insightful? To get any speed out of python, you have to write most of your program in C. You're back to being not portable again.

    16. Re:Java ??? by Anonymous Coward · · Score: 0

      lol mod parent funny or maybe insightful introducing the python link. we used python for a search project and it was a disaster. the vast majority of issues were related to the lack of type enforcement and variables redeclared all over the place. granted the developers were newbies but java wouldn't let them make half of the mistakes.

    17. Re:Java ??? by Trejkaz · · Score: 1

      I guess someone has to use Python, because all the good Python programmers already moved to Ruby.

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
  4. Stick to binary by Anonymous Coward · · Score: 1, Funny

    And only use '0's. I've found using '1's just leads to too many problems.

    1. Re:Stick to binary by Anonymous Coward · · Score: 0

      Not so good for file compressions though - more 1's can be squished on a single line than 0's. (Using smaller fonts also helps with document compression)
      ---
      Dynoroddy, BOfH with Damn All Integrity

  5. web apps by xikzantric · · Score: 3, Insightful

    and this is why web applications are becoming so popular...it's much easier to make something written in PHP and distributed through the web available to everyone than to try to port something in C++ across a bunch of platforms. imho this trend towards AJAX and more web applications is a good thing and makes it easier on developers trying to deal with clients on multiple platforms. i don't want to have to deal with porting applications (although cross-browser compatibilities offer their own complications).

    1. Re:web apps by TedCheshireAcad · · Score: 2, Insightful

      AJAX and fat web apps are turning the browser into the new development "platform". The browser isn't nearly as robust a platform as, say, Java, only by virtue of the statelessness of HTTP. Not everything needs to be a web app. I know eventually some jackass is going to make an AJAX word processor/spreadsheet, but does anyone else see that this is just wrong?

    2. Re:web apps by slackmaster2000 · · Score: 1

      Web apps are also nice in that you don't have to distribute client programs, making administration a lot easier.

      Of course there are serious drawbacks to web apps. For instance, I've been demoing an opensource document management system that's web based. It seems to have many of the features that I'm looking for, but checking files in and out via a web browser is a big enough pain that I don't think that my users are going to happy with it at all. So while the developers have a product that can run on just about any platform, they comprimised ease of use and functionality.

    3. Re:web apps by ForumTroll · · Score: 1

      I'm with you. I detest the fad of having absolutely everything run through the browser. I still haven't seen any web app that can compete with a similar rich client side application. The loading times are also a pain in the ass and nothing you can do with Ajax will completely eliminate that.

      --
      "A Lisp programmer knows the value of everything, but the cost of nothing." - Alan Perlis
    4. Re:web apps by PureCreditor · · Score: 1

      > I know eventually some jackass is going to make an AJAX word processor/spreadsheet, but does anyone else see that this is just wrong?

      wasn't it a while ago that Google wants to take over Microsoft's dominance by moving every desktop app onto AJAX, thus nullifying the significance of the OS. if a new version of AJAX can output to your speakers, i'll bet Google will create an OGG streaming AJAX player.

    5. Re:web apps by defMan · · Score: 1

      Yes but those web apps have to run on an operating system and if the person who hosts this app wants to switch from windows to linux or from linux to the hurd (hey it'll be ready within the next ten years, no?) it would still be nice if it's portable.

      This is probably no biggy with php but that's the scripting language bit of the book about i guess. But sometimes these web apps use some pogram which is not scripted. Google has some web apps but i don't think they can switch os easily in the backend.

      Webapps are still a nice idea though. I wouldn't like it for everything though. You'll also still need a portable web browser. This book is for the mozilla people maybe.

    6. Re:web apps by Arandir · · Score: 1

      Webapps are okay for some things, but are inferior and unsuitable for most. The major problem is the limitation of the interface. You can make it look pretty, and with Ajax, even make it somewhat interactive, but you can't make it very usable.

      But not every application is a front end to a backend database. I know this sounds like heresy to you database programmers, but it's true.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    7. Re:web apps by AKAImBatman · · Score: 1

      AJAX is a bridge thin-client technology that doesn't go as far as to shunt an entire desktop across the network, yet is robust enough to support nearly any application. All the real logic is usually done on the server using a real language. (No matter how much I grow fond of JavaScript, I will never think of it as a "real" language.)

      As a thin client platform it works pretty well. As a general purpose coding platform it sucks. You still need to have a portable language on the server or you won't be able to move your code from system to system. (Though you will have the client nailed.)

    8. Re:web apps by jlarocco · · Score: 1
      and this is why web applications are becoming so popular...

      Bullshit. It works great in theory. Too bad so many "web applications" require a specific web browser. As far as I'm concerned, if your web application can't work with Lynks over a 14.4K modem, it shouldn't be a wep application.

      Before you say "But that's because the web developers..." you should realize that it's just as possible to write C or C++ code that compiles and runs on multiple platforms as it is to make a web app work in multiple browsers. Fact of the matter is, in both cases, most people just don't put in the effort. In fact, it may even be easier in C and C++ because they're ISO standards, and deviations from the standard tend to be documented somewhere, unlike browser incompatibilities.

    9. Re:web apps by Anonymous Coward · · Score: 0

      I haven't found a web app that unlocks the doors on my car yet.
      Oh, you forgot about all that embedded stuff?
      Yup, that would be cool, a web app version of a big friggin router.
      What, you need code to run on the router?

      The web app world may be useful to all us carbon life forms, but there is an lot of off-line processing taking place all around you, and if it is written carefully, it can be ported to new hardware quick.

    10. Re:web apps by Bill+Dog · · Score: 1

      I thought you were going to say AJAX is here, you can't hide, you will be assimilated...

      Which I think is true. Just like Java was a PHB's wet dream (no longer need smart, expensive C++ people, some of whom still couldn't keep it together), so is AJAX, in that it enables businesses to get away from install and upgrade and differing desktop configuration nightmares. And who cares if a browser app is not as easy to use, afterall in business the person who makes decisions about software is not the person that has to use it.

      You still need to have a portable language on the server or you won't be able to move your code from system to system.

      I do not understand the great need for portability on the server. (And as I think Java is only suitable for server-side development, I don't understand the great need for Java.) If you've just bought a bunch of expensive Windows or Solaris servers, why would you later decide to throw them all away and buy new servers just so you could move your software to another OS?

      --
      Attention zealots and haters: 00100 00100
    11. Re:web apps by AKAImBatman · · Score: 1

      If you've just bought a bunch of expensive Windows or Solaris servers, why would you later decide to throw them all away and buy new servers just so you could move your software to another OS?

      Sure. It's all about the scalability. If I find that I've scaled my app to the limit of say, the IA-32 architecture, I can move to a more powerful architecture like AMD64 or Sparc. All depends on the needs. If there's a bottleneck between the machines, maybe it's time to replace them with that 64 way Starfire. If the problem is maintainability of these systems, maybe I need to move from Windows to *nix.

      And let's not forget development. It's nice for the developers to be able to develop on Windows or Macs and deploy on Solaris servers.

      There are a lot of reasons to change architectures, even on the server side.

    12. Re:web apps by Anonymous Coward · · Score: 0

      ... and web apps do not need to be installed (or upgraded by users).

    13. Re:web apps by ckaminski · · Score: 1

      And someone has obviously never gone between major compiler/OS revisions, say from NT 3.1/VC++ 2.0 to NT 4/VC++ 4. Portable coding is required, even when staying on a single platform, because technologies evolve and are deprecated (MAPI/CDO) (ODBC/RDO/ADO).

      Nevermind the fiasco that was Windows 95/98/ME/NT support. One platform (Win32), 4 different incarnations. Thankfully that painful bit of history is over.

    14. Re:web apps by ckaminski · · Score: 1

      Why not add support for WebDav? I've got a similar problem with a document management/CMS system I'm putting together for my father's manufacturing business, and without a semi-decent webdav interface, it's going to be too much of a pain for him to use.

    15. Re:web apps by Bill+Dog · · Score: 1

      What big problems did you have going from NT 3.1/VC++ 2.0 to NT 4/VC++ 4? The only thing I can think of is maybe compiler standards compliance (C++ wasn't standardized yet, and the draft standard was a moving target). But that's a compiler thing -- the platform on NT was still Win32.

      Technologies evolve and are deprecated all the time. (Java's API docs was where I first encountered the term "deprecated", and that was only Java version 1.1! That didn't take long!) I think what you're talking about is not portable coding, but modular coding, where you isolate the main code from whatever the email or database technology is you're currently using, that may change later.

      And Windows 95/98/ME/NT aren't exactly 4 different incarnations of one platform. NT is Win32, with full support for that API, security, Unicode, etc. The other three were together a single other category, hybrid 16/32-bit OS's, missing or having NOOP'ed some of the more powerful but less relevant to home users portions of Win32. You just code to the lowest common denominator (95). Not sure how that makes a "fiasco".

      --
      Attention zealots and haters: 00100 00100
    16. Re:web apps by Anonymous Coward · · Score: 0

      You're suffering from the "everything I don't know about doesn't exist" fallacy.

    17. Re:web apps by heinousjay · · Score: 1

      As far as I'm concerned, if your web application can't work with Lynks over a 14.4K modem, it shouldn't be a wep application.

      Just curious - who made you the arbiter? Why should anyone worry about that? It's just as ridiculous for me to say "As far as I'm concerned, if any application doesn't run on my C-64, it shouldn't be an app." Certain things require a minumum level of capability. That's life.

      It's pretty obvious you're just evincing symptoms of computer-based NIMBYism here. Too bad, you'll miss out on a lot of very cool stuff. It's all good by me, though. I don't really mind if bigoted people lose out.

      --
      Slashdot - where whining about luck is the new way to make the world you want.
    18. Re:web apps by Anonymous Coward · · Score: 0

      Name one web app that is superior to its rich client side counter part.

    19. Re:web apps by jlarocco · · Score: 1
      Just curious - who made you the arbiter? Why should anyone worry about that? It's just as ridiculous for me to say "As far as I'm concerned, if any application doesn't run on my C-64, it shouldn't be an app." Certain things require a minumum level of capability. That's life.

      Okay, I admit I did a poor job of making my point. But the fact of the matter is, if a web app requires IE or Firefox, it's missing the potential for portability. It's easy to say "This software requires a certain minimum level of capability. And that minimum level is IE 6.0.1234 on Windows." But it's not very portable.

      It's pretty obvious you're just evincing symptoms of computer-based NIMBYism here. Too bad, you'll miss out on a lot of very cool stuff. It's all good by me, though. I don't really mind if bigoted people lose out.

      Yeah, someone is always going to miss out. But the whole point in writing portable code is to have as few people as possible missing out.

  6. os by chris+macura · · Score: 2, Funny

    What? Are you telling me that the OS I've been developing won't run on Windows, Linux, and OS X?

    Whad` up wit` dat, fool?

    1. Re:os by wpmegee · · Score: 1

      Well, if you're a sadist and don't want a usably fast system, follow M$'s example and write large parts of the Operating System in Visual Basic, Java, or your $INTERPRETED_LANGUAGE of choice. If you don't believe, me download the Win2k source and see for yourself. Then all you have to do is write the interpeter in assembly/C/C++.

      And if you're dumb enough to do all that, chlorinate the gene pool by removing yourself from it.

    2. Re:os by Anonymous Coward · · Score: 0

      You mean emacs right? That boots perfect on the systems you mention.

    3. Re:os by Anonymous Coward · · Score: 0

      Must... get... mod... points...
      (+1 Funny)

    4. Re:os by Surt · · Score: 1

      Actually, with the virtualization programs available on all of those platforms, people should be able to run your os without difficulty.

      --
      "Who is the Journal of Quantum Physics going to believe?" --Stephen Hawking
  7. Re:Small book by dslauson · · Score: 0

    Yeah, total flamebait. If your only solution to writing cross-platform code is by writing everything for a runtime environment, you have a thing or two to learn, there, fella.

  8. Re:Small book by Anonymous Coward · · Score: 0

    1. #include
    2. Learn to love the ANSI standadrd library
    3. Learn that open,read,write,close are available on all systems.
    4. #include for htonl/htons
    5. Profit

  9. Cross platform by Ratbert42 · · Score: 1

    Cross platform as long as it's Windows or *nix. How about zSeries, iSeries, HP NonStop, etc.

    1. Re:Cross platform by no_pets · · Score: 0

      Windows and some *nix can run on iSeries.

      --
      "A government is a body of people, usually notably ungoverned." - Shepard Book Quoting Malcolm Reynolds
    2. Re:Cross platform by danpsmith · · Score: 0
      Cross platform as long as it's Windows or *nix. How about zSeries, iSeries, HP NonStop, etc. They are all ignored because anyone dumb enough to use an OS that only ten people ever bothered installing shouldn't expect to be able to run the new version of...well pretty much anything I guess.
      --
      Judges and senates have been bought for gold; Esteem and love were never to be sold.
    3. Re:Cross platform by Just+Some+Guy · · Score: 3, Insightful
      How 'bout 'em? Since they have basically nothing whatsoever in common with other "small" systems, I doubt there's much you can do for them besides shooting for POSIX compliance and crossing your fingers.

      Write Once Compile Anywhere will never be completely realized since various systems have incompatible design goals. No matter how portable you've made your command line application, it probably won't make a lot of sense on a Palm. That's not a limitation of your code or PalmOS, but an acknowledgment that they're different animals.

      --
      Dewey, what part of this looks like authorities should be involved?
    4. Re:Cross platform by Urusai · · Score: 1

      If it doesn't run on OS/9 on a CoCo III, it ain't portable.

    5. Re:Cross platform by Randall311 · · Score: 1

      If you're using those platforms then you deserve to be left in the dust. 99% of the world uses Windows, OS X, or some form of *NIX. It's easy to write platform intependent programs in C++, just as long as you don't use a GUI. Actully the best way to write platform independent code is (if possible) write the engine in ISO C/C++ whatever your favorite language is, then write a GUI client for each OS you wanna support, that interacts with the main engine of the program, which is platform independent.... Or just just Java. (That was a joke) ;)

    6. Re:Cross platform by AuMatar · · Score: 1

      Even easier- write the logic in C++ and keep it isolated from your UI code. Then write the GUI using a crossplatform GUI library (of which there are at least 3 major ones that I know of), and tweak only if necessary. 90% of it will work out of the box from the libraries. Then submit your bug fixes to the libraries, please.

      --
      I still have more fans than freaks. WTF is wrong with you people?
    7. Re:Cross platform by jonadab · · Score: 1

      > Cross platform as long as it's Windows or *nix. How about zSeries, iSeries, HP NonStop, etc.

      When you need that kind of portability, you program in Inform and compile to z3. Then you can run it on everything from the PDP10 to Nintendo Gameboy.

      The downside of this is that there are certain limitations. For instance, due to the need to run on platforms that don't have a filesystem, your file I/O functionality is limited to save (all read-write memory in one go to a user-specified location; tiny platforms may have only one location), restore (all read-write memory in one go from a user-specified location; same caveat), and start or stop logging the I/O to a transcript.

      Still, it's impressive how many things you *can* do within the limitations imposed by extreme portability.

      --
      Cut that out, or I will ship you to Norilsk in a box.
  10. Portable Mac apps? by I'm+Don+Giovanni · · Score: 4, Insightful

    How can I write portable versions of Mac OS X apps when the Cocoa API doesn't exist outside of Mac OS X (don't tell me about YellowBox or what-have-you) and the language Objective C isn't supported outside of Mac OS X (Apple is killing off Cocoa's Java support)? Oh, and the Carbon API doesn't exist outside of Mac OS X either (but at least it uses a widely supported language). You mentioned a software company in the Northwest US, but what about the one in Cupertino? Apps written to their platform are no more portable than Windows apps.

    Besides that, apps that aren't able to take advantave of the underlying platform's unique features aren't sellable. Mac users in particular want apps that take advantage of the unique features of Mac OS X (and no, they don't consider some unix app to be a real "Mac" app, and rightly so). That means Cocoa or Carbon, and neither api is supported outside of Mac OS X.

    --
    -- "I never gave these stories much credence." - HAL 9000
    1. Re:Portable Mac apps? by Sharth · · Score: 1

      write a portable back-end, and keep the amount of things that are platform specific to a minimum. Or atleast write compile time things so that if mac, then use the os spell checker, or spotlight, or what have you, if it isin't, then use a different implementation or what not.

    2. Re:Portable Mac apps? by Dr.+Manhattan · · Score: 5, Insightful
      How can I write portable versions of Mac OS X apps when the Cocoa API doesn't exist outside of Mac OS X

      Well, you factor the UI away from the engine. The guts can do things portably, perhaps with a few wrappers (I have my own personal set that abstracts threads, so I can use POSIX threads and Windows threads without having to change the guts around). The user interface can be as Maclike as you want.

      --
      PHEM - party like it's 1997-2003!
    3. Re:Portable Mac apps? by WillAdams · · Score: 2, Informative

      Try GNUstep, which is an opensource re-implementation of NeXT/Sun's OPENSTEP standard:

      http://www.gnustep.org/

      It'll allow you to deploy on Linux, Windows, and possibly even the Sharp Zaurus depending on your project.

      They even have a web page up clarifying a mention of it in Aaron Hillegass' _Cocoa Programming on Mac OS X, Second Edition_

      http://www.gnustep.org/resources/BookClarification s.html

      It's licensed under the LGPL, so should be usable for most tasks.

      William

      --
      Sphinx of black quartz, judge my vow.
    4. Re:Portable Mac apps? by BurntNickel · · Score: 1

      How can I write portable versions of Mac OS X apps when the Cocoa API doesn't exist outside of Mac OS X (don't tell me about YellowBox or what-have-you) and the language Objective C isn't supported outside of Mac OS X (Apple is killing off Cocoa's Java support)? Oh, and the Carbon API doesn't exist outside of Mac OS X either (but at least it uses a widely supported language). You mentioned a software company in the Northwest US, but what about the one in Cupertino? Apps written to their platform are no more portable than Windows apps.

      The Cocoa API is semi-complete as part of GNUstep. GCC has built-in support for Objective-C.

      As far a Carbon is concerned, for some time now I have been interested in statring a project to re-implement that API in a more open manner so that you could use the Carbon API under GNU/Linux or some other operating system. I just haven't had the time to give it much effort.

      Besides that, apps that aren't able to take advantave of the underlying platform's unique features aren't sellable.

      On this point I agree 100%. Most "portable" applications are lowest common denominator and support only the small subset of functionallity that is avaliable on all of the platforms and this makes for what is often an unpleasant experience.

      --
      And the knowledge that they fear is a weapon to be used against them...
    5. Re:Portable Mac apps? by Arandir · · Score: 1

      Except that GNUstep/NeXT apps feel alien anywhere outside of NeXT. They're not so bad under OSX, but they're jarring under traditional Unix or Windows. They may look correct, but they just don't *feel* correct.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    6. Re:Portable Mac apps? by Arandir · · Score: 1

      It's not a perfect solution (nothing is), but you might give Qt a try. I criticized the guy suggesting you try GNUstep, and my criticisms also apply to Qt. But both have one advantage: they're portable. A native Mac OSX app doesn't do Windows or Unix users any good.

      apps that aren't able to take advantave of the underlying platform's unique features aren't sellable.

      Rubbish! Integration is great, but it's hardly the end-all and be-all of software. There are more worthwhile features out there than mere nativeness.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    7. Re:Portable Mac apps? by AnonymousBystander · · Score: 1

      and the language Objective C isn't supported outside of Mac OS X

      AFAIK gcc can compile obj.C

    8. Re:Portable Mac apps? by OrcaCSS · · Score: 1

      A nice benefit of Apple's gcc is that it has supported Objective-C++ since Mac OS X 10.1. Unfortunately, I think that non-Apple versions of gcc cannot yet compile Objective-C++. Although it looks like support might be planned for gcc 4.1. Still, Objective-C code will need to be factored away from code that might require compiling with some compilers.

    9. Re:Portable Mac apps? by Anonymous Coward · · Score: 0

      Cocoa in particular is built with the MVC architecture in mind, so the solution is pretty simple: write your Model code in portable C or C++, both of which integrate very smoothly with Objective-C, and rewrite your Views and Controllers in Objective-C. (Alternately, you can write the Model code in the subset of Cocoa that is compatible with GNUStep, and provide the Windows GNUStep DLLs as part of your application package.) The UI needs to be largely re-engineered for every platform anyway, because what's idiomatic on one platform is clunky on another, and because different platforms offer different resources.

      It would be really wonderful for programmers if Apple supported the Application Kit and Objective-C on other platforms, but there's no return for them on that investment, and you'd need to rewrite a lot of the UI code to get a native Windows feel anyway. And Apple doesn't need to support the Foundation Kit on other platforms, because the GNUStep project already does that quite well.

    10. Re:Portable Mac apps? by Arandir · · Score: 1

      Gaagh! I can't believe how hypocritical I am! That's because in another post I suggested he use Qt. Shame on me.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    11. Re:Portable Mac apps? by nvrrobx · · Score: 1

      Objective-C *does* exist outside of the Mac (gobjc anyone?) and a large portion of the Cocoa API exists in a form known as GNUstep - maybe you've heard of it?

      Sure, the .nib's created in Interface Builder do not work in GNUstep, but many other things do.

      But, if you're focused on cross platform support, why are you using Cocoa or Carbon anyhow?!

    12. Re:Portable Mac apps? by Sax+Maniac · · Score: 3, Interesting
      Indeed, but I'll take this one step further. The rule is any external API that you rely but don't control should be factored out similarly. It's not just UIs, though, UIs are the most common, because they change fashion very quickly.

      Let's say that you have a Windows app that relies on DirectX for some stuff, OpenGL for other stuff, some POSIX functions for yet others. Each one of those APIs represent a possibly different porting problem: move to a different platform, and one of the libraries might be missing or poorly implemented.

      So, if your code intermixes calls to all three libraries, you are going to have a hell of a time porting it over. Example: you move to IRIX and now you problably have a good GL implementation, but too bad, it's mixed up with DirectX code, and now you have to rewrite all that code, even though the GL calls would work.

      Portability is in the eye of the beholder. X code is mostly portable, but, you need an X server on the other side. So writing portable X code isn't going to help you make your native Mac UI application. Once you take the view that X is just another external API, and you wall it off appropriately, you've done you work.

      Now, you can group APIs - if you're on windows, you are pretty much assured that, say, Win32 GDI calls and DirectX are going to be there, so no need to go overboard and factor them out separately.

      The devil is choosing your abstractions. You can't over-abstract, otherwise the application will be too alient and never be completed. You almost have to have a sense of where the project will go in the future and what the most critical components are.

      --
      I can explanate how to administrate your network. You must configurate and segmentate it, so it can computate.
    13. Re:Portable Mac apps? by they_call_me_quag · · Score: 1

      > How can I write portable versions of Mac OS X apps when
      > the Cocoa API doesn't exist outside of Mac OS X

      You could write your app in REALbasic and compile it as a native Mac app.

      Then click a check box and compile it as a native Windows app.

      Then click a check box and compile it as a native Linux app.

      > Besides that, apps that aren't able to take advantave of the
      > underlying platform's unique features aren't sellable.

      The Mac version of your app can have metal windows, drawers, sheets, AppleEvents, etc. The Windows version can access the Registry, System Tray, ActiveX, etc. Some of this is handled automatically, others require a little bit of conditional coding.

    14. Re:Portable Mac apps? by bani · · Score: 1

      implementing a UI in opengl is actually the best way to maintain portability across platforms :-/ short of using Qt or something like that.

    15. Re:Portable Mac apps? by Anonymous Coward · · Score: 0

      You could do it the way Apple did with iTunes and QuickTime, and the way Microsoft does with Office. By keeping the backend platform agnostic and using native tools for the front-end. Word uses tons of Carbon stuff for the UI. That doesn't mean they can't use a portable layout engine, though, for example.

    16. Re:Portable Mac apps? by Bob+McCown · · Score: 2, Interesting

      A year ago, we took a huge step, decided to support Win32, OSX, and Linux with our next product release. After looking at various cross-platform UI tools, we settled on wxWidgets. So far, no complaints. We've factored out all the UI into separate modules, and the underlying code uses std libraries. So far so good!

    17. Re:Portable Mac apps? by pherthyl · · Score: 1

      Easy, use a cross platform toolkit. Either Qt (my favourite) or wxWidgets (if you don't mind some MFC-style macroness) would be a good choice.
      As a bonus you get cross platform functionality beyond the GUI, such as network, databases, and utility classes in one package.

    18. Re:Portable Mac apps? by geekschmoe · · Score: 1

      How can I write portable versions of Mac OS X apps when the Cocoa API doesn't exist outside of Mac OS X

      M
      V
      C

    19. Re:Portable Mac apps? by julianmayer · · Score: 1

      >How can I write portable versions of Mac OS X apps when the Cocoa API doesn't exist outside of Mac OS X
      of course it does!
      check out gnustep (http://www.gnustep.org/) for a portable version of the cocoa API (works quite well on linux and even on windows ;-)

      >and the language Objective C isn't supported outside of Mac OS X
      of course, it is supported. gcc ships with objective-c support since AGES and runs on nearly all platforms. gcc 4.1 will even feature obj-c++

    20. Re:Portable Mac apps? by WillAdams · · Score: 1

      GNUmail on Mac OS X _is_ a native app --- you get Services and everything one would expect.

      For other platforms, that's a library issue and all it wants is for someone to put in the effort to improve it.

      William

      --
      Sphinx of black quartz, judge my vow.
  11. "Q: Why is six scared?" by Thud457 · · Score: 1

    "It was horrible! There were 1's and 0's everywhere! And I think I saw a 2!"

    --

    the preceding comment is my own and in no way reflects the opinion of the Joint Chiefs of Staff

    1. Re:"Q: Why is six scared?" by BurntNickel · · Score: 1

      There is no such thing as 2.

      --
      And the knowledge that they fear is a weapon to be used against them...
    2. Re:"Q: Why is six scared?" by Anonymous Coward · · Score: 0, Funny

      Because seven ate nine.

    3. Re:"Q: Why is six scared?" by Anonymous Coward · · Score: 0

      On what do you Base this assumption?

      Base 2? Base 10? Base 1?

  12. Profitable? by Anonymous Coward · · Score: 0

    I'm willing to bet that (unless you're is some really niche market) it is totally un-profitable to write software for anything other than Windows. The amount of effort you spend on making it portable, is not worth the extra chump-change you get.

    1. Re:Profitable? by gnuLNX · · Score: 1

      You do of course realize that most software is targeted at niche markets right?

      --
      what?
    2. Re:Profitable? by TinyManCan · · Score: 1
      You know, I could write the exact same thing about just about any OS.

      While you may think of niche's as chump change, I hate to tell you that some vendors are getting $xx Million a year for licensing on software that only runs on HP-UX. And licensing is from a company that isn't even on the Fortune 400. There are other larger companies that are surely paying several times that amount for this same software.

      Products that fill a niche can gather very large amounts of money, depending on the niche.

  13. C++ is cross-platform, dont know what your smoking by everphilski · · Score: 2, Insightful

    I write simulations with GUI's in C++ exclusively and I develop in both Linux and XP (depends on the customer as to the final platform, but I code on both depening on where I am). Its easy to do c++ cross-platform. The only difference is I type "make" on the Linux box and "nmake" on the Windows box :P

    hint: use standard C++ calls, don't get locked in to vendor-specific functions, use cross-platform libraries for the rest (opengl, xerces, etc.)

    -everphilski-

  14. Trolling? by CDPatten · · Score: 5, Insightful

    "as a certain large software company located in the North-West of the United States of America might wish otherwise, there are many different operating systems and platforms in use in the world today. "

    If his first sentence isn't trolling I don't know what is. Why is it ok to do it against MS, but nobody else?
    You do it against MS, you make the front page, against apple you get flamed.

    1. Re:Trolling? by slapout · · Score: 1

      Because it's not as funny when you try it the other way:

      "Much as that nerd from Finland might wish otherwise, there are many different operating systems and platforms in use in the world today."

      --
      Coder's Stone: The programming language quick ref for iPad
    2. Re:Trolling? by Anonymous Coward · · Score: 0

      Actually, I found that funnier than the MS joke ... :)

    3. Re:Trolling? by Anonymous Coward · · Score: 0

      Because /. is an anti-MS website. They make their living from bashing MS.

      That's a joke, right? In the past month, we've had over twenty XBox articles, five since yesterday. Switch your ad-blocker off, and you'll see Microsoft adverts. Slashdot make their living by stirring up flamewars - flamewars mean more pageviews (every submit, every preview, every flame is another pageview), more pageviews mean more ad impressions.

    4. Re:Trolling? by nico60513 · · Score: 1

      Um ... because Microsoft is a convicted monopolist?

      Or maybe because Microsoft expends a great deal of effort to make it difficult for other OSes to interoperate with theirs (embrace and extend)?

      I agree, however, it is trolling. You wouldn't be able to use the same dig at Apple, though, I doubt that Apple employees are deluded enough to believe that they're the only game in town given their small percentage of the market.

    5. Re:Trolling? by Just+Some+Guy · · Score: 1
      Mainly because Microsoft is the only major company that's explicitly stated a desire to control all aspects of computer. A judge even found them guilty of working toward those ends.

      Linus flat-out said that he doesn't want to own the world. I'm sure Apple would love to sell more machines, but they've positioned themselves as the low-volume, high-end solution (sort of like Mercedes or Cadillac). Microsoft, though, wants it all and has said this on many occasions.

      That is why you can justifiably say these things about "a certain large software company". Well, Oracle, too, but that's a different topic.

      --
      Dewey, what part of this looks like authorities should be involved?
    6. Re:Trolling? by Anonymous Coward · · Score: 0

      If his first sentence isn't trolling I don't know what is. Why is it ok to do it against MS, but nobody else?

      Because you are a Moron that thinks cross-platform is Win9x, WinNT, and WinCE. Why don't you come out of the closet and admit you work for the Microsoft mis-information er... Marketing department.

    7. Re:Trolling? by CDPatten · · Score: 1

      "Mainly because Microsoft is the only major company that's explicitly stated a desire to control all aspects of computer"

      MS doesn't control the hardware, and has no intention of it, so that would make your statement false, "all aspects of computer". However, let me introduce you to Apple (www.apple.com). The company that not only bundles all the things MS bundles (media player, IE, etc.), but are a "monopoly" on hardware for their closed source operating systems (osx). Its a complete closed circuit system, realistically, worse then MS, but with a much much smaller market share.

      Oh and don't kid yourself, Steve Jobs wants to "own the world". Anyone who has been around since the 80's knows damm well that Steve Jobs is no saint, he just got beat by MS. In any case, check them out, maybe you can start flaming them along with MS.

    8. Re:Trolling? by Just+Some+Guy · · Score: 1
      The company that not only bundles all the things MS bundles (media player, IE, etc.), but are a "monopoly" on hardware for their closed source operating systems (osx).

      In exactly the same way, GM has a monopoly on GM cars. Was there a point in there?

      --
      Dewey, what part of this looks like authorities should be involved?
    9. Re:Trolling? by CDPatten · · Score: 1

      My point is Apple gets a free pass for similar, same, or worse activities that MS gets ripped apart for.

      Are the attacks principled, or is it only wrong when you are number one?

    10. Re:Trolling? by Anonymous Coward · · Score: 0

      Um ... because Microsoft is a convicted monopolist?

      You say that like it's bad. Or true.

      And you say it over, and over, and over, and over... Maybe you're a bot. Or have the mind(lessness) of one.

      Hopefully next year when you turn fourteen you'll have a new boogeyman that you'll come here to whine about, because we could all use some variety.

    11. Re:Trolling? by Anonymous Coward · · Score: 0

      Ah, to be blissfully ignorant of the fact that every corporation would do what MS has done if they only had the ability to. I wish I lived with my head in a hole. Reality, insight, perspective, they're all just too complicated to bother with.

    12. Re:Trolling? by Anonymous Coward · · Score: 0

      They might not control the hardware, but they certainly influence it. I use an IBM Model M keyboard. When it dies I'll have to buy a new keyboard and all modern keyboards come with that piece of shit Windows® keys that I find both useless and annoying. That's enough for me to never ever use anything made by Microsoft, let alone the piss poor quality software they try to pass as enterprise ready.

    13. Re:Trolling? by Anonymous Coward · · Score: 0

      Microsoft? Oh. I thought he was railing against those of us at Amazon.com.

    14. Re:Trolling? by Trejkaz · · Score: 1

      Trolling? Do you seriously think that Microsoft aren't trying to dominate the world?

      --
      Karma: It's all a bunch of tree-huggin' hippy crap!
  15. What About UI? by toonerh · · Score: 1

    I did RTFA but haven't RTFB. I appears it is oriented toward non-UI intensive modules. Java, as others mentioned, handles the UI stuff quite well. The GNU build utilities help a lot if it's a *NIX system, but most true portability problems require more OS's.

    1. Re:What About UI? by RingDev · · Score: 1

      "Java ... handles the UI stuff quite well"

      Who put crack in your weaties this morning?

      -Rick

      --
      "Most people in the U.S. wouldn't know they live in a tyrannical state if it walked up and grabbed their junk." - MyFirs
    2. Re:What About UI? by Anonymous Coward · · Score: 0

      Ah.. I was so going to post something similar. I'm glad to see that YOU are the one that beat me to it at least.

      sparX

    3. Re:What About UI? by miyako · · Score: 2, Informative

      If you want a cross-platform GUI, then I think Java/Swing is the way to go a lot of the time.
      I program mainly in Java and C++, and if you are looking just at desktop machines (which is what I work with) then it's really not a big deal either way since you are mainly looking at *nix, Windows and maybe OS X. Swing is pretty much write-once for all three platforms- though you have to do some funkyness to get mac programs to look like mac programs under OS X. Qt is available for all three platforms as well. Athough I've never developed with it, AFAIK GTK+ is also available on OS X, as well as *nix and Windows.
      The thing is, it's no longer unreasonable to expect to write an application and have it run on a desktop system, a cell phone, and a PDA. Since most cellphones support at least a subset of Java, whereas I do not know of any that support Qt or GTK+, it seems that in these instances Java is the way to go.

      --
      Famous Last Words: "hmm...wikipedia says it's edible"
  16. 2 slow by Anonymous Coward · · Score: 0

    yeah, but it's too slow (anectodatal evidence that invoking an assembly language routine "runs just as fast as c" is not proof ... c'mon java fans : think! )

    Name me a program that runs under java. I mean that everybody knows about.
    That's right, there are none.

    1. Re:2 slow by Anonymous Coward · · Score: 0

      Azureus?

    2. Re:2 slow by Anonymous Coward · · Score: 0

      Shh, leave the nerd to his fixation on living in the 90s. To be so unintelligent that one can cleave to only one thought/idea/way must be somewhat of a blessing.

    3. Re:2 slow by S.O.B. · · Score: 2, Insightful

      For enterprise strength app servers WebLogic and WebSphere are written in Java. Not as scalable but getting better is Tomcat also written in Java. The Java application I work on processes about 10 million transactions a week and was ported from the mainframe. The biggest porting headache was not the Java code but SQL differences between DB2 and Oracle. In terms of cost per transaction it's cheaper than many of our mainframe apps.

      For development Eclipse is written in Java using SWT. Eclipse has become the new standard for open IDE tools.

      Up until I lost it in a machine crash I had a Java email program program that I ran using Java 1.1 through to 1.5 on Linux, Windows and MacOS. When was the last time you had a program that didn't even need to be recompiled through 4 major operating system releases let alone as you moved it from OS to OS. Heck, with Linux a 0.0.1 change in the kernal could force a recompile.

      Now, for pure number crunching Java is definitely not the right choice but most apps are not simply churning the CPU. Most real life apps also involve disk I/O, network I/O, etc. If 90% of your app is I/O then it's not going to make much of a difference what technology you use on the other 10%. So why not use Java and make it portable as well.

      With Java, what you gain in portability, isolation from OS releases and a wealth of open source APIs far outweigh the less than 5% (yes it's that little) overhead that the Java runtime adds to 10% of your app.

      --
      Some of what I say is fact, some is conjecture, the rest I'm just blowing out my ass...you guess.
  17. Good. This needs to be taught. by dslauson · · Score: 3, Insightful

    I got my first job and started digging into some code that was written for portability, it all seemed so obfuscated.

    I was like, "Why are they #defining all their data types to something else? And what's with all the crazy compiler directives?" It seemed like they were going out of their way to make the code less readable.

    Once I figured out that it was all there so that the code could be recompiled for different platforms, it all clicked together. It's really cool, and I'm pissed that I got out of college not knowing this stuff. It should be a required course, IMHO.

  18. Write and test on three different platforms by Dr.+Manhattan · · Score: 5, Interesting
    Best combination is one big-endian, one little-endian, and a 64-bit machine. That catches at least 85% of the portability problems right off the bat, and has the bonus of catching memory errors very quickly. Something that silently corrupts data on one platform will often cause an instant loud crash on a different one.

    "If you haven't ported your code, it isn't portable."

    Sticking to the libraries and (subsets of) languages that are really portable helps, too, like this book appears to cover, but if you just start off on a small mix of platforms, it becomes usually quite trivial to port to others. My Ostiary program runs on (at least) Linux, *BSD, OSX, Solaris, HP-UX, AIX, Tru64, IRIX, and Cygwin. I've written commercial code that runs on all of those plus Windows, NetWare, and OpenVMS, though that requires a few more #ifdefs.

    --
    PHEM - party like it's 1997-2003!
    1. Re:Write and test on three different platforms by GebsBeard · · Score: 1

      I agree. I built a 10+ meg library in C++, currently backporting to C. The thing runs identically and flawlessly in Win 4.0, Win 2k & 2k3, SCO Unix, Red Hat Linux, SuSE Linux, and Free BSD. Also preliminary tests indicate it compiles on Solaris 10 (SPARC) in 32 and 64 bit mode. I will be adding an RS/6000 Power-III box to the mix sometime early next year. Can't agree with you more: multiple boxes, different chipsets (PA-RISC, SPARC, POWER and x86), different void * sizes (32 and 64 bit) and operating systems. The key to my portability was heavy (but proper) use of typedef, #ifdef and creating OS level portability wrappers. Works like a charm and still fast as hell (especially in this day of byte code).

    2. Re:Write and test on three different platforms by br00tus · · Score: 1
      I agree, if you write for portability on just two platforms, say Windows and Linux, porting to anything else becomes that much easier. I'm not even much of a C programmer but I managed to write a program that uses threads, and sockets that works on Windows and Linux (and Solaris running on big endian chips, and FreeBSD, and OpenBSD etc.) My program is GPL and I borrowed portable code for threading and sockets from other GPL programs. So if you are writing a GPL program it is not a big deal, as you don't have to spend the time figuring all of this stuff all out.

      Another thing is I just make some minor changes in my programming to keep things portable. For example, some systems still have the bzero() function, and programs using it will work on that platform, but the memcpy() function can do the same thing and is on most platforms, so now I never use bzero() and always use memcpy().

      Most platforms are pretty compatible, Windows is the one platform that seems to need lots of special defines and whatnot, probably purposefully. 80% of the #ifdef's in my system are "#ifdef WIN32". Aside from many differences in thread and socket calls (closesocket instead of close), things like the sleep function are different as well.

    3. Re:Write and test on three different platforms by jonadab · · Score: 1

      > I agree, if you write for portability on just two
      > platforms, say Windows and Linux, porting to anything
      > else becomes that much easier.

      This is more true if the two platforms are more different from one another. If possible, they should have completely different concepts of filesystem structure, use different byte orders (big-endian versus little), have different numbers of bits in the basic data types, one should be heavily multi-user with a detailed security and permissions model and the other not, and so on and so forth. MacOS 9 on PPC and VMS on Vax, for instance, would make a good pair. Anything that compiles and runs without modification on both of those should be *nicely* portable.

      --
      Cut that out, or I will ship you to Norilsk in a box.
  19. All desktop apps I write by drgroove · · Score: 4, Insightful

    are done w/ J2SE using SWT as the front end. Looks like a native app, runs super fast since it relies on native widgets, and portability issues are largely mitigated for me.

    1. Re:All desktop apps I write by misleb · · Score: 1

      Is this what the Azureus bittorrent client uses? Not bad, but it is still a bit slower than a native app.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    2. Re:All desktop apps I write by ForumTroll · · Score: 1

      Yes, Azureus uses SWT for its GUI as does Eclipse and RSSOwl. However, from what I've found Swing has made some very strong improvements in performance over the past few years, especially with the 1.5 VM. The next VM release should also really speed up some aspects of Java GUI performance. Personally, as it stands now I would much rather write programs using Swing however that's just a personal preference. From recent experience, I think SWT and Swing are so close now in terms of performance that I think many developers are choosing one or the other based on API preferences.

      For some examples of great Java programs written using Swing take a look at Swing Sightings. Especially, IntelliJ IDEA. =)

      --
      "A Lisp programmer knows the value of everything, but the cost of nothing." - Alan Perlis
    3. Re:All desktop apps I write by Anonymous Coward · · Score: 0

      are done w/ J2SE using SWT as the front end. Looks like a native app, runs super fast since it relies on native widgets, and portability issues are largely mitigated for me.

      But doesn't work with the 64-bit JVM on Windows. grr.

    4. Re:All desktop apps I write by misleb · · Score: 1

      Sure, but Swing is ugly and it doesn't use local widgets. I personally would tend to avoid a Swing application even if it were fast enough.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    5. Re:All desktop apps I write by Tuross · · Score: 1

      There's no such thing as "local widgets", given that there are so many varied widget libraries available. Sun are doing the right thing by providing a decent default one for their Java platform, but not tying you to it. Many other VM'd languages do the same thing, Python has Tk bundled with it, for example. Doesn't stop me from using GTK, Qt, wxWidgets, Tuross'TotallyTerrificToolkit, or whatever.

      I agree Swing is ugly by default, that's why it is possible to theme it. In fact, making something ugly by default is probably a good idea as it encourages you to think about UI issues and not simply code something with the mindset of "I like it this way, therefore everyone else will like it this way". Aesthetics are a personal thing - there's probably people who think the default Swing look(s) (plural because it has 3 - motif, metal and windoze) are beautiful.

      Also, Java apps run perfectly fine on any machine made in the past 5 years; repeating the "Java is slow" myth only makes you look foolish. In fact, I find that for example, JEdit feels a lot faster than Visual Studio (its also more useful too, but that's beside the point)

      --
      Matt
      1. Read Slashdot
      2. ???
      3. Profit
    6. Re:All desktop apps I write by Serpent+Mage · · Score: 1

      Works superbly with 64-bit JVM (sun java5) on Linux though ^_^

    7. Re:All desktop apps I write by misleb · · Score: 1
      There's no such thing as "local widgets"

      There is on OS X and Windows. Perhaps "local" isn't the correct word. I should say native. If I am running GNOME, the native toolkit is GTK+.

      Sun are doing the right thing by providing a decent default one for their Java platform, but not tying you to it. Sun are doing the right thing by providing a decent default one for their Java platform, but not tying you to it.

      Good for the programmer, bad for the user, IMHO. Historically, this has been one of the major shortcomings of the X environment from a user's perspective. Too many different looks and feels.

      I agree Swing is ugly by default, that's why it is possible to theme it. In fact, making something ugly by default is probably a good idea as it encourages you to think about UI issues and not simply code something with the mindset of "I like it this way, therefore everyone else will like it this way". Aesthetics are a personal thing - there's probably people who think the default Swing look(s) (plural because it has 3 - motif, metal and windoze) are beautiful.

      Exactly. Aethetics are a personal thing. That is why you should use a "native" widget toolkit (or at least emulate it as best as possible) which conforms to the user's local desktop preferences and not use some application/VM specific look and feel. You have demonstrated exactly why I think Swing is a bad UI toolkit.

      Also, Java apps run perfectly fine on any machine made in the past 5 years;

      But not as good as a native app. Java's brand of portability has a price.

      epeating the "Java is slow" myth only makes you look foolish.

      It is a partial myth. Java is just fine when it comes to raw computational power. Great on backend servers. But It is noticably slower for a lot of graphical applications. It has a much slower startup as well as a noticably sluggish UI. Where I work, our Mac users refuse to use the Groupwise java client because it is slow (as well as lacking features)

      JEdit feels a lot faster than Visual Studio

      I've never used VS, but I have heard that it is quite bloated with features. If it is slow, that probably owes to its size. I have used JEdit. I'd prefer a native GNOME/KDE application. On a Mac I use TextMate (not exactly comparable, but I do mostly web/script programming). Given two applications, one in Java and one in Cocoa with roughly similar features, I'd take the Cocoa application any day.

      -matthew

      --
      "THERE IS NO JUSTICE, THERE IS ONLY ME." -Death
    8. Re:All desktop apps I write by Anonymous Coward · · Score: 0

      "On a Mac I use TextMate (not exactly comparable, but I do mostly web/script programming). Given two applications, one in Java and one in Cocoa with roughly similar features, I'd take the Cocoa application any day."

      That's more of your personal preference than anything else. I know many people including myself that would take the Java app, regardless of whether it was written using Swing or SWT.

  20. From id? by dFaust · · Score: 2, Interesting

    Is this the same Brian Hook that previously worked at id software??

    1. Re:From id? by rsmith-mac · · Score: 1

      Yes. It's the same Hook from id, 3dfx, and all those other gaming-related companies. His bio has more details.

  21. But what does Alex St. John say in response!?!?! by Evangelion · · Score: 0, Offtopic


    Come on, we have to know.

  22. Re:Small book by Daniel_Staal · · Score: 2, Insightful

    Java doesn't run everywhere: For instance, there is no Java JVM for a Palm. C/C++ programs that started elsewhere have been ported to Palm, on occasion.

    It's a bit of an extreme case, I admit, but...

    --
    'Sensible' is a curse word.
  23. blah by Anonymous Coward · · Score: 1, Insightful

    let me guess. There must be a chapter that describes the operation of autoconf and automake and tell you how to check that HP-UX98/version 2.3.45 has a broken strfchok() function that doesn't accept a second argument of 0.

    These systems must die. POSIX should be the only supported target for young programmers. HP-UX87 and SunOS 0.x can RIP. Their admins should upgrade to a newer OS if they want to run new programs.

    Help deprecate those beasts! Don't write portable code for ancient systems.

    1. Re:blah by Anonymous Coward · · Score: 0

      All my mod points are belong to you. Well, they would if I had any at the moment.

      The horror that is autoconf/automake should be eradicated and remain only as a bad memory.

    2. Re:blah by Mancat · · Score: 2, Interesting

      Unfortunately, all too many Linux programmers are not writing to POSIX standards themselves. Far too many "Linuxisms" abound.

      --
      hello dear sirs my name is jamesh i are india (bihar) can u guide me install red had linux 9?
  24. One issue with portable code: Testing by Anonymous Coward · · Score: 0

    As an open source developer who is currently in the pre-beta testing stage with my main open-source application, one of the issues that come to mind is the issue with testing. It is fairly easy to write portable code (and fairly impossible to retroactively make non-portable code portable). The problem is testing.

    In order to test a given program, the program has to be tested on any and all supported architechures and platforms for the program in question. This requires a large number of compters to perform testing on. Distro Watch has a large number of Linux distributions; it is not practical to test a program on all of them. What is done, usually, is for professional software vendors to say "This program is for RHEL 3; if you want to run it on any other distribution of Linux, we will not support it".

    As just one example, after writing my application on RHEL 3 (OK, Centos 3.6), I couldn't get it to compile on FreeBSD because FreeBSD uses "-pthread" instead of "-lpthread" to indicate that an application uses the pthread libraries.

    As another example, I went to some effort to have the application generate no warnings when compiled on GCC 3.2.3; however, the application generates a number of warnings when compiled with GCC 4.0.

    As another example, the Loki games no longer run on Fedord Core 3; even though the people at Loki went to a lot of effort to make their games as portable as possible, things in Linux changed so that older binaries no longer run; I had to create special chroot() environments to run older binaries in FC3; I had a Slackware 8.1 and a RedHat6.2 chroot() environment for running older browsers for my cross-browser compatibility testing (something Slashdot hasn't done; The new "standards compliant" Slashdot breaks on a number of older browsers which rendered the old site just fine)

    The point being that, while portable code minimizes the development expenses of an application, it does nothing to lower testing costs.

  25. Portable code... again! by Anonymous Coward · · Score: 5, Insightful
    First, C. was going to free us from non-portable code, by abstracting away the underlying assembly language. But hardware was different, and required different libraries to communicate with it. Not all the libraries were identical, and things diverged.


    Then device drivers and operating systems were going to let us abstract away the details of the underlying implementation of the hardware, letting us write portable code. But not all O/S versions are compatible; there are glibc issues under Linux, and so on.


    Then JAVA was going to be completely portable to all operating systems. But not all Java virtual machines are identical, and different version of Java came out, and things diverged.


    All of these things made life more portable, to some degree. All of them still require boostrapping a system that understands the underlying hardware and deals with it efficiently; then abstracts all that hardware specific efficiency away again.


    Portability is *hard*: in some sense, it's the enemy of efficiency. You need to abstract away all those nice hardware specifics that make the hardware work, and replace them with a theoretical construct that caters to the lowest common denominator that you're willing to support.


    What's worse, as soon as someone makes a different design decision, or an improvement, or something that isn't universally adopted all at once, you have multiple versions -- divergent standards which aren't completely compatible. It happened with UNIX; it's happening with Linux (to a lesser extent, because code can merge again after a fork), and it happened with C and Java.


    What can the developer do? Just our best; true universal portability is a Holy Grail that we'll never attain, because the day we do, someone will invent a radical new system that doesn't quite fit our abstraction model...

    1. Re:Portable code... again! by woolio · · Score: 1

      The true enemy to portability is reall laziness How many people write C programs where "main" returns "0". AHEM! We should be returning EXIT_SUCCESS or something like that. Same thing with libraries. Take sockets in Linux. People don't seem to define a "standard" set of includes for doing socket functions. Or programmers just start including headers until the compiler errors go away. Change the platform and all of the sudden the header files have different names or different ones need to be included. Is this following POSIX standards? (Dont' know) If someone would just get everyone to agree on function names and header file structures, a whole lot of portability programs could be solved.

    2. Re:Portable code... again! by Fred+Foobar · · Score: 1

      According to the C standard, returning 0 from main is an acceptable way to indicate success. The EXIT_SUCCESS macro exists mainly to complement the EXIT_FAILURE macro (whose exact value depends on the host environment).

      --
      It was a really good paper.
    3. Re:Portable code... again! by jonadab · · Score: 3, Interesting

      > True universal portability is a Holy Grail that
      > we'll never attain

      If you're willing to accept the limitations that go along with writing to the least common denominator, Inform comes *really* close to true universal portability -- compile once, run anywhere that has the VM, which is *almost* anywhere. You can, for instance, use the same z3 module on the PDP10, Palm and Psion handhelds, Nintendo Gameboy, Atari ST, TRS80, the BBC micro, Acorn/Archimedes/RiscOS, and a *wide* assortment of other systems (including, of course, all the major ones: DOS, Windows, Mac, Apple II, Amiga, pretty much any POSIX system, anything with Perl5 or a Java vm, Emacs, Mozilla (with XUL), ...). There is not a complete list anywhere of the platforms that have a z-code interpreter available, but I strongly suspect that it is the third most widely-supported computer format after ASCII and HTML (which are nothing like equivalent in their capabilities (z-code is not some kind of glorified markup; Inform is a very nice language to work in, with extensive object-oriented features), and HTML is nowhere near as consistent in how it is rendered; even ASCII isn't if you consider line-ending differences or other characters outside the range of 32-127 (decimal)). For instance, given the number of platforms with no graphics capability, I cannot imagine that GIF is as widely portable as z3, although it is surely more widely-known.

      If you need the extra memory afforded by z5, the list shortens a little; if you need graphics (z6) or even more memory (z8), the list shortens rather more, but is still fairly impressive.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    4. Re:Portable code... again! by plumby · · Score: 2, Interesting
      Then JAVA was going to be completely portable to all operating systems. But not all Java virtual machines are identical, and different version of Java came out, and things diverged.

      Yet it's still perfectly possible (and really not that hard) to write portable Java.

      At my organisation, Java development is done almost entirely on peoples' local Windows boxes, before being transfered over to the HP-UX boxes for the test/production environments. To the best of my knowledge, in the past 5 years, we'e had one single bug has ever been found that was down to a difference between Windows and HP-UX environments (and than was a bug in the specific HP-UX JVM that we were running - it was fixed with an upgrade to the latest version).

    5. Re:Portable code... again! by blake182 · · Score: 1

      Then JAVA was going to be completely portable to all operating systems. But not all Java virtual machines are identical, and different version of Java came out, and things diverged.

      I maintain a 300KLOC Java source code base for a mail server product on four platforms (Windows, Linux, Solaris and OS X). We started out with AIX and HP/UX also, but removed those as targets because the markets weren't there (not because of portability issues). We don't ship on OS X, but it is my day-to-day development environment, so I still make sure it works on there. The issues I remember having are:

      • End of line conventions. Make sure you use CRLF or LF as appropriate, which is available through the Java environment as the line.separator property.
      • Path separator. Slash or backslash as appropriate, and actually if you just use slash all the time, the java.io.File methods will figure it out. But that's also available through the environment file.separator property.
      • Filesystem case semantics. This is a harder one. Windows is case-retentive and case-insensitive. Most other OS's are case-retentive AND case-sensitive. So on Windows "foo.txt" and "FOO.TXT" are the same file, but not on other platforms. Don't be a jerk -- use the right case. That's usually just sloppy.

      The most important thing that saved our bacon was having a comprehensive set of unit tests. We operate under the principle that "if it's not tested, the functionality doesn't exist", and maintain about 90% code coverage through unit tests. It's very easy to track down cross-platform niggling issues when you have a clean, automated unit testing system that makes a loud crashing noise when something smells bad. I was able to do the Solaris platform testing in about a day and fix the stuff that snapped off (basically that list above).

      As far as "But not all Java virtual machines are identical, and different version of Java came out, and things diverged", I'm tempted to say that this is fearmongering and that this does not present a practical problem. However I will confess that we have only ever tested with the Sun JVM, the OS X port of that, and the IBM JVM, which I think all tie back to the Sun code. It's not clear what the practical reasons for using another JVM are, and I presume that it has something to do with licensing and philosophy moreso than practicality. If you only use features within the scope of your target JVM, you don't have any problems, so make sure they're matched up.

    6. Re:Portable code... again! by sapgau · · Score: 1

      Please mod parent up.

      In our shop we successfully launched our j2ee system by developing on windows and deploying on unix.

      The notion that diferences between JVMs are as wide as C libraries is FUD. There are different JVMs because they focus more on performance for certain platforms.

      Also, if you would make a JVM that is so different from the standard Sun would come and sue your a$$ off. Microsoft did it and they paid dearly for it.

  26. Mod parent up by dpbsmith · · Score: 3, Insightful

    Amen, brother.

    I've been involved in way too many projects where people said, "Oh, yeah, we're doing all our development on Windows but it's no big deal. We aren't going to use anything non-portable."

    Then, when the time came to port it... it was utterly intertwingled with Windows-specific cruft, half of which crept in because nobody even knew they were doing it. If they'd ever tried even once to port it, they could have caught this stuff as it happened.

    I don't mind a conscious decision to use .ini files, or CStrings, or what have you. It was all the non-portable things they did without even knowing it--and the fact that the non-portable stuff was salted and peppered evenly throughout the whole project instead of concentrated in a few well-defined modules--that got to me.

    And it didn't help that everything was compiled with permissive compiler options regarding C/C++ conformance, and a low warning level.

    1. Re:Mod parent up by Rei · · Score: 1

      To be fair, while I strongly appreciate them (and run with werror), sometimes warnings can be problematic. As an example, I recently coded something similar to the following for a home project:

      template
      void foo::bar()
      {
              T var = random();
              if (sizeof(T) == 8)
              {
                      var 32;
                      var |= random();
              }
              do_something(var);
      }

      Now, picture this being run over a range of types, from u_int8_t to u_int64_t. sizeof() is a compile-time function; it gets optimized out. Only 64-bit variables will ever see the inside block of this code. Yet, you'll get a warning on, say, T=u_int8_t that the shift is too large. The warning is preventable, but requires an annoying workaround using inline functions to replace the bitshift operators.

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
    2. Re:Mod parent up by Rei · · Score: 0

      Blah, forgot about how slashdot strips out brackets. The class foo is templated over "class T"

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
  27. Unfortunate by under_score · · Score: 4, Interesting

    I've written production code in C, C++, Objective-C, Lisp, Pascal, many different scripting languages, and Java. Bar none, if you want to write something portable, Java is the language to use. It has the incredibly complete and mature libraries, performance is excellent, tool support with IDE's and app servers and source repositories is fabulous, and it is designed to be cross platform! Games, huge transactional systems, office apps, and utilities are all appropriate types of applications to build on Java. I've started to do scripting on FreeBSD with Java. I'll admit, it's hard to write a useful bit of Java that is less than about 10 lines of code, particularly for text processing. But that is probably the only place it is lacking. The one other place one might consider using something else is in Dynamic Client-Side Web Apps (AJAX stuff). Other than that, I always groan when people talk about using other languages for cross-platform development.

    1. Re:Unfortunate by keesh · · Score: 2, Informative

      Eh? Java is 'cross platform' only in that it forces you to use the lowest common subset of all 'supported platforms'. Plus, far fewer platforms have a working JRE than a working C or C++ compiler or Perl or Ruby interpreter.

    2. Re:Unfortunate by under_score · · Score: 1

      You are right about the relatively limited number of JVMs. However, the lowest common denominator isn't actually very low unless you're trying to develop an operating system.

    3. Re:Unfortunate by Arandir · · Score: 1

      If Sun could figure out how to make Java user friendly, you might have a point. I use FreeBSD and as a *user* Java is a royal pain in the butt. Sun hasn't approved Java binaries for FreeBSD, so I have to build it myself, after agreeing to all sorts of cheesy licenses to get the sources downloaded. Then I have to execute them in a non-standard way, and wait for several seconds for the runtime to load before they start.

      Don't get me wrong, I like the language. I just hate the environment.

      --
      A Government Is a Body of People, Usually Notably Ungoverned
    4. Re:Unfortunate by Just+Some+Guy · · Score: 1
      Other than that, I always groan when people talk about using other languages for cross-platform development.

      Funny - I see Python the same way. No offense, but I'm glad you don't get the last word on the subject.

      --
      Dewey, what part of this looks like authorities should be involved?
    5. Re:Unfortunate by dominator · · Score: 2, Informative

      C and C++ are "portable assembly". All the languages that you mentioned are inherently portable and cross-platform.

      What Java has going over C and C++ is a useful large standard library framework. But heck, if you use say Qt, Mozilla's NSPR, Apache's APR, Glib, or something else as your C/C++ platform you'd have many of the same advantages that the Java library gives you.

    6. Re:Unfortunate by NullProg · · Score: 1

      Bar none, if you want to write something portable, Java is the language to use.

      Then why does Sun choose C/C++ to write java?

      Enjoy,

      --
      It's just the normal noises in here.
    7. Re:Unfortunate by gnuLNX · · Score: 1

      If you use QT you have much more. I do a goo d bi tof cross platform development and QT makes going between windows/Linux/OSX trivial.

      --
      what?
    8. Re:Unfortunate by Anonymous Coward · · Score: 0

      Now why on earth would they ??

    9. Re:Unfortunate by Col+Bat+Guano · · Score: 1

      Er, Java is not very portable at all. It generally only runs on the JVM "hardware". The JVM is the portable bit of software here.

    10. Re:Unfortunate by trollable · · Score: 1

      Plus, far fewer platforms have a working JRE than a working C or C++ compiler or Perl or Ruby interpreter.

      It is true for C, probably true for C++. But not for Perl and Ruby. Check out all the free JVMs and all the embedded JVMs. There is more than one hundred. I never see Perl or Ruby on a mobile phone or on a credit card. IIRW, Python has been ported on a mobile phone but that's all.

    11. Re:Unfortunate by jonadab · · Score: 1

      > Bar none, if you want to write something portable,
      > Java is the language to use.

      "Bar none" is awefully strong language. I would have said that Java was middle-of-the-road in terms of portability. It's more portable than any of the other languages you expressly list, sure, but those are mostly fairly unportable langauges. Java is better, but in terms of extreme portability, it is not a contender.

      There are a *lot* of platforms with no Java vm: most of the 8-bit micros, most of the older handhelds, as well as most of the lighter handhelds, some game consoles, most of the older non-micro systems, ...

      If you write in Inform, you compile once and run on any of those, as well as, of course, anything with a Java VM, anything with Perl 5.003 or later, anything with Emacs 20 or later, Texas Instruments calculators, and practically anything else.

      Granted, these are all systems you typically don't need to support with e.g. a desktop business application, so for that sort of thing Java is a good choice, especially if GUI is important, as Java handles that rather nicely (and Perl, another midrange system in terms of portability and my personal preference for almost anything command-line oriented, is particularly weak for GUI stuff). And Inform is not a choice at *all* if you need a GUI or any of a number of other features it doesn't support. On the other hand, if really extreme portability is needed, Java is not a choice at all.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    12. Re:Unfortunate by jonadab · · Score: 1

      Java is middle-of-the-road for portability. (So is Perl. I don't really know where Ruby falls on this.) Although more platforms have a C compiler, Java code is more portable from one of those platforms to another, in general, than C code. It is *possible* to write C code that is more portable than Java, but it is highly unusual.

      I would rate Perl as more portable than Java as long as you don't do stupidly unportable things (hardcode filepaths, call system binaries, that sort of nonsense) or need to provide a GUI; Java handles the GUI rather better than Perl, however. (Any kind of GUI is inherently far less portable than a command-line program, and inherently you will support fewer platforms (typically only Win32, Mac, X11 on POSIX, and possibly OS/2 or BeOS), but sometimes it's a requirement.) Again, I don't know where Ruby falls on this.

      I strongly suspect, from the other poster's comment, that he was assuming the application in question needed a GUI, because if we add that assumption into the mix, his comment makes a lot more sense than otherwise.

      Perl is fairly portable, if you need amenities like access to the filesystem and the ability to allocate memory dynamically. If you can do without such niceties, it's possible to be *MUCH* more portable, e.g. by programming in Inform and compiling to z3.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    13. Re:Unfortunate by kaisyain · · Score: 1

      C and C++ are "portable assembly". All the languages that you mentioned are inherently portable and cross-platform.

      No they aren't. If the language spec ever says "Implementation dependent" then it is not "inherently portable and cross-platform." Any time it says "can" or "may" you have lost portability. Any other definition of "portable" lessens the meaning of the word.

    14. Re:Unfortunate by Anonymous Coward · · Score: 0

      So how do YOU check for the free space of a filesystem? http://bugs.sun.com/bugdatabase/view_bug.do?bug_id =4057701

    15. Re:Unfortunate by Dwonis · · Score: 1

      If there are Perl, Ruby, or Python implementations in Java, then they are at least as portable as Java. :P

    16. Re:Unfortunate by trollable · · Score: 1

      But there isn't. I'm aware of JRuby and Jython (I don't know a java-based Perl impl.). AFAIR, JRuby and Jython provide the core of their respective languages. For example, there is no GUI or they use Swing. Same for database access, ... Most of jython programs won't run on CPython and vice-versa. That may change in the future.

      No let's do the reverse: since there is a Java implementation in Perl (well Parrot), Java is at least as portable as Perl :)

    17. Re:Unfortunate by Nevyn · · Score: 1
      Bar none, if you want to write something portable, Java is the language to use. It has the incredibly complete and mature libraries, performance is excellent, tool support with IDE's and app servers and source repositories is fabulous, and it is designed to be cross platform!

      I've seen a bunch of quotes like this, and all I can think is that there must be a lot of people writting crap. For instance, you can't even write a correct version of rm ... Java just doesn't support the APIs you need to call to do it well. Yes, you can do a crap version that has security problems and that'll be buggy everywhere ... Most people have been able to write code that doesn't work everywhere in C for a long time.

      --
      ustr: Managed string API with ave. 44% overhead over strdup(), for 0-20B
  28. Re:Small book by smackjer · · Score: 2, Insightful

    Isn't an OS just a kind of runtime environment? After all, it's just one level of abstraction among many levels of abstraction. A Java Virtual Machine is just one more level of abstraction.

    --

    This is my sig. There are many like it, but this one is mine.
  29. Re:Small book by Anonymous Coward · · Score: 0

    Java, web, etc. (other people have said web apps)

    Not all code can simply run above the system. That's like saying that you're going to write the most portible operating system ever, in perl!

  30. Beeeehhhh, wrong. by BitwizeGHC · · Score: 1

    1) Objective-C is supported wherever gcc is. Get a klew.

    2) With the GNUstep api, you can write code which targets Cocoa but is portable to other platforms. You may have to rebuild your NIBs in Gorm, however; but if you wrote a platform-agnostic back end this is a cosmetic issue.

    3) If you're using Carbon, your interests really are Mac only.

    --
    N4st0r, trixx0r h0bb1tz0rz! Th3y st0l3 0ur pr3c10uzz!
    1. Re:Beeeehhhh, wrong. by mederjo · · Score: 1
      3) If you're using Carbon, your interests really are Mac only.

      Beeeehhhh, double wrong. I'm writing a cross platform UI framework using Carbon right now. It's C++ and abstracts most of the platform specific functionality ( currently Mac and Windows, maybe Linux in the future ) away primarily using a Bridge pattern. Works well. It takes a thin approach and allows access to platform specific underpinnings to allow you to give the best platform specific experience where that can only be given by writing platform specific code. It also doesn't try and abstract away general drawing stuff ( apart from OpenGL stuff ), so you would write drawing code on OS X using Quartz and on Windows using GDI or whatever. This approach has worked well for us in our current product, so we're sticking with it.

      Most of the major cross platform apps I'm aware of use Carbon, mainly because it's easier to use with C/C++ and also no doubt because they didn't see sufficient value in adopting Cocoa when they moved to OS X. I don't know of anyone taking the approach you suggest, I've never heard anyone saying anything except GNUstep covers enough ground relative to Cocoa to make using it as the basis for a portable application of any size. I don't really know much about it except that as a developer it seems to me that trying to maintain an app using two different frameworks ( Cocoa and GNUstep ) with different Objective-C runtimes ( Apple's one and GNUsteps ) is likely to be just as much hassle as using two different APIs ( Carbon and Win32 ) underneath a C++ framework. Does GNUstep keep with all the new things Apple adds which developers are likely to want to use, such as Cocoa Bindings ? Do you have to compromise and take a least common denominator approach ?

      Qt uses Carbon under the hood on OS X.

      It may surprise you to learn that people have been writing cross platform applications on the Mac for a long, long time, long before OS X and Cocoa, for example, virtually ever major 2D graphics/DTP app. They used the predecessor of Carbon. Carbon is the "classic" MacOS C APIs cleaned up, modernised and improved.

      In theory I could be using Cocoa instead of Carbon for the Mac specific stuff in our framework, but using Carbon isn't hard and it's what I know, so there doesn't seem to be much point in adding the extra compexity of meshing two languages.

      So, dude, it seems like you're the one who needs to get a klew ;-).

      Regards,

      Jo Meder

  31. Small and efficient beats portable by xtal · · Score: 4, Interesting

    If the task is well defined, a small, tightly defined app tied very closely to the target API has a better chance of performing well with fewer bugs as you can spend the portability-effort in testing.

    I abstract math and models to generic C++. I tie the rest as tightly as possible to the target API and focus on being fast and bug free. In my career so far, the only code I have ever ported for business reasons ($$) has been mathmatical algorithm related.

    YMMV.

    --
    ..don't panic
    1. Re:Small and efficient beats portable by MimsyBoro · · Score: 1

      I don't have any comments -- so I'll strengthen the parent with a comment.

      He is completely correct.
      It is very hard to seperate GUI and Functionality correctly but if you are willing to give it a few tries (and YES it's a few tries every time you try to seperate) -- then you can have 'portable' C++ program.

      All the logic should compile easily on any platform that supports normal C++ (not including embedded, but that's never really portable) and the GUI should be tightly wrapped around an API (no MFC, straight resources QT and GTK are OK) so that if you want you can just replace those *small* classes and walla!

      It helps to start with a command-line type program and then proceed to "Gui-ize" it.

      --
      God made the natural numbers; all else is the work of man - Kronecker
  32. Scripting by Anonymous Coward · · Score: 1, Informative

    When I made the decision to move to Linux, I started looking around for a cross-platform language. I was thinking about Java but there was an article on Slashdot about a Sun programmer who thought Java was not a good fit with their environment. One of the languages he suggested was Python. It has worked well for me.

    It may take a performance hit because it is interpreted but for the stuff I write that isn't usually a problem. It is relatively easy to distribute applications. I just burn a CD with python and the application. I write in a Linux environment and distribute to a Windows environment. I'm glad I chose Python because I get a lot more work done that if I were coding in Java.

  33. Genius... lets re-invent Java... by MosesJones · · Score: 2, Insightful


    I write portable code, I'm writing on Windows, deploying to an AMD Solaris box and the target is SPARC. I've also done this same "magic" trick on AS/400 and OS/360...

    Now me I just use the tool designed for the job of being platform portable, rather than trying to invent new standard headers (STL anyone?) that address a fraction of the problem.

    Want to do sound on multiple platforms? Graphics? Business Process? Then use Java, its what it was designed to do. And to all those muppets who shout "its not possible"... the deploy has just finished and within 30 seconds its running on two different platforms.

    --
    An Eye for an Eye will make the whole world blind - Gandhi
    1. Re:Genius... lets re-invent Java... by Anonymous Coward · · Score: 0

      Can you comment on the applicability of Java to intensive graphics apps that need strong printing options?

      I'm moving from online/web development to a GUI project that requires heavy use of both of those. I'm starting over, in a way, but I'm just tired of coding enterprise e-commerce apps.

      I figured OS X and CoreFoundation was the way to go, but I considered Java, too. I'm not sure I'm as convinced that it's the way to go for consumer-level GUI app deployments.

    2. Re:Genius... lets re-invent Java... by bani · · Score: 0, Redundant

      it's a pity java is so slow though, at least the gui apps are.

      the "flagship" examples of "successful gui java apps" like azureus and eclipse are monstrously slow and bloated, and complaints about them are common.

      all the third party java apps our business partner uses and all the ones they've developed from scratch are slow too.

      java might be nice for portability and even server backend stuff, but java still has a long, long ways to go on gui performance.

      there are also enough issues with major JVM incompatibilities across platforms that the current joke for java is "write once, run nowhere".

    3. Re:Genius... lets re-invent Java... by CaseyB · · Score: 1

      Indeed. It's telling that in order for a GUI Java app to be regarded as useful, it has to be as insanely great as those two are. Anything less, and you haven't made the painful tradeoff of going to the platform worthwhile.

    4. Re:Genius... lets re-invent Java... by ydrol · · Score: 1
      Check out JDiskReport as an example of what a good developer can do with Java. Very useful program. Even our IT Support guy loves it..

      I have a suspicion that some apps are slow simply because they are coded by 'GUI' oriented coders who dont prioritize writing efficient code (ie minimising object creation etc) as its often harder to maintain because its not the immediate solution that comes to mind?

      When my firm wanted a program to index some database tables but needed to run on different platforms and against different databases I wrote it in Java using JDBC. They were all worried it would be slow, but it blazes along and is completely Database bound in execution time.

    5. Re:Genius... lets re-invent Java... by bani · · Score: 1

      backend stuff doesnt have the interactive response issues that you have with a gui. you could use a language 10,000x slower than C and still be completely database bound in execution time, and still have little to no measurable difference in overall execution time between C, perl, php, java, or anything else.

  34. Re:C++ is cross-platform, dont know what your smok by Rei · · Score: 3, Informative

    C++ also has some very nicely organized ways you can write portable code. For example, data serialization - if I care about a piece of code being portable, all of my "structures" that may need to be shared are classes with the functions "serialize" and "deserialize", and all of the member variables/structures are classes with such functions (down to the most simple members, which are just wrappers around basic types; you can even wrap vectors and maps so that arrays of any kind are dealt with automatically). Each class's serialize function simply calls the serialize function on all of its members that need to be preserved; only the most basic types actually do any IO themselves.

    The net effect is that no matter how you change your code, or even if you template it over a range of types, everything always gets written out and read back in properly without having to resort to constantly changing special case read/write functions or having to know what is in every structure and how to write it. It keeps it very simple indeed. You could have a structure nested twenty levels deep containing arrays (vectors) and associative arrays (maps), and go in and change a dozen datatypes at different levels, and not have to modify a single piece of reading/writing code.

    --
    He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
  35. Java by trollable · · Score: 1

    Most of the code portability issues are solved in Java. By using Java, your code will run 90% of the boxes. Of course, Java is not perfect. And even if the portability is good, it is not perfect: there was some minor bugs when our sowftare was runned on OSX. However, it was extremely easy to fix it. Also Java is some way limited so doesn't fit the bill for some applications. OTOH, Classpath.org is going well and there is plenty of good free JVMs. Almost for any box. If you take the limitations in consideration, you can write code that will run on 99% of the boxes. You could do the same in C but it would be painful and much more limited (no GUI, no DB, ...). Also, most issues with L10N and I18N are already solved with Java.

  36. A few, simple rules by jandersen · · Score: 1, Informative

    1. If writing for both UNIX and Windows - and/or possibly other systems, do the development on UNIX. The reason for this is simply that if you develop on Windows, you will all the time be pushed towards using non-portable features; the development toys, I mean tools, are made that way. Also, the portable parts of the C libs were made on UNIX with that system in mind.

    2. Stick to POSIX. The POSIX standard convers almost all the functionality needed for the internals of any application.

    3. Separate the GUI from the business end of the application. Use IPC to communicate between the parts.

    4. Avoid threads. Threads are the source of some of the hardest errors to debug; plus threads are NOT the same kind of fish on all platform, even when they are called 'POSIC threads'.

    1. Re:A few, simple rules by LaughingCoder · · Score: 1

      Funny, I did the opposite. I was developing for an embedded Linux device and it frustrated me to have to return to the 80's for my development environment. So, I wrote a hardware abstraction layer and wrote a simple simulator for Windows. Then I used Visual Studio for all my development, debugging, etc. This worked very well and dramatically accelerated my productivity. Of course I didn't have a gui (just a simple "tui") to deal with, but the application did use multimedia and internet communications - my abstraction layer wrapped these two interfaces.

      --
      The more you regulate a company, the worse its products become.
  37. but'cept by Anonymous Coward · · Score: 0

    but'cept that
    1) It runs too slow to compete with a C/C++/Objective C application.
    2) It looks different on different systems.
    3) It takes forever to start up.
    4) The GUI feels icky and looks creepy and is slow and non-native.
    5) Sun holds Java hostage

    1. Re:but'cept by under_score · · Score: 5, Interesting
      but'cept that
      1) It runs too slow to compete with a C/C++/Objective C application.
      2) It looks different on different systems.
      3) It takes forever to start up.
      4) The GUI feels icky and looks creepy and is slow and non-native.
      5) Sun holds Java hostage
      1) Performance is now basically the same as C/C++/Objective-C apps.
      2) Only if it is programmed that way... a developer can force a specific Look and Feel.
      3) If by forever you mean 4) Again, only if it is programmed that way.
      5) From a purist perspective, I'll grant you this one. But from a practical perspective, it's just not a big deal. Lots of JVM's out there, source code is available (although it's not Free).
    2. Re:but'cept by Anonymous Coward · · Score: 1, Informative

      1) Performance is now basically the same as C/C++/Objective-C apps.

      No its not, peruse a few of the benchmarks here http://shootout.alioth.debian.org/

    3. Re:but'cept by Anonymous Coward · · Score: 0


      Performance is now basically the same as C/C++/Objective-C apps


      wtf?

      you don't beleive this, do you?

      do you have a reference for this? or this this some java myth?

    4. Re:but'cept by Anonymous Coward · · Score: 0

      You obviously forgot to read the part of that shootout where they say:

      "Compare programming language performance on a few dozen flawed benchmarks"

      FLAWED. Jeez. AFAIK Java gets close enough as to make no difference to C/C++ speeds when you factor in "real" conditions and requirements beyond number crunching over the course of two seconds.

    5. Re:but'cept by bani · · Score: 1

      4) the "flagship" applications so frequently touted as "proof of java success": eclipse and azureus. they are so bloated and slow that most people run away screaming. why people tout these as examples is beyond me.
      5) is what is driving a lot of people to C#. that and the fact that C# took a more pragmatic approach to language problems, while java takes an idealistic one in the name of intellectual and academic purity. a lot of us wish the steering group would come down from their ivory tower and see whats going on at ground level.

    6. Re:but'cept by tfinniga · · Score: 1

      1) Performance is now basically the same as C/C++/Objective-C apps.

      I'm sure I'm not the only one who takes issue with this. Performance may be comparable if you're otherwise IO bound - for example, Azureus is a great bittorrent client, written in java. But I do image processing, 3d graphics, simluations, machine learning, and other CPU intensive operations. Java is not fast enough.

      So, maybe you should say that Java performance is great, as long as the operation isn't CPU bound.

      --
      Powered by Web3.5 RC 2
    7. Re:but'cept by ObsessiveMathsFreak · · Score: 1

      1) Performance is now basically the same as C/C++/Objective-C apps.

      I guess that's why the majority of bleeding edge games, telephone server software and mainstream applications are written in Java nowadays.

      Oh Wait.

      --
      May the Maths Be with you!
    8. Re:but'cept by petermgreen · · Score: 1

      whilst forever is obviously an exaggeration, small java apps take noticable time to start, small native apps (at least on windows) don't.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  38. Pipe Dream by loose_cannon_gamer · · Score: 1
    I think portable code is awesome. I also think as long as the world has commercial operating systems, those operating systems will do their best to differentiate from each other (otherwise, noncommercial operating systems will win). Therefore, as programmers become arbitrarily good at writing portable code, I'm afraid that commercial O/Ses will do their best to make sure that they break common portability (through extensions, unsupported standards, there are plenty of examples).

    As one example, consider Windows Vista and DirectX vs. OpenGL. Windows essentially is saying that if you want hardware accelerated video, it's going to be DirectX only (on Windows) through a complete 'nerfing' of OpenGL support.

    --
    In Soviet Russia, us are belong to all your base.
    1. Re:Pipe Dream by Anonymous Coward · · Score: 0

      As one example, consider Windows Vista and DirectX vs. OpenGL. Windows essentially is saying that if you want hardware accelerated video, it's going to be DirectX only (on Windows) through a complete 'nerfing' of OpenGL support.

      That's entirely not true. Yes, Microsoft is implementing OpenGL as a wrapper around DirectX in Windows Vista. What everybody fails to recognize is that you NEVER EVER USE THE REFERENCE WINDOWS DRIVERS.

      Manufacturers like ATI and nVidia alreadyship their own OpenGL drivers. Seriously, do you really use the VGA drivers in windows now?

  39. I got a better one ! by Anonymous Coward · · Score: 0

    An oldies but still goodies ;-)

    http://tinyurl.com/9umok

    Duke rulez :P

  40. instructive by sammy+baby · · Score: 1, Informative

    "Flipping the bird" is a colloquialism for making this gesture.

  41. Something I know about... by pieterh · · Score: 3, Insightful

    My team's been writing 100% portable C code since 1991 or so. We took the same approach that Apache has done since version 2, i.e. build a distinct portability library and remove all non-portable code from the application itself.

    It's amazing anyone would actually write non-portable code except through ignorance. As a programmer, I still run code written in 1991-2 (though it's been marginalised by newer work), and we have made some quite complex products (web servers, code generators) that run on anything that has standard C libraries and BSD-style TCP/IP, including OS/2, OpenVMS, and of course all Unix and Windows boxes.

    The alternative option is to use a VM. Since we write fast system software that's not an option.

    A wise person taught me this over 20 years ago: life is too short to throw out code just because some platform changed. Portability is one of those skills that lets a normal programmer like me accumulate enough quality code over time to become a master programmer.

    1. Re:Something I know about... by irritating+environme · · Score: 1

      It seems pretty clear you're writing server-only code. Server/command line code is trivial to make portable compared to GUI applications.

      --


      Hey, I'm just your average shit and piss factory.
    2. Re:Something I know about... by pieterh · · Score: 1

      The principle can be extended to GUI applications, this is what tools like Qt are for. But yes, server-side code has a more focussed set of needs - sockets, process control, threading, mutexes, database access, etc.

      For GUI code, a VM obviously makes sense since performance is not usually the key thing. By "performance" I don't mean doing a fast screen refresh, I mean getting 10k-100k messages per second through a server.

      The arguments for/against writing portable code are very old, and come down to people who say, "it's too slow, it can't do such-and-such, it's too complex," on the one hand, and people who do it, and profit, on the other. Basically *anywhere* you can make your code more portable, you will win. The longest-lived applications are the most portable ones.

      Interestingly, the main argument against VMs is that when the vendor or development team changes the VM, you're screwed. With a portability layer you don't care.

    3. Re:Something I know about... by Lord+Bitman · · Score: 1

      Until something comes along that you never expected to be "non-portable code". Everything would be portable to everywhere already if we all had infinite forsight.

      --
      -- 'The' Lord and Master Bitman On High, Master Of All
    4. Re:Something I know about... by Just+Some+Guy · · Score: 1
      My team's been writing 100% portable C code since 1991 or so.

      Do you have a link to the Amiga port?

      Consider this a friendly reminder that all the world is not Unix and Windows. The remainder might be tiny, but "100% portable" is a pretty ambitious statement.

      --
      Dewey, what part of this looks like authorities should be involved?
    5. Re:Something I know about... by jonadab · · Score: 1

      > Do you have a link to the Amiga port?

      Amiga? Bah! I want to run it on a Texas Instruments calculator, a BBC micro, or Nintendo Gameboy. Writing C code won't get you anywhere here; you need a language with *real* portability.

      --
      Cut that out, or I will ship you to Norilsk in a box.
    6. Re:Something I know about... by Anonymous Coward · · Score: 0

      dude, if you think you're a master programmer, you're not.

      do you think, e.g., linus thinks of himself as a "master programmer"?

  42. Windows Portability by Mignon · · Score: 1

    I write code for a Windows app for a living and feel the need to point out that even just limited to Windows, our code has to be aware of the different Windows versions. The 9x family in particular comes up short compared to NT/2K/XP, not fully supporting many GDI calls (which is what my code mainly uses.)

    1. Re:Windows Portability by jonadab · · Score: 1

      > I write code for a Windows app for a living and feel
      > the need to point out that even just limited to
      > Windows, our code has to be aware of the different
      > Windows versions.

      Yeah, and how do you know your code will run on the next version of Windows, and the version after that? Do you know what's going to change? How can you?

      You can work around the differences in known versions, but if your code is unportable, the next change could break it.

      Write *portable* code, get it running on at least four really distinct platforms (Windows, Mac, VMS, and Linux would be a good start -- and I'm talking about getting the *same* code running on all the platforms, not four different branches of #IFDEF), and then in 2012 when Windows Conversation comes out, or whatever oddball name they give the next one after Vista, you'll be ready.

      There will, of course, be a few small bits of code that have to be written differently for each platform; these you put in separate, platform-specific files, and you keep them as short as possible, and then when you have to port to the next Windows -- or whatever you port to -- those are hopefully the only parts you have to rewrite.

      --
      Cut that out, or I will ship you to Norilsk in a box.
  43. Save $11.88! by Anonymous Coward · · Score: 0

    Save yourself $11.88 by buying the book here: Write Portable Code: An Introduction to Developing Software for Multiple Platforms. And if you use the "secret" A9.com discount, you can save an extra 1.57%!

  44. I've got just one thing to say: by ovit · · Score: 3, Informative


    Apache Portable Runtime.

            td

  45. wxWindows and Objective-C++ by Anonymous Coward · · Score: 0

    If it's GUI you're after, you can use the wxWindows libraries (http://www.wxwindows.org./ GUI for: Windows, WindowsCE, GTK, Motif, Carbon, and Cocoa. It also supports C++, Java, python, and perl.

    If wxWindows is not your style for the Mac, just use C++. Objective-C and C++ can be merged in a single binary (AKA Objective-C++). Write all your heavy lifting in C++. Write all your views (model-view-controller, anyone?) in Cocoa.

  46. All my code is portable... by slapout · · Score: 1, Redundant

    ....I just burn it to a CD and take it with me anywhere! :-)

    --
    Coder's Stone: The programming language quick ref for iPad
  47. Don't write portable code by ajs · · Score: 4, Insightful

    That's right, you heard me. Don't write portable code.

    Use portable libraries and languages; re-factor your working code to be portable; make high-level choices that support portability (e.g. don't lock yourself in to proprietary solutions), but don't write portable code.

    Why? Because premature portability, like premature optimization is a red herring that steals your attention from the only two things that will ever matter: correctness and maintainability. Write correct code. Write verifiably correct code. Write maintainable code. Do these things and you are done. Then, port it to another platform or ten and optimize the hell out of it. Don't do these things up-front, as they buy you nothing on the first pass, and doing them later will give you the chance to re-consider the structure of your system which you should do at least twice before your first release anyway.

    That said, do not snub portability unduely. If you have the choice of trivially supporting or not supporting portability-enhacing features (e.g. in your choice of a configure/build system), there's no reason not to be portable. Just don't let it set priorities for your project from day one.

    1. Re:Don't write portable code by dslauson · · Score: 2, Insightful

      Yeah, um, that only makes sense in certain contexts

      For example, I work for a company writing embedded software for medical equipment. For testing and QA purposes, we have to target two different architectures: VxWorks for the embedded stuff, and Windows for simulation. From the start, portability has to be a consideration, because code that doesn't port to these two platforms is completely worthless to us, and will have to be rewritten.

      I get your point, and that makes sense when writing desktop apps and plenty of other stuff, but doesn't apply to every situation.

    2. Re:Don't write portable code by Just+Some+Guy · · Score: 1
      Use portable libraries and languages; re-factor your working code to be portable; make high-level choices that support portability (e.g. don't lock yourself in to proprietary solutions), but don't write portable code.

      I agree completely, as long as you're targetting a platform that's completely static and not, say, in the process of switching from 32 to 64 bits. If you're not coding for PowerPC or x86, then go ahead and write all the non-portable code you want. It probably won't bite you in the butt when your IT department shows you the new production server you're expected to start running on next week that's not opcode-compatible with your development system.

      --
      Dewey, what part of this looks like authorities should be involved?
    3. Re:Don't write portable code by ajs · · Score: 1

      Sure. The only universal rule is that every rule has exceptions. Of course, if you are targetting very specific, highly constrained environments, you program with them in mind. The point is that you don't do the first pass with 10 other platforms in mind, but you DO set aside time for that work in a second pass, once your code is working correctly and maintainable.

    4. Re:Don't write portable code by ajs · · Score: 1

      "It probably won't bite you in the butt when your IT department shows you the new production server you're expected to start running on next week that's not opcode-compatible with your development system."

      Been there, done that. It's a major pain, but consider the trade-offs. You can be prepared for that eventuallity ahead of time, or you can narrow your focus on correctness and maintainability. Every bit of developer attenetion that you can focus on those two things buys you a little bit less pain when curve-balls are sent your way. Do it right, and it's not such a big deal that someone asked you to port to funky platform Z because your code is solid, and easily re-enginered.

      Of course, you don't go long without worrying about portability. It should be one of the earliest, and best reasons to re-engineer your code, but it should be a re-engineering, not an effort you undertake as you initially design and build.

    5. Re:Don't write portable code by Anonymous Coward · · Score: 0

      Asinine. You and Just Some Dumb Guy must be from the same womb. All you said was don't do things prematurely. Congratulations. +100 Stupifyingly Obvious. If you know something's going to take a while to run, and it needs to be as fast as possible, you optimize, else you wait and see. If you know something will need to be or probably need to be ported to another platform, you make sure you write as portably as possible, else you don't worry so much about it. Genius!

    6. Re:Don't write portable code by Anonymous Coward · · Score: 0

      I've found that writing portable code *from the front* tends to make it much easier to prove correct. Yes, you have to set up and run tests on all platforms you're directly supporting -- that's more work.

      However, if I can run exactly the same code on different OS and architecture pairs[1], and get exactly the same results, I find that the chances that my code is correct is *much* higher than if I only wrote for a single platform

      [1] in my case, Linux on AMD (G++), Windows on Intel (VC++), and Tru64 on Digital/Compaq/HP/whatever-the-hell-they-are-now (forget which C++).

      I had three different OS, three different compilers, and two greatly different architectures. I had identical output across all three systems. I may have had a *logic* problem, but I was damned confident that the code was sound.

      Keith

    7. Re:Don't write portable code by Anonymous Coward · · Score: 0

      You heard me: write portable code, when your code is compiled in multiple platforms.

      If you are a Windows programmer: DON'T write portable code, YOU won't gain anything from it. I think that's what the "insightful" poster meant.

    8. Re:Don't write portable code by tgv · · Score: 1

      Ok, you've had your say, now take a tranquilizer and sit down.

      Some portability issues are too important to leave for the last moment. Some could require you to rewrite your application.

      E.g., there's nothing wrong with sizeof() in C/C++, but it isn't 100% portable (think file i/o). These are some other stupid issues with compilers that can really drive you crazy (try the HP C++ compilers; they're quite different from GNU, and linking g++ code against HP object files is not possible).

      And then there are library differences. E.g., deleting an ifstream object doesn't close the file handle anymore. It used to at some platform. So if you're relying on that kind of thing, porting your system will become anything between a pain in the ass or a nightmare.

      GUIs are another example. If you rely just a little bit too much on the functionality of your initial develop environment, breaking functionality away from the interface to the library can be horrible. Think #ifdef spaghetti here. Making a cautious design decision beforehand could have saved the day.

      I agree you should design your code properly first, but keep in mind that some coding decisions you can silently make, can have horrible consequences for portability.

    9. Re:Don't write portable code by RAMMS+EIN · · Score: 1

      Err, I think your message is sort of vague. ;-) You say "don't write portable code", and then proceed to list a lot of things that make your code portable. What?

      What I distil from it is that you consider portability not to be the most important aspect, and something that can be added later. I agree with the first part. Nobody is waiting for code that runs on every platform but doesn't do what it's supposed to do, or that is so full of kludges that nobody understands why it does what it does. However, I don't agree that portability is something tou can focus on later. There are a lot of simple things that you can do while writing your code that will make portability easier.

      If you keep in mind that your code should be portable right from the start, you're probably more likely to use APIs that are generally available, rather than just happen to exist on your platform. I've seen a lot of code that was considered portable, because it worked on both Linux and Windows, but the Linux code was so full of GNUisms that it was a monumental task to get it working on OpenBSD. Had the developers considered up front that the code was to run on OpenBSD, they could have used POSIX equivalents to the GNUisms, and they would have supported a whole host of systems with a single codebase.

      During my own development projects, I found that it's also important to test on other sytems while you develop. This helps you catch problems quicker, giving you a better indication of where they occur. For example, I initially developped muhttpd on OS X, and then moved to Linux. When the feature set was complete, I tested it on FreeBSD, and was pleased to see that it compiled, but not so pleased that all pages it served contained just a few garbage characters. It took me a long time to find where things were going wrong, probably much longer than it would have if I had regularly tested the code on FreeBSD.

      --
      Please correct me if I got my facts wrong.
    10. Re:Don't write portable code by GWBasic · · Score: 1
      That's right, you heard me. Don't write portable code.

      I agree with what you're trying to say, but instead may I suggest a different statement:

      Identify the platforms that your application will have to run on and code to those platforms.

      If you are writing an application that will have to run on a Windows desktop and a Windows CE device, there is no point in employing techniques that would allow the application to run on Linux. Some times portability means having to handle varying hardware configurations for the same operating system.

      For example, two projects that I have been involved with were for a specific use by a small number of people, and will never be ported from the operating system that we developed for.

    11. Re:Don't write portable code by ajs · · Score: 1

      "Identify the platforms that your application will have to run on and code to those platforms."

      Nope, that's not what I meant.

      I meant that you should put portability aside from the time your fingers hit the keys to the time that you have a working first version. Of course, if you're just gleefully hacking away without any thought of correctness and maintainability, then ignore this advice as it won't help you. If you are attempting to focus on the above items, however, you should not be thinking about portability or optimization. Those can be taken care of later, and the engineering that it will take to make your application portable and optimize it will benefit a well-structured, maintainable program more than it would have benefitted your first version anyway.

      To all of the posters who said that making your code portable shook out bugs: you're correct. I've certainly discovered my share of bugs in my own and other people's code by porting (or just making the code portable, which doesn't mean you port it). Consider, however: how much more benefit do you get by isolating the portability work, doing it with a working system, and focusing on it and following up on everything that falls out of that work because it IS your focus at that stage?

      This is not a matter of suggesting that portability isn't important. If anything, I'm suggesting that it's MORE important than most people give it credit for. You just don't want to be in the position of worrying about portability in with the paramount priorities of working code and maintainability.

    12. Re:Don't write portable code by GWBasic · · Score: 1

      Perhaps you misunderstood me. For example, if you know that your application has to run on both Windows and Mac, it would be a bad idea to "ignore portability" by developing in Hypercard. (I'm assuming that Hypercard doesn't have much Windows support, but you can correct me if I'm wrong.)

    13. Re:Don't write portable code by ajs · · Score: 1

      And perhaps you missed the part in my original post where I drew a clear line between choosing portable systems, languages and libraries from writing portable code.

      Writing portable code is difficult, time-consuming and very important. It is, in fact, so important that you should do it only when you have a complete, working, maintainable system and can thing in the large about the ramifications of portability for your entire system.

    14. Re:Don't write portable code by GWBasic · · Score: 1

      We're in complete agreement. When I had to write a portability layer in an application, it was a tedious pain in the ass!

  48. Re:Small book by dslauson · · Score: 1
    Isn't an OS just a kind of runtime environment? After all, it's just one level of abstraction among many levels of abstraction. A Java Virtual Machine is just one more level of abstraction."


    Sort of...

    But, if you write C++ for Windows or Linux or whatever, the OS can hand the machine code directly to the processor.

    If you write C# or Java, there is a middle man in there. The OS has to load this whole runtime environment, which takes up a big memory footprint and system resources, and then interprets your code, and then based on that tells the processor what to do.

    So, every level of abstraction you add in there becomes more and more costly in terms of system resources. Yeah, desktop systems are getting beefier, but what about compiling code for embedded systems and stuff like that? Sometimes efficiency is a big consideration.
  49. Human Language Portability... by adavies42 · · Score: 1

    ...obviously needs improvement, or the reviewer wouldn't be such a horrible writer. What the hell was samzenpus smoking to let this tripe make the front page?

    --
    Media that can be recorded and distributed can be recorded and distributed.
    -kfg
    1. Re:Human Language Portability... by CaptainPinko · · Score: 1

      I think the language portability is fine. In English it's a little rough around the edges buttry rereading the article as Swahili: much better then. Overall I give it 4/5.

      --
      Your CPU is not doing anything else, at least do something.
  50. Re:Good. This needs to be taught. by secureboot · · Score: 1
    This was my experience, nearly exactly. I had no clue what all that #define business was for, I just ignored it, didn't include it in my stuff, and moved on.

    It'd be nice if I could say that years later, I understood what it was all for, and now I use it all the time, but I can't. I still have no clue. I just write in python, but I sure wish someone had explained it to me (or that I had looked for myself). It'd be nice if at least one class of one course had discussed this and potential issues that may arise.

  51. Re:Small book by finite_automaton · · Score: 2, Insightful
    Java doesn't run everywhere: For instance, there is no Java JVM for a Palm

    Hmmmm, IBM and PalmSource might disagree with you there.

    But you're correct in general. Not every platform you'll want to port code to will have a JVM. And those that do will not have the right JVM

  52. Use groovy for scripting by irritating+environme · · Score: 1

    It's a little immature, but groovy will provide you java cross-scripting with more script-like capabilities and syntactic sugar.

    --


    Hey, I'm just your average shit and piss factory.
    1. Re:Use groovy for scripting by under_score · · Score: 1

      Thanks! I just took a quick look and it seems pretty "groovy" :-) I love closures since I did a bunch of work with functional programming languages like Miranda in school.

    2. Re:Use groovy for scripting by LDoggg_ · · Score: 1

      I've been using Beanshell for a while and it works pretty well. I like that it allows to write scripts in java syntax.
      My only gripe is that there isn't a safe way to kill a script that is running in a seperate thread. Groovy any better in that respect?

      BTW, here's a little app I wrote using swing & beanshell.

      --

      "If they have both, tell them we use Linux. And if they have that, tell them the computers are down." -Dave Chapelle
  53. Re:C++ is cross-platform, dont know what your smok by Anonymous Coward · · Score: 0

    How do you manage the makefiles for both gnu make and nmake.exe? I've tried writing makefiles that would run under both, but the intersection of the two programs' compatible features is almost empty. Do you just write separate makefiles for each one?

  54. Portable? by Heembo · · Score: 1

    Oh comon - you want portable code, just work with Java and you are good to go! *duck*

    --
    Horns are really just a broken halo.
  55. Re:Good. This needs to be taught. by slapout · · Score: 1

    Enjoy reading the windows.h did yea? :-)

    --
    Coder's Stone: The programming language quick ref for iPad
  56. Re:C++ is cross-platform, dont know what your smok by everphilski · · Score: 1

    In all honesty I'm not the one who manages those... but basically the makefiles are broken into parts and it looks for the section appropriate for the operating system, exports the appropriate compiler / linker options, and your good to go.

    -everphilski-

  57. Re:This book is OK and all by Anonymous Coward · · Score: 0

    Portable my ass.

    I have an application compiled for Windows 2.0 that still runs on Windows XP 64.

    Wake me up when Linux does not fuck-up ABIs and annoy professionals with every new sub-sub-subversion of their ridiculously bloated macrokernel.


    Despite the crudity of the parent poster's statements, he is essentially correct. Linux/GCC have regularlly changed the ABI for seemingly no reason at all. All that says to us programmers is that either the coders are changing the ABI as a feel good session (See? It looks puuuurrdy!) or they didn't take the time to get it right the first five times.

  58. Python... by FuzzyDaddy · · Score: 1
    Yes, I know this book is about writing portable C/C++ code.

    I have to switch between Linux and Windows (Linux has the AVR tools, Windows supports the drivers for our Vector Network Analyzer). I've written most of my (non-avr) code in Python. I've been able to move my testing code and GUI interface code effortlessly between the two environments.

    And yes, python has been released for PalmOS. So there.

    --
    It's not wasting time, I'm educating myself.
  59. I write code on pacman hardware by tazan · · Score: 1

    Then run it in mame. It runs on more systems than I've even seen. It'll even run on digital camera's.

    1. Re:I write code on pacman hardware by Just+Some+Guy · · Score: 1
      It'll even run on digital camera's.

      May we assume that it's not a grammar checker?

      --
      Dewey, what part of this looks like authorities should be involved?
  60. think by Anonymous Coward · · Score: 0

    I said "think", not "rationalize". Ad-homiem attacks aren't going to prove any point you're trying to make.

  61. Re:C++ is cross-platform, dont know what your smok by Erioll · · Score: 1

    While your solution works, I'll admit that the whole serialization thing is one of the nicer things about Java. Obviously there are other pitfalls with the language, but serialization is one of the things done "well" in most cases. I only wish there was something like that for C++, or the standard libraries at the least, with perhaps a class you could extend with your own class wherein you serialize your own primitives, or something.

    I dunno, rambling. But Serialization is a real PITA sometimes.

  62. Re:Small book by AKAImBatman · · Score: 2, Insightful

    For instance, there is no Java JVM for a Palm.

    There isn't? What will I do?

    Dude. Java is everywhere. It's in tiny little cards and in the latest ARM processors. You can't run. You can't hide. Java will find your OS, and you will be assimilated. Submit to the collective!

  63. Bah! by RealProgrammer · · Score: 2, Funny

    Write on the bare silicon, with a microscope and an electron beam.

    Compilers are for feebs who can't read schmatics!

    Portability is for indecisive cowards!

    +-------+
    | Sorry |
    +-------+
    --
    sigs, as if you care.
  64. OH MY GOD by Anonymous Coward · · Score: 0

    "alot" is not a word. Learn English before posting.

    1. Re:OH MY GOD by Anonymous Coward · · Score: 0

      You should learn English too. Alot is a word - it roughly means the same as "allocate". It just isn't the _right_ word.

    2. Re:OH MY GOD by Anonymous Coward · · Score: 0
      Uh... no, "allot" means to allocate. "alot" is the ticker symbol for Astro-Med, Inc. (Nasdaq).

  65. Re:Small book by Daniel_Staal · · Score: 1

    Now, why hadn't I seen that before? Thanks.

    Not that my device is listed as supported though... ;)

    --
    'Sensible' is a curse word.
  66. Re:Small book by AKAImBatman · · Score: 1

    If you write C# or Java, there is a middle man in there. The OS has to load this whole runtime environment, which takes up a big memory footprint and system resources, and then interprets your code, and then based on that tells the processor what to do.

    That's precisely why the Java Runtime should be the OS. ;-) (I'm only half joking, too. Java is basically an OS platform. Moving it down isn't that big of a step.)

    BTW, Java might be interpreted, or it may be JITted, it may be run in a mix of the two, or it may be outright pre-compiled. Depends on the runtime.

    And I'd just like to say that the mods are a bunch of pricks for modding 955301 down. Remember the modding guidelines? Mod UP, not down. If you don't like it, leave it alone.

  67. My experiments with portability by agslashdot · · Score: 2, Interesting

    I had to take a mandatory graduate level course CS 533 Developing portable software, taught by Dr. Mooney, who was known around school as "that portability guy".

    The class went thru umpteen strategies to write portable code & culminated in a portability project, where you wrote a "Quiz Program" in C, that ran on Solaris, Windows & the Mac with minimum code changes.
    All code changes had to be confided to the stdio.h & other header libraries. I see these days he has added Java to the mix.

    My own experience has been that it has very limited utility in real-life ie. corporate IT. All the jobs I held since I graduated did not require an ounce of thinking portable. They were all about writing proprietary code to be run off the web, and for some 10 years, Java was the only option until C# came along. So I practised portability by default, since that was the nature of my employment in the industry. But I can see how this might be useful for somebody doing systems level programming (assuming there are still such jobs in the IT industry in the US, of course...)

    1. Re:My experiments with portability by Anonymous+Brave+Guy · · Score: 1
      My own experience has been that it has very limited utility in real-life ie. corporate IT. [...] But I can see how this might be useful for somebody doing systems level programming (assuming there are still such jobs in the IT industry in the US, of course...)

      I think perhaps your definition of "real-life" is a little limited. As well as systems applications, you have to consider mathematical and scientific applications (numerous, and often run on diverse platforms), engineering and instrument control applications (ditto), CAD/CAM/CAE (ditto), and various related fields. Not everything is a web app or a database.

      --
      If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  68. And one RISC by apankrat · · Score: 1
    Best combination is one big-endian, one little-endian, and a 64-bit machine.

    And a RISC box for catching SIGBUS issues.

    Stuff like this -
    char * p = malloc(128);
    *(long *)(p+2) = 0;
    --
    3.243F6A8885A308D313
    1. Re:And one RISC by Dr.+Manhattan · · Score: 1
      And a RISC box for catching SIGBUS issues.

      Good point. In practice, I've found that developing on Linux/ia32, Solaris/SPARC, and then something 64-bit works pretty well. If you'll need to port to things like Windows or oddballs like Netware or OpenVMS (floating point isn't the same there!) it makes sense to test occasionally, but if you do the first three you'll be, like I said, about 85% of the way there already.

      --
      PHEM - party like it's 1997-2003!
    2. Re:And one RISC by ckaminski · · Score: 1


      *(long *)(p+2) = 0;
      </quote>

      A piece of software I worked on many years ago used a similar version of the above to crash when it discovered an internal consistency error. No big deal, usually, because every user interface operation was recorded for posterity.

      But it shocked the fsck out of me to know someone was deliberately doing:

      (*(int*)(NULL)) = 1982;

  69. Is it? by Anonymous Coward · · Score: 0
    1. Re:Is it? by elknco1 · · Score: 1

      perfect example of why GP post was a joke...

  70. OS X - Windows & Linux by yerdaddie · · Score: 1

    One interesting method for cross-platform code I've been tinkering with is using GNUStep libraries to cross-compile apps between OS X, Windows, and Linux.

    Seems to work reasonably well as long as you stick with Foundation Kit or Application Kit. However some weirdness is enoucntered when trying to do fancy things like use .LIB libraries on Windows.

  71. Re:Small book by smackjer · · Score: 1

    Writing C++ and having the OS talk directly to the processor is partly to blame for instable systems. Low-level access requires high-level knowledge -- one byte out of place and someone's mechanical lung stops working.

    Operating systems 20 years ago used much less memory than they do today. That doesn't mean that modern OS's aren't as good, just as having a virtual machine isn't necessarily bad. The concept of abstraction layers is a good one, even though they usually have a cost. Like anything else, the cost has to be weighed against other factors (efficiency being one, but also portability, security, time-to-market, and robustness).

    Embedded systems may be an exception in a lot of cases. However, there is embedded Java (J2ME), and resources are relatively cheap (and getting cheaper). It's probably often cheaper to use Java and a bit more hardware than designing against a proprietary system to skimp on the hardware costs. Economies of scale, and all that.

    --

    This is my sig. There are many like it, but this one is mine.
  72. Re:C++ is cross-platform, dont know what your smok by AKAImBatman · · Score: 1

    You forgot reflection. Reflection is the key to the awesome serialization, and is useful for all kinds of cool and interesting stuff. :-)

  73. Abstraction backfires by Anonymous Coward · · Score: 0

    Ever heard of 'Java - write once, debug everywhere' expression ?

    It does not refer to the bugs in JVM (at least to a lesser degree),
    it refers to the fact that JVM abstraction purposefully hides all
    host platform details INCLUDING ITS LIMITS.

    Sure thing it's not that important for running HelloWorld, but it
    is essential if your application pushes system to the limit. Like
    say it happens in real life.

    1. Re:Abstraction backfires by LDoggg_ · · Score: 1

      >>Ever heard of 'Java - write once, debug everywhere' expression ?

      And that's so much worse than: '[some other language], compile everywhere, debug everywhere' ?

      Of course you should test on your target platforms.
      Writing in java makes a lot of things easy, but it doesn't stop people hard coding something like 'new File("C:\winnt\myconfig.conf");'

      I don't how many times I've heard the 'Java - write once, debug everywhere' mantra used as though its some clever zinger that invalidates 12 years of Sun's research and development.
      Its more than a little irritating.

      --

      "If they have both, tell them we use Linux. And if they have that, tell them the computers are down." -Dave Chapelle
    2. Re:Abstraction backfires by Anonymous Coward · · Score: 0

      It's not hardcoded file names that matter. It is things like threading and memory management that become suddenly improtant when stressing the system. With Java these are unknown and highly volatile factors that change from one platform to another. Things like adding a thread to a pool of a hundred (it's a random value) may grind whole system to a halt.

      It's not a big deal with non-Java applications, because this things are factored in into the application. With Java however you are not even supposed to THINK about this stuff and that's what makes it evil. Not being directly exposed to the problems does not mean they don't happen. It just means that it is that much harder to deal with them.

    3. Re:Abstraction backfires by LDoggg_ · · Score: 1

      It's not hardcoded file names that matter. It is things like threading and memory management that become suddenly improtant when stressing the system. With Java these are unknown and highly volatile factors that change from one platform to another. Things like adding a thread to a pool of a hundred (it's a random value) may grind whole system to a halt.

      I seem to find the exact opposite to be true. Its pretty easy to put constraints on the amount of memory allocated to a VM. "Stress the system" as far as you'd like.
      And things like setting up thread thread pools are trivial in java.

      It's not a big deal with non-Java applications, because this things are factored in into the application. With Java however you are not even supposed to THINK about this stuff and that's what makes it evil. Not being directly exposed to the problems does not mean they don't happen. It just means that it is that much harder to deal with them.

      Why wouldn't you think about system and application performance just because something is written in java?

      I've been developing in several different languages for almost 16 years and almost ten in java. I'm really having trouble following your train of thought. Could you give examples?

      --

      "If they have both, tell them we use Linux. And if they have that, tell them the computers are down." -Dave Chapelle
    4. Re:Abstraction backfires by Anonymous Coward · · Score: 0

      Java is about an abstraction, right ? So, you are given VM and told 'here's an
      API'. Since we are talking about portable code here, we are presumably interested
      in writing something once and then running it without any changes on a different
      platform. Say, we wrote it first on Linux and then need to port to OS/400.

      VM developers clearly have two options - to define API either be an intersection
      of Linux and OS/400 system functionality OR to define API wider and emulate part
      of the functionality on the system that does not support it natively. Correct me
      if I'm wrong, but Java goes the second way. Meaning that some things in VM are
      not mapped directly to the OS and therefore there is a layer of some 'stuff' that
      I as a developer need to be aware of when considering scalability and performance
      of my code. And this completely defeats the whole purpose of VM, which is to give
      me a portable API.

      Note that I am talking about fairly rare cases when I do care about performance
      and scalability UNDER THE LOAD, ie when emulating portions of VM are put to a
      real test.

      I've been developing in several different languages for almost 16 years and almost ten in java. I'm really having trouble following your train of thought. Could you give examples?

      17 years for me :-p

    5. Re:Abstraction backfires by LDoggg_ · · Score: 1

      I see your point now, but in practice this isn't the issue you're making it out to be.
      The level of abstraction java provides does tend to lend itself to solving business processes and less to tuning for specific hardware. Its clearly not the right tool for every job. But when productivity and timelines are an issue I generally look to java first.

      17 years for me :-p

      Old timer :)
      How many of those years were in java?

      --

      "If they have both, tell them we use Linux. And if they have that, tell them the computers are down." -Dave Chapelle
  74. lua a "suprise"? by bani · · Score: 1

    lua is usually the first choice for an embedded scripting language, because it's so minimal. it's reasonably powerful and easy to sandbox. it would be very suprising if lua wasn't included.

    1. Re:lua a "suprise"? by The+Masked+Rat+Fink · · Score: 1

      True, but just because Lua is targeted at the embedded scripting niche, doesn't mean that many people know about it or even think to list it. That's the unusual thing about Lua being listed.

      --
      simonpeter.org | simonpeter.com | techbook.info
    2. Re:lua a "suprise"? by bani · · Score: 1

      being suprised that lua is listed, but not being suprised that ecmascript is listed... that is what I find odd.

    3. Re:lua a "suprise"? by baxissimo · · Score: 3, Interesting

      Lua is quite big among game developers, and I suspect that's why it's on Brian Hook's radar screen, Brian having spent a good amount of time in the game dev arena. Why is it popular with game developers? For one, because when they look for portability, they really need portability. Often all the way from dual proc Wintel boxes right down to GBA. This is possible in part because Lua is apparently quite light weight in terms of memory requirements unlike most other scripting languages.

  75. Typo by vocaro · · Score: 1

    according to it's subtitle --> according to its subtitle

  76. MS bashing really necessary here? by Anonymous Coward · · Score: 0

    Much as a certain large software company located in the North-West of the United States of America might wish otherwise

    Can we have one story without flame-bait? Was that comment even necessary for the story? The story is about compact software. The first thing I think of when I think of bloated software is KDE and Gnome. Windows is bloated as well but damn...there was no reason to throw that in there unless you wear blinders and are clueless about the whole picture.

  77. been there done that by linforcer · · Score: 1

    Much as a certain large software company located in the North-West of the United States of America might wish otherwise, there are many different operating systems and platforms in use in the world today. As a matter of that it's been like that since "ancient times" when there were bunches of unixes, and the reason unix didn't prevail was supposedly that people preffered coding for one OS, instead of 12 unix variants. I don't think this has changed. Of course above reasoning was taken from an article to promote the linux standard base, which I'm against anyway :)

  78. Re:C++ is cross-platform, dont know what your smok by renehollan · · Score: 1
    gotta... ...ugh... ...carry... ...all... *pant* ...that... *wheeze* ... run time type information ...around. Whew!

    Though, I will admit that reflection is one of the things I like about C#. Still, the whole idea of using RTTI to defer what should be a compile-time decision to run-time just leaves a bad taste in my mouth.

    --
    You could've hired me.
  79. Some points based only on the review. by QuestorTapes · · Score: 3, Interesting

    Note: I am a C++ programmer. I didn't read the book, just the review here. Apologies in advance if anyone takes offense.

    > The first couple of chapters introduce the reader to portability concepts
    > and then to some of the specific portability features of ANSI C and C++
    > that are used throughout the rest of the book.

    I think enough software is written in languages other than C and C++ that any serious author should put C or C++ in the title when the book is C or C++ specific.

    It's not wrong that the author or publisher chose to call the book "Write Portable Code" instead of "Write Portable Code in ANSI C". But it does make me question if the author's knowledge is limited by a single-language bias.

    > The last two chapters look at some alternative ways of getting portability.
    > Scripting languages are discussed and the pros and cons of each ones
    > portability is weighed. Lastly the use of cross-platform libraries and
    > toolkits is addressed.

    Given that scripting is limited to one chapter, wouldn't it have been better to refer the reader to other works with more detail and value, and only give a paragraph or so? Particularly since the book is not trying to be about portable code in general, but portability in ANSI C, and discusses nothing (AFAIK) about higher-level compiled languages.

    The book's about C. Why clutter it with a chapter on Ruby, Python, and JavaScript/ECMAScript and say nothing about Java, Lisp, SmallTalk, etc? Writing a chapter on scripting languages strikes me as gratuitous filler.

    And any non-trivial cross-platform C application is likely to use some sort of cross-platform toolkit. So why only a chapter?

    > An example: Rule 4 - "Never read or write structures monolithically from or
    > to memory. Always read and write structures one element at a time, so that
    > endian, alignment, and size differences are factored out."

    Writing structures one element at a time is a -minimum- required for portability. It doesn't completely address byte-order issues, variable internal data representations, or data element size issues. It just ensures that structure packing and alignment issues that might change based on compiler flags are covered. But change the compiler or platform and all these issues are still there even if you write the data elements singly. They are all unspecified or incompletely specified in ANSI C.

    It's better to design a complete data representation format, including embedded version information, or just use a higher level data store engine.

    My concern is that many of the other rules in the book might be similarly too "low-level" and incompletely specified. Rather than teaching inherently better, more portable coding techniques, they might just be teaching how to work around the low-level nature of C.

  80. Amiga Anywhere by rubberbando · · Score: 1

    Amiga Anywhere was supposed to create that environment that java wasn't quite able to. You could write a piece of software and have it run on all platforms (PC, Mac, *nix, palm, etc.) but never really went anywhere due to setbacks and poor company management. In the end, I think they just ended up using it to make software for slot machines. :-/

    --
    DEAD DEAD DEAD DELETE ME
  81. Why Java doesn't work by Anonymous Coward · · Score: 3, Insightful

    I know you're kidding, but unfortunately there are a lot of responses here which indicate that Java is the end-all and be-all of portable programming.

    I'm sorry folks. Such people have never done real cross-platform programming. Java simply isn't an option on MANY platforms. If all you do is x86 platforms, and perhaps some Motorola workstation-class platforms, hey, you're fine.

    But that's not the real world.

    The real world includes MIPS, ARM and other processors. What's more, the embedded world makes up most of the usage of CPU's. Java is not an option in most cases, unless you go out and pay one of the few small shops that will port it a bunch of money. And that assumes your system have the footprint and horsepower to run it.

    I see outfits where the programmers have never programmed on a non-x86 system in their life suddenly wake up to this fact. It would be funny if it wasn't so sad.

    Now, granted the GNU folks are coming up with their Open Source version, and it appears to be coming along fine. But it's not quite there yet.

    Also, keep in mind that it won't run on many platforms, simply because of size limitations. All the world isn't your dual-core 3 GHz x86 with 4 GB of RAM.

    And I'm sorry, but the Java claims that it is as fast as C code just aren't true. Don't believe me? Try doing some benchmarks on 100 MHz small-RAM systems. If you're lucky enough to get it to fit, you'll see that things are just dog slow.

    Most programmers and students today are just too used to working with the supercomputer type of CPU's that the modern desktop is like, and aren't used to dealing with small-footprint type of systems which make up most of the world

    1. Re:Why Java doesn't work by AKAImBatman · · Score: 3, Informative

      I'm sorry, but if you can't manage to track down a JVM for your platform, you need your geek card revoked. I mean, hell, there are JVM instructions built into the damn ARM processors! What more do you want, an Angel to come down from the sky and say, "Hey you, over that way!"

    2. Re:Why Java doesn't work by twiddlingbits · · Score: 1

      Yep, JVMs are darn near ubiqitous. You can even get the JVM for DSPs. Now whether or not Java is the RIGHT choice for a very tight embedded system is a different discussion. The GP should have his Geek card suspended.

    3. Re:Why Java doesn't work by AKAImBatman · · Score: 1

      What's amazing is that the Mods keep modding him up.

      MODS: His post is disinformation! I realize that he probably wasn't aware of the various options, but that doesn't make his post informative or insightful!

    4. Re:Why Java doesn't work by smcdow · · Score: 1
      I'm sorry, but if you can't manage to track down a JVM for your platform, you need your geek card revoked.

      Okie dokie, can you help me find a JVM for a PIC 10F200 microcontroller? http://www.microchip.com/stellent/idcplg?IdcServic e=SS_GET_PAGE&nodeId=2061&param=en505736

      --
      In the course of every project, it will become necessary to shoot the scientists and begin production.
    5. Re:Why Java doesn't work by AKAImBatman · · Score: 1

      Now you're just being weird. There are Java VMs that target devices of a similar size (e.g. JavaCard), but why oh why do you need a JVM for an application specific microprocessor?

      Hrumph. Now someone will hear us and go write one. Way to go chief. ;-)

    6. Re:Why Java doesn't work by smcdow · · Score: 1

      Um, a PIC10 maxes out at 512 bytes of program memory, 23 bytes of RAM, and 2 (count 'em) stack levels. I doubt anyone will be writing a JVM for the thing. Nonetheless, this is an example of a processor that is in widespread use.

      --
      In the course of every project, it will become necessary to shoot the scientists and begin production.
    7. Re:Why Java doesn't work by AKAImBatman · · Score: 1

      I doubt anyone will be writing a JVM for the thing. Nonetheless, this is an example of a processor that is in widespread use.

      1) You're twisting my words. I never stated that there was a JVM for every processor. I said there was one for every platform. A PIC is not a platform no matter how many cutesy hacks people make with them. (That PONG game on a PIC was pretty darn cool, though.)

      2) If you really want Java on a PIC, you have to be a little more creative. Write the code in Java (preferable targetting something like JavaCard), then translate the instructions to the native set before the load. This is a pretty common practice, and has been done with a lot of embedded devices. If you do it right, you can even fit most of the Java features, just without the normal class format.

    8. Re:Why Java doesn't work by maxmg · · Score: 1

      So the real question would be: why (and how?) do you propose to write portable, cross-platform code for this processor anyway? In my experience, with devices as limited as this, you're almost always better off writing the code in hand-crafted assembler anyway, which given the size limitations is entirely possible. Heck, you could write the code in binray, if you wanted to. No portability there, I'm afraid...

      --
      I asked for a refund - and got my monkey back.
    9. Re:Why Java doesn't work by CoolVibe · · Score: 1

      One could probably retarget or write some compiler for it. I hear that such a thing can be quite reasonally done with C or Pascal. here you go, "portability".

    10. Re:Why Java doesn't work by Anonymous Coward · · Score: 0

      thank you. I thought i was going to have to tell them ASM is usually your best option. the code is near impossible to understand, however. most languages are. oh, and its "binary"

    11. Re:Why Java doesn't work by commbat · · Score: 1

      Um, a PIC10 maxes out at 512 bytes of program memory, 23 bytes of RAM, and 2 (count 'em) stack levels. I doubt anyone will be writing a JVM for the thing.

      It is, however, possible. Use the resources you have to code a more capable virtual processor using external storage as RAM, maybe designing it with Java bytecode in mind... you might have to code another, higher, level to get the capabilities needed, all at a serious speed penalty though.

      Think Basic Stamps.

      --
      'Intellectual Properties' are uncontrollable in the wild. To base an economy on them is just stupid.
    12. Re:Why Java doesn't work by plumby · · Score: 3, Informative
      I know you're kidding, but unfortunately there are a lot of responses here which indicate that Java is the end-all and be-all of portable programming.

      I'm sorry folks. Such people have never done real cross-platform programming. Java simply isn't an option on MANY platforms. If all you do is x86 platforms, and perhaps some Motorola workstation-class platforms, hey, you're fine.

      But that's not the real world.

      Might not be your real world, but in mine (enterprise-scale apps for a multinational financial company), we have no problem with portable Java (usually developed on Windows, mostly run in test/production on HP-UX, with the occasional Solaris and now Redhat Linux, and even a little running on our IBM mainframes).

      It's true that for some uses, such as certain embedded devices, Java is almost certainly not a sensible (or even possible) option, but in much of the industry it's a perfectly sensible choice for cross-platform development.

    13. Re:Why Java doesn't work by Anonymous Coward · · Score: 0

      Easy. If there isn't a JVM for whatever processor you're talking about, then it doesn't count.

      Java nuts are worse than Wikipedia editors, I swear...

    14. Re:Why Java doesn't work by Hal_Porter · · Score: 2, Informative

      Jazelle runs something like 90% of the Java instructions, true. So a mobile phone for example does run most Java instructions.

      But you still need to support the rest in software. And then you need to get the java libraries, and write the native code that the java libraries end up talking to to touch the screen/filesystem/etc So you still need a JVM, even if most of the instructions run natively. And even if the API is the same, you are still running on a machine with either a tiny screen or none at all, not much CPU power, RAM or disk space and so on. And no hardware floating point, so any FP code will run like molasses. Oh, and the DRAM access is really slow.

      So you end up writing applications from scratch - its not as if something like Eclipse or Azureus or any desktop Java app will run on a mobile phone. And if you're going to do that, you might as well write them in C/C++ which is still quicker than Java, even with the Jazelle instructions.

      E.g. write some integer code. Look at what comes out of a decent ARM C compiler. It's tiny and it fits in the L1 cache. You can hoist all the CRT calls out of the loop to where they aren't time critical. The compiler can do a great job using the ARM instruction set to keep things quick. Now look at the Java equivalent. It's more instructions and because Java is stack based it needs to do much more loads from memory. And it needs to check all the array accesses, usually with calls into library code. So the footprint of the loop when it runs is too big to fit in the L1 cache.

      Plus you need to have flash memory space to store the java libs, native code and so on. If you JIT for performance, you need RAM for the native code and RAM or flash for the java, whereas for C you can run code out of flash. The C code will tend to use smaller libraries too.

      If you don't believe me, here's what John Carmack said

      http://www.armadilloaerospace.com/n.x/johnc/Recent %20Updates
            The biggest problem is that Java is really slow. On a pure cpu / memory /
            display / communications level, most modern cell phones should be
            considerably better gaming platforms than a Game Boy Advanced. With Java,
            on most phones you are left with about the CPU power of an original 4.77
            mhz IBM PC, and lousy control over everything.

      --
      echo -e 'global _start\n _start:\n mov eax, 2\n int 80h\n jmp _start' > a.asm; nasm a.asm -f elf; ld a.o -o a;
    15. Re:Why Java doesn't work by petermgreen · · Score: 1

      find me one that works on pic18 ;)

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
    16. Re:Why Java doesn't work by shutdown+-p+now · · Score: 1
      Might not be your real world, but in mine (enterprise-scale apps for a multinational financial company), we have no problem with portable Java (usually developed on Windows, mostly run in test/production on HP-UX, with the occasional Solaris and now Redhat Linux, and even a little running on our IBM mainframes).
      Let me guess, it's a J2EE web app - right?

      Because that's where it is cross-platform enough, for sure. But not quite so elsewhere. Especially when it comes to rich GUI clients.

    17. Re:Why Java doesn't work by jrumney · · Score: 1

      Which platforms is Java not cross-platform enough to run rich GUI clients on? I'm interested because my company makes a rich GUI client based on Java, and we have yet to find a sensible workstation or PDA platform it does not work on.

    18. Re:Why Java doesn't work by shutdown+-p+now · · Score: 1

      Oh, it runs, of course. But the way it looks and behaves usually makes the end-user want to gouge his eyes out - ugly, non-smoothed fonts, distinct unusual look, lack of familiar features (ever tried to drag'n'drop an icon from a Swing file open dialog on Linux?) etc. And if he copes with that, he'll have to learn to deal with a regular UI stutter. That's if you use Swing, anyway. SWT is definitely better, but nowhere near as portable.

    19. Re:Why Java doesn't work by plumby · · Score: 1

      They are mostly j2ee, and one of them is a web app. There are a whole collection of backend services/batch apps for our internal applications as well though.

      I agree there are places that you wouldn't want to use Java, but not so convinced on GUI clients. If I were writing a 100% Windows GUI, that was never likely to get ported to anything else, I would probably not pick Java (I'd probably go for C#), but if there was any liklihood of it needing to be run elsewhere, I'd definitely consider Java. Apps like Eclipse run fine (at least on my Windows and Linux boxes).

  82. Re:C++ is cross-platform, dont know what your smok by AKAImBatman · · Score: 2

    gotta... ...ugh... ...carry... ...all... *pant* ...that... *wheeze* ... run time type information ...around. Whew!

    And yet, Java programs tend to compile to smaller files than native code, and also take a far shorter period of time. Even on the largest projects, I can compile Java code inside of ten minutes. It can take days to compile a C program of comperable size. And once it's in bytecode, it's only a short hop for the JVM to compile it to native code. Works pretty darn well. :-)

    Still, the whole idea of using RTTI to defer what should be a compile-time decision to run-time just leaves a bad taste in my mouth.

    Not sure what you mean by this. Pretty much all code with direct references are properly checked at compile time. Obviously the run-time has to be a bit smarter when you dynamically load things via reflection, but that's very much a feature, not a bug.

    Besides, you gotta love the ability to build a self-organizing program scheme in 20-30 lines of Java code. Doing the same thing in C++ is a PITA, and would only serve to confuse the heck out of the developer debugging the app and the OS trying to run it. I can just see it now, "Program X has 3,102 DLLs loaded." ;-)

  83. Not for me by bluGill · · Score: 2, Interesting

    Sun makes the Java install process on FreeBSD so complex that I've given up. Therefore any Java program instantly cannot run on my computers. So far I haven't seen any loss either. Java is mostly used for long running server processes (where JVM start up time is irrelevant and the JIT compiler can speed things to just as fast as C++), so I don't need it anyway.

    I find that cross platform C++ is not hard if your code is properly modular. Libraries like QT or wxWidgets take care of most issues these days anyway.

    1. Re:Not for me by trollable · · Score: 1

      Sun makes the Java install process on FreeBSD so complex that I've given up. Therefore any Java program instantly cannot run on my computers.

      Right (and it is a shame). However, once installed, it is reported to run well (I haven't try myself). OTOH, Kaffe is avaliable everywhere. Depending on your program, it can be an option.

      Java is mostly used for long running server processes

      I disagree. There is plenty of client-side apps. And the rumour says 30% of the Java Developpers do client-side stuff. The JIT is fast enough for GUIs. The startup time is still a problem. Partialy solved by JDistro or a native compiler (GCJ, Jet).

  84. Re:C++ is cross-platform, dont know what your smok by jonadab · · Score: 1

    > For example, data serialization - if I care about a piece of
    > code being portable, all of my "structures" that may need to
    > be shared are classes with the functions "serialize" and
    > "deserialize", and all of the member variables/structures are
    > classes with such functions (down to the most simple members,
    > which are just wrappers around basic types; you can even wrap
    > vectors and maps so that arrays of any kind are dealt with
    > automatically). Each class's serialize function simply calls
    > the serialize function on all of its members that need to be
    > preserved; only the most basic types actually do any IO themselves.

    Wow, all that work, and here all along I've just been using Data::Dumper for this sort of thing. (Granted, if you have lexical closures this doesn't preserve their lexical context, but I don't think that would work with your C++ serialization system either.)

    --
    Cut that out, or I will ship you to Norilsk in a box.
  85. Re:C++ is cross-platform, dont know what your smok by renehollan · · Score: 1
    And yet, Java programs tend to compile to smaller files than native code

    Now where did I put that interpreter again? Ah! Here it is! *oof*. Geez, that's getting heavier every year.

    Not sure what you mean by this. Pretty much all code with direct references are properly checked at compile time.

    I refer to the trend I've seen where types are checked at run-time out of laziness instead of using plain old polymorphism.

    Besides, you gotta love the ability to build a self-organizing program scheme in 20-30 lines of Java code. Doing the same thing in C++ is a PITA

    Well, yeah. Anytime you have to shoehorn in your own pseudo-reflection mechanism, it's a pain. But, reflection is one of those things that cane be *so* abused, it isn't funny.

    Then again, I spent a lot of time in the embedded world, where you do as much at compile time as you can to avoid spending the time, code, and memory, to do it at run-time. Footprint matters. (Though, sometimes clever interpretation at runtime can help you trade space for time, and that's handy, but you're still making a trade.)

    --
    You could've hired me.
  86. Re:C++ is cross-platform, dont know what your smok by Pxtl · · Score: 1

    A-freakin'-men. The way that some metaprogramming systems I've seen abuse RTTI by handling all the members by name lookup make me wonder why the even bothered with a dynamic language in the first place. RTTI is basically a substitute for a solid metaprogramming model and a well-thought-out standard library.

  87. Re:C++ is cross-platform, dont know what your smok by AKAImBatman · · Score: 1

    Now where did I put that interpreter again? Ah! Here it is! *oof*. Geez, that's getting heavier every year.

    The interpreter is small. So is the JIT. That's why those are the options usually offered on cell phones and other embedded devices. It's the highly optimized, mixed-mode execution model that gets us such a massive chunk of translation. It is fast, though. ;-)

    I refer to the trend I've seen where types are checked at run-time out of laziness instead of using plain old polymorphism.

    You mean like this: "if(object instanceof MyObject) DoSomthing();"?

    There are a lot of good reasons to do that. However, I do agree that some programmers abuse it. If they'd just create an Interface, they could stop with the "if" statements.

    Then again, I spent a lot of time in the embedded world, where you do as much at compile time as you can to avoid spending the time, code, and memory, to do it at run-time. Footprint matters.

    Ah, different worlds. Java's most popular platform (business logic) requires maintainability and architectural clarity above all else. So plugging code at odd times can make a lot of sense. In the embedded world, stripping your Java code down is one of the first things you do. And I say this as a previous winner of the Java 4K Coding Contest.

  88. Re:Grow up by Anonymous Coward · · Score: 0

    For once, realize that not all of the worlds problems are caused by Microsoft.

    That's true. Microsoft is only responsible for 98% of all problems. The other 2% can be blamed on SCO.

  89. off-topic: MonoDevelop form designer by CrazedWalrus · · Score: 0, Offtopic

    Speaking of cross-platform programming, I've been wanting to write up an application under C#/mono. I compiled mono and MonoDevelop, only to find that MonoDevelop has no integrated form (GUI) designer. The only option, so far as I can tell, is to use the stand-alone Glade designer and import the .xml file into the project through the C# Glade bindings (which doesn't work anyway, due to some API changes, apparently).

    I did some Google-ing, and found some (slightly dated) information stating the MonoDevelop team had no plans of including Glade, opting instead to write their own designer. That's a noble goal and all, but isn't there a way to wrap Glade in the meantime so you can replace it with the custom one when the time comes?

    Out of curiosity, has any progress been made on this front? Even if they had to fork Glade to pound it into MonoDevelop, it would seem to be a reasonably stable and mature starting point.

    I ask because I really don't have time for all of the box_pack_start/show_widget trial and error world of pain I remember from using Gtk+ in C. Any insights? Other recommended IDEs? Should this be an AskSlashdot?

  90. Re:C++ is cross-platform, dont know what your smok by renehollan · · Score: 1
    If they'd just create an Interface, they could stop with the "if" statements.

    Exactly. It's as if they learn RTTI before they learn polymorphism. Though, if one were pedantic, one could argue that the vtable is as indicative of type as anything else.

    In the embedded world, stripping your Java code down is one of the first things you do.

    I dunno. I've never managed to get Java as fast and lean as I'dve liked it to be, and others insist that it can be. And don't get me started on RMI.

    The kind of things I drool over are the Turing-completness of the C++ template mechanism, but that just goes back to wanting to get the compiler to figure out as much as possible for me.

    --
    You could've hired me.
  91. Re:Grow up by Alderin1 · · Score: 2

    I love how Anonymous Cowards like to slander and ridicule Slashdot, fully forgetting the fact that Slashdot is a free community service provided at a cost to those providing it, with little to no recompense. I also love how they attack the entire community for something one person writes in an article. It makes me feel all warm and fuzzy inside watching them make fools of themselves in their ignorance. Keep posting cowards, because THAT's how I make myself "feel bigger".

    "For once, realize that not all of the worlds problems are caused by Microsoft."
    You know, you are right, the rest of them are caused by people who complain about free services.

    --
    No conformist ever made history.
  92. I wanted to say that! by lheal · · Score: 1

    But I couldn't find the right wording.

    Another point I think is important is that porting can help you find bugs. Try compiling your code on some weird compiler and system instead of your favorite. Usuallly (for nontrivial programs) you'll get a different set of warnings, and sometimes you'll luck out and the thing will crash. Then you get to look at your program and find that error, which probably would have come up only after users started to bang on it.

    If you can use #ifdef to avoid a bug, you haven't found it yet.

    --
    Raise your children as if you were teaching them to raise your grandchildren, because you are.
  93. quit whining by Anonymous Coward · · Score: 0

    Java boys just don't get.

    Right now: how many java apps are running on your machine? Zero.
    Your browser/emailclient/shell/imageviewer/sshclient/sp reasheet etc are all
    written in C/C++/or/Objective C?

    Why? Because it runs faster than java ... or perl ... or ruby ... or any other high level language.

    Bottom Line: speed wins, java loses.

    (whaps idiot over the head) Now do you get it?

  94. Developing Portable Code, without buying a book by jd · · Score: 3, Informative
    First, split your code into four distinct modules. These modules need to be "black box" - ie: none of them can know the internals of the others. The first module should contain the internals of your code. The stuff that actually does the hard work, but doesn't try to do any I/O of any kind. It is also the only one you absolutely need to have.

    The second module deals with all the user interface stuff and nothing else. Any event handling is done in this module and nowhere else. That way, the rest of your code doesn't need to worry about what type of execution model is being used. It'll just work as you would expect. If there is no user interface, you don't need this module.

    To make the UI truly portable is hard. No specific capability is guaranteed. eg: GUIs don't guarantee a text console, and text consoles don't guarantee a GUI. My advice would be to split the module into two sub-modules. The first sub-module handles what you want to do, but contains nothing specific on how. For example, it might be filled with commands for selecting fonts, drawing lines, etc. However, it would not contain any calls to an underlying system. It should assume some abstract, theoretical, idealized user interface.

    The second sub-module (which may be a third-party library and not something you need to program at all) would then convert these commands into actual interface calls. If you're writing this yourself, I'd suggest starting with interfaces that are already fairly portable (eg: Qt, Gtk+, Ascii Art Library) where possible. If you can't, then you'll need to write alternative versions for different types of interface. But at least it's all in one place and squished down to the routine level, not entire screens.

    The third sub-module (again, third-party if available) would do the same as above but for file I/O. Again, the upper levels should make no assumptions at all. "Anything is possible in the next half hour", as Gerry Anderson would say. The lower levels then convert the "ideal" into what the system can actually do. Here, there are at least some standards. Use them. But then write special case code for platforms that can do better. Portable need not mean sub-optimal, it merely means sub-optimal (but guaranteed to work) until tuned.

    The fourth would do the same for networking. There is absolutely no reason why an application should know if you're using sockets, MPI message passing, IPv4, IPv6, DECNet or a guy waving two flags. At the application level, data comes in and goes out. The other end should be of no consequence, and the method of getting there should matter even less. High level networking should be abstract connections, using some sort of token to identify which connection is being referred to. There needs to be a middle layer here, to turn the abstract connection into a real networking protocol. The lowest level then handles the network calls required.

    You need the three layers, because you've two levels of abstraction (the network protocol and the network hardware) and therefore you need two levels of reification to turn the abstract into something usable. As network protocols can work over multiple mechanisms, the protocols are resolved first and the mechanisms second.

    Coding styles for ALL abstract components AND the first module should emphasize portability. There should be nothing system-specific there, so you should be able to use the absolutely vanilla ANSI specification of a language (where one exists). For C, if you want to cover ancient or obscure systems as well, you should duplicate all function declarations and external declarations, using a #ifdef to distinguish between ANSI C and K&R. There are probably other languages you need to support multiple variants of, just keep the areas where you need to have compile-time or interpret-time selection kept to a minimum.

    The low-level routines are only going to work on a limited range of systems, no matter what. Therefore, anything valid for that subset is fair

    --
    It's a small world and it smells funny; I'd buy another if it wasn't for the money; Take back what I paid (SoM)
  95. Portable code howto: by Anonymous Coward · · Score: 0

    Write the code using your favorite language.
    Sell your client a Mobile Code Container aka laptop.

  96. I can answer all your questions by p3d0 · · Score: 1

    This book simply contains everything the author knows about writing portable code.

    --
    Patrick Doyle
    I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
  97. Re:Small book by Anonymous Coward · · Score: 0
    "Now, why hadn't I seen that before?"

    Because you're a fucktard, fucktard.

  98. Indeed... by Svartalf · · Score: 3, Insightful

    I think all the proponents of Java kind of missed the point here. Not everything has or even NEEDS the level of horsepower that Java requires- and just adding more muscle isn't always in the chips.

    And even then, saying "Java" will run everywhere, is really a mis-concept. It'll run most everywhere where there is a least common denominator. I can tell you that while it makes it easier for Oddlabs to make Tribal Trouble for three platforms simultaneously, Java doesn't make it cross-platform- you can't take it and run it on say a Solaris box (though I suspect they could MAKE a Solaris iteration of the game easily enough...) or on an embedded machine using Java, say like the Ignite platform.

    Java makes some things "easier" to make cross-platform, but again, it's like anything else- cross-platform is more of a philosophy than a feature set of a language or toolset. And it's definitely NOT the panacea that the proponents in this thread make it out to be- I should know, I do Java development amongst other things. If you can't make a C++ program at least 40% faster than your best Java code, you might want to re-work the C++ code. This is not to say that it's a bad idea or anything; it's just that people keep trying to jam it into problem sets that it's ill suited for.

    --
    I am not merely a "consumer" or a "taxpayer". I am a Citizen of the State of Texas
  99. No serialization, please! by Anonymous Coward · · Score: 0

    Serialization is not a good way to manage persistent data structures, because it ties your data structures to internal details of your program structure (i.e. your class structure). Change your program structure, and suddenly you can't read old data files any more, because your serialize/deserialize methods no longer match up with what data you previously wrote.

    Program structure and (persistent) data structures should be kept carefully separated for this reason.

    In any case, serialization does nothing for code portability.

    1. Re:No serialization, please! by Rei · · Score: 1

      If you use versioning information, you're fine unless things are incompatible between versions (in which case you're in trouble no matter what). Any serialization function in a class that keeps track of versioning information does so transparently to any classes above it, so even if it increases the complexity at that level (which is inherent if you want to deal with old versions that no longer use the same data), the changes still only need to occur in one place (unlike handling changes between versions in a non object-oriented system). I.e., it only makes things simpler than the equivalent system in your standard C-style data writer/reader.

      does nothing for code portability

      It most definitely does help in code portability. Things like float conversion and dealing with byteorder are done by the primatives' wrappers, so the higher level objects never even know that it's going on. Write a single set of wrappers for your basic types, and you never again have to worry about endian or floating point conversions in anything you write.

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
    2. Re:No serialization, please! by petermgreen · · Score: 1

      note that javas standard classes for io (e.g. datainpustream and dataoutpustream) pretty much don't let you write code that will have different results on diffent platforms anyway even if you aren't using serialisation.

      personally i belive that file formats should where possible be as independent from the program thats generating and parsing them as possible like html png jpeg etc are.

      --
      note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  100. brings back memories by bobalu · · Score: 1

    I ported a DOS character-based windowing library called C-Scape to the Amiga and OS/2 in 1990 or so. Worked pretty well. I never figured out why that kind of thing wasn't used more.

    --
    The revolution will NOT be televised.
  101. Re:C++ is cross-platform, dont know what your smok by Rei · · Score: 1

    When perl gets within an order of magnitude the performance of C++, let me know. When perl gets generic programming, let me know. When perl does full polymorphism, let me know. When perl gets anywhere near the bazillion libraries used in C/C++ (yes, perl has a lot. No, they're nowhere close to the amount C/C++ has), let me know. In fact, when perl does essentially anything of what people use C++ for, let me know (for example, when you think you can get it to do much of anything ITK does for developers anywhere even remotely close to its performance - start reading at "Generic Programming", continue through "Smart Pointers", and don't stop until you get the point).

    Perl is a great language, and has many widespread uses. It is not anywhere close to a C++ replacement. Period.

    --
    He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
  102. You've got to be kidding... by gr8_phk · · Score: 1
    Some consideration should be given to portability before you even start. You say to use portable languages and libraries, but that means you've considered portability up front. OK, just doing that doesn't make your code portable, but it will keep you from being locked in when you do decide to port. If you're going to be reading/writing files, or communicating over a network it's also important to consider item #4 mentioned in the review and not lock yourself into any platform specific data structure layouts - otherwise you may release on one platform and find compatibility a BIG issue in the future when you do port. Declaring and using your own types isn't a big deal - I wish I'd learned about it much sooner than I did - it's a pain in the butt to go back and change every variable definition and every cast after the fact when you discover another architecture defines the "standard" types differently.

    Some things really should be considered from the start - which you seem to agree with. Others can probably wait, so I don't think you're totally out of line either. Reading of a book like this is probably a good way for people to make reasonable decisions as to which things really should be done up front. I just wish everyone would at least consider portability up front even if they don't plan to do it. Plans change.

    1. Re:You've got to be kidding... by ajs · · Score: 1

      Note that, "don't write portable code," and, "don't consider portability," are different statements, and I only made one of them.

      I would also say, "don't write optimized code," not, "don't consider optimization."
      Different.

  103. Re:Good. This needs to be taught. by Anonymous Coward · · Score: 0

    It's really cool, and I'm pissed that I got out of college not knowing this stuff. It should be a required course, IMHO.

    Gawd, no.

    I've seen this too many times. Somebody says "hey, students graduate not knowing /pet idiom xyz/, we better make it Required!". Then you end up with lots of little "required" classes with important-sounding names ("Software Engineering, For Engineers"!), and in 2 years when the original prof moves on, they don't even teach that, any more.

    There's no way you can teach every student everything you want to. At some point, the responsibility is on the student to learn -- you're at college, you're paying $X thousand a credit, it's not their job to spoon-feed you everything. College teaches you *how* *to* *learn*, more than a certain set of skills; otherwise it'd just be a trade school.

    If you write large programs with other people, you'll figure this stuff out. What, you got a CS degree and never wrote a large program with other people? (Do you think any English majors graduate without having read a long book?)

  104. I'm writing a FOSS app to help with an online fan project at the moment.

    I chose XUL, because essentially the only user requirement for installation is that they have Firefox or another Mozilla suite program.

    XUL will run on any box Firefox will run on. And that means about 99% of the boxen out there.

    --
    May the Maths Be with you!
  105. just one problem: It's Impossible by pyrrho · · Score: 1

    portable code is a pipe dream, a search for the fountain of youth or holy grail.

    and I should know... I'm running Mozilla on AmigaOS and the tables render a little funny.

    --

    -pyrrho

    1. Re:just one problem: It's Impossible by Maximum+Prophet · · Score: 1
      main()
      {
      printf("Hello World\n");
      }
      --
      All ideas^H^H^H^H^Hprocesses in this post are Patent Pending. (as well as the process of patenting all postings)
  106. Me too, and I agree by Anonymous+Brave+Guy · · Score: 1

    Exactly. More than that, a "portability layer" is just a handy term for a specific example of modular programming, which is good practice as a general principle anyway. If your code is constructed from carefully separated subsystems with well-planned interfaces and a layered structure internally, portability pretty much becomes the default, because it's little more than "adapting the stuff in the bottom layer".

    --
    If you disagree, post your argument. (-1, Overrated) isn't your personal censorship tool for views you don't like.
  107. Re:C++ is cross-platform, dont know what your smok by Erioll · · Score: 1
    The kind of things I drool over are the Turing-completness of the C++ template mechanism, but that just goes back to wanting to get the compiler to figure out as much as possible for me.

    I dunno what you mean by "turing-compleness", but the Generics mechanism in 1.5 is probably what you're looking for: compile-time type-safety. Before when using collections you were always casting back-and-forth from collections, but now you can let the compiler ensure what you're doing.

    Still not 100% efficient, as they made it a compiler-trick, and thus it's still doing type-checking at runtime (why they implemented it this way (even though it preserves backwards-compatability with existing bytecode, which isn't a good enough reason IMO) is beyond me, as the speed improvement would have been worth it).
  108. Portability can be a type of testing. by roystgnr · · Score: 1

    This can be true even if you never plan to switch compilers, OSes, or architectures in production - I've seen errors which will silently corrupt your memory on one platform but segfault (and thus give you a nice stack trace to work from) on another.

    But really, how much of your code is so ephemeral that it'll be thrown away before the next compiler, OS, or architecture you want to run it on comes around? I've seen programmers scream that "This new compiler version breaks my program!", then waste time wading through their standards-incompliant code that could have been correct if it had been tested on multiple compilers from day one. I've seen "optimizations" that were written based on profiling on only one system and become hard-to-refactor "pessimizations" on newer systems. I've seen programs stuck on slow and expensive hardware because nobody wanted to worry about endianness issues until competing fast and cheap hardware made those worries necessary.

    For someone writing popular open source code, portability is even more important for testing. The number of people who want to use your code will almost certainly be greater than the number of people who want to use your code and your operating system. It's nice to get bug reports and patches from the whole former set rather than just the latter.

  109. Re:C++ is cross-platform, dont know what your smok by renehollan · · Score: 1
    I dunno what you mean by "turing-compleness"

    Look here

    Those kinds of things are possible because the C++ template metalanguage is Turing Complete.

    Of course, the syntax gets real ugly real fast, because, I think, the template metalanguage is Turinc Complete by accident, and not design, but it's amazing what you can do.

    I haven't looked at Java Genrics closely enough to know if they have the same expressive power, but I suspect they don't.

    --
    You could've hired me.
  110. Big mouth, no brains. by Anonymous Coward · · Score: 1, Insightful

    You have no idea what you're talking about.

    Should me some JVMs which are available for Broadcom's 64-bit processors. That I can buy, right now. According to MIPS, they have Java. Guess what? There are a lot of MIPS CPUs out there which can't run Java, without paying to have it ported.

    Show me some JVMs which are available for Atmel's 32-bit processors.

    You can't.

    For someone who doesn't know what he's talking about, you have a big mouth.

  111. Hehe. by hummassa · · Score: 1

    hmmmm... let's see:
    an order of magnitude the performance of C++: this depends. If we're talking about regular expression-based parsing and general string manipulation, perl5 is already there. Hard math? 3- and 4-d matrix manipulations? not yet. Maybe perl7, who knows?
    generic programming: perl5 has this, sort of. lots of stuff can be done in compile time. perl6 has generic types, I think even pugs have them already, but I don't recall exactly.
    bazilion libraries? here, actually, this is one of the things the world (including c++) could learn from the perl community. really. including c and c++-written libraries that you can call from inside your perl programs.
    I am still reading about this ITK thingie, so I won't comment, but looks good for starters.
    Mind you, I work with C++ myself. But I don't think it's a perfect language (nor I am saying you said that), and I think each tool has its trade (but, seriously, I loathe Java).

    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    1. Re:Hehe. by Rei · · Score: 1

      In generalized real-world tasks, perl is about two orders of magnitude slower than C++. Only for certain very specialized applications, such as regexp matching does it even compare. That is one reason perl is *NOT* a replacement for C++

      Maybe perl7

      Not going to happen. It has potential to improve, but things like loose typing and other things that prevent compile-time optimizations will prevent most code from ever coming close.

      sort of

      Not.

      generic types

      Generic types != templates. Templates are compile-time, and it's a critical difference.

      c++ libraries ... inside perl

      Go ahead, make ITK calls from inside perl. I double-dog-dare you! ;)

      As I mentioned, perl has many, many libraries. But due to the nature of decades of C/C++ development by companies and invidiuals all over the world, C/C++ libraries are almost countless. They could learn from Perl about making libraries more standardized and accessible, however :)

      I loathe java

      Shared ;) Don't get me wrong, languages like Perl are outright great for some tasks (I'm more of Python gal myself, but that's mostly a style issue). I especially love python for tasks like interfacing with databases and things involving lots of filesystem searching/accessing/processing. But they're not even close to a replacement for C/C++ in the sort of tasks that C/C++ are primarily used for - ones that need to either run fast, be massive shared-development projects, or access any of the bazillion libraries developed over the past couple decades properly and efficiently.

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
  112. Your thingie is not inteligible by hummassa · · Score: 1

    I get that the template is missing from the first line, but there are other stuff missing and I don't know what they are. care to repeat, please?

    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
    1. Re:Your thingie is not inteligible by Rei · · Score: 1

      Sure.

      template <class T>
      void foo<T>::bar()
      {
                T var = random();
                if (sizeof(T) == 8)
                {
                        var << 32;
                        var |= random();
                }
                do_something(var);
      }

      This is perfectly valid and reasonable code which generates warnings.

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
    2. Re:Your thingie is not inteligible by zixyer · · Score: 1

      I think that would be much more natural to just specialize the template for 64 bit types. Using sizeof to figure out the type in a template seems pretty ugly. Templates are supposed to be type-agnostic.

    3. Re:Your thingie is not inteligible by Rei · · Score: 1

      This is a big oversimplification ;) The problem occurs in dozens of different forms, most of which aren't nearly that easy to work around.

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
    4. Re:Your thingie is not inteligible by shutdown+-p+now · · Score: 1

      Can we have another example then? I really can't envision any such case which couldn't be dealt with neatly by proper application of template specialisation (not necessarily for the class the code occurs in - it can be another class written specifically for that purpose).

    5. Re:Your thingie is not inteligible by Rei · · Score: 1

      Sure. First off, it is important to remember that template specialization defeats the purpose of templates if you have to do it often, and that there are far more datatypes than u_int8_t and u_int64_t. Anyways, just to give you another example (I have as many as you want):

      template <class T, int ArrayBits, int BlockWidth, int BlockHeight>
      void foo<T, ArrayBits, BlockWidth, BlockHeight>::bar(T var)
      {
              const int borderbits=BlockWidth*BlockHeight+4;
              if (ArrayBits>borderbits)
              {
                      var >>= ArrayBits-borderbits+1;
              }
              else
              {
                      var >>= borderbits-ArrayBits;
              }
              do_something(var);
      }

      In this case, you'll get complaints about negative shifts. Yes, there are workarounds. My favorite settled-on workaround (because it works in all cases, preventing you from having to do specific template implementations or code rewrites) is to implement shl, shr, shle, and shre for shift-left, shift-right, shift-left-equals, shift-right-equals respectively as inline functions. This function optimizes out, but you don't get warnings because since the arguments are variables, the compiler doesn't bother you.

      However, one shouldn't have to do this. This is compiler stupidity. Again, I've got dozens of examples of foolish warnings, so just let me know if you need more.

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
    6. Re:Your thingie is not inteligible by shutdown+-p+now · · Score: 1
      First off, it is important to remember that template specialization defeats the purpose of templates if you have to do it often, and that there are far more datatypes than u_int8_t and u_int64_t.

      Trick is, you don't specialise for types, you specialise for sizeof! =)


      Your previous example, then, would become:

      template <typename T, int Size = sizeof(T)>
      struct foo_helper
      {
        static void prepare(T& x) { }
      };
       
      template <typename T>
      struct foo_helper<T, 8>
      {
        static void prepare(T& x) { (x <<= 32) |= random(); }
      };
       
      template <typename T>
      struct foo
      {
        void bar()
        {
          T var = random();
          foo_helper<T>::prepare(var);
          cout << var << endl;
        }
      };
      Unfortunately, you cannot do it inside the class itself and make the helper classes private (specialisations are only allowed on namespace level); but if you put it in the implementation file and hide it inside your namespace, there shouldn't be any difference.


      In the second example, you do the same thing, but you require one more level of indirection there. Things like that are much easier with Boost.MPL:

      struct foo_helper_gt
      {
        template <typename T, int ArrayBits, int BorderBits>
        static void shift(T& x) { x >>= ArrayBits-BorderBits+1; }
      };
       
      struct foo_helper_le
      {
        template <typename T, int ArrayBits, int BorderBits>
        static void shift(T& x) { x >>= BorderBits-ArrayBits; }
      };
       
      struct foo
      {
        template <class T, int ArrayBits, int BlockWidth, int BlockHeight>
        void bar(T var)
        {
          static const int border_bits = BlockWidth*BlockHeight+4;
          boost::mpl::if_c<(ArrayBits > border_bits), foo_helper_gt, foo_helper_le>::
            type::shift<T, ArrayBits, border_bits>(var);
      ...
        }
      }
      Ugly, I know. But it's the price paid for the power - of C++ templates, that is. I once wrote Conway's Life completely in them just for the sake of it.
    7. Re:Your thingie is not inteligible by Rei · · Score: 1

      I once wrote Conway's Life completely in them for just the sake of it

      Funny you should mention that - I'm doing precisely that right now. ;) I'd like to get the Conway's speed record for large chaotic sets - I'm using every trick in the book I can find (plus some of my own) except hashlife (because it's unscalable for chaotic data), and I have some scalable ways I may attempt to mimic it. This includes:

        * Blocks of cells
        * Self-optimizing block dimensions
        * Composite associative arrays consisting of direct lookup and the associative array type of your choice (hash, map, direct), to make use of your ram as efficiently as possible, filled in advance to contain an optimal range of lookups, and self-optimized by cache type and details.
        * Stacking blocks of cells like bricks to reduce the border-blocks from eight to six.
        * Only looking at regions that have the potential to change
        * (Possible, still working on the details) checking for cyclic repitition within regions to simulate hashlife.
        * Cells inside blocks arranged in a spiral instead of linearly in order to keep border cells contiguous to speed up border lookups
        * Networked engines to split the rows among multiple machines on a fast network (each engine only needs to share its border rows with the others)
        * Self-validating code.
        * Optional entropy addition.

      I'm actually pretty far into it; I'm currently working on validating the prediction cache (which makes use of the engine for its optimization). Yeah, a waste of time, but hey, its fun, gives me more template and style practice, and with gigantic fast, entropy-rich worlds, it'd certainly have the best odds of any at finding interesting behavior :)

      --
      He's just being nice so my real father won't freeze him in carbonite and sell him for spice.
  113. Strict portability by BagMan2 · · Score: 1

    My rule is that if a piece of code has #ifdef WIN32 or similar in it, then it is not portable code. I classify code with platform #ifdef's as non-portable code that has been implemented on select platforms. To ensure rules aren't broken, I don't allow code that is classified as 'portable' to even have visibility of header-files that are platform specific (like windows.h). Access to all platform dependencies is accomplished through either pure virtual base class interfaces or where the internal representation is hidden. For example:

    class FileObjectInternalData;
    class FileObject
    {
        public: // non-virtual interface functions for object go here
        private:
              class FileObjectInternalData *mData;
    }

    The internal platform-specific data is hidden in a class that is simply pre-declared in the header, then actually defined in the .cpp file for each platform (like Win32FileObject.cpp). In this manner, the abstraction class header files do not need to include the platform-specific header files, thus preventing the rest of the application from even seeing the platform specific headers. In this manner, it becomes impossible to accidentally use non-portable platform functions or types. It also serves to completely isolate the code that must be changed for the system to work on the next platform.

    Ultimatley, the goal is to implement as much as possible in the portable code. My rule is that if it can be implemented in a portable manner, I don't increase the size of the platform-specific interface abtractions. Things like big-endian and little-endian can be dealt with completely portably with functions like this:

    inline unsigned PutValue32(void *buffer, unsigned value)
    {
        unsigned char *bufptr = (unsigned char *)buffer;
        *bufptr++ = (unsigned char)(value >> 24);
        *bufptr++ = (unsigned char)((value >> 16) & 0xff);
        *bufptr++ = (unsigned char)((value >> 8) & 0xff);
        *bufptr = (unsigned char)(value & 0xff);
        return(value);
    }

    inline unsigned GetValue32(const void *buffer)
    {
        const unsigned char *bufptr = (const unsigned char *)buffer;
        return((*bufptr 24) | (*(bufptr + 1) 16) | (*(bufptr + 2) 8) | *(bufptr + 3));
    }

    Which serve to portabily write and read 32-bit values in a big/little endian neutral way. Thus not increasing the size of the platform-specific abstracted interface.

    The true goal in creating portable code is NOT in making code that can run on a lot of different platforms, but rather in writing code that can easily be ported to another platform. There is a big difference between the two. The secret to the latter is to strictly isolate dependencies and to minimalize their size as much as possible.

  114. Re:Small book by CoderJoe · · Score: 1

    Yeah, desktop systems are getting beefier, but what about compiling code for embedded systems and stuff like that?

    Why would you be writing cross-platform code for an embedded envirionment? If you are targetting an embedded envirionment, then you aren't even planning on going cross-platform.

  115. Re:This book is OK and all by PastaLover · · Score: 1
    Despite the crudity of the parent poster's statements, he is essentially correct. Linux/GCC have regularlly changed the ABI for seemingly no reason at all. All that says to us programmers is that either the coders are changing the ABI as a feel good session (See? It looks puuuurrdy!) or they didn't take the time to get it right the first five times.

    I mostly agree, but you have to take into consideration that Microsoft's tendency to support ancient ABI's for windows 2.0 applications greatly increases the complexity of their product. In fact, it is often cited as the very reason for windows's relative instability (and linux's stability). So perhaps it's better this way.

  116. Portable code? that's fine,but more importantly... by helix_r · · Score: 1


    Let's be honest, what percentage of projects are actually ported to other architectures? My guess is that it is a very very low number-- like 10%.

    These days, the fashion is to scrap everything as legacy and do total re-writes using new tools and practices. Somehow, I don't think that will change.

    Today's gleamming cutting edge J2EE project is tomorrow's crufty legacy that no one understands.

  117. Cross platform GUI by Dog135 · · Score: 1
    Server/command line code is trivial to make portable compared to GUI applications.

    Pieterh already answered you on this, but I'll put in my 2 cents too.

    I too write cross platform code, between Windows, Linux, and OSX. For each OS, I have a "shell" program, along with a "gcross" (graphics cross-platform) class, which standardizes the graphics. The shell calls an "app" class, which in turn uses the "gcross" class for the GUI. My app class contains all the code for the application. I've written many graphic intense programs in this, and they run as quickly as any other equivalent program, even faster in many cases. (My fractal program runs faster then most others I've found)

    So for whatever system I'm currently programming on, I only need to copy my "app.c" and "app.h" files, as well as any other custom files and recompile with the different shell programs.
    --
    "That's so plausible, I can't believe it!" - Leela
  118. Concur on Java/Swing by Latent+Heat · · Score: 1
    I am beginning to think that Java/Swing has a lot going for it and its time has finally come.

    Windows took a good 10 years until Windows 95 came out and Windows became the big deal it is today. Java has been out since 1995 -- so it is 2005 -- and I am beginning to think that Java is finally getting to the point where Swing has enough features (clipboard support, images where you can directly set the pixels, hardware graphics acceleration) that it is usable for serious applications. There is a ton of docs on Java/Swing on the Web. People used to talk about Internet time and how fast things moved in the industry, but it really takes a long, long time for many software products to mature.

    Now Swing still has some rough edges -- why does a Files Open dialog take 3-10 seconds to come up on first activation, why does expanding a window cover up the Start bar on Windows (I guess there are some look-and-feel options).

    But I was able to get an x-ray image viewer program developed under Windows to run under Solaris and Debian Linux without much fuss. I think Mr. Gates should be afraid, very afraid. Maybe not this year, or the year after, but there will be a time when you won't have to make a platform dependent GUI.

  119. Portable code techniques = less bugs by ozzee · · Score: 1

    I didn't see anyone mention this. The last 3 projects I have worked on were done in such a way that they compiled (most of the code) and ran (lots of unit tests) on Linux and Windows. It also consisted of a build environment where builds and tests were continuously run on Windows and Linux (recently also Linux on AMD64) and both "release" and "debug" builds.

    There were a non trivial number of bugs found on Linux and not on Windows or Windows and not on Linux or on 64 bit and not on 32 bit or visa versa by doing the automated tests that undoubtedly would have bitten us in the most inappropriate times.

    It also opens up the skill set and tools. If a set of engineers are more comfortable on Linux and another on Windows, you get a much better cross-pollenation of skills. For example, most of the app runs on Linux and so we can use "valgrind" (a totally awesome tool for mem checks instigated by my hero Julian Seward). Other Win32 weenies like to use other tools for mem checks. So you end up getting the best of both worlds. Finding bugs sooner means lower development costs.

    The most recent project is a heavily threaded network client with about 100,000 lines of C++. When we got the product limping along I decided to run valgrind for a mem leak check and to my utter surprise was not able to find ANY (unintentional) memory leaks. Admitedly, the team is a seasoned group of engineers who have a combined 100+ years of job experience, but I was still impressed.

    1. Re:Portable code techniques = less bugs by Anonymous Coward · · Score: 0

      As a game developer who has to have a portable core technology base in order to develop for Mobile phones, GBA, PSP, PS2, XBox, PC plus numerous other embedded systems, I find it amusing that people still think 'cross platform' means Linux to/from Windows and perhaps a Mac if you're lucky.

      No offense intended, but the first thought that came to my mind: 100,000 lines of C++ sure sounds like a bucket load of bloat to me, especially for an app described as 'heavily threaded network client' - the emphasis on client... I'm also curious why you'd introduce intentional memory leaks? (seriously, why?)

    2. Re:Portable code techniques = less bugs by ozzee · · Score: 1
      (seriously, why?)

      Lazy.

      It's a singleton and a start-up race condition. One could either place a whole bunch of code everywhere to deal with it (which uses memory and adds complexity) or simply create an object the gets dropped on the floor when no-one accesses it. It's a piece of cake to fix, but in this case it will never ever be an issue, (other than a positive hit on valgrind).

      I did game development 6 years ago. The tools sucked. Is there a purify/valgrind for them now ?

  120. Re:C++ is cross-platform, dont know what your smok by Anonymous Coward · · Score: 0

    There is nothing platform dependent about the language, of course. However, the adherence to the standards of the many compilers out there varies greatly.

    When there are problems, they usually center around the compiler lacking support for some aspect of templates.

  121. Java for Palm by cameronpurdy · · Score: 1

    > there is no Java JVM for a Palm I have seen at least 3 different JVMs for the Palm. Peace.

  122. Re:C++ is cross-platform, dont know what your smok by petermgreen · · Score: 1

    is there a way to make reflection work on non-public fields and methods and if not how do degbuggers and serialisation do it?

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  123. Re:C++ is cross-platform, dont know what your smok by petermgreen · · Score: 1

    reflection is addictive though because unlike interfaces etc it doesn't require the classes to be designed for it.

    look at the following code for instance. by using reflection i can make it use any method of the objects to do the conversion to strings thus making it very generic.

            public static String[] objectArrayToStringArray(Object[] in,Method conversionmethod) throws InvocationTargetException,IllegalAccessException {
                int l = in.length;
                String [] out = new String [l];
                for (int i=0;il;i++) {
                        out[i] = (String)conversionmethod.invoke(in[i],(Object[])nu ll);
                }
                return out;
            }

    you could generalise this further to make it go from an array of any object to an array of any object (and i might do that if i found a reason to do so).

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  124. Keep it simple stupid by Anonymous Coward · · Score: 0

    How to 'best' write portable code depends ...

              If you are going to have as many end-users
    as Oracle has for it's RDBMS/tools, then you go to the
    hard core tools. You spend a lot of time with C/C++,
    OS abstraction layers (e.g. the Adaptive Communication
    Environment - ACE - wrappers), GUI abstraction layers (e.g.
    WxWindows) and so on (and so on).

              Yes, this *WILL* take 2x-3x-4x-5x longer to
    develop/write the (commercial?) code. Hard-core,
    portable, small/fast, commercial-grade code is *NOT*
    easy. But it can be portable *EVERYWHERE* (from
    Windows to *nix to HP NonStop to zSeries to Apple
    to whatever). The speed/footprint benefits will
    quickly swamp the additional development
    time/investment/cost. Just ask Oracle. If it
    really matters, sweat the details. Do the C/C++.

              If you are doing some MIS/IT utility
    program, perhaps for just one company's internal
    use, then *please* don't fight the MIS/IT
    department - no matter how whacky. If those MIS/IT
    guys are all JAVA heads - whip it up in JAVA. If
    like COBOL - whip it up in COBOL. If they
    prefer PHP for most new stuff, then use PHP. At least
    somebody else will be able your stuff once you find
    greener pastures. Whatever. Yawn.

              If you get to do your own thing, on a rich server,
    then rapid-app-dev (RAD) with Python/WxPython -- and tune by
    replacing performance critical bits with hand-optimized
    C/C++ (but, as needed, drag in OS abstraction/portability
    layers, GUI abstraction/portability layers, etc.).
    Once you dip a toe into the hard core C/C++ stuff,
    portability always costs. Lets face it. C/C++ is the
    modern (source-level) 'portable' (macro) assembler.

              If you're in impoverished parts of the
    embedded space (e.g. not embedded WinCE/*Nix), then you
    might have to skip past scripting in python. While
    the python VM is about 1/5 the size of the latest
    JVM (just at start up!), Python might not be
    available. Bummer. If so, you end up going
    directly to C/C++ (and often ANSI C is a better
    bet with low-end embedded tool chains).

              I'll not say anything about portable web server
    (side) programming. That is sort of an oxymoron. You
    typically decide what web/app servers you'll choose
    to support/run. The portabilitiy challenge
    is more common across browsers. Lets just
    say hail w3c. Bad Microsoft. No wonder AJAX
    is all the rage. AJAX is portable!

              If you just want to expand your mind,
    and free your inner-programmer, then you do
    Haskell (or O'Caml) or even Scheme. Once you
    finish binding unification into Haskell
    combinators ... you'll probably need
    a (nother) real job ... to go with your new
    PhD. If the lambda calculus rubs you the
    wrong way, then try the imperative
    elegance of Ruby or Lua.

  125. Enough by ClosedSource · · Score: 1

    I think we've already gone too far in our pursuit of portable code.

    Look at Java threading. You have to use synchronization to protect your thread against being preempted, while yielding to protect all the other threads in case you never are.

    That's because the underlying process and thread models used by different OS can't be abstracted away in single model. So you end up with very little thread behavior that you can count on.

    Cross-platform code will always be more complex and less satisfying than targeting a particular platform.

    1. Re:Enough by Anonymous Coward · · Score: 0

      Many folks write applications with OS abstraction
      layers that cover both multi-processing (with IPC) and
      multi-threading (with mutexes, thread-specific storage,
      etc.). Please check out the Adaptive Communications
      Environment (ACE/C++) OS wrappers. Chapters 12 and 13
      of The ACE Programmer's Guide detail thread abstractions
      (ISBN 0-201-69971-0).

                Basically, you need the pre-compiler to
      write portable source for exotics like VxWorks (RTOS) that
      don't properly support anything like a traditional process
      concept. Still, a modicum of 'portable' design work and
      some judicious/disciplined #ifdefs/#defines does the job
      even for these exotic 'ports'. Yes, you have to sweat
      the details if you want portability (and small footprint
      and speed).

                Scripting languages, like JAVA, are generally not
      available for exotic/embedded platforms anyway. JAVA is
      far too big, far too slow and far too unpredictable for most
      real-time/embedded applications. So is Python
      (ableit python is about 5x smaller than a JVM - just at
      start up - and even smaller a few instants after start up).
      Ruby, Perl and the rest all too big, too slow and too
      unpredictable.

                If you're determined to find 'portability' in
      a scripting language, you might check out Lua.

                In general - you'll *always*
      want native/system-level/JNI options/abilities to
      ensure arbitrary 'portability'. Nothing beats C/C++
      for portability. Yet you have to do the heavy lifting
      to make your single source code base work across your
      entire (growing) list of 'ports'. You get the
      'portability' you pay for. There's no free lunch.

  126. Re:C++ is cross-platform, dont know what your smok by renehollan · · Score: 1
    reflection is addictive though because unlike interfaces etc it doesn't require the classes to be designed for it.

    Well, no, but it does require the class to expose a method that does the right thing. That isn't much different from the class implementing the right interface.

    Where reflection comes in handy is when you have a plain old data struct, with data members, and you want to automagically generate a UI to fill in the struct members. For example, if you have a struct that holds all the possible command line arguments for a program, with a bit of work, you can automagically generate a command line parser to fill it in within the limits of the types your automagic routine understands.

    --
    You could've hired me.
  127. Re:C++ is cross-platform, dont know what your smok by DimGeo · · Score: 1

    Yes, there is. See the javadoc for SecurityManager. Basically, you write your own SecurityManager that permits you to do that, then activate it and you are done. However, there's a catch. You can do that only once. As most big frameworks (J2EE app servers, OSGI frameworks, etc.) usually do that on startup, you can't.

  128. Re:C++ is cross-platform, dont know what your smok by shutdown+-p+now · · Score: 2, Insightful
    When perl gets generic programming, let me know.
    Most (all?) loosely-typed languages are generic, by definition.

    On a side note, generic programming in C++ is very much a joke. I mean, you cannot even define constraints on template arguments, and have to resort to dirty tricks with delayed instantiation - WTF?

    yes, perl has a lot. No, they're nowhere close to the amount C/C++ has
    The problem with C++ libs is that very few of them adhere to the C++ philosophy, and thus play well with STL and boost. Most are, at best, "C with classes". Quite a few are essentially Java redone in C++ (Qt being the most prominent example). Generic programming, full-scale use of templates, STL-compatible iterators? A rare sight, unfortunately.

    Anyway, if you know a decent cross-platform GUI toolkit written in and for proper C++, please do tell (gtkmm comes close, but it's not really cross-platform enough, and some design decisions, such as ustring, are questionable). I've been looking for that for ages, and got desperate enough that I might well start writing one myself.

  129. Re:C++ is cross-platform, dont know what your smok by shutdown+-p+now · · Score: 1
    Still, the whole idea of using RTTI to defer what should be a compile-time decision to run-time just leaves a bad taste in my mouth.
    Just try to count how many times this particular wheel has been reinvented by C++ programmers (you can start with wxWidgets and Qt, and continue from there), and you'll see why it is really needed so badly. Of course, it can be misused - but well, C++ being what it is, I'd be surprised if that is an argument worthy of attention of a C++ programmer =)
  130. Re: "not going to happen" by hummassa · · Score: 1

    Don't count on it. Albeit Perl6 is a very dynamic language, it has the potential to type-strong every single variable. Better and better tools appear every day: have you ever seen pyrex and psyco? I am not the greatest python fan either (*), but a psyco-like thing will "take over" more and more languages, especially potentially type-strong ones like perl6. And perl6 has compile-time generic types (templates) and compile-type syntax modifications (macros).

    (*) I worked with it already, and I admit python code is normally very readable, but OTOH I prefer the conciseness (and possibility of expressing SIMD, when applicable) of

    @a >>+<<= @b

    to the supposed clarity of the equivalent for-loop in python. DISCLAIMER: this is just a matter of (personal) taste. I am not trolling.

    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
  131. But the argument still stands. by hummassa · · Score: 1

    you should have done something in the line of (one specialization for each special case):

    template <class T> void foo<T>::bar() {
    T var = random();
    do_something(var);
    }

    template <> void foo<uint8_t>::bar() {
    uint8_t var = (random() << 32);
    var |= random();
    do_something(var);
    }

    --
    It's better to be the foot on the boot than the face on the pavement. ~~ tkx Kadin2048
  132. Re:C++ is cross-platform, dont know what your smok by AKAImBatman · · Score: 1

    Where reflection comes in handy is when you have a plain old data struct, with data members, and you want to automagically generate a UI to fill in the struct members.

    That's one use (though you probably want to use the bean libraries for that). There are a few other good ones:

    1. Since Java didn't implement variable arguments until recently, reflection could be used to dynamically call a method with an unknown number of arguments. An example of this is JHDL which looks at a static array to get the number of wires to pass to the constructor, then uses any additional ints or Strings as configuration parameters.

    2. Somewhat related to serialization, reflection is perfect for creating Object databases by dynamically saving field values to disk, and reloading the state.

    3. Reflection can be used to take a multidimensional array and quicky flatten it for storage on disk, or redimensionalize it after you pull the flat array from disk. This only works because an array of any dimension can be cast to an Object (and vica-versa) allowing you to have only one method for any size array. :-)

  133. High-Level Languages by RAMMS+EIN · · Score: 1

    My advice? Use high-level languages and libraries. If your tools don't expose platform differences to you, there's no way you can make your code non-portable. As a bonus, you can also get garbage collection (which automagically gets rid of memory leaks), automatic allocation (no more buffer overruns), and structured composition of code (no more injection vulnerabilities). Also, the more high-level your language is, the less code you write, thus the fewer bugs you introduce and the more productive you get.

    Of course, there are a few gotchas. Sometimes, you may actually want to do things at a lower level than the creators of your libraires thought you would. If your language is flexible enough, you shouldn't really have a problem getting at the lower levels (especially if the libraries you use are open source). It could also be that the language of your choice is too slow for a certain task (although there's nothing that makes high-level langauages necessarily slow). Fear not! Many high-level languages can interface with C code, so you can probably write parts in C, or even assembly if you need to. This can also solve the flexibility problem. For the rest, it's mostly a matter of seeing through the myths and picking the right language.

    Some examples? OCaml, Common Lisp, Ruby, Scheme (with appropriate extensions), heck, even Java and C#, Perl, Python, ...

    --
    Please correct me if I got my facts wrong.
  134. Apache Portable Runtime by endoplasmicMessenger · · Score: 1

    If you must write in C, use the Apache Portable Runtime.

    --
    Evolution is a fact. Darwinism is a joke.
  135. Re:C++ is cross-platform, dont know what your smok by petermgreen · · Score: 1

    Well, no, but it does require the class to expose a method that does the right thing. That isn't much different from the class implementing the right interface.

    its not if its your code thats constructing the instances but its not always. Quite a few java libraries return arrays of objects and if you wan't to fill a combo box with that information you are going to have to convert it to strings. The tostring method might do what you wan't but it might not.

    --
    note: i'm known as plugwash most places but i screwd up registering that here somehow in the past and now can't register
  136. Re:C++ is cross-platform, dont know what your smok by renehollan · · Score: 1
    ...you'll see why it is really needed so badly. Of course, it can be misused...

    I didn't say reflection wasn't useful -- it certainly is (as are C# Attributes, for that matter, which generalize the concept of metadata about types and objects being available at run as well as compile time).

    But, I've seen it used way too often to take something that's been upcast to a base type, and selectively downcast it back into a type of interest, when the upcast is what's really wrong (and Java must have contributed to this, what with "generic" libraries returning Objects that then needed to be downcase, before Generics were added to the language).

    The "smell" test for me is to see if the code that takes advantage of reflection, or other metadata about types and objects, can handle any values for the information it gets (or at least a large class of them), or just a few finite ones: i.e. a poorly coded open-coded case statement on type.

    In general, what's missing in C++ has neen the ability for the compiler to pass knowledge it has about types and objects to the code it has compiled. C# fixes that, and Java does this by design (though far too often than necessary). Though, with C#, the separation between syntax and type has been become a bit to fuzzy for my liking: the use of foreach over an iterator is one example: the foreach syntax should be defined as a language extention as part of the definition of the iterator base class type -- Think Mary 2, if you want to look at languages with dynamic syntax.

    --
    You could've hired me.
  137. I was joking... by pyrrho · · Score: 1

    ... but that doesn't make the strongest case.

    But see... Mozilla on AmigaOS... complaining the tables render "a little funny"... that's still...

    anyway... cheers.

    --

    -pyrrho

  138. wyoGuide/wxWidgets by Anonymous Coward · · Score: 0

    There are many ways to Rome and there are many ways to get portable code. But when it comes to write full featured portable applications there isn't a better alternative than wyoGuide/wxWidgets (http://wyoguide.sf.net/, http://www.wxwidgets.org/).

  139. Oh really? by Viol8 · · Score: 1

    Well show me how you do a simple (in unix) operation
    to create a pipe , fork, redirect pipe to stdin/out then do
    an exec in the child process , then have the parent do
    a wait() & read/write on the child in win32? Go on , whats
    the problem, its trivial isn't it?