Thread: Java vs C to make an OS

  1. #46
    Registered User
    Join Date
    Jan 2007
    Posts
    330
    Quote Originally Posted by Bubba View Post
    There is so much misinformation in this post it is absurd.

    And what would make you an authority on this topic? So instead of using a pre-built, pre-tested, and pre-optimized library a game company would code their own container classes? Even when the more time they take the more money they spend? I highly doubt it. Reinventing the wheel is not what game companies will do and nearly every single job application for game programming mentions familiarity with the STL.
    I got it from the guys in comp.games.programming.misc who work at different games companies. Its not about reinventing the wheel, of course they have their own tested library ready. For tools stl is probably used.

    I myself make video casino games for a living, but we work in C on 16 and 40mhz processors, would love to try out C++ with STL one day

    Our kernel code (call it the OS) is internally developed in C and of course asm. Its funny to see that some driver code uses the OO approach with "virtual" functions.

  2. #47
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    I've found several articles on the net stating that STL is in fact used and those companies that refuse to use it are using less tested error prone in-house container code.

    Many, many, many titles have shipped on the PC and consoles which used the STL. Unless you can prove with numbers and empirical data that your container classes are indeed faster I would stick with STL. Doom 3's container system was proven to actually be slower than the same coded using the STL.

    But anything can be abused and I see it all the time here. If you try to create a map of a map of a list of vectors then of course it's probably not going to set any speed records. Again use the right tool for the job.


    But we diverge. Back on the topic of OS code.
    Last edited by VirtualAce; 05-24-2007 at 09:44 AM.

  3. #48
    Registered User
    Join Date
    May 2007
    Posts
    147
    KIBO

    A point about STL containers.

    You can set the type to a pointer to a class, rather than a class, in which case it's not an object copy that's made, and the objects placed in the container can come from custom allocated designs so that the end result is actually faster than default allocations in C, IN REAL WORLD WORK.

    Some of us are professionals, some are students - many of us have toured the map. I'm new to this board, but I own my own firm, have 27 years of development history, and I've been a C programmer for years before C++ was released. I don't make games, but I've hired several from the gaming industry. Young (or freshly out of the young stage), overworked, underpaid, nearly burnt out from post college all night adrenal overload.

    3 of 4 said they used STL in game development. However, (I just asked one guy) - there are some structures in 3D gaming that are specific to engine design for which either a hybrid is used, or a custom - which is usually made complaint with STL container standards.

    That's typical practice in many fields, including neuro-nets for AI, 3D for non-gaming, etc.

    KIBO, you seem to outright state that all claims of performance benefits from C++ development are contrived, and in real development things don't work that way.

    Please keep in mind, many of us here are professionals, too. You said you write for a rather niche specialty (I mean, in today's environment, a 40Mhz processor is a bit of a unique target, most of us are working with desktop, workstation or server oriented systems - though I managed an IT department for a fortune 1000 company with an array of 10 Unix boxes clocked at 40Mhz). No doubt you have considerable experience, but I urge you to consider that some of us have many years under the belt, too. I, for example, own my own firm, have a staff of loosely knitted contractors, and have developed applications in various platforms for 27 years. I started my business in 1982/83, and a few of my clients date from that time.

    I can assure you, the claims of performance in C++ do not fail in real world applications of considerable ambition. 3DS Max, for example, for which I've written (I was trying to count from memory - at least 12) plugins, is an excellent example.

    One other point about exception handling. No experienced C++ engineer would put exception handling on the inside of a performance oriented loop. On another forum, a question came up regarding the performance of exception handling, and my reply coincided with others. The impact of the prolog for a try is about the same as the prolog of a function call. One poster claimed that with optimizations, there are certain circumstances where the overhead evaporates to zero, but I can't confirm that claim. Still, unless an exception is actually thrown, there's otherwise no impact on code interior to the exception. An examination of the resulting assembler bares this out. Exceptions ought to be used for 'exceptional circumstances', though I've seen copious misuses that were conspicuously from the hand of an amateur.
    Last edited by JVene; 05-24-2007 at 03:40 PM.

  4. #49
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Quote Originally Posted by Bubba View Post
    Fact is you absolutely 100% cannot code an OS in any high level language. It is not technically possible, feasible, nor worth debating about. Before talking about operating systems perhaps it would do some good to actually research them and how they are coded. This is not simple programming and it most certainly goes far beyond simple items such as how a language allocates memory or does not allocate memory. There is so much to an operating system I could not even begin to scratch the surface here.
    I've done the research, I've looked at the linux kernel dating from version .01 to 2.6. I've also investigated and worked with other systems ranging from Plan 9 to MINIX and DynastOS.
    No amount of 'hogwash' is ever going to change the definitions of computer science we have today: Turing completeness is something you're just ignoring; that isn't going to make it go away.

    You can call it theoretic nonsense all you want, but if you were to ever say something like that in any academic circles, you'd most certainly be written off as a complete fool without second thoughts, and with good reason.

    No amount of waxing eloquent or hogwash is ever going to change the fact that this is simply not possible in ANY mid to high level language much less Java. You use the right tool for the job or you don't get the job done. You could have Java as the GUI but you most certainly would not be able to use Java as is to get any type of OS code to do anything close to managing the entire system.
    You can call it hogwash and call BS all you want. It doesn't change the facts (particularly, look up singularity and jnode.)

    In order to do that would require a nearly complete re-write of Java and it would also need to run without a virtual machine. How can you run a virtual machine when your OS is the 'machine'? Cannnot be done.
    It's obvious you haven't read a single thing I've posted in this topic. Aside from that, I've only said it to be possible, I never said it was practical or anything along the lines; I think you're simply confusing the two.

    Good luck on even getting to C since this would require a completely new C compiler to even get it to work with your OS.
    No, it wouldn't. How much research and work have you actually put into operating systems? You hardly need to write a brand new compiler, all you'd have to do in reality is retarget a compiler to output binaries that your OS will load. This is a lot simpler than simply re-writing your compiler entirely (and it should be, modern compilers have several stages. If you're using a compiler that's so hard-coded it would need to be re-written just to output to a different file format, it's probably a compiler that's either very specific to the OS anyway, or one not worth using.)
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  5. #50
    Registered User
    Join Date
    Jan 2007
    Posts
    330
    Quote Originally Posted by JVene View Post
    KIBO

    3 of 4 said they used STL in game development. However, (I just asked one guy) - there are some structures in 3D gaming that are specific to engine design for which either a hybrid is used, or a custom - which is usually made complaint with STL container standards.

    That's typical practice in many fields, including neuro-nets for AI, 3D for non-gaming, etc.

    KIBO, you seem to outright state that all claims of performance benefits from C++ development are contrived, and in real development things don't work that way.

    Please keep in mind, many of us here are professionals, too. You said you write for a rather niche specialty (I mean, in today's environment, a 40Mhz processor is a bit of a unique target, most of us are working with desktop, workstation or server oriented systems - though I managed an IT department for a fortune 1000 company with an array of 10 Unix boxes clocked at 40Mhz). No doubt you have considerable experience, but I urge you to consider that some of us have many years under the belt, too. I, for example, own my own firm, have a staff of loosely knitted contractors, and have developed applications in various platforms for 27 years. I started my business in 1982/83, and a few of my clients date from that time.

    I can assure you, the claims of performance in C++ do not fail in real world applications of considerable ambition. 3DS Max, for example, for which I've written (I was trying to count from memory - at least 12) plugins, is an excellent example.
    Looks like I didnt get my point across lol. I wasnt debating that "C++ and STL is sloooooooow" or anything like that. I've written big server and gui C++ apps too and the only times I've seen performance problems was because the algorithms chosen were wrong or the code was structured wrong. Never needed to do micro optimizations yet.

    I was trying to say that statements like, "see this matrix library is faster than C's qsort because of templates and inlining in C++" are twisting reality because when you create a real app around that library you lose that performance gain again. That doesnt mean that it matters!
    It will matter though if one would use heavy exception handling and object copying at a kernel level when writing an OS so the lower level one gets the more these high level features arent used anymore. The lower you get the more C like you will start to code

  6. #51
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    Just to make something clear: the 9x-ME kernels and the NT/2000/XP/Vista kernels are completely different. The API and the interface is similar, but they don't share the internals.
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

  7. #52
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Quote Originally Posted by Sang-drax
    the 9x-ME kernels and the NT/2000/XP/Vista kernels are completely different.
    One example to further prove that is the Blaster worm. If I'm not mistaken, differences in the kernels was blamed for it being limited to the NT range of kernels.

    To get further back on the topic, I'd think a Java OS would be possible but only if the hardware implemented the VM as well as the various libraries. That would be interesting to see.

  8. #53
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Hardware implemented libraries? Once you have the VM you have all of the java libs.

  9. #54
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    Quote Originally Posted by Frobozz View Post
    To get further back on the topic, I'd think a Java OS would be possible but only if the hardware implemented the VM
    If the VM is in the hardware, it's no longer a virtual machine.

    That's no different than just compiling Java down to native code. You may as well just do that and save yourself the trouble of designing a processor that runs on Java byte code.

  10. #55
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Point is, Why would you bother?

  11. #56
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    Point is, many people bother.

  12. #57
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Unless your new java OS can provide something that others already don't, then theres no real point other than learning...

  13. #58
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    I was talking about compiling to native code, not writing an OS.

  14. #59
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,895
    Quote Originally Posted by Mad_guy View Post
    No amount of 'hogwash' is ever going to change the definitions of computer science we have today: Turing completeness is something you're just ignoring; that isn't going to make it go away.
    Turing completeness is a description of the theoretical computability of problems. It has nothing to do with language capabilities that are outside the realm of numeric problems, such as hardware access. Java does not provide a way to access machine registers, raw memory or I/O ports. Without these three, you cannot make an OS, period. To perform these tasks in Java, you need libraries that do it, and these libraries in turn cannot be written in Java. Or else you need to extend your virtual machine or native code compiler beyond the Java Language Specification, in which case you're no longer programming in Java.

    Computability has nothing to do with it.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  15. #60
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    Quote Originally Posted by Perspective View Post
    I was talking about compiling to native code, not writing an OS.
    And I was talking about writing an OS in java

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Java for real-time applications
    By zacs7 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 08-26-2008, 06:34 AM
  2. Mats, the java answers
    By Jaqui in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 04-22-2008, 02:12 AM
  3. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  4. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  5. What to make?
    By Caldus in forum C++ Programming
    Replies: 4
    Last Post: 04-06-2005, 01:12 PM