[Development] Views

Marco Bubke Marco.Bubke at qt.io
Tue May 21 11:20:32 CEST 2019



On 20/05/2019 23:11, André Pönitz wrote:
> On Mon, May 20, 2019 at 08:44:47PM +0000, Marco Bubke wrote:
>> On May 20, 2019 22:16:11 André Pönitz <apoenitz at t-online.de> wrote:
>>
>>> On Fri, May 17, 2019 at 10:17:10AM +0200, Mutz, Marc via Development wrote:
>>>> [...] There is no readability difference between the use of a Qt container and
>>>> that of an STL container.
>>>
>>> Exhibit A:
>>>
>>>      foo().contains(x)
>>>
>>>
>>> Exhibit B:
>>>
>>>      {
>>>          ... container = foo();
>>>          std::find(container.begin(), container.end(), x) != container.end();
>>>      }
>>
>> AFAIK contains is now part of the STL.
> 
> Define "now"...
> 
>> But to show a pattern I see often with Qt container is the use of contains and
>> then access the element with a key again. I that case the STL with iterators
>> leads you to better performing code. Ranges hopefully make much of this code
>> even more readable and performant.
> 
> Performance is always a combination of "raw run-time performance" and "time to
> market".

Yes, it is an economic decision too but there is not only "time to 
market" but "stay in the market" too. So you have be careful with your 
investments but if you do not invest enough you will loose too.

> There's no point in saving 30 processor cycles a day, even for a million users,
> if that takes one hour of developer time to implement in a desktop application.
> 
> People who disagree wouldn't ever touch Java or JS or any interpreted language.
> Or std::ostream for that matter.
> 
> You know as well as I do that e.g. QList is heavily used in e.g. the Qt Creator
> code base, and that this is absolutely *no* performance problem. Sure, it's not
> used in *really* time-critical parts, but for the 100%-\epsilon non-exceptional
> stuff it's just "good enough".
> 

I would agree that we have not much performance problems because most 
containers use only few entries but I ran in some. What I want to say is 
that there are solutions to that problem. For example with ranges you 
get readability and performance in many cases but if you are not 
familiar with that patter it looks strange. Very often the first 
reaction is to reject something because it looks unfamiliar as 
unreadable. Yes it is as you encounter it the first time but maybe it 
will be more readable in the long run.



More information about the Development mailing list