Live data from Hacker News

"Parse, don't validate" through the years with C++

derekrodriguez.dev

51–52 of 52 posts

Re: "Parse, don't validate" through the years with C++

#51
post #47
post #11

Earlier quoted context omitted.

What Java code? Regardless of how they might have used LLMs, I tend to have an issue with this kind of complaint, given the C++ example code on the Design Patterns: Elements of Reusable Object-Oriented Software book, released in 1994, 2 years before Java was made public. Or the examples from "Using the Booch Method: A Rational Approach", "Designing Object Oriented C++ Applications Using The Booch Method", or "Using t…

> What Java code? A class with a passel of static member functions is Java code. It is not in any way idiomatic C++ code which has had namespace-level ("free") functions since it was invented as C-with-classes many decades ago. Using classes holding a whole lot of static member functions is strongly frowned on in the professional C++ community.

Author here:

A lot of my professional C++ experience comes from the computer vision space where I am specifically linking against FFmpeg (libav does its own share of memory management tricks that don't always play well with RAII).

I think of static functions (even within member classes) as a signifier of "hey, you don't need a constructed object for this to work and it doesn't depend on class instance state".

In application code, I was typically relying on Myers Singletons and the implicit thread-safeness more than what you see here. I debated dropping the static keyword because it stands out as odd especially in a private class method, but settled on keeping it.

Re: "Parse, don't validate" through the years with C++

#52
post #34

The second sentence of your summary is fine, but I don’t like the first sentence: > Use your language’s type system to parse unstructured inputs. We don’t use the type system to parse. We use the type system to provide evidence (also called a proof or a witness) that parsing was successful, and we rely on the language’s access control facilities (public/private) and the soundness of its type system to prevent fabrica…

I like the linking of "construction of a type is evidence of correctness"!
Post reply on HN