[fpc-pascal] Re: TLinkedList

Jorge Aldo G. de F. Junior jagfj80 at gmail.com
Wed Feb 15 16:44:56 CET 2012


http://theory.stanford.edu/~amitp/rants/c++-vs-c/

found the thing... its not a book and C++ has no generics but
templates (for me both are the same, im no C++ programmer).

Now reading it again... The thing is that a quicksort in C can be fast
only if used for one single type (at least the comparision function)
while in C++ the template specialization makes the comparision
function work for a greater number of types, simplifying resulting
code...

2012/2/15 Juha Manninen <juha.manninen62 at gmail.com>:
> 2012/2/15, Jorge Aldo G. de F. Junior <jagfj80 at gmail.com>:
>> i once read a textbook about generics (C++ generics) showing how C++
>
> C++ does not have generics, it has templates. Templates syntax is
> complex, you can do actual programming with it. IMO, using all its
> capacity leads to over-engineered and unreadable code.
> I read about a plan to add Java style generics syntax to C++, in
> addition to templates. I guess it will not happen. C++ has enough
> syntax already.
>
>
>> code can end up being FASTER than C equivalent due to lack of type
>> checks...
>>[...]
>> the point being made was that object orientation is not necessarely
>> "bloat" but leads to better written code. (not always true, but...)
>
> Code can still be fast even if it is bloated in size. Object
> orientation helps in writing readable and maintainable code but that
> is yet another issue.
> The code duplication we discussed here has no advantage for speed. It
> is quite useless duplication.
>
>
> >From Sven Barth:
>> Free Pascal is a native language. There aren't much alternatives to code duplication.
>
> Yes there is. The same container code can be reused (when possible),
> just like Java does.
> Free Pascal is native, Java generates byte-code, but that is irrelevant here.
>
> I was planning to use generics in many places in Lazarus code but now
> I must rethink...
> Lazarus executable is quite big already.
>
> Juha
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal



More information about the fpc-pascal mailing list