Other Programming Languages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreOther Programming Languages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 17th, 2006, 11:24 AM
lingon's Avatar
lingon lingon is offline
C++arl!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Location: Stockholm
Posts: 165 lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 5 h 59 m 35 sec
Reputation Power: 12
C++ and pascal

I made this fibonacci-series program in C++ and in pascal and noted that the pascal version is 150k and the C++ is 464k. How can there be such a difference in size?

The pascal code:
Code:
program fibbonacci;
uses
  crt;
var
  x, y, temp : longint;
  p, i : byte;
begin
  clrscr;
  writeln('This program handles the fibonacci series');
  write('Enter length of series:');
  readln(p);
  i := 1;
  x := 1;
  y := 0;
  while i <= p do begin
    inc(i);
    temp := x;
    x := y;
    y := temp+y;
    write(y, ' ');
  end;
  writeln();
  writeln('Press ENTER.');
  readln();
end.

And this is the C++ code:
Code:
#include<iostream>

using namespace std;

int main(){
         int x;
         int y;
         int temp;
         int i;
         
         cout<<"This program handels the fibonacci series \n";
         cout<<"Enter length of series:";
         cin>>i;
         cin.ignore();
         x = 1;
         y = 0;
         for (int p = 1; p<=i; p++){
             temp = x;
             x = y;
             y = x+temp;
             cout<<y<<" ";
             }
         cout<<endl<<"Press ENTER.";   
         cin.get();
         }

Could this be because some big unit that C++ uses? Oh yeah, I use FPC and Bloodshed Dev-C++ compilers.

Reply With Quote
  #2  
Old July 17th, 2006, 12:19 PM
Yegg`'s Avatar
Yegg` Yegg` is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Dec 2004
Location: Meriden, Connecticut
Posts: 1,676 Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 13 h 50 m 24 sec
Reputation Power: 68
Send a message via AIM to Yegg`
With FreePascal, I always have issues when compiling, everything seems to compile to a very large size, it wasn't like that for me in past versions. As for the C++, sounds like you may be compiling in Debug Mode. Make sure it is set to Release Mode when you compile.

FPC lets you use a certain directive within source codes so that when another source imports that source, the first source only exports what the second source uses. This should cut back on the size of the produced executable. I'm guessing that the sources that are used in your program by default, such as System do not have this directive in their source. And you cannot figure out if they have it or not because it is not Pascal code that you can view of System (as well as other libraries that come with FPC), it is something output by FPC that converts the Pascal to maybe byte-code? But they are usually in .ppu files and you cannot see Pascal code from them.

Last edited by Yegg` : July 17th, 2006 at 12:22 PM.

Reply With Quote
  #3  
Old July 19th, 2006, 03:51 AM
lingon's Avatar
lingon lingon is offline
C++arl!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Location: Stockholm
Posts: 165 lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 5 h 59 m 35 sec
Reputation Power: 12
Quote:
Originally Posted by Yegg`
With FreePascal, I always have issues when compiling, everything seems to compile to a very large size, it wasn't like that for me in past versions. As for the C++, sounds like you may be compiling in Debug Mode. Make sure it is set to Release Mode when you compile.

Nothing to do about the size of the pascal exe then =(, but how do you change the C++ debug mode (noob warning) to normal mode cuz I didnt find any 'release mode' (or something like that) option in the compiler options menu and I cant recall activley uisng the debuger. BTW, wich C++ compiler do you think is the best?

Reply With Quote
  #4  
Old July 19th, 2006, 04:32 AM
displeaser's Avatar
displeaser displeaser is offline
Periodically energetic Perler
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: May 2005
Location: Dublin, Ireland
Posts: 2,266 displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 76661 Folding Title: Intermediate FolderFolding Points: 76661 Folding Title: Intermediate FolderFolding Points: 76661 Folding Title: Intermediate FolderFolding Points: 76661 Folding Title: Intermediate Folder
Time spent in forums: 4 Weeks 5 h 23 m 13 sec
Reputation Power: 532
what compiler are you using?

In dev c++, in the project options, there is a "compiler options" tab, clicking on this and then linker you will see an option "generate debugging information". Most compilers will have something similar.

which compiler is the best depends on how much you are going to spend.

2 good free ones for windows (and probably linux to but I dont know):
Dev c++
lcc

Microsoft have released Visual C++ Express edition for free. I've never used it myself.

Hope this helps.
Displeaser
__________________
Vi Veri Veniversum Vivus Vici.

Reply With Quote
  #5  
Old July 19th, 2006, 12:14 PM
lingon's Avatar
lingon lingon is offline
C++arl!
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2006
Location: Stockholm
Posts: 165 lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level)lingon User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Day 5 h 59 m 35 sec
Reputation Power: 12
Thnx man. I used the Dev-C++ 5 wich is at the moment a beta version so I switched to version 4 and when I compile the same source as above it compiles to a nice and handy 72k exe. =)

Reply With Quote
  #6  
Old July 19th, 2006, 01:53 PM
displeaser's Avatar
displeaser displeaser is offline
Periodically energetic Perler
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: May 2005
Location: Dublin, Ireland
Posts: 2,266 displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)displeaser User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 76661 Folding Title: Intermediate FolderFolding Points: 76661 Folding Title: Intermediate FolderFolding Points: 76661 Folding Title: Intermediate FolderFolding Points: 76661 Folding Title: Intermediate Folder
Time spent in forums: 4 Weeks 5 h 23 m 13 sec
Reputation Power: 532
Quote:
Originally Posted by lingon
Thnx man. I used the Dev-C++ 5 wich is at the moment a beta version so I switched to version 4 and when I compile the same source as above it compiles to a nice and handy 72k exe. =)


Cool

Reply With Quote
  #7  
Old July 19th, 2006, 03:34 PM
Yegg`'s Avatar
Yegg` Yegg` is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Dec 2004
Location: Meriden, Connecticut
Posts: 1,676 Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 13 h 50 m 24 sec
Reputation Power: 68
Send a message via AIM to Yegg`
For Visual C++ on Windows, I prefer Microsoft Visual C++ 6. I can't recommend software piracy on these forums. Do what you need to get a copy, if you're that into C++ for Windows then I do recommend it, it's my favorite.

Reply With Quote
  #8  
Old July 19th, 2006, 03:50 PM
Oler1s Oler1s is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2006
Posts: 1,490 Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Oler1s User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 4 Weeks 19 h 36 m 20 sec
Reputation Power: 440
Quote:
Originally Posted by Yegg`
For Visual C++ on Windows, I prefer Microsoft Visual C++ 6. I can't recommend software piracy on these forums. Do what you need to get a copy, if you're that into C++ for Windows then I do recommend it, it's my favorite.


If you have access to Visual Studio .NET 2005, definitely use that for Windows development. It's compiler is amazingly good and optimizes very well.

A suitable alternate, and for free, is using MinGW (a Win32 port of gcc) and the code blocks IDE.

There is one more thing to note. The code can be compiled down into a very small size, mingw or VS. First, you are using the iostream library. Nothing wrong with this, but if you are interested in small file size, using the C output functions is worthwhile.

Not good enough? You can disable the default libraries assumed by the compiler. Include windows.h, and use a messagebox for output. Be sure to use WinMainCRTStartup (not main() ).

Reply With Quote
  #9  
Old July 19th, 2006, 03:53 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonder.
Posts: 5,543 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Weeks 1 Day 22 h 42 m 5 sec
Reputation Power: 378
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook
Talking about pascal, You know I never tried or seen any pascal codes, Can someone post up an example so I can see how it looks.

Reply With Quote
  #10  
Old July 19th, 2006, 07:04 PM
Yegg`'s Avatar
Yegg` Yegg` is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Dec 2004
Location: Meriden, Connecticut
Posts: 1,676 Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 13 h 50 m 24 sec
Reputation Power: 68
Send a message via AIM to Yegg`
Quote:
Originally Posted by xlordt
Talking about pascal, You know I never tried or seen any pascal codes, Can someone post up an example so I can see how it looks.


Code:
function IsRegistered (Account : string) : boolean;

var

   dbFile : text;

   data   : string;



begin

   IsRegistered := FALSE;

   assign (dbFile, 'database.db');

   reset (dbFile);

   while not eof (dbFile) do begin

      readln (dbFile, data);

      if data = concat ('  Account:', Account) then begin

         IsRegistered := TRUE;

         close (dbFile);

         exit;

      end;

   end;

   close (dbFile);

end;


I wrote this when working on a server in Pascal using FreePascal.

Quote:
Originally Posted by Oler1s
If you have access to Visual Studio .NET 2005, definitely use that for Windows development. It's compiler is amazingly good and optimizes very well.

A suitable alternate, and for free, is using MinGW (a Win32 port of gcc) and the code blocks IDE.

There is one more thing to note. The code can be compiled down into a very small size, mingw or VS. First, you are using the iostream library. Nothing wrong with this, but if you are interested in small file size, using the C output functions is worthwhile.

Not good enough? You can disable the default libraries assumed by the compiler. Include windows.h, and use a messagebox for output. Be sure to use WinMainCRTStartup (not main() ).


IIRC, .NET wants Windows 2000 and up? .NET also won't work properly with WINE. Microsoft Visual C++ 6 will compile programs for Windows 95 as well as Vista, doesn't rely on .NET, is very simple and efficient, uses the Windows API which works better with WINE.

Compatibility with WINE is not important, but I think it's cool to have.

I've never had a problem with MSVC++ 6. I like how it uses much less resources than MSVC++ 2005 Express.
Comments on this post
xlordt agrees: So thats pascal nice.

Last edited by Yegg` : July 19th, 2006 at 07:07 PM.

Reply With Quote
  #11  
Old July 19th, 2006, 08:37 PM
xlordt's Avatar
xlordt xlordt is offline
Only the strong survives!!.
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Feb 2003
Location: A World of wonder.
Posts: 5,543 xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)xlordt User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1Folding Points: 108894 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 4 Weeks 1 Day 22 h 42 m 5 sec
Reputation Power: 378
Send a message via ICQ to xlordt Send a message via AIM to xlordt Send a message via MSN to xlordt Send a message via Yahoo to xlordt Send a message via Google Talk to xlordt Send a message via Skype to xlordt
Facebook
Thanx for the update Yegg

Reply With Quote
  #12  
Old July 19th, 2006, 09:50 PM
Yegg`'s Avatar
Yegg` Yegg` is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Dec 2004
Location: Meriden, Connecticut
Posts: 1,676 Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level)Yegg` User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 13 h 50 m 24 sec
Reputation Power: 68
Send a message via AIM to Yegg`
Quote:
Originally Posted by xlordt
Thanx for the update Yegg


If you're one to use Visual Basic, or are considering Visual Basic, I recommend Pascal (definately FPC (FreePascal Compiler)) over VB ANY day! FreePascal works on many operating systems, the Gameboy Advance port has much success. VB limits you to one OS and IMO, has less power than Pascal. FPC also has Lazarus. Lazarus is a very nice, drag-and-drop RAD IDE for Pascal, IIRC using specifically FPC. Here is a screenshot of Lazarus, I've never used it but it looks great, and IIRC it runs on multiple platforms, which includes Windows.

http://www.osnews.com/img/10607/Lazarus.gif