Rust-Based, Memory-Safe PNG Decoders "Vastly Outperform" C-Based PNG Libraries

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • lowflyer
    replied
    Originally posted by TheMightyBuzzard View Post

    That I have written Rust is precisely why I can say it with absolute certainty. I even contributed to a few crates back before they all started adopting CoCs. The second they did I stopped contributing to them.
    I commend you for standing up against these CoC's

    Leave a comment:


  • kerosina
    replied
    Originally posted by TheMightyBuzzard View Post

    That I have written Rust is precisely why I can say it with absolute certainty. I even contributed to a few crates back before they all started adopting CoCs. The second they did I stopped contributing to them.
    Seeing your [github profile](https://github.com/TheMightyBuzzard), you only ever contributed to perl projects, no Rust projects.

    Leave a comment:


  • lowflyer
    replied
    I emphasize the importance of using up-to-date compilers and libraries. Especially since clang-19 and gcc-14 are readily available on all Linux distributions. Likewise, rust developers also no longer use versions from before rust-1.60.0.

    Originally posted by back2未來 View Post
    ... it's more difficult adjusting type conversions within Cpp ...
    Type conversions is a concept originating from the C language. The goal of C++ is to make most type conversions unnecessary. C++ has "type inheritance" to accomplish that and it has made type casts (like "reinterpret_cast<T>()") deliberately ugly to push programmers to write better code.

    Originally posted by back2未來 View Post
    ...
    for 'unknown' libraries (with reading header files and research of compiler warnings/errors) and more distracting from feature building within Rust getting all necessary dependencies inserted (and an overview of available packages/features?), especially creating error messages seems being a more demanding task.
    With debugging enabled, small Rust programs can get a relatively huge storage requirement (~1-2GB, with several dependency package/feature versions inside a /target/debug sub directory(?), yes, some report even high ~x0GB sizes for the target/debug/deps folder, a
    Code:
    cargo clean
    clears that, with a next compiling taking longer again.).
    ...
    Complicated error messages are no longer a big issue with clang and gcc - unless you still work with microsoft compilers, Python or Java.

    You raise an important point about library dependencies. Rust makes it way too easy to add dependencies. That's perhaps the reason why rust is so much liked by web developers.

    Novice C++ programmers often make the mistake to ignore the "Boost" library. And what's worse even the C++ standard library. Boost is easy to install on any Linux system. With it there is rarely a need for other libraries.

    Leave a comment:


  • back2未來
    replied
    Originally posted by lowflyer View Post

    Adding the "-pedantic" option to the compiler does not change anything. The code compiles - as it did before. But it still fails at the same place with the same message with both g++ and clang++. I think you don't actually know why it fails.

    The compilers are way too old. clang++ is currently at version 18 and g++ at version 14. And I suggest you also define a more recent C++ standard like C++23 or so by adding:
    Code:
    -std=c++23
    [ it's mostly functional, with adjusted sources and
    Code:
    clang++-14 -pedantic -std=c++20 tmp.cpp -o tmp.clang14.bin
    Code:
    g++-11 -pedantic -std=c++23 tmp.cpp -o tmp.gpp11.bin
    (compilers: ~2.5/3.5yrs since release date)

    With not that much practice in programming, it's more difficult adjusting type conversions within Cpp for 'unknown' libraries (with reading header files and research of compiler warnings/errors) and more distracting from feature building within Rust getting all necessary dependencies inserted (and an overview of available packages/features?), especially creating error messages seems being a more demanding task.
    With a debug(/release) compile target, small Rust programs can get a relatively huge storage requirement (~1-2GB, with several dependency package/feature versions, (easy to choose from versions,) being rebuilt, inside a /target/debug sub directory(?), some report even high ~x0GB sizes for the target/debug/deps folder; a
    Code:
    cargo clean
    clears that, with a next compiling taking longer again.).
    (For what's there with software: Since the build systems also differ, it's not only about source code translation/conversion.)

    Statistics reflecting more attention/demand for C&Cpp, like
    'Most demanded programming languages by recruiters worldwide in 2024'(?)
    • Python ~42%
    • JavaScript ~41%
    • Java ~39%
    • C# ~25%
    • SQL ~24%
    • C++ ~24%
    • Typescript ~23%
    • Html CSS ~22%
    • Php ~18%
    • C ~12%
    • Bash ~7%
    • Go ~6%
    • PowerShell ~4%
    • Ruby ~4%
    • Rust ~3.5%
    • R ~3%
    • Perl ~2%
    • Lua ~1%
    • Fortran/Pascal/Delphi/Haskell/Julia/Tcl ~0.7-0.9%

    (thx) ]
    Last edited by back2未來; 17 December 2024, 03:57 AM.

    Leave a comment:


  • lowflyer
    replied
    Originally posted by darkonix View Post
    I'm not arguing. I agree with what you said. My point that all that C language is embedded in C++. There is no switch to separate both. To write safe code requires a conscious effort that evidently most people can not or will not do.
    Your point "C language is embedded in C++" is only "almost" true. There are a few things in C that are not in C++, but as a C++ programmer you'll not miss these. There are command line switches in (nearly) all compilers that allow you to separate the subsets.

    "To write safe code requires a conscious effort" is a generic truth that is valid even for so called "memory safe" languages. I highly doubt that "most people" are not willing to write safe code. But there are always a few dickheads around that cannot be convinced otherwise. Just look around in this forum.

    Leave a comment:


  • darkonix
    replied
    Originally posted by lowflyer View Post

    I'm sure you're not trying to argue that putting your C-code through a C++ compiler because "it works" is a good thing. Honestly, would you still classify them as "good C++ developers" then? Despite them only writing C?

    The point I try to make is "with a C++ compiler you don't have to write C". I understand that people still do it (for a certain time) because they are used to it. But C makes it way too easy to write e.g. null-pointer exceptions in perfect valid C. In C++ it is a lot harder to write such atrocities. Every programmer that leaves C-habits behind (pointer arithmetic, malloc, ralloc, free, etc.) can outgrow himself and become a decent C++ developer.

    Good developers - irrespective of the language - always attempt to learn and grow.
    I'm not arguing. I agree with what you said. My point that all that C language is embedded in C++. There is no switch to separate both. To write safe code requires a conscious effort that evidently most people can not or will not do.

    Leave a comment:


  • lowflyer
    replied
    Originally posted by sdack View Post
    This is your opinion, but opinion is not the same as fact. Fact is Wuffs PNG exists as Rust and as C code. fpng was written in C++ and is faster than Wuffs PNG. Wuffs PNG is said to have borrowed from fpng. Your opinion is therefore false and likely only based on wishful thinking.

    C and C++ are not simply different. You are intentionally blurring the line for the sake of making a false argument. C++ was derived from C deliberately. These share many language features on purpose. The name C++ itself is a direct reference to the C language for example. Even you will know this. If you then believe it is not OK that C++ code can look like C code then you are wrong. You may disagree with this, but it is again just an opinion you have and not based on fact.
    You accuse me of:
    • intentionally blurring the line
    • making a false argument
    • just voicing my opinion​
    1. what does "blurring the line" actually mean? What exactly do I blur? Where do I do that? I can assure you that I did not do that intentionally.
    2. I did not have a close look at the performance figures. But I take what you write: "fpng was written in C++ and is faster than Wuffs PNG". Doesn't that speak for the point I make: "higher level languages can optimize better"? In what way is my argument false then?
    3. In what way is voicing my humble opinion wrong? Anybody should be able to voice his opinion - even if it is wrong. (Or, are you trying to implement hate-speech laws here?) You say my opinion is "not based on fact". What is the "fact" then?

    C++ was not "derived" from C. C++ is a new language that was designed to have C as a subset, for backwards compatibility. (Read: "Design and Evolution of C++") It also shares some heritage from Smalltalk.

    I try to make the following point: "with a C++ compiler you don't have to write C". The whole point of C++ is that people don't have to deal with things like pointer arithmetic, malloc, realloc, free, etc. and rather express their intention in code directly. I can understand that people start with using C for a certain time as they grow. But it's only to their detriment. C makes it way too easy to write bugs like e.g. null-pointer exceptions in perfect valid C. Such atrocities are a lot harder to write in C++. Every programmer that leaves his beloved C-habits behind will grow and become a decent C++ developer.​

    Leave a comment:


  • lowflyer
    replied
    Originally posted by darkonix View Post
    Well that's not too surprising. It is a part of C++, people will use it.
    I'm sure you're not trying to argue that putting your C-code through a C++ compiler because "it works" is a good thing. Honestly, would you still classify them as "good C++ developers" then? Despite them only writing C?

    The point I try to make is "with a C++ compiler you don't have to write C". I understand that people still do it (for a certain time) because they are used to it. But C makes it way too easy to write e.g. null-pointer exceptions in perfect valid C. In C++ it is a lot harder to write such atrocities. Every programmer that leaves C-habits behind (pointer arithmetic, malloc, ralloc, free, etc.) can outgrow himself and become a decent C++ developer.

    Good developers - irrespective of the language - always attempt to learn and grow.

    Leave a comment:


  • lowflyer
    replied
    Originally posted by back2未來 View Post

    [ It's not him. Initially it was not meant being a json parse example and it was my task adjusting the structure he provided into a suitable example.
    Being more focused on the Rust example compiling, the Cpp example failed some detail, adjusted now, at least for
    Code:
    clang++-14 -pedantic tmp.cpp -o tmp.clang14.bin
    Code:
    g++-11 -pedantic tmp.cpp -o tmp.gpp11.bin
    (thx) ]
    Adding the "-pedantic" option to the compiler does not change anything. The code compiles - as it did before. But it still fails at the same place with the same message with both g++ and clang++. I think you don't actually know why it fails.

    The compilers are way too old. clang++ is currently at version 18 and g++ at version 14. And I suggest you also define a more recent C++ standard like C++23 or so by adding:
    Code:
    -std=c++23

    Leave a comment:


  • sdack
    replied
    Originally posted by lowflyer View Post
    Simple: "Rust expresses the intention of the program better and clearer than C". Under C, the compiler sees only a sequence of conditions and loops. With any higher order language the compiler "sees" what the loops and conditions are meant for. Therefore it is able to provide much better optimizations. You guys might not like what I say next, but I expect the same performance-uplift when these libraries would have been written in C++.

    sdack I disagree with "it's OK for code to look like C in a C++ program". C++ is a different programming language, it deserves to be treated as such. I understand what you're trying to say: "if the only tool in your box is a hammer, every problem starts to look like a nail to you". Not every C++ program you don't understand is automatically "idiotic". I have seen a lot of absolutely idiotic C programs in my life. Understanding C++ needs a bit of learning. If you are tainted with C already, it needs unlearning and a lot of learning.​
    This is your opinion, but opinion is not the same as fact. Fact is Wuffs PNG exists as Rust and as C code. fpng was written in C++ and is faster than Wuffs PNG. Wuffs PNG is said to have borrowed from fpng. Your opinion is therefore false and likely only based on wishful thinking.

    C and C++ are not simply different. You are intentionally blurring the line for the sake of making a false argument. C++ was derived from C deliberately. These share many language features on purpose. The name C++ itself is a direct reference to the C language for example. Even you will know this. If you then believe it is not OK that C++ code can look like C code then you are wrong. You may disagree with this, but it is again just an opinion you have and not based on fact.
    Last edited by sdack; 15 December 2024, 01:25 PM.

    Leave a comment:

Working...
X