Thread: Compares C++ and Pascal

  1. #1
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187

    Question Compares C++ and Pascal

    I used to compare Object Pascal (Delphi) with Borland C++5.0 with several source programs. All programs written in same algorithm. I found that for all cases, Object Pascal can run faster than BC++, moreover Object Pascal generates much smaller size of exe files. I question that why so many people say C++ is faster and smaller, is it correct?
    Remark All programs are tested on Windows 2000's command prompt. Programs written with BC++, I abbreviated the codes as much as possible (idioms) and debug informations were removed.
    May I ask the following questions.
    1. which one is smaller and faster?
    2. If I want smaller size of exe file translated from C++, how shall I do? (As I tested, exe file translated from C++ consumes at least 40 KB, to write application of 10 KB is not possible, but it's possible for Object Pascal and Assembly)

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    I've always heard the same thing, so your results are interesting. I think what we've heard is wrong, because it just doesn't make any sense. Aseembly is very close to the system. In fact, it's about as close as you're going to get to the system with out using binary and microcode chips! Being close to the system, you have a lot of control, and you use just what you need. C++ will bring in tonnes of libraries that you'll probably never use. C++ is useful because it's high level language structure makes it easy to program with, but ASsembly and Object Pascal are powerful. It really depends on what you want in a language and the project you're working on, but I agree completely with your results.

  3. #3
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Aseembly is very close to the system. In fact, it's about as close as you're going to get to the system with out using binary and microcode chips!
    You where right till you got to binary, binary doesnt let you do anything more than you can do with assembly, it just makes it hard to understand!
    VC++ 6

  4. #4
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187

    Thumbs up Thanks for yr comments

    Yr comments r very useful.

    Thx a lot.

  5. #5
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    ACtually it does. It's in a PC storable format. You can store things on microprocessors with a bse 256 system yet. There's a big difference between 256 and 2. It's 254 if I'm not mistaken.

  6. #6
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Sorry Sean, I dont have a clue what your talking about! If your talking about he diffrence between Hex and Binary there is none i.e. 0x0A = 00001100b and 00001100b = 0x0A. They are entirely the same, just a different way of representing numbers. The computer does store at as binary, but it doesnt care if it was binary, hex or even decimal to begin with.

    BTW hex is base 16 and binary is base 2.
    VC++ 6

  7. #7
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    I found that for all cases, Object Pascal can run faster than BC++, moreover Object Pascal generates much smaller size of exe files.
    Very interesting. At university we started learning Pascal and then C, C++ and Java. Mainly because a lot of companies use it these days. But Pascal stayed one of my favourite languages, its a very elegant language and nice to read.

    But I guess these results are compiler dependent isn't it? Or is Object Pascal a more efficient/faster/smaller language than C++?

    I noticed that Pascal and C can do the same things and when using a good compiler, there are no big differences when it comes to speed and size. So I was really wondering why C came up, but I guess it has to do with the popularity of the Unix OS.

  8. #8
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    Originally posted by Shiro


    But I guess these results are compiler dependent isn't it? Or is Object Pascal a more efficient/faster/smaller language than C++?

    I absolutely agree with Shiro. It's compiler dependent.

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    True - but I think on average is what he's asking. The characters are essentially a base 256 system. Computer do store it in binary. YOu just don't see the 1's and 0's. Instead, parts of the disk are either magnetized (1), or not (0). Getting it into binary is a huge step towards putting it on the computer.

  10. #10
    Registered User VBprogrammer's Avatar
    Join Date
    Mar 2002
    Posts
    175
    Sean the only base 256 system i can think of is Octal, something even low level programmers rearly have to deal with.

    Unless your talking about sticking wires into your computer to try to program it (do not try that at home) converting numbers to binary does pretty much nothing, apart from making it look wierd!
    VC++ 6

  11. #11
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    OK, now would be a good time for you to go and learn about number systems. Octal is base 8, hence the name Octal. Characters - 256 of them. They can be represented by a base 256 number system. In BASIC for example, if you imagine each character as a = 1, b = 2, etc.. until z = 26. You can do math operations on strings. AZ > AY, AZ < ZA.

  12. #12
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Here is my 2 cents. When I was doing DOS stuff I used Turbo C and then I started doing windows programming and began to us mingw. Well I found that GCC's output was much faster and smaller than the Borland Compilers. When comparing GCC to GPC (gnu c compiler versus gnu pascal compiler) you will find that gcc produces similar results. So to me your results are inconsequential since you are using a crappy c compiler. And a decent pascal compiler. Besides, what you are doing isn't exactly how they do benchmarks. Using your logic if I put my thumb in the air and it obscures the sun I could say "My thumb is bigger than the sun."

  13. #13
    Registered User quagsire's Avatar
    Join Date
    Jun 2002
    Posts
    60
    If you disable the exception handling and RTTI, the executable size drops. Also make sure that the compilers don't include the debug info. The executable size should then be much smaller.

  14. #14
    still a n00b Jaguar's Avatar
    Join Date
    Jun 2002
    Posts
    187
    Originally posted by quagsire
    Also make sure that the compilers don't include the debug info. The executable size should then be much smaller.
    As stated in my first sentence I had already removed debug info. But anyway I have known that it's compiler-dependent. My opinion BC++ is not a good compiler. Even getchar() not functioning properly on win32 and it lacks stability. Have anyone ever felt this?

Popular pages Recent additions subscribe to a feed