Re: [fpc-pascal] Generics vs templates

2018-01-11 Thread Sven Barth via fpc-pascal
Am 11.01.2018 08:06 schrieb "Michael Schnell" : On 09.01.2018 08:04, Sven Barth via fpc-pascal wrote: But you need to program in a way that allows the usage of multiple, different types. That can more often than not lead to worse performance. Seemingly it is done that way. I rather often did a

Re: [fpc-pascal] Generics vs templates

2018-01-10 Thread Michael Schnell
On 09.01.2018 08:04, Sven Barth via fpc-pascal wrote: But you need to program in a way that allows the usage of multiple, different types. That can more often than not lead to worse performance. Seemingly it is done that way. I rather often did a kind of "Generics" in ANSI C by using Macros. It

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Sven Barth via fpc-pascal
Am 10.01.2018 05:10 schrieb "Ryan Joseph" : > On Jan 10, 2018, at 6:37 AM, Graeme Geldenhuys < mailingli...@geldenhuys.co.uk> wrote: > > When using the Generics.Collections unit of Delphi I can define a list class that can hold Integer data types, by doing the following: > > var >IntList: T

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Sven Barth via fpc-pascal
Am 10.01.2018 07:39 schrieb "Marco van de Voort" : In our previous episode, Sven Barth via fpc-pascal said: > Precisely these virtual methods are one point. They might not add much by > themselves, but if they're called for each Add or Remove operation they can > add quite a bit. > Why do you thin

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Marco van de Voort
In our previous episode, Sven Barth via fpc-pascal said: > Precisely these virtual methods are one point. They might not add much by > themselves, but if they're called for each Add or Remove operation they can > add quite a bit. > Why do you think that the TFP(Object)List classes don't have notifi

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Ryan Joseph
> On Jan 10, 2018, at 6:37 AM, Graeme Geldenhuys > wrote: > > When using the Generics.Collections unit of Delphi I can define a list class > that can hold Integer data types, by doing the following: > > var >IntList: TList; > begin >IntList := TList.Create; >IntList.Add(12345);

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Graeme Geldenhuys
On 2018-01-09 01:29, Ryan Joseph wrote: What does this have to do with generics exactly? Everything I guess. ;-) That was the point of my reply. When using the Generics.Collections unit of Delphi I can define a list class that can hold Integer data types, by doing the following: var I

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Maciej Izak
2018-01-08 21:30 GMT+01:00 Graeme Geldenhuys : > Speaking of Generics and Benchmarks. Has anybody done some benchmarks on > FPC's Generics vs "old-school" TList and TObjectList. Recently I did a very > simple test with Delphi XE3 using TList and a stock TList. Adding > 50,000 and 200,000 integer

Re: [fpc-pascal] Generics vs templates

2018-01-09 Thread Sven Barth via fpc-pascal
Am 09.01.2018 08:13 schrieb "Ryan Joseph" : > On Jan 9, 2018, at 2:04 PM, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > > But you need to program in a way that allows the usage of multiple, different types. That can more often than not lead to worse performance. > Exampl

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Ryan Joseph
> On Jan 9, 2018, at 2:04 PM, Sven Barth via fpc-pascal > wrote: > > But you need to program in a way that allows the usage of multiple, different > types. That can more often than not lead to worse performance. > Examples? I had to add some if statements in a couple areas I didn’t want to

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Sven Barth via fpc-pascal
Am 09.01.2018 02:59 schrieb "Ryan Joseph" : > On Jan 9, 2018, at 3:30 AM, Graeme Geldenhuys < mailingli...@geldenhuys.co.uk> wrote: > > Recently I did a very simple test with Delphi XE3 using TList and a stock TList. Adding 50,000 and 200,000 integer values to each list, and timing the creation

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Ryan Joseph
> On Jan 9, 2018, at 3:30 AM, Graeme Geldenhuys > wrote: > > Recently I did a very simple test with Delphi XE3 using TList and a > stock TList. Adding 50,000 and 200,000 integer values to each list, and > timing the creation of the list and population of the list. Then I also timed > the de

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Giuliano Colla
Il 08/01/2018 21:30, Graeme Geldenhuys ha scritto: I was horified to find out how much slower Delphi's Generics were compared to TList and TObjectList I don't expect FPC behave much better. Whenever you move something from compile time to execution time you may gain in flexibility, but you s

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Graeme Geldenhuys
On 2018-01-08 10:58, Sven Barth via fpc-pascal wrote: FPC essentially reparses a generic during specialization so I'd say that they definitely affect compile times. However we're still only doing a single pass of parsing. This while the compilation might be slower it might not be as bad as with a

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Sven Barth via fpc-pascal
Am 08.01.2018 12:52 schrieb "Ryan Joseph" : > On Jan 8, 2018, at 5:58 PM, Sven Barth via fpc-pascal < fpc-pascal@lists.freepascal.org> wrote: > > FPC essentially reparses a generic during specialization so I'd say that they definitely affect compile times. Does c++ not “specialize” in one loca

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Ryan Joseph
> On Jan 8, 2018, at 5:58 PM, Sven Barth via fpc-pascal > wrote: > > FPC essentially reparses a generic during specialization so I'd say that they > definitely affect compile times. Does c++ not “specialize” in one location like FPC? looking at c++ code I often see things like Vector used

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Mattias Gaertner
On Mon, 8 Jan 2018 14:19:42 +0700 Ryan Joseph wrote: > I was talking with a c++ developer who explained how templates are > implemented in c++ and how use some recursive method which causes them to > totally murder compile times. > Having just started to use generics in FPC myself I was curious

Re: [fpc-pascal] Generics vs templates

2018-01-08 Thread Sven Barth via fpc-pascal
Am 08.01.2018 08:50 schrieb "Ryan Joseph" : I was talking with a c++ developer who explained how templates are implemented in c++ and how use some recursive method which causes them to totally murder compile times. This isn’t the first I’ve heard of the problem though and I recall some game studio

[fpc-pascal] Generics vs templates

2018-01-07 Thread Ryan Joseph
I was talking with a c++ developer who explained how templates are implemented in c++ and how use some recursive method which causes them to totally murder compile times. This isn’t the first I’ve heard of the problem though and I recall some game studios who develop engines in c++ saying they a