Re: PB written by which language?
Posted: Tue Jan 12, 2010 11:07 am
The problem isn't the language conversion, the problem is the PB library framework that C doesn't have access to.
http://www.purebasic.com
https://www.purebasic.fr/english/
Actually it does, the PB libraries are just packed static libraries as far as I know.Foz wrote:...the problem is the PB library framework that C doesn't have access to.
Sure, eveything is possible. But it will not fit right with the current expression parser, so the generated code will be really unoptimized (but working i guess).milan1612 wrote:It would be possible though? What amount of work would you reckon it'd be for you?Fred wrote:Nop.
Not a very good idea. Don't just trust the compiler to optimize every bad code.milan1612 wrote:let the C compiler do the optimiziations.
Code: Select all
MOV EBP,ESP
PUSH ECX
MOV DWORD PTR SS:[EBP-4],ECX
MOV ECX,DWORD PTR SS:[EBP-4]
How many people are working on the Visual Studio compiler 10? 20? 40? 80?Thorium wrote:To just show you a example of failed compiler optimization. The following code was generated by VC++ 7:
Code: Select all
MOV EBP,ESP PUSH ECX MOV DWORD PTR SS:[EBP-4],ECX MOV ECX,DWORD PTR SS:[EBP-4]
Suppose emitting C code would only make sense if PureBasic would have a target processor different from X86 or X86-64.Fred wrote:Sure, eveything is possible. But it will not fit right with the current expression parser, so the generated code will be really unoptimized (but working i guess).milan1612 wrote:It would be possible though? What amount of work would you reckon it'd be for you?Fred wrote:Nop.
It isn't that easy because PB's rules of expression evaluation are different from C.milan1612 wrote:How do you parse the expressions? I guess it's best to parse them into a recursive
tree structure. For a C output, you would just have to serialize the tree back to C
syntax expressions, let the C compiler do the optimiziations.
Code: Select all
Double.d
Int1.i = 3
Int2.i = 2
Int3.i
Double = Int1/Int2
Int3 = Int1/Int2
Debug Double ; This would be 1.0 in C.
Debug Int3The only reason i would have is when I get a Linux ARM computer (here's to saving up for the Nokia N900), being able to code in PB rather than C would definitely be a great helpTrond wrote:Also, what would the point be? C compilers are ten times slower than the PB compiler and there always seems to be an endless list of shouldn't-really-be-a-problem problems with C (why else would we use PB?).
I think that's a pretty good reason and it's really why I asked the question.Foz wrote:The only reason i would have is when I get a Linux ARM computer (here's to saving up for the Nokia N900), being able to code in PB rather than C would definitely be a great help
All those curly brackets and semi-colons - whoever invented C must have had a punctuation fetish.Foz wrote:Switching between C and PB is a pain - I'd rather use one language, otherwise you start to blend languages, i.e. putting a semi colon at the end of the PB line and missing them in the C lines...
Mmm, it's like comparing this with thisTrond wrote:(why else would we use PB?).
I'm with you on this one, if only the N900 would have a real compass...Foz wrote:The only reason i would have is when I get a Linux ARM computer (here's to saving up for the Nokia N900), being able to code in PB rather than C would definitely be a great help
What the code does it reads a value and writes it back.milan1612 wrote:Well Thorium, I don't know assembler, I can't even read it mostly,
Code: Select all
a.i = b.i
b.i = a.i
It isnt premature optimization if you get 1000% speed up. Which isn't unrealistic. If you process large data blocks writing the routine in assembler can give you a huge speed up and using extensions like SSE can boost the performance of your assembler code by like 10 times. Depants strongly on your algo, but thats not premature optimization at all.milan1612 wrote: but if I learned anything
in the past years, then it's the fact that you don't need hand-written assembler in almost
all cases. Imho, that's just premature optimization. But still, you have a point there![]()
I really love Python, but I'm not sure the current generation of mobiles are powerful enough to do it justice.fsw wrote:Could live coding in C or something different (as long it's not Python)