[offtopic] FreePascal

For other topics related to the FreeBASIC project or its community.
bitbeisser
Posts: 1
Joined: Jun 01, 2018 20:52

[offtopic] FreePascal

Postby bitbeisser » Jun 01, 2018 21:15

(Split from viewtopic.php?p=216866#p216866)
badidea wrote:http://www.freepascal.org/ A lot of platforms supported, but how does it look like, and how to start.
Sorry, but being a long time (Free)Pascal user, I am a bit confused about that comment about FreePascal.

FreePascal, by itself, is a command line compiler, so no sure what you expect it to "look like" and what exactly you mean by "how to start". Most information can be found at the Wiki, at http://wiki.freepascal.org/, including tutorials...

If you are referring in terms of a GUI, that is a separate project, though directly associated with FreePascal, called Lazarus.

https://www.lazarus-ide.org/

The Lazarus downloads also include the matching FPC compiler and sources. As well as some cross-compiler versions (incl. iOS and Android).

I am using it as my main development environment on Windows (7, 8.1 and 10), Linux (mostly Mint 18.2 right now) and macOS (though the latest XCode update to 9.4 borked something, and just when checking, there's a new macOS update to 10.13.5 out today as well).
Also running Lazarus on my Raspberry Pi 3+, though more for debugging than actual development.

Ralf
badidea
Posts: 974
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: New website

Postby badidea » Jun 01, 2018 22:06

bitbeisser wrote:
badidea wrote:http://www.freepascal.org/ A lot of platforms supported, but how does it look like, and how to start.
Sorry, but being a long time (Free)Pascal user, I am a bit confused about that comment about FreePascal.

Pretty sure it wasn't me who said the above :-)
edit: oh, it was me. My memory does not go back 2 years :-)
jj2007
Posts: 851
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: New website

Postby jj2007 » Oct 10, 2018 13:58

bitbeisser wrote:FreePascal, by itself, is a command line compiler, so no sure what you expect it to "look like" and what exactly you mean by "how to start".
Compiling a program is very simple.:

Code: Select all

@echo off
echo.
echo *** compiling %1 ***
echo.
set MyExe=%~n1.exe
if exist %MyExe% del %MyExe%

\FPC\3.0.4\bin\i386-win32\fpc.exe -v0 "%1"
echo.
if exist %MyExe% (
  echo *** running %~n1.exe ***
  %MyExe%
) else (
  echo *** compilation error, no %~n1.exe - sorry! ***
)
See also here. Killing the exe and checking for the existence of the new exe is needed because fpc.exe "forgets" to set ERRORLEVEL. Seems a bad Linux habit, I've seen that mainly with gcc toolchains.
Last edited by jj2007 on Oct 10, 2018 16:48, edited 1 time in total.
caseih
Posts: 1297
Joined: Feb 26, 2007 5:32

Re: New website

Postby caseih » Oct 10, 2018 14:24

Guess I don't quite understand, jj. That same batch file could be modified to compile and run BASIC programs with FBC. I've done something similar with FBC for years on Linux.

I'm not sure why these tools don't set the errorlevel. They seem to properly set the return code in Linux.
jj2007
Posts: 851
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: New website

Postby jj2007 » Oct 10, 2018 16:47

caseih wrote:I'm not sure why these tools don't set the errorlevel.
Oops, I checked again: they do set the errorlevel. I stand corrected. Stupid error - I forgot to put the % around errorlevel:

Code: Select all

IF ERRORLEVEL==0 echo WRONG
IF %ERRORLEVEL%==0 echo RIGHT
marcov
Posts: 2627
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: [offtopic] FreePascal

Postby marcov » Oct 11, 2018 16:09

JJ2007, that batchfile looks complicated. Such functionality works out of the box, just do (if you have fpc bin dir in path):

Code: Select all

instantfpc  <sourcefilename>


which compiles and runs it.
jj2007
Posts: 851
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: [offtopic] FreePascal

Postby jj2007 » Oct 11, 2018 16:23

Sure? It works, but I don't see the corresponding exe. There is the instantfpc process, though - maybe it's interpreted Pascal?
marcov
Posts: 2627
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: [offtopic] FreePascal

Postby marcov » Oct 11, 2018 16:26

jj2007 wrote:Sure? It works, but I don't see the corresponding exe. There is the instantfpc process, though - maybe it's interpreted Pascal?


No, it makes an exe in some temp dir.
jj2007
Posts: 851
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: [offtopic] FreePascal

Postby jj2007 » Oct 11, 2018 16:56

Yes, that's what I also found out in the meantime - some distant obscure local\temp\etc folder. Not so nice actually, I prefer to see the exe next to the source.
marcov
Posts: 2627
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: [offtopic] FreePascal

Postby marcov » Oct 11, 2018 17:00

jj2007 wrote:Yes, that's what I also found out in the meantime - some distant obscure local\temp\etc folder. Not so nice actually, I prefer to see the exe next to the source.


Set environment variable INSTANTFPCCACHE=.
jj2007
Posts: 851
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: [offtopic] FreePascal

Postby jj2007 » Oct 11, 2018 17:07

OK, thanks. I've been playing with FPC\3.0.4\demo\win32\winhello.pp, pretty straightforward. Here is the MasmBasic equivalent:

Code: Select all

GuiParas equ "Hello World program", x400, y300, w300, h100
include \masm32\MasmBasic\Res\MbGui.asm
Event Paint
  invoke GetClientRect, hWnd_, addr rc_
  invoke DrawText, PtDC, Chr$("Hello World by MasmBasic"), -1, addr rc_, DT_SINGLELINE or DT_CENTER or DT_VCENTER
GuiEnd
The FPC version creates a shorter exe, though, 32k against MB's 44.5k. Too much overhead ;-)
marcov
Posts: 2627
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: [offtopic] FreePascal

Postby marcov » Oct 11, 2018 19:18

jj2007 wrote:
GuiEnd[/code]The FPC version creates a shorter exe, though, 32k against MB's 44.5k. Too much overhead ;-)


FPC is not really optimized for binary size. So if it beats some other tool, that other tool is really bad :-)
Carlos Herrera
Posts: 62
Joined: Nov 28, 2011 13:29
Location: Dictatorship

Re: [offtopic] FreePascal

Postby Carlos Herrera » Oct 11, 2018 21:39

@marcov
I am in the process of migrating from fbc to fpc. I hope that Free Pascal is as fast as Free Basic.
Is it also a kind of gcc emitter?
Carlos
jj2007
Posts: 851
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: [offtopic] FreePascal

Postby jj2007 » Oct 12, 2018 2:13

marcov wrote:So if it beats some other tool, that other tool is really bad :-)
Hmmm... I made some quick tests following roughly the test case in the 64-bit asm woes thread, and it seems that 'the other tool' is a factor 3 or so faster than Free Pascal (but FPC is a bit faster than FB). But indeed, the other tool's exe might be a bit bloated ;-)
marcov
Posts: 2627
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Re: [offtopic] FreePascal

Postby marcov » Oct 12, 2018 8:31

jj2007 wrote:
marcov wrote:So if it beats some other tool, that other tool is really bad :-)
Hmmm... I made some quick tests following roughly the test case in the 64-bit asm woes thread, and it seems that 'the other tool' is a factor 3 or so faster than Free Pascal (but FPC is a bit faster than FB). But indeed, the other tool's exe might be a bit bloated ;-)


From what I can see that is natural. FPC has a higher level string type that is safe and fairly convenient, and as alternative going to rock bottom pointer to char handling. Probably the masmbasic default is closer to the latter.

Return to “Community Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests