[fpc-devel] Modernising Pascal

Jamie McCracken jamie-junk at blueyonder.co.uk
Thu Feb 24 13:51:30 CET 2005


DrDiettrich wrote:

>>My main gripes with Delphi/pascal is its additional verbosity and
>>somewhat tedious coding practices which seem superfluous in some cases.
>>Now I dont mind typing a bit extra to make code cleaner and more legible
>>but I have a few ideas which would reduce needless typing and improve
>>clarity at the same time.
> 
> 
> IMO the best solution for (almost) all of your problems were garbage
> collection. GC is part of Oberon, and it would fit into .NET/DotGNU as
> well.


GC is very inefficient with memory and current implementations tend to 
cost a lot performance wise too.

GC gets a lot slower with the more objects you create.

Mixing unmanaged with managed code cause severe performance issues 
(marshalling penalties calling ummanaged c functions)

Interoperability with C gets increasingly difficult. Writing bindings 
becomes much more complicated and time consuming.

GC is therefore a poor choice for a high performance language IMHO.


> 
> 
>>1. Memory management. Delphi is quite incosistent here by allowing
>>component classes to be auto managed (via their owner) whilst
>>non-component class have to be manually managed.
> 
> 
> In a GUI a management overhead is acceptable, in other classes IMO it's
> not a good idea: the management costs time and requires rigid design
> rules, what makes it not very convenient and safe to use.
> 
> 
>>no longer be a need for having loads of try..finally statements
> 
> 
> GC ;-)

It might be better to do this in an IDE and get it to add the 
try..finally crap.

EG if I say use the @ symbol to indicate a variable should be auto 
created and destroyed then I could have :

var st@, st2@ : tstringlist;
begin
   st.add('some text');
   st2.add('some more text');
end;


which the IDE would translate behind the scenes to :


var st, st2 : tstringlist;
begin
    st := tstringlist.create;
    try
      st2 :=  tstringlist.create;
      try
        st .add('some text');
        st2.add('some more text');
     finally
       st2.free;
     end;
   finally
     st.free;
   end;
end;


I do need an IDE anyhow for container based GTK2/Gnome2/Glade apps so 
maybe I ought to start writing one that implements this.

jamie.




More information about the fpc-devel mailing list