Thread: Role of c++ in simulation software

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    76

    Role of c++ in simulation software

    I want to know about role of c++ in making simulation software.

    Is c++ is prime language for creating simulation softwares(for FBI,Military etc)?

    How bigger c++ plays for creating simulation softwares as compared to other
    languages such as Java,C#,Smalltalk etc. ?

    best regards,
    Chakra

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    The problem with your question is that "simulation" covers a huge area of different types of programs that simulate something. There is a big difference between a commercial level flight simulator to some piece of code that you or I write to simulate playing Yatzy.

    It probably depends on what you are simulating, and when the software for it was originally written. A lot of heavy calculations are still written in Fortran - because fortran is/was the best language and compiler to make math work in.

    Nowadays, most programmers are more familiar with either C or C++, and use that instead of Fortran simply because it makes little difference to the overall performance - also C compilers have come a long way since 1970's when Fortran was THE language for calculations.

    Other types of simulation, where calculations aren't the biggest part of the problem (e.g. generating random numbers and measuring queuing time in the post-office based on number of tills and number of customers, or traffic management etc, where a lot of the logic is based on other code rather than pure math), then the language choice wasn't so obvious in the 1970's or 1980's, and still isn't clear. There is Simula67, which was specifically designed for simulation.

    Simula67 is an object oriented language, and essentially the reason for C++ to exist - Bjarne Stroustrup was working with a program in Simula67, which worked fine for small models of the simulation, but when the model grew, the performance was useless - because it spent a large proportion of it's time doing garbage collection. The solution then was to rewrite the Simula67 code in C, using a "preprocessor" to make the object oriented part work. The preprocessor was the first step towards cfront, which was the first C++ compiler.

    As a more practical example, I have worked on a C++ simulator that simulated a graphics chip. But I also know of companies that still have huge fortran programs that are used for various forms of simulation.


    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    I was searching in wiki about C++ application domains where simulation is not listed.I saw
    an banner on the game programming institutes's site which read "Make interactive application
    and simulation for military".The language they are using is c++ so I was curious to know
    what's the role of c++ in that kind of simulation that's why I tickled you with an question.

    Thanks for the details and your time.

    best regards,
    Chakra

  4. #4
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    937
    For what it's worth, I've found C++ to be indispensable for scientific simulations. While some newer language might be better fitted to a particular task, I've found that C++ has just the right balance of performance and power. Modeling some very object-ish physics concept in a plain old procedural language is a drag, and writing expensive simulations in a super high-level language would make you grow old.
    There's my two cents.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Well, I don't think there are many application types that can NOT be written in C++, and simulations was one of the first things C++ was being used for (before the name C++ was even invented, I'd hazard a guess).

    Whether C++ is the right language for simulations is of course a different matter. I can't say that it is or isn't. It would depend on WHAT you are simulating. Just like any other application being ideally written in language X depends on what the application actually does - some applications are better off written in language Y or language Z, because the language has special strengths that help it perform the type of tasks that are needed. For example, php is used for web-sites, because it has a good set of string handling and conversion from arrays to strings, numbers to strings, etc, etc. It would be POSSIBLE to do all the code neeed to run this forum in C++ - but it would be unsuitable, as the majority of the time spent processing this forum is in the database entries where the posts are, rather than the production of the HTML content that appears as a result of the PHP code. C++ would be faster, but it would take longer to develop.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    I learned that Maths and Physics are more important than a programing language when
    it comes to programming simulation software.

    one more question,is there a language other than c/c++ which can do console game programming?


    thanks for your reply

    best regards ,
    Chakra

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by CChakra View Post
    I learned that Maths and Physics are more important than a programing language when
    it comes to programming simulation software.

    one more question,is there a language other than c/c++ which can do console game programming?


    thanks for your reply

    best regards ,
    Chakra
    Maths and even more so physics is obviously important if you are simulating an aeroplane flying (Flight Simulator) or a the tire-deflection on a formula one car going around a particular corner at a particular speed and with a particular fuel-load (and probably all other parameters that affect the tire deflection on a corner) (this is just one example of "Engineering simulation", another example would be crash-test simulations - instead of building a nearly complete car and driving it into a concrete wall, simulate it in a computer, and only when the manufacturer is reasonable sure that it's OK, run a car into a concrete wall to see that the simulation is correct).

    Simulating a post-office queue probably hasn't got that much to do with raw maths.

    Simulating a processor chip will have very little to do with pure math or physics (at least as long as we're using a "logic level simulator"), as all of the simulation is logical levels - something is either 0, 1 or "floating" (X). There is no real need for math in this case.

    Console = Gaming Consoles like XBox or PS<2, 3>, or Console as in command prompt/shell? If we assume that it's the former, programming languages here are defined by the availability of the relevant tools, and that in turn is controlled by access to development kits and the ability to compile relevant compilers and libraries in those dev kits. My guess would be that nearly all of those games consoles are strictly using C and C++ and nothing much else. That's not because it's not possible to develop a Fortran or ADA compiler for those machines, but because there is no commercial benefit in having a Fortran or ADA compiler for the machines - no company is going to pay money to have a Fortran compiler for a Xbox - so there's no company interested in developing a compiler. There may be individuals willing to spend the time getting gfortran to work on such a platform, but it may be quite a bit of work to get that going - and what's the real benefit.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    76
    Code:
    while(true)
    {
    cout<<"thanks Mats :)";
    }
    Even if you know I have nothing to do with all of this crap(crap for me ,hehe),you replied
    and spent your precious time.The word 'great' is suitable for people like you.

    I asked this kind of unrelated questions because it will help me in group discussions ,
    debate ,seminar and developing strong general knowledge.This kind of knowledge is
    beyond from ordinary book knowledge and can only be found in great forum like this.

    best regards,
    Chakra

  9. #9
    Registered User
    Join Date
    Jan 2007
    Location
    Euless, TX
    Posts
    144
    If I may add a few more cents to the "simulation" question. I work on commercial level flight simulation systems. Most of the coding is now done in C. I believe the main reason for this was the simpler way of converting the old Fortran code to C rather than try to re-create the Fortran code to C++. I assume it is/was a money issue in getting the code to market in the cheapest way possible and still retain it's accuracy and fidelity.

    Some of the military use Ada, which was developed specifically with the military mission in mind. However, a good portion of 'military' simulation code is also done in C. There are many more C programmers out there than there are Ada programmers. Especially those that can gain clearance access or who already have that access.

  10. #10
    Registered User
    Join Date
    Nov 2006
    Posts
    519
    The military simulations I know are written in C (if we're talking about the core simulation and image generation part). Newer ones in C++.
    If it comes to GUIs I saw nearly everything which is able to interface C/C++...VB, Java, C(++) itself....

    Reason is of course speed. While the simulations run in distributed systems so one could argument like add another set of CPUs and program in java/basic/whatver, the finished simulator may end up beeing deployed in 1,5 or two air-conditioned buildings cluttered up with hardware instead of only a single one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Software Design/Test - Redmond, WA
    By IRVolt in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 06-11-2008, 10:26 AM
  2. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  3. Adding trial period to software
    By BobS0327 in forum C Programming
    Replies: 17
    Last Post: 01-03-2006, 02:13 PM
  4. software licences
    By trekker in forum Tech Board
    Replies: 3
    Last Post: 06-17-2003, 08:37 AM