|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
||||
|
||||
|
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. |
|
#2
|
||||
|
||||
|
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. |
|
#3
|
||||
|
||||
|
Quote:
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? |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
||||
|
||||
|
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. =)
|
|
#6
|
||||
|
||||
|
Quote:
Cool |
|
#7
|
||||
|
||||
|
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.
|
|
#8
|
|||
|
|||
|
Quote:
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() ). |
|
#9
|
||||
|
||||
|
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.
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev |
|
#10
|
||||
|
||||
|
Quote:
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:
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. Last edited by Yegg` : July 19th, 2006 at 07:07 PM. |
|
#11
|
||||
|
||||
|
Thanx for the update Yegg
![]() |
|
#12
|
||||
|
||||
|
Quote:
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 |