[Development] Future of java-style iterators?

2023-12-03 Thread Christian Ehrlicher

Hi,

Some days ago we got an error report in the forum about QHashIterator,
turned out to be a missing documentation for a complete class which
remained unnoticed since Qt 6.0
(https://bugreports.qt.io/browse/QTBUG-119461).
This leads to the question if we should deprecate all java-style
iterators since they seem to be a) not widely used and b) it looks like
we don't support them in a way we should.
What do you think?


Cheers,
Christian


--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-03 Thread Giuseppe D'Angelo via Development

Hello,

On 03/12/2023 21:56, Christian Ehrlicher wrote:

Some days ago we got an error report in the forum about QHashIterator,
turned out to be a missing documentation for a complete class which
remained unnoticed since Qt 6.0
(https://bugreports.qt.io/browse/QTBUG-119461).
This leads to the question if we should deprecate all java-style
iterators since they seem to be a) not widely used and b) it looks like
we don't support them in a way we should.
What do you think?


While any "serious" code should build under QT_NO_JAVA_STYLE_ITERATORS¹, 
how much maintenance do they cost us? There's been virtually 0 changes 
on them since Qt 6.0.


¹ We should of course open the chapter of having something that defines 
all these QOL macros. No one should be using the Java iterators. Here's 
a draft:

https://codereview.qt-project.org/c/qt/qtbase/+/522833

My 2 c,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts



smime.p7s
Description: S/MIME Cryptographic Signature
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-04 Thread Jyrki Yli-Nokari

While I do not use them, I feel that deprecating such core functionality of a 
framework without measurable gain would seriously harm anyone using them and, 
most importantly, fundamentally harm the promise and dependability of Qt as a 
framework of choice.

> Giuseppe D'Angelo via Development  kirjoitti 
> 3.12.2023 kello 23.35:
> 
> Hello,
> 
>> On 03/12/2023 21:56, Christian Ehrlicher wrote:
>> Some days ago we got an error report in the forum about QHashIterator,
>> turned out to be a missing documentation for a complete class which
>> remained unnoticed since Qt 6.0
>> (https://bugreports.qt.io/browse/QTBUG-119461).
>> This leads to the question if we should deprecate all java-style
>> iterators since they seem to be a) not widely used and b) it looks like
>> we don't support them in a way we should.
>> What do you think?
> 
> While any "serious" code should build under QT_NO_JAVA_STYLE_ITERATORS¹, how 
> much maintenance do they cost us? There's been virtually 0 changes on them 
> since Qt 6.0.
> 
> ¹ We should of course open the chapter of having something that defines all 
> these QOL macros. No one should be using the Java iterators. Here's a draft:
> https://codereview.qt-project.org/c/qt/qtbase/+/522833
> 
> My 2 c,
> --
> Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
> KDAB (France) S.A.S., a KDAB Group company
> Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
> KDAB - The Qt, C++ and OpenGL Experts
> 
> --
> Development mailing list
> Development@qt-project.org
> https://lists.qt-project.org/listinfo/development
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-04 Thread Marc Mutz via Development
On 04.12.23 09:06, Jyrki Yli-Nokari wrote:
>
> While I do not use them, I feel that deprecating such core functionality of a 
> framework without measurable gain would seriously harm anyone using them and, 
> most importantly, fundamentally harm the promise and dependability of Qt as a 
> framework of choice.

Only if you insist on compiling with deprecation warnings enabled.
No-one forces you to do that.

We need a way to inform (or even prevent) new users from using such APIs
while still allowing existing users to continue to use them. That's what
deprecations are for. If you know of a better mechanism, I'm all ears.

Until then, either you want to be notified of sub-optimal APIs asap,
then you enable deprecation warnings with the intent to fix them, or you
don't, then you don't, and fix once every decade when a new Qt major
release comes out.

Thanks,
Marc


>> Giuseppe D'Angelo via Development  kirjoitti 
>> 3.12.2023 kello 23.35:
>>
>> Hello,
>>
>>> On 03/12/2023 21:56, Christian Ehrlicher wrote:
>>> Some days ago we got an error report in the forum about QHashIterator,
>>> turned out to be a missing documentation for a complete class which
>>> remained unnoticed since Qt 6.0
>>> (https://bugreports.qt.io/browse/QTBUG-119461).
>>> This leads to the question if we should deprecate all java-style
>>> iterators since they seem to be a) not widely used and b) it looks like
>>> we don't support them in a way we should.
>>> What do you think?
>>
>> While any "serious" code should build under QT_NO_JAVA_STYLE_ITERATORS¹, how 
>> much maintenance do they cost us? There's been virtually 0 changes on them 
>> since Qt 6.0.
>>
>> ¹ We should of course open the chapter of having something that defines all 
>> these QOL macros. No one should be using the Java iterators. Here's a draft:
>> https://codereview.qt-project.org/c/qt/qtbase/+/522833
>>
>> My 2 c,
>> --
>> Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
>> KDAB (France) S.A.S., a KDAB Group company
>> Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com/
>> KDAB - The Qt, C++ and OpenGL Experts
>>
>> --
>> Development mailing list
>> Development@qt-project.org
>> https://lists.qt-project.org/listinfo/development
--
Marc Mutz 
Principal Software Engineer

The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
http://www.qt.io/

Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-04 Thread Jyrki Yli-Nokari
Fair enough, as long as they are not removed anytime soon

> Marc Mutz via Development  kirjoitti 4.12.2023 
> kello 10.20:
> 
> On 04.12.23 09:06, Jyrki Yli-Nokari wrote:
>> 
>> While I do not use them, I feel that deprecating such core functionality of 
>> a framework without measurable gain would seriously harm anyone using them 
>> and, most importantly, fundamentally harm the promise and dependability of 
>> Qt as a framework of choice.
> 
> Only if you insist on compiling with deprecation warnings enabled.
> No-one forces you to do that.
> 
> We need a way to inform (or even prevent) new users from using such APIs
> while still allowing existing users to continue to use them. That's what
> deprecations are for. If you know of a better mechanism, I'm all ears.
> 
> Until then, either you want to be notified of sub-optimal APIs asap,
> then you enable deprecation warnings with the intent to fix them, or you
> don't, then you don't, and fix once every decade when a new Qt major
> release comes out.
> 
> Thanks,
> Marc
> 
> 
 Giuseppe D'Angelo via Development  kirjoitti 
 3.12.2023 kello 23.35:
>>> 
>>> Hello,
>>> 
 On 03/12/2023 21:56, Christian Ehrlicher wrote:
 Some days ago we got an error report in the forum about QHashIterator,
 turned out to be a missing documentation for a complete class which
 remained unnoticed since Qt 6.0
 (https://bugreports.qt.io/browse/QTBUG-119461).
 This leads to the question if we should deprecate all java-style
 iterators since they seem to be a) not widely used and b) it looks like
 we don't support them in a way we should.
 What do you think?
>>> 
>>> While any "serious" code should build under QT_NO_JAVA_STYLE_ITERATORS¹, 
>>> how much maintenance do they cost us? There's been virtually 0 changes on 
>>> them since Qt 6.0.
>>> 
>>> ¹ We should of course open the chapter of having something that defines all 
>>> these QOL macros. No one should be using the Java iterators. Here's a draft:
>>> https://codereview.qt-project.org/c/qt/qtbase/+/522833
>>> 
>>> My 2 c,
>>> --
>>> Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
>>> KDAB (France) S.A.S., a KDAB Group company
>>> Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com/
>>> KDAB - The Qt, C++ and OpenGL Experts
>>> 
>>> --
>>> Development mailing list
>>> Development@qt-project.org
>>> https://lists.qt-project.org/listinfo/development
> --
> Marc Mutz 
> Principal Software Engineer
> 
> The Qt Company
> Erich-Thilo-Str. 10 12489
> Berlin, Germany
> http://www.qt.io/
> 
> Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
> Sitz der Gesellschaft: Berlin,
> Registergericht: Amtsgericht Charlottenburg,
> HRB 144331 B
> 
> --
> Development mailing list
> Development@qt-project.org
> https://lists.qt-project.org/listinfo/development
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-04 Thread Kevin Kofler via Development
Marc Mutz via Development wrote:
> Until then, either you want to be notified of sub-optimal APIs asap,

What is "suboptimal" about Java-style iterators, other than that they do not 
work the same way as the STL ones? I find the Java-style iterators to be 
easier to use and less error-prone than the STL-style ones (which, as I 
understand it, is why they were originally added to Qt to begin with).

Kevin Kofler

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-05 Thread Giuseppe D'Angelo via Development

Il 05/12/23 03:52, Kevin Kofler via Development ha scritto:

Marc Mutz via Development wrote:

Until then, either you want to be notified of sub-optimal APIs asap,

What is "suboptimal" about Java-style iterators, other than that they do not
work the same way as the STL ones? I find the Java-style iterators to be
easier to use and less error-prone than the STL-style ones (which, as I
understand it, is why they were originally added to Qt to begin with).


The huge downside is that they don't work with any algorithms or 
range-based facilities. They work, in their little bubble.


My 2 c,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - Trusted Software Excellence



smime.p7s
Description: Firma crittografica S/MIME
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-05 Thread Marc Mutz via Development
On 05.12.23 10:06, Giuseppe D'Angelo via Development wrote:
> Il 05/12/23 03:52, Kevin Kofler via Development ha scritto:
>> Marc Mutz via Development wrote:
>>> Until then, either you want to be notified of sub-optimal APIs asap,
>> What is "suboptimal" about Java-style iterators, other than that they 
>> do not
>> work the same way as the STL ones? I find the Java-style iterators to be
>> easier to use and less error-prone than the STL-style ones (which, as I
>> understand it, is why they were originally added to Qt to begin with).
> 
> The huge downside is that they don't work with any algorithms or 
> range-based facilities. They work, in their little bubble.

Const ones are ok-ish, except they need to maintain two iterators 
instead of one, like STL ones, and the state depends on the history 
(specifically, whether next() or previous() was called). The problem is 
the Mutable ones. Which element does setValue() work on? Which one does 
remove() remove? I don't want to look it up, but I remember there was 
some conceptional problem there.

Also, remove() in a loop is quadratic, and since no-one ever made 
Java-style iterators for C arrays and STL containers, and they hard-code 
the name of the container in the class name without containers providing 
a typedef for them, they cannot possibly be used in generic code.

Thanks,
Marc

-- 
Marc Mutz 
Principal Software Engineer

The Qt Company
Erich-Thilo-Str. 10 12489
Berlin, Germany
www.qt.io

Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
Sitz der Gesellschaft: Berlin,
Registergericht: Amtsgericht Charlottenburg,
HRB 144331 B

-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-05 Thread Mathias Hasselmann via Development

Hi,

would QDirIterator[1] be part of this deprecation? Its API clearly seems 
be inspired by the Java-style iterators.


While I do not care much about the other Java-style iterators, I really 
like this iterator and use it a lot.

What would be this iterator's modern replacement in Qt?

Ciao
Mathias

[1] https://doc.qt.io/qt-6/qdiriterator.html

Am 03.12.2023 um 21:56 schrieb Christian Ehrlicher:

Hi,

Some days ago we got an error report in the forum about QHashIterator,
turned out to be a missing documentation for a complete class which
remained unnoticed since Qt 6.0
(https://bugreports.qt.io/browse/QTBUG-119461).
This leads to the question if we should deprecate all java-style
iterators since they seem to be a) not widely used and b) it looks like
we don't support them in a way we should.
What do you think?


Cheers,
Christian



--
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-05 Thread Andreas Aardal Hanssen
How about QDir::iterator, QDir::cbegin, basically make QDir a container? Or 
make a new class that serves the same purpose… /me likes the QDir idea.. :-)

Andreas

Tir 5 des 2023 kl. 22:15 skrev Mathias Hasselmann via Development:
> Hi,
> 
> would QDirIterator[1] be part of this deprecation? Its API clearly seems 
> be inspired by the Java-style iterators.
> 
> While I do not care much about the other Java-style iterators, I really 
> like this iterator and use it a lot.
> What would be this iterator's modern replacement in Qt?
> 
> Ciao
> Mathias
> 
> [1] https://doc.qt.io/qt-6/qdiriterator.html
> 
> Am 03.12.2023 um 21:56 schrieb Christian Ehrlicher:
> > Hi,
> >
> > Some days ago we got an error report in the forum about QHashIterator,
> > turned out to be a missing documentation for a complete class which
> > remained unnoticed since Qt 6.0
> > (https://bugreports.qt.io/browse/QTBUG-119461).
> > This leads to the question if we should deprecate all java-style
> > iterators since they seem to be a) not widely used and b) it looks like
> > we don't support them in a way we should.
> > What do you think?
> >
> >
> > Cheers,
> > Christian
> >
> >
> -- 
> Development mailing list
> Development@qt-project.org
> https://lists.qt-project.org/listinfo/development
> 
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-05 Thread Jaroslaw Kobus via Development
https://code.qt.io/cgit/qt-creator/qt-creator.git/tree/src/libs/utils/filesearch.h

FileContainer & FileContainerIterator could be an inspiration, too.
The SubDirFileContainer enables traversal according to the selected filters and 
exclusion filters.
This all is a part of the Utils lib inside QtCreator.

Jarek


From: Development  on behalf of Andreas 
Aardal Hanssen 
Sent: Tuesday, December 5, 2023 10:26 PM
To: Qt Development
Subject: Re: [Development] Future of java-style iterators?

How about QDir::iterator, QDir::cbegin, basically make QDir a container? Or 
make a new class that serves the same purpose… /me likes the QDir idea.. :-)

Andreas

Tir 5 des 2023 kl. 22:15 skrev Mathias Hasselmann via Development:
Hi,

would QDirIterator[1] be part of this deprecation? Its API clearly seems
be inspired by the Java-style iterators.

While I do not care much about the other Java-style iterators, I really
like this iterator and use it a lot.
What would be this iterator's modern replacement in Qt?

Ciao
Mathias

[1] https://doc.qt.io/qt-6/qdiriterator.html

Am 03.12.2023 um 21:56 schrieb Christian Ehrlicher:
> Hi,
>
> Some days ago we got an error report in the forum about QHashIterator,
> turned out to be a missing documentation for a complete class which
> remained unnoticed since Qt 6.0
> (https://bugreports.qt.io/browse/QTBUG-119461).
> This leads to the question if we should deprecate all java-style
> iterators since they seem to be a) not widely used and b) it looks like
> we don't support them in a way we should.
> What do you think?
>
>
> Cheers,
> Christian
>
>
--
Development mailing list
Development@qt-project.org<mailto:Development@qt-project.org>
https://lists.qt-project.org/listinfo/development


-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-05 Thread Giuseppe D'Angelo via Development

Hello,

Il 05/12/23 22:15, Mathias Hasselmann via Development ha scritto:

would QDirIterator[1] be part of this deprecation? Its API clearly seems
be inspired by the Java-style iterators.

While I do not care much about the other Java-style iterators, I really
like this iterator and use it a lot.
What would be this iterator's modern replacement in Qt?
Some classes still only have Java-like iterators, not STL-like, so it 
would not make sense to deprecate them there.


QDirIterator, QRegularExpressionMatchIterator, (private) QStringIterator 
and similar don't have replacements yet.


Yes, one can wrap a Java iterator back into a range API (as I've done 
for QREMI, so you can use do `for (auto match : re.globalMatch(subj)`), 
but then one really wants C++20 for the algorithms.



Thank you,

--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - Trusted Software Excellence



smime.p7s
Description: Firma crittografica S/MIME
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development


Re: [Development] Future of java-style iterators?

2023-12-05 Thread Thiago Macieira
On Tuesday, 5 December 2023 14:02:36 PST Giuseppe D'Angelo via Development 
wrote:
> QDirIterator, QRegularExpressionMatchIterator, (private) QStringIterator
> and similar don't have replacements yet.
> 
> Yes, one can wrap a Java iterator back into a range API (as I've done
> for QREMI, so you can use do `for (auto match : re.globalMatch(subj)`),
> but then one really wants C++20 for the algorithms.

QDirIterator could be rewritten either as an input or a forward Standard 
Library iterator. It wouldn't be a bad idea because its implementation is 
broken: while you're trying to get the information about the current item, 
it's stat()ing the next. It's also hard to guess which element you're getting 
and whether you're accidentally skipping the first entry, or missing the last 
one.

All of which are caused by the fact that it *is* a Java-style iterator.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Cloud Software Architect - Intel DCAI Cloud Engineering


smime.p7s
Description: S/MIME cryptographic signature
-- 
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development