Thread: AI Programming language

  1. #16
    Registered User knightjp's Avatar
    Join Date
    Nov 2008
    Location
    Dubai, U.A.E.
    Posts
    15
    Quote Originally Posted by Elysia View Post
    I would recommend C++ if your platform supports it (and if you choose to go C/C++), because it's higher level than C, and higher level always means making it easier for you. As well, it is a somewhat modern language with powerful features and tools - but the best thing is that in case you need to go lower, then C++ is backwards compatible with C and hence you can do those lower parts in C, too. Or you can compile them using a C compiler, if you wish.

    And let's be fair about one thing - the myth that C is faster than C++ just is not true. They have advantages and disadvantages and are thus about equal in speed.

    C and C++ can sometimes also deal with assembly, although it's tricky and requires safety guidelines.
    My thought was that lower would be more difficult, but the application's speed would be better. Higher, easier to program, but slower run speed.
    True?? Or does that all depend on the programmer?

  2. #17
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    Quote Originally Posted by knightjp View Post
    My thought was that lower would be more difficult, but the application's speed would be better. Higher, easier to program, but slower run speed.
    True?? Or does that all depend on the programmer?
    In general lower == faster, but programmer skill can generalyl have a big impact on that, a great GW-BASIC programmer can write code that beats crappy assembly. but a good assembly writer can produce the fastest code possible. Ultimatelyassembly has teh potential to be as fast or faster than any other language, but ti takes programmign skil to unlock that potential.

  3. #18
    Registered User knightjp's Avatar
    Join Date
    Nov 2008
    Location
    Dubai, U.A.E.
    Posts
    15
    Quote Originally Posted by abachler View Post
    In general lower == faster, but programmer skill can generalyl have a big impact on that, a great GW-BASIC programmer can write code that beats crappy assembly. but a good assembly writer can produce the fastest code possible. Ultimatelyassembly has teh potential to be as fast or faster than any other language, but ti takes programmign skill to unlock that potential.
    So what you are saying is that a programs speed depend not on just the language its written, but also in the skill of the programmer.
    So a skilled C programmer can write a program that runs faster than a program written in C++?

    I apologise for being an ignorant fool in asking so many questions, but I would just like to be sure before I spend time learning a language and getting started on my project.
    Last edited by knightjp; 11-26-2008 at 11:13 PM.

  4. #19
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by knightjp
    So what you are saying is that a programs speed depend not on just the language its written, but also in the skill of the programmer.
    Yes, and that holds true regardless of programming language.

    Quote Originally Posted by knightjp
    So a skilled C programmer can write a program that runs faster than a program written in C++?
    Not likely, since with a few tweaks of that C program (or none at all) it probably could become a C++ program.

    Quote Originally Posted by knightjp
    Is there any way to learn assembly online??
    Yes. Search the Web to find out.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #20
    Malum in se abachler's Avatar
    Join Date
    Apr 2007
    Posts
    3,195
    There are plenty of resources on the web for learnign assembly. Intel has some very in depth pdf manuals on their processors that are free to download. I think AMD offers stuff too.

    A question asked in search of understanding, is never a sign of a dull wit.
    Last edited by abachler; 11-26-2008 at 11:18 PM.

  6. #21
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by knightjp View Post
    So a skilled C programmer can write a program that runs faster than a program written in C++?
    From a language perspective code in C++ is neither faster nor slower than code written in C, given good quality compilers for both languages. As both languages have a common base, and the resulting code for the same source code should have the same performance and give the same result.

    C++, however, supports a higher level language, which can be used to make the code simpler. If the "make the code simpler" is used incorrectly, it may offer higher productivity for the programmer but at the cost of performance. However, that is not a necessity. There are good ways and bad ways to write code in all languages.

    Writing good code in any language requires a good understanding of the language and the algorithms for the problem. The choice of algorithm is often the most critical aspect of any part of the optimization/performance of any application - if we pick the wrong sorting algorithm to sort 1 million elements, it will take 1 million times 1 million iterations to sort it. With the right algorithm, it is 1000 times faster. That is just one example of many such things.

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

  7. #22
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by knightjp View Post
    So a skilled C programmer can write a program that runs faster than a program written in C++?
    No. C++ was designed to be a fast, native language which lends tools and features from other paradigms to get the job done.
    It was to be an evolution of C, and maintain backwards compatibility, and so it does.
    All in all, C++ is a very fast, blazingly fast language, like C, with very little overhead.
    It's true that using some tools, it may be a little slower than C, say 10% or so (taken from a recent vector of vector vs dynamic array test).

    But you can do all that in C within C++, as well, giving additional flexibility, when the necessity arises.
    Anyhow, C++ also features things that C could only dream of, and it becomes at very little performance cost. Being able to automatically clean up resources. Great facilities for code reuse. Lots of finished, tested and flexible code for things such as dynamic arrays.

    It also has the ability to perform a lot of work at compile time, saving execution time where C would have to do it all in runtime.
    So it all evens out.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #23
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    A skilled C programmer can write a program that's faster than a poorly written C++ program.
    A skilled Basic programmer could probably do the same...

    All languages have their strengths and weaknesses, but most often those are less of a factor in runtime performance of the generated executables than are outside factors like the skill of the people writing the code, the compiler and how it was used, the hardware on which it runs, network and disk latency, etc. etc.

    And most often those differences are not a problem in real world use of the programs.
    For example a program that spends 90% of its time waiting for user input isn't going to benefit from some clever bit of coding that makes the other 10% of the code 1% faster.
    A program that's going to be running for hours or days at a time isn't going to benefit from having its startup time reduced from seconds to milliseconds.

  9. #24
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Quote Originally Posted by jwenting View Post
    A skilled C programmer can write a program that's faster than a poorly written C++ program.
    A skilled Basic programmer could probably do the same...
    And...
    a skilled C++ programmer can write a program that's faster than a poorly written C program.
    A skilled Visual Basic programmer could probably do the same...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #25
    Registered User knightjp's Avatar
    Join Date
    Nov 2008
    Location
    Dubai, U.A.E.
    Posts
    15
    Looks like 'C' has the vote and considering that this is a forum for C programming, I'm not surprised. C is the choice here and I'm pretty sure that's good enough for me.

  11. #26
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    This is a forum for C and C++ programming.
    For AI, I am willing to bet C++ has an advantage over C.
    Especially due to OO programming.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #27
    Registered User knightjp's Avatar
    Join Date
    Nov 2008
    Location
    Dubai, U.A.E.
    Posts
    15
    Quote Originally Posted by Elysia View Post
    This is a forum for C and C++ programming.
    For AI, I am willing to bet C++ has an advantage over C.
    Especially due to OO programming.
    I did hear that C didn't have Object Oriented programming capabilities. Is that true or is it that its harder to do when compared with C++?

  13. #28
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    C does not have OO capabilities.
    You can emulate it, sure, but it will a lot of pains and headaches and probably hurt performance, as well.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  14. #29
    Registered User knightjp's Avatar
    Join Date
    Nov 2008
    Location
    Dubai, U.A.E.
    Posts
    15
    Quote Originally Posted by Elysia View Post
    C does not have OO capabilities.
    You can emulate it, sure, but it will a lot of pains and headaches and probably hurt performance, as well.
    Thanks for the info....
    What about memory management? Does C++ have ways to manage the RAM usage when a program is running?

  15. #30
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    What does manage RAM usage mean?
    You use what resources you need and free them when you don't need them. Otherwise you get a memory leak.
    Do you have to do memory management manually in C++? No, you can use smart pointers to handle that for you.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Why C Matters
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 136
    Last Post: 01-16-2008, 09:09 AM
  2. chess ai contest
    By Raven Arkadon in forum Contests Board
    Replies: 7
    Last Post: 07-09-2005, 06:38 AM
  3. AI Contest Proposal
    By MadCow257 in forum Contests Board
    Replies: 4
    Last Post: 03-13-2005, 03:27 PM
  4. Language of choice after C++
    By gandalf_bar in forum A Brief History of Cprogramming.com
    Replies: 47
    Last Post: 06-15-2004, 01:20 AM
  5. Game Design Topic #1 - AI Behavior
    By TechWins in forum Game Programming
    Replies: 13
    Last Post: 10-11-2002, 10:35 AM