Given enough eyeballs - a Sunday rant...
-
... after a frustrating week, this could be taken as a general rant at the quality of open-source software with applications to particular pieces. Given enough eyeballs, where are those eyeballs looking? Surely not at libpng[^] - the reference implementation for the PNG format. It is a smallish library of about 20 kLOC but the configuration file with all the possible options has over 200 different options. That makes for 200x200 = 40k potentially different ways you could build the library. Either that or some of the options are redundant. The code quality is atrocious. I understand that it's a project started in the '90es but that's no excuse for not cleaning it up from time to time. You cannot let one test program get to 12000 lines in a single file. And those 12000 lines are full of miracles like parameters and structure members called
this
! Don't you worry! At the beginning of the file there is this fragment:#ifdef __cplusplus
define this not_the_cpp_this
define new not_the_cpp_new
:omg: Also, if the byzantine compile time configuration options make it impossible for the program to run would you think of throwing an error using a
#error
directive? NO, good quality open-source code just wraps the whole program in an#if
block with the#else
clause, 12000 lines below:#else /* write or low level APIs not supported */
int main(void)
{
fprintf(stderr,
"pngvalid: no low level write support in libpng, all tests skipped\n");
/* So the test is skipped: */
return SKIP;
}
#endifRemember: these are compile time conditions; why would you fail at run time? Have you heard of semantic versioning? Well, check this out (straight from the LIBPNG) web site:
Quote:
At present, there are eight branches: master (actively developed) libpng16 (equivalent to master) libpng17 (frozen, last updated on 2017-Sep-03) libpng15 (frozen, last updated on 2017-Sep-28) libpng14 (frozen, last updated on 2017-Sep-28) libpng12 (frozen, last updated on 2017-Sep-28) libpng10 (frozen, last updated on 2017-Aug-24) libpng00 (frozen, last updated on 1998-Mar-08)
These translate in version numbers as 1.6.x, 1.7.x, 1.5.x
-
... after a frustrating week, this could be taken as a general rant at the quality of open-source software with applications to particular pieces. Given enough eyeballs, where are those eyeballs looking? Surely not at libpng[^] - the reference implementation for the PNG format. It is a smallish library of about 20 kLOC but the configuration file with all the possible options has over 200 different options. That makes for 200x200 = 40k potentially different ways you could build the library. Either that or some of the options are redundant. The code quality is atrocious. I understand that it's a project started in the '90es but that's no excuse for not cleaning it up from time to time. You cannot let one test program get to 12000 lines in a single file. And those 12000 lines are full of miracles like parameters and structure members called
this
! Don't you worry! At the beginning of the file there is this fragment:#ifdef __cplusplus
define this not_the_cpp_this
define new not_the_cpp_new
:omg: Also, if the byzantine compile time configuration options make it impossible for the program to run would you think of throwing an error using a
#error
directive? NO, good quality open-source code just wraps the whole program in an#if
block with the#else
clause, 12000 lines below:#else /* write or low level APIs not supported */
int main(void)
{
fprintf(stderr,
"pngvalid: no low level write support in libpng, all tests skipped\n");
/* So the test is skipped: */
return SKIP;
}
#endifRemember: these are compile time conditions; why would you fail at run time? Have you heard of semantic versioning? Well, check this out (straight from the LIBPNG) web site:
Quote:
At present, there are eight branches: master (actively developed) libpng16 (equivalent to master) libpng17 (frozen, last updated on 2017-Sep-03) libpng15 (frozen, last updated on 2017-Sep-28) libpng14 (frozen, last updated on 2017-Sep-28) libpng12 (frozen, last updated on 2017-Sep-28) libpng10 (frozen, last updated on 2017-Aug-24) libpng00 (frozen, last updated on 1998-Mar-08)
These translate in version numbers as 1.6.x, 1.7.x, 1.5.x
Thanks for the amusing rant! You're saying the implementation of the PNG format is only 20 KLOCs and is a hacked together PoS written in C? I'm stunned no one has rewritten it. That was something that regularly gave me joy! But let me guess. Obscure corners of the spec for which no test images exist? People who'd scream about a breaking change that forced them to revisit magic settings for 200 options? Or just, "if it ain't broke, don't fix it"--which makes sense if it's not seeing new development, but it sounds like it is. And that many developers contributing to it over a long period of time were fearful of breaking it, so most (or all, because of a "policy") enabled their new code with a new option?
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
Thanks for the amusing rant! You're saying the implementation of the PNG format is only 20 KLOCs and is a hacked together PoS written in C? I'm stunned no one has rewritten it. That was something that regularly gave me joy! But let me guess. Obscure corners of the spec for which no test images exist? People who'd scream about a breaking change that forced them to revisit magic settings for 200 options? Or just, "if it ain't broke, don't fix it"--which makes sense if it's not seeing new development, but it sounds like it is. And that many developers contributing to it over a long period of time were fearful of breaking it, so most (or all, because of a "policy") enabled their new code with a new option?
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing.C:\development\png\src>cloc *.c
15 text files.
15 unique files.
0 files ignored.github.com/AlDanial/cloc v 2.00 T=0.11 s (134.0 files/s, 275793.4 lines/s)
Language files blank comment code
C 15 4626 5400 20838
SUM: 15 4626 5400 20838
Greg Utas wrote:
is a hacked together PoS written in C?
I wouldn't go to call it a PoS, but certainly in dire need of a cleanup.
Mircea
-
C:\development\png\src>cloc *.c
15 text files.
15 unique files.
0 files ignored.github.com/AlDanial/cloc v 2.00 T=0.11 s (134.0 files/s, 275793.4 lines/s)
Language files blank comment code
C 15 4626 5400 20838
SUM: 15 4626 5400 20838
Greg Utas wrote:
is a hacked together PoS written in C?
I wouldn't go to call it a PoS, but certainly in dire need of a cleanup.
Mircea
There's actually a reasonable number of comments and blanks!
Robust Services Core | Software Techniques for Lemmings | Articles
The fox knows many things, but the hedgehog knows one big thing. -
C:\development\png\src>cloc *.c
15 text files.
15 unique files.
0 files ignored.github.com/AlDanial/cloc v 2.00 T=0.11 s (134.0 files/s, 275793.4 lines/s)
Language files blank comment code
C 15 4626 5400 20838
SUM: 15 4626 5400 20838
Greg Utas wrote:
is a hacked together PoS written in C?
I wouldn't go to call it a PoS, but certainly in dire need of a cleanup.
Mircea
"cloc *.c" Dear Jesus, I miss the command line. I really need to go back to Unix development. Or go on a car camping road trip alone...
Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.
-
"cloc *.c" Dear Jesus, I miss the command line. I really need to go back to Unix development. Or go on a car camping road trip alone...
Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.
In my last job, we needed to know the number of code / blank / comment / hash / blockdelimiter-only lines in various languages (with different comment markers and block delimiters), as well as code lines with embedded or end-of-line comments. Coding it wasn't much above the 'trivial' level. Setting up a standard directory search dialog, a set of check boxes for file selection on type and optionally name, traversing/filtering the selected directories are straightforward, standard tasks. Actually, my biggest problem was handling those files that were themselves processing source code: They frequently contained string values that were comment start/end, confusing the search for "real" comment markers. And nested comments were nasty. I didn't have the resources for writing full parsers for all the languages in question, so I did a few dirty shortcuts; I am not sure if nested comments always were counted 100% correctly, but the assignment called only for an 'estimate', reporting in KLOCs, not exact values, so it was 'good enough'. The functionality went significantly beyond cloc. The tree traversal and file analysis (i.e. line counting) was somewhere around 400 lines of C# code. So, if you really miss it badly: Sit down and code it, with a GUI interface.
Religious freedom is the freedom to say that two plus two make five.
-
In my last job, we needed to know the number of code / blank / comment / hash / blockdelimiter-only lines in various languages (with different comment markers and block delimiters), as well as code lines with embedded or end-of-line comments. Coding it wasn't much above the 'trivial' level. Setting up a standard directory search dialog, a set of check boxes for file selection on type and optionally name, traversing/filtering the selected directories are straightforward, standard tasks. Actually, my biggest problem was handling those files that were themselves processing source code: They frequently contained string values that were comment start/end, confusing the search for "real" comment markers. And nested comments were nasty. I didn't have the resources for writing full parsers for all the languages in question, so I did a few dirty shortcuts; I am not sure if nested comments always were counted 100% correctly, but the assignment called only for an 'estimate', reporting in KLOCs, not exact values, so it was 'good enough'. The functionality went significantly beyond cloc. The tree traversal and file analysis (i.e. line counting) was somewhere around 400 lines of C# code. So, if you really miss it badly: Sit down and code it, with a GUI interface.
Religious freedom is the freedom to say that two plus two make five.
I agree. Of course, this can be done. I just miss the cleanliness of Unix as compared to the 5 headed hydra monstrosity that Windows has become. VS2022 is so bloated, we should bring back whaling and turn it into oil.
Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.
-
... after a frustrating week, this could be taken as a general rant at the quality of open-source software with applications to particular pieces. Given enough eyeballs, where are those eyeballs looking? Surely not at libpng[^] - the reference implementation for the PNG format. It is a smallish library of about 20 kLOC but the configuration file with all the possible options has over 200 different options. That makes for 200x200 = 40k potentially different ways you could build the library. Either that or some of the options are redundant. The code quality is atrocious. I understand that it's a project started in the '90es but that's no excuse for not cleaning it up from time to time. You cannot let one test program get to 12000 lines in a single file. And those 12000 lines are full of miracles like parameters and structure members called
this
! Don't you worry! At the beginning of the file there is this fragment:#ifdef __cplusplus
define this not_the_cpp_this
define new not_the_cpp_new
:omg: Also, if the byzantine compile time configuration options make it impossible for the program to run would you think of throwing an error using a
#error
directive? NO, good quality open-source code just wraps the whole program in an#if
block with the#else
clause, 12000 lines below:#else /* write or low level APIs not supported */
int main(void)
{
fprintf(stderr,
"pngvalid: no low level write support in libpng, all tests skipped\n");
/* So the test is skipped: */
return SKIP;
}
#endifRemember: these are compile time conditions; why would you fail at run time? Have you heard of semantic versioning? Well, check this out (straight from the LIBPNG) web site:
Quote:
At present, there are eight branches: master (actively developed) libpng16 (equivalent to master) libpng17 (frozen, last updated on 2017-Sep-03) libpng15 (frozen, last updated on 2017-Sep-28) libpng14 (frozen, last updated on 2017-Sep-28) libpng12 (frozen, last updated on 2017-Sep-28) libpng10 (frozen, last updated on 2017-Aug-24) libpng00 (frozen, last updated on 1998-Mar-08)
These translate in version numbers as 1.6.x, 1.7.x, 1.5.x
Quote:
# define this not_the_cpp_this
I'm refactoring my code now to follow this pattern. May future maintainers writhe in pain.
cheers Chris Maunder
-
Quote:
# define this not_the_cpp_this
I'm refactoring my code now to follow this pattern. May future maintainers writhe in pain.
cheers Chris Maunder
You succumbed to the the power of the dark side[^] :laugh:
Mircea