Recent

Author Topic: Possible future competition for Delphi and FPC?  (Read 5645 times)

SlightlyOutOfPhase

  • New member
  • *
  • Posts: 8
Possible future competition for Delphi and FPC?
« on: December 14, 2018, 04:27:10 am »
.
« Last Edit: February 21, 2020, 10:39:46 pm by SlightlyOutOfPhase »

CCRDude

  • Hero Member
  • *****
  • Posts: 596
Re: Possible future competition for Delphi and FPC?
« Reply #1 on: December 14, 2018, 09:48:43 am »
From something called "professionally written", I would expect file headers. Would make it much easier for the reader to understand the basic structure of the repo.
I would also expect some kind of documentation, "docs/" is just external information used, and "features.txt" is in cyrillic letters, and Google Translate only reveals attributes as something worth noting. I see in your post history that you're unhappy about FPC not supporting attributes, but I mostly see many features that are not listed in the translation.
I see references to JS, LLVM and execution VMs, but all this seems to be external.
And I see that it seems to use CodeTyphon for testing, instead of pure Lazarus. Since CT is based on Lazarus, it would make much more sense to test it with Lazarus first.

Finally, keep in mind that any advanced IT student can write a simple compiler, but Delphi and FPC are much more than that (take a look at their rich RTLs).

I could try to see it from a different perspective, but if you raise the bar that high, disappointment is a logical first reaction ;)

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Possible future competition for Delphi and FPC?
« Reply #2 on: December 14, 2018, 10:23:13 am »
Instead of posting here some empty message, why don't you post your testing results with e.g. Delphi or FPC sources?

From what I can see it is a parser more than a compiler with an incomplete virtual machine.
« Last Edit: December 14, 2018, 10:25:41 am by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 14204
  • Probably until I exterminate Putin.
Re: Possible future competition for Delphi and FPC?
« Reply #3 on: December 14, 2018, 11:24:30 am »
Rather nice, but not very good code:
Code: Pascal  [Select][+][-]
  1. function Sign(I: Integer): Integer; inline; // faster then Math.Sign.
  2. begin
  3.   if I < 0 then
  4.     Sign := -1
  5.   else if I > 0 then
  6.     Sign := +1
  7.   else
  8.     Sign := 0;
  9. end;

That does not look too good when a proper student would probably write something like this:
Code: Pascal  [Select][+][-]
  1. function sign(const i:integer):integer;
  2. begin
  3.  Result := integer(i > 0) - integer(i < 0); // casts are cheap..
  4. end;
Which is branchless....

There are more first look issues...
Specialize a type, not a var.

wp

  • Hero Member
  • *****
  • Posts: 11857
Re: Possible future competition for Delphi and FPC?
« Reply #4 on: December 14, 2018, 11:42:55 am »
Code: Pascal  [Select][+][-]
  1. function Sign(I: Integer): Integer; inline; // faster then Math.Sign.
  2. begin
  3.   if I < 0 then
  4.     Sign := -1
  5.   else if I > 0 then
  6.     Sign := +1
  7.   else
  8.     Sign := 0;
  9. end;
A question regarding the comment "faster than Math.Sign": Why is this code supposed to be faster than the one which I just copied out of Math.pas?
Code: Pascal  [Select][+][-]
  1. Type
  2.   TValueSign = -1..1;
  3.  
  4. const
  5.   NegativeValue = Low(TValueSign);
  6.   ZeroValue = 0;
  7.   PositiveValue = High(TValueSign);
  8.  
  9. function Sign(const AValue: Integer): TValueSign;inline;
  10. begin
  11.   If Avalue<0 then
  12.     Result:=NegativeValue
  13.   else If Avalue>0 then
  14.     Result:=PositiveValue
  15.   else
  16.     Result:=ZeroValue;
  17. end;  

440bx

  • Hero Member
  • *****
  • Posts: 3945
Re: Possible future competition for Delphi and FPC?
« Reply #5 on: December 14, 2018, 04:11:23 pm »
Rather nice, but not very good code:
<snip>
That does not look too good when a proper student would probably write something like this:
Code: Pascal  [Select][+][-]
  1. function sign(const i:integer):integer;
  2. begin
  3.  Result := integer(i > 0) - integer(i < 0); // casts are cheap..
  4. end;
Which is branchless....
Yes, it is branchless but...  as written above the function's result is undefined when the parameter passed to it is zero.

Should that be documented as a "limitation" ?  I guess a "proper student" would properly initialize the return value upon function entry.  In programming, propriety is even better than property.


(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Remy Lebeau

  • Hero Member
  • *****
  • Posts: 1312
    • Lebeau Software
Re: Possible future competition for Delphi and FPC?
« Reply #6 on: December 15, 2018, 01:26:21 am »
Yes, it is branchless but...  as written above the function's result is undefined when the parameter passed to it is zero.

How do you figure that?  I see it as being defined as 0:

integer(i > 0) = integer(0 > 0) = integer(false) = 0

integer(i < 0) = integer(0 < 0) = integer(false) = 0

So:

Result = integer(i > 0) - integer(i < 0) = 0 - 0 = 0

Yours is from the FPC version I think? It seems likely they're referring to Delphi. I can't remember what that implementation looks like.

Like this:

Code: [Select]
type
  TValueSign = -1..1;

const
  NegativeValue = Low(TValueSign);
  ZeroValue = 0;
  PositiveValue = High(TValueSign);

function Sign(const AValue: Integer): TValueSign;
begin
  Result := ZeroValue;
  if AValue < 0 then
    Result := NegativeValue
  else if AValue > 0 then
    Result := PositiveValue;
end;

function Sign(const AValue: Int64): TValueSign;
begin
  Result := ZeroValue;
  if AValue < 0 then
    Result := NegativeValue
  else if AValue > 0 then
    Result := PositiveValue;
end;

function Sign(const AValue: Single): TValueSign;
begin
  if (PInteger(@AValue)^ and $7FFFFFFF) = $00000000 then
    Result := ZeroValue
  else
    if (PInteger(@AValue)^ and $80000000) = $80000000 then
      Result := NegativeValue
    else
      Result := PositiveValue;
end;

function Sign(const AValue: Double): TValueSign;
begin
  if ((PInt64(@AValue)^ and $7FFFFFFFFFFFFFFF) = $0000000000000000) then
    Result := ZeroValue
  else if ((PInt64(@AValue)^ and $8000000000000000) = $8000000000000000) then
    Result := NegativeValue
  else
    Result := PositiveValue;
end;

function Sign(const AValue: Extended): TValueSign;
begin
{$IFDEF CPUX64}
  if ((PInt64(@AValue)^ and $7FFFFFFFFFFFFFFF) = $0000000000000000) then
    Result := ZeroValue
  else if ((PInt64(@AValue)^ and $8000000000000000) = $8000000000000000) then
    Result := NegativeValue
  else
    Result := PositiveValue;
{$ELSE !CPUX64}
  if (PExtendedRec(@AValue)^.Frac and $FFFFFFFFFFFFFFFF) = $0000000000000000 then
    Result := ZeroValue
  else
    if PExtendedRec(@AValue)^.sign then
      Result := NegativeValue
    else
      Result := PositiveValue;
{$ENDIF}
end;
« Last Edit: December 15, 2018, 01:30:29 am by Remy Lebeau »
Remy Lebeau
Lebeau Software - Owner, Developer
Internet Direct (Indy) - Admin, Developer (Support forum)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Possible future competition for Delphi and FPC?
« Reply #7 on: December 15, 2018, 01:44:59 am »
I'd encourage assisting with FPC rather than competing. Hard to see how they could jump ahead. That's a huge bar. What is the goal?
« Last Edit: December 15, 2018, 01:58:09 am by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

440bx

  • Hero Member
  • *****
  • Posts: 3945
Re: Possible future competition for Delphi and FPC?
« Reply #8 on: December 15, 2018, 02:04:52 am »
Yes, it is branchless but...  as written above the function's result is undefined when the parameter passed to it is zero.

How do you figure that?  I see it as being defined as 0:
Remy, you are absolutely correct. It gets assigned false - false which is false. 

I owe Taddy an apology.

Thank you for pointing out that mistake.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11383
  • FPC developer.
Re: Possible future competition for Delphi and FPC?
« Reply #9 on: December 15, 2018, 01:30:32 pm »
From what I can see it is a parser more than a compiler with an incomplete virtual machine.

I'm not so sure about that. It seems to implement the full infrastructure of a compiler, e.g. type-checker/e.t.c and even a package system.

It also has a variety of in-progress codegen backends, not just a VM implementation:

Well, we see. The point remains, what does it do?  Can it compile code? Can it produce working exes for major OSes ? How do they perform, what dialect does it support? Does it require modification of existing delphi sourcode, and if it does, how much? (always a problem with compilers with IL backends) Does it have a massive own libraries (fileformats, networking, even simple date calculations), or can it compile borrow them from some major compiler?

I think the whole competition angle is dragged in by the hairs. All I see is one of the many pascal->IL attempts(*), nothing close to a production product like Delphi or FPC. That Il2LLVM generator has barely 100 uncommented lines.

Worse, I don't see any evidence of what works, just the codedump. Talk of competition is very, very, very premature. >:D

Initial compilers can be made by a focussed person or a team (e.g. as part of a student project) in a few months, specially if you borrow code and avoid the hard parts like own codegenerators.

But then every step you take widens the project, and it slows down, usually beyond the abilities of a single person who can only afford fulltime work on it for so long.

Making them production ready, dialect, codegeneration quality and libraries beyond the bare minimum and supporting them for a period of time, that is where the work goes.  Initial means nothing there are so many small compilers

(*) the last similar message is not even that long ago: http://forum.lazarus-ide.org/index.php/topic,43007.0.html
« Last Edit: December 15, 2018, 01:50:19 pm by marcov »

Laksen

  • Hero Member
  • *****
  • Posts: 724
    • J-Software
Re: Possible future competition for Delphi and FPC?
« Reply #10 on: December 15, 2018, 09:48:40 pm »
Diversity in a software ecosystem is great. Good luck to those people :)

 

TinyPortal © 2005-2018