FB 64bit

General FreeBASIC programming questions.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Postby AGS » Nov 20, 2009 19:47

Emitting C code is something that's being done by quite a few programming language projects. There's SmartEiffe,ATS,LISAAC,OpenDYLAN, Euphoria etc... All of these languages come with a compiler that produces C code.

The reason for this willingness to produce C code has to do with

- the effort that has gone into building optimizing C compilers;
- the widespread availability of C compilers;
- the unwillingness of developers to learn all sorts of assembler idioms.

Developers might not like programming in C but at least when targeting C you only have to learn one programming language (C) as opposed to a bunch of different sets of assembler mnemonics when targeting assembler.

Since a C compiler produces code that's pretty close to what could be achieved when writing a program in assembler targeting C makes sense.

I'm getting the impression marcov is not too thrilled about the idea of a compiler targeting anything but assembler. And the idea of a compiler targeting FreePASCAL.....

My opinion on the whole targeting issue: creating software should be fun. And I would have a lot more fun trying to translate FB to FP than I would have translating FB to C. I don't like C, I do like FP.

It might make more sense to target C (or assembler) but as an amateur programmer I find having fun while programming to be more important than doing things that make sense.

FB2C: nea.
FB2FP: yea.
stylin
Posts: 1253
Joined: Nov 06, 2005 5:19

Postby stylin » Nov 20, 2009 19:54

AGS, well, let us know when you get that done. :D
Richard
Posts: 2942
Joined: Jan 15, 2007 20:44
Location: Australia

Postby Richard » Nov 20, 2009 20:59

AGS wrote:
as an amateur programmer I find having fun while programming to be more important than doing things that make sense.

I agree with you.
No one wants to stop you having fun writing an FB 2 FP converter. The language / tool you use to write that translator is up to you, but I am sure you would want that tool to be available and work reliably. That tool might be FB. For that reason, the choice of FB emitter has been made on pragmatically stoic grounds.

Unisys have, since the Burroughs B5000 series machines, based their large systems on ALGOL. That was a very sensible and rational decision, not picked up by the industry in general. http://en.wikipedia.org/wiki/B5000 As a successful precedent it indicates that FP would be an elegant choice for the FB emitter. Unfortunately an elegant solution is seldom the reality, so we are faced with C as the lowest common denominator. Excreta happens.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Postby AGS » Nov 25, 2009 22:11

stylin wrote:AGS, well, let us know when you get that done. :D


:-D :-D Tell you what: I'll do FB2FP if you'll do FB2C :)
angros47
Posts: 1444
Joined: Jun 21, 2005 19:04

Postby angros47 » Nov 21, 2010 14:54

Ok, I know I'm opening an old thread, anyway...

Can the ASM emitter be changed to emit 64 bit code? Has anybody already tried it?

I'm asking that because I have to change my old desktop, and I'll take a 64 bit machine, with linux: I know that, with a tricky workaround, freebasic can be used, by installing 32 bit libraries, but, why it cannot use 64 bit libraries?
To build a true FreeBasic 64, what would be the steps to do?
I believed that porting an assembly program from 32 bit to 64 bit should not be impossible, so why everyone talked only about c emitter?
dkl
Site Admin
Posts: 3207
Joined: Jul 28, 2005 14:45
Location: Germany

Postby dkl » Nov 21, 2010 15:02

Yea I don't think it's extremely hard either, one of the things I'm working on at the moment is making the other parts of the compiler 64bit-ready, and then the asm emitter update shouldn't be a problem. I think the rtlib/gfxlib are fine already, and if not, that's easy to fix.
angros47
Posts: 1444
Joined: Jun 21, 2005 19:04

Postby angros47 » Nov 21, 2010 15:07

thanks for your quick answer!

is there any way to check which part are 64-bit ready?
marcov
Posts: 2752
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Nov 21, 2010 18:34

AGS wrote:Emitting C code is something that's being done by quite a few programming language projects. There's SmartEiffe,ATS,LISAAC,OpenDYLAN, Euphoria etc... All of these languages come with a compiler that produces C code.

The reason for this willingness to produce C code has to do with

- the effort that has gone into building optimizing C compilers;
- the widespread availability of C compilers;
- the unwillingness of developers to learn all sorts of assembler idioms.


- instant gratification, since you get a workable solution quicker, but pay for the problems generated by this shortcut for the rest of your life.

IMHO the latter is the more important one.

Developers might not like programming in C but at least when targeting C you only have to learn one programming language (C) as opposed to a bunch of different sets of assembler mnemonics when targeting assembler.


No, you need to learn the quirks of say 3-4 C compilers in 4 versions, including their associated toolchains (think autoconf, make, binutils etc). Emulation platforms like mingw are different enough in practical usage from mainline gcc (older versions, deficiencies, extra parameters, other debug format (no dwarf!)) to consider it a different compiler. These are all way, way more complicated beasts than assembler instruction sets with a mere 100 instructions in active use per architecture.

Since a C compiler produces code that's pretty close to what could be achieved when writing a program in assembler targeting C makes sense.


This is misleading statement. While the C compiler often produces quite optimal code from handcoded C code, it doesn't meant that automatically generated C will translate to a similar level as when the Basic was hand translated to C.

I'm getting the impression marcov is not too thrilled about the idea of a compiler targeting anything but assembler.


Almost correct. It's more that I'm not too thrilled to add dependancies on huge, complex and versioned external codebases. I believe in focussing on your own strengths of developing and building something, not on smart shopping.

My fear is that after a really swift startup you get mired down into a situation where half of the work goes into managing the dependancies, their changes, as well as a really bad situation on non Unix platforms where the GNU tool chain typically sucks.

And the idea of a compiler targeting FreePASCAL.....


You could do worse. However the main reason for bringing up FPC is to drive home a certain point. FPC considers Unix and Windows as equal platforms.

In general that was a hint to more narrowly define what you are targeting. So not "C", but "gcc 4.x on Linux" and "msvcc 2010 on Windows".

My opinion on the whole targeting issue: creating software should be fun. And I would have a lot more fun trying to translate FB to FP than I would have translating FB to C. I don't like C, I do like FP.


Well that makes two :-)

It might make more sense to target C (or assembler) but as an amateur programmer I find having fun while programming to be more important than doing things that make sense.

FB2C: nea.
FB2FP: yea.


The main problem would be MIPS and Sparc64 support, the only somewhat commonly used architectures where there is no FPC backend for.
dodicat
Posts: 5809
Joined: Jan 10, 2006 20:30
Location: Scotland

Postby dodicat » Nov 21, 2010 21:24

@ Marcov

Here are a couple of comments from the Computing Languages List.
Of course, we don't believe a word.

By the way I used Pascal and Pascal alone at one stage of my amatuer coding for fun, Turbo Pascal and Virtual Pascal.
I still like Pascal, but GNU Pascal defeats the whole purpose because it is just a front end for C.

(Sorry Richard, you can program for fun and be a puritan at the same time.)

Anyway the comments:

BASIC- language originally designed for Dartmouth's experimental timesharing system in the early 1960's.
A novice can write short BASIC programs (10-12 lines) very
easily, writing anything longer a) is very painful, and b) encourages bad habits that will make it harder to use more powerful languages well. Dijkstra observed in "selected Writings on Computing", "It is practically impossible to teach good programming style to students that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond all hope of regeneration". And whereas every programming language has flaws, BASIC's are deep and many.

PASCAL- father of Delphi. Developed by Professor Niklaus Wirth. Originally developed primarily as a teaching language, but it has more often been recommended as a serious language. But, according to Brian W. Kernighan the creator of C, it is not suitable for serious programming,"It is suitable only for small, self-contained programs which have only trivial interactions with their environment and that make no use of any software written by anyone else".
Pascal is very good for writing well-structured and readable programs, but it is not as flexible as C.
marcov
Posts: 2752
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Nov 21, 2010 21:47

dodicat wrote:Here are a couple of comments from the Computing Languages List.
Of course, we don't believe a word.

By the way I used Pascal and Pascal alone at one stage of my amatuer coding for fun, Turbo Pascal and Virtual Pascal.


This discussion is IMHO not about Pascal vs C. If you really want my opinion about that, find a forum where it is on topic, and reserve a $%#@ of time for that discussion ;-)

I see this discussion more as a discussion about multiple paths that a young compiler/language related project might take. And I hate oversimplification of arguments (like people talking about "C" as if it were a homogenous subject. It is not, they are real life compilers with incompatibilities and problems. And no, standards only cover language. There are no standards for calling a C compiler, no standards for if a compiler truely supports Windows more than a minimal unix emulation, there is nothign set about versioning, debugging etc. At best there are temporary conventions)

I still like Pascal, but GNU Pascal defeats the whole purpose because it is just a front end for C.


Now, that _IS_ ontopic, since many of the opinions above have been formed by me following GPC for over a decade. I once wrote a text about this:

http://www.stack.nl/~marcov/gpctxt.txt

BASIC- language originally designed for Dartmouth's experimental timesharing system in the early 1960's.
A novice can write short BASIC programs (10-12 lines) very
easily, writing anything longer a) is very painful, and b) encourages bad habits that will make it harder to use more powerful languages well. Dijkstra observed in "selected Writings on Computing", "It is practically impossible to teach good programming style to students that have had prior exposure to BASIC: as potential programmers they are mentally mutilated beyond all hope of regeneration". And whereas every programming language has flaws, BASIC's are deep and many.


Having used Basics since Commodore Basic V2, for me BASIC is more a syntax that at the most reminds a bit of the interpreter syntaxes of old.

The interpreter and later compiled dialects differ IMHO in more places than the small bit of syntax they have in common.

PASCAL- father of Delphi. Developed by Professor Niklaus Wirth. Originally developed primarily as a teaching language, but it has more often been recommended as a serious language.


People forget that the "teaching bit" in that time meant that CS master level students could write down algorithms down in it. This 1970 remark is often confused with the situation in the eighties and early nineties where Pascal was typically used for an introductionary programming course.

Actually both those uses have nothing in common.

But, according to Brian W. Kernighan the creator of C, it is not suitable for serious programming,"It is suitable only for small, self-contained programs which have only trivial interactions with their environment and that make no use of any software written by anyone else".


And he was probably right about pre 1980 Pascal. Note that this was in an era where C and Unix hadn't really gotten out into the world yet.

Pascal is very good for writing well-structured and readable programs, but it is not as flexible as C.


Please provide some fundament to your opinions. This seems to be your own unfunded opinion. (and IMHO it is ludicrous. A somewhat modern Pascal supports way more than C. The only exceptions I think are the ? operator, assignment in expressions, and the addition of a preprocessor to the language requirements (which IMHO is C's biggest fault)
dodicat
Posts: 5809
Joined: Jan 10, 2006 20:30
Location: Scotland

Postby dodicat » Nov 21, 2010 22:36

marcov wrote:
dodicat wrote:Pascal is very good for writing well-structured and readable programs, but it is not as flexible as C.


Please provide some fundament to your opinions. This seems to be your own unfunded opinion. (and IMHO it is ludicrous. A somewhat modern Pascal supports way more than C. The only exceptions I think are the ? operator, assignment in expressions, and the addition of a preprocessor to the language requirements (which IMHO is C's biggest fault)


Sorry to disapoint you Marcov, but the opinion was part of the quote.

Maybe I'll join the FreePascal forum, under a nom de plume of course.
Cheers.
marcov
Posts: 2752
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Nov 21, 2010 22:51

dodicat wrote:
marcov wrote:
dodicat wrote:Pascal is very good for writing well-structured and readable programs, but it is not as flexible as C.


Please provide some fundament to your opinions. This seems to be your own unfunded opinion. (and IMHO it is ludicrous. A somewhat modern Pascal supports way more than C. The only exceptions I think are the ? operator, assignment in expressions, and the addition of a preprocessor to the language requirements (which IMHO is C's biggest fault)


Sorry to disapoint you Marcov, but the opinion was part of the quote.


Well, then I'll wait for any post-1980 opinion :-)

Maybe I'll join the FreePascal forum, under a nom de plume of course.


No need for a nom de plume. I can be a aggressive on forums sometimes, but it is a way of swiftly cutting through wooly, vague or parroted arguments. It is not personal.

However I don't hold grudges easily. You can't be in discussion forums for 25 years and easily hold grudges :) The administration alone would kill you.
Last edited by marcov on Nov 25, 2010 16:24, edited 1 time in total.
dodicat
Posts: 5809
Joined: Jan 10, 2006 20:30
Location: Scotland

Postby dodicat » Nov 21, 2010 23:21

marcov wrote:
No need for a nom de plume. I can be a aggressive on forums sometimes, but it is a way of swiftly cutting through wooly and vague arguments and too general parroted arguments.

However I don't hold grudges easily. You can't be in discussion forums for 25 years and easily hold grudges :) The administration alone would kill you.

Thank you Marcov, but you can say what you like to Dodicat, he has a thick hide.
I'll download the latest FPC and the Lazarus interface, and see what it is all about these days.
I hope you can have redimensionable arrays now, and allow a real step in for--
I hope FreeBASIC doesn't go the way of Virtual Pascal, but I don't think so just yet, not with all these fiery members.
marcov
Posts: 2752
Joined: Jun 16, 2005 9:45
Location: Eindhoven, NL
Contact:

Postby marcov » Nov 22, 2010 9:47

dodicat wrote:I hope you can have redimensionable arrays now,


Dynamic arrays yes, since Delphi 4/ FPC 2

and allow a real step in for--


No. The for has been expanded, but more into the foreach/for..in iterator direction, not step or by.

I hope FreeBASIC doesn't go the way of Virtual Pascal, but I don't think so just yet, not with all these fiery members.


(assuming you meant FPC, not FBC), well the project is somewhat suffering from the success more or less. The rapid progression makes a lot of things possible, but you risk spreading yourself too thin.

VP never was a true open source project. The project itself had only minor bugfixes in the 21th century, and no official releases at all after 2005.

See also a similar text that I have for VP: http://www.stack.nl/~marcov/vptxt.txt
Theunis Jansen
Posts: 248
Joined: Jul 01, 2010 9:35

fbc 64

Postby Theunis Jansen » Dec 13, 2010 9:50

@ Marcov

I know this post is a bit old but I found something interesting when trying out Mandriva Linux. There is a program p2c. Pascal to C.
I have also come across Boomerang which is an open source decompiler. which produces C code.

Being a playpen programmer (QB4.5 only) You will excuse me asking a rather uneducated question or two
1. Boomerang seems to unassemble the program. Does this mean it first generates ASM and from that the C code.
2. Couldn't this program be used to unassemble an FBC.exe and then generate ASM or C code.
3. Could such a program be a means to get to 64 bit ?

Return to “General”

Who is online

Users browsing this forum: No registered users and 6 guests