Fluent C++

fluentcpp.com · Personal blog · on HN since 2016

Jonathan Boccara writes about C++, covering ranges, metaclasses, named arguments, code readability, and language changes.

What HN saysCommenters recommend it as a solid C++ resource and link its posts on strong types and named arguments, which C++ lacks natively.
66HN people shared it
18linked it in comments
162stories submitted
1.6Kstory points
2 years agolast shared
2016people per year2026

Most-shared posts

  1. 1
    C++ Will No Longer Have Pointers
    5 people · 16 points · first shared 2018 · 3 comments on HN
  2. 2
    What Books to Read to Get Better in C++
    4 people · 20 points · first shared 2017 · discussion on HN
  3. 3
  4. 4
    A Summary of the Metaclasses Proposal for C++
    3 people · 41 points · first shared 2017 · 18 comments on HN
  5. 5
    Function poisoning in C++ with gcc
    3 people · 14 points · first shared 2018 · 1 comments on HN
  6. 6
    Named Arguments in C++
    3 people · 6 points · first shared 2018 · discussion on HN
  7. 7
  8. 8
    Std::iterator is deprecated
    3 people · 4 points · first shared 2018 · discussion on HN
  9. 9
    Strong types for strong interfaces
    3 people · 2 points · first shared 2016 · discussion on HN
  10. 10
    Homepage
    3 people · first shared 2017
  11. 11
    Technical Debt Is Like a Tetris Game
    2 people · 257 points · first shared 2020 · 118 comments on HN
  12. 12
    The Shapes of Code
    2 people · 151 points · first shared 2020 · 68 comments on HN
  13. 13
    On Design Patterns in C++
    2 people · 88 points · first shared 2020 · 67 comments on HN
  14. 14
    The Most Beautiful Piece of Code That Prints 42
    2 people · 75 points · first shared 2018 · 23 comments on HN
  15. 15
    The C++ Metaclasses Proposal in Less Than 5 Minutes
    2 people · 28 points · first shared 2018 · 20 comments on HN

What HN people wrote when they linked it

Pr0ject217 · 2022-02-07
EDIT: Paste this hacky snippet into your browser's console to save all of the links into your clipboard: (() => { let result = [...document.querySelectorAll('td a')] .map((link) => link && !link.href.includes('ycombinator') && !link.href.includes('javascript:void') ? link.href : '' ) .filter(Boolean); result = [...new Set(result)]; result.sort(); copy(result.join('\n\n')); })(); Just to help, here's a compiled-list of all of the links shared here so…
ivanmontillam · 2022-02-07
If you're into C++, check out: https://www.fluentcpp.com/ It's a solid resource if you consider yourself a programming athlete. I won't shamelessly plug mine, as it doesn't fit this category yet (programming posts are the least ones I have by quantity), but looking forward to improve that.
vlovich123 · 2020-05-18
For dynamic languages sure. For strongly typed languages it's better to just use the type system to prevent those kind of things. C++ doesn't have great support here (lots of boilerplate needed) & usually people reach for Boost Units or Boost strong types but it's not that hard (https://www.fluentcpp.com/2016/12/08/strong-types-for-strong-interface… Mozilla is also exploring this specifically for coordinate spaces & whatnot too (https://research.mozilla.org/2014/06/23/static-checking-of-units-in-se…
archi42 · 2019-09-27
That's a nice idea. Also, while I love C++, I'm really frustrated that there are no native named arguments :( However, after your comment, I decided to spend a few minutes on the topic, and came up with these links: https://www.fluentcpp.com/2016/12/08/strong-types-for-strong-interface… https://www.fluentcpp.com/2018/12/14/named-arguments-cpp/ I am now looking forward to refactor some of our code base to make use of this. Awesome and thanks for the nudge!
andythemoron · 2017-07-25
Julia Evans' blog is one of my favorites! It was a big inspiration for starting my own blog (https://andythemoron.com). I also love High Scalability and Dan Luu's blog which have been mentioned in other comments. I "follow" several which are mostly defunct, but in terms of blogs that still feature active updates: Evan Klitze's blog: lots of topics around Linux, C++, etc. https://eklitzke.org/ Sutter's Mill: lots of "state of the world" for C++, but also context, history, etc. https://herbsutter.com/ IT Hare: C++, game programming http://ithare.com/ The Erlangelist: Erlang/Elixir http://theerlangelist.com/ null program: lots of miscellaneous topics http://nullprogram.com/ Fluent C++: the name speaks for itself http://www.fluentcpp.com/ Another Programmer's Blog: Linux, C, C++, C#, MSSQL https://www.stev.org/
turtleyacht · 2023-12-23
Curiously Recurring Template Pattern (CRTP): https://www.fluentcpp.com/2017/05/12/curiously-recurring-template-patt… (2017)
jimbob45 · 2021-10-24
That’s actually what I do whenever I’m lacking humility as a coder. One F12 on std::iterator (which is now deprecated lol [0]) is enough for me to remember that I don’t know anything. [0] https://www.fluentcpp.com/2018/05/08/std-iterator-deprecated/
steveklabnik · 2021-03-31
So, I dug into this a bit more, and you're right! https://www.fluentcpp.com/2017/06/13/the-real-difference-between-struc… Maybe it was the era that I learned C++ (which was in the 98 days), but I was taught something closer to this convention, and didn't realize until just now there was such little difference by the book. Just bundling some data together? Use a struct. Doing more? Use a class. I still think this distinction is useful overall, because there often is more of one in many languages, but I will be more precise when speaking about C++ specifically in the future. I would also still argue the same thing overall, that is, Rust does not have what C++ calls classes. Our structs are apparently even simpler than C++ structs.
lpapez · 2021-02-11
When it comes to std::optional, the answer is no. In fact, std::optional<T&> is explicitly forbidden (see here: https://www.fluentcpp.com/2018/10/05/pros-cons-optional-references/) It is used in some other places though. For instance, std::string implementations typically employ small-string optimization (SSO) which means that there might be a limit on string::size() since some of the bits inside that value are used for different purposes (example: https://akrzemi1.wordpress.com/2014/04/14/common-optimizations/). The "niche" in this case is the realization that strings are unlikely to be exabytes in size, so there is no reason to always store zeros in high bits of _size.
dgellow · 2020-09-09
Meta classes in 5 years? You're optimistic :) For those who don't know, there is a short video from fluentcpp: https://www.youtube.com/watch?v=v9eJE2m3CYk (and a transcript if you prefer: https://www.fluentcpp.com/2018/03/09/c-metaclasses-proposal-less-5-min… And the proposal from Herb Sutter is here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0707r3.pdf
MaxBarraclough · 2020-05-22
> It's super common Curiously recurring, even! [0] Although what you're showing seems to be a variation on the curiously recurring template pattern, as the classes being mixed are listed 'symmetrically' without much regard for which will inherit from which. I found a blog post on 'mixin classes', which are like the CRTP but invert the inheritance relation. [1] What you've shown seems to be a third way. [0] https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern [1] https://www.fluentcpp.com/2017/12/12/mixin-classes-yang-crtp/
nitnelave · 2019-10-31
I wrote something similar in C++, completely compile time that disappears at runtime: https://www.fluentcpp.com/2019/09/24/expressive-code-for-state-machine… Although the language itself doesn't guarantee that the value is not used again after a move, good static analyzers will provide a warning in that case, so it can still be safely used.
_pmf_ · 2019-06-18
> In C#, you create a class when it's an object, and a struct when it's a data structure, or am I missing something? Yes and no. Due to the technical limitation that (unlike in C++[0]) structs in C# cannot derive from other structs, DTOs in C# are often implemented (or rather: generated) as classes to allow derivation from a base class that has certain behavioral hooks (say, for misc. custom serializers). [0] See https://www.fluentcpp.com/2017/06/13/the-real-difference-between-struc… (the real technical difference between struct and class in C++ is just that the default visibility modifier for a struct is public and the default visibility modifier for a class is private; both can use inheritance and have virtual methods)
twic · 2019-01-27
Constexpr is not bad, but not macros. Macros can do things like generate new types, and add methods existing types. That's crucial for things like custom derive. C++ will get that sort of thing from the metaclasses proposal, which slouches towards WG21 to be born: https://www.fluentcpp.com/2017/08/04/metaclasses-cpp-summary/
cesarb · 2018-04-01
Having started using the Internet in the 90's, and thus still remembering Geocities-era websites, I loved that they did this as a webring (https://en.wikipedia.org/wiki/Webring): each blog post has a link to the next one, making a singly-linked circular list. Starting with this one, we have: - http://www.bfilipek.com/2018/04/deprecating-pointers.html - http://www.modernescpp.com/index.php/no-new-new - https://www.fluentcpp.com/2018/04/01/cpp-will-no-longer-have-pointers/ - https://blog.tartanllama.xyz/no-pointers/ - https://arne-mertz.de/2018/04/raw-pointers-are-gone/ And it circles back to this one.
sus_007 · 2018-04-01
Another blogger wrote about this : https://www.fluentcpp.com/2018/04/01/cpp-will-no-longer-have-pointers/ Is this actually a joke ?
0xmarcin · 2023-01-20
Seems to me that someone "stole" it from F#. F# probably also take this idea from some unknown (to me) language. Here a similar idea in C++ https://www.fluentcpp.com/2019/10/18/piping-to-and-from-a-stream/ This is generally a weakness of text based programming languages, that you cannot easily express graph flows like: / B1 \ A>-| | -> C \ B2 / |> operator only solves the problem for non-branched flows like A -> B -> C making them more readable by removing nested calls. In theory you can create something similar using JS OOP by attaching e.g. map/use(func) methods to every prototype: function use(func) { func(this); return this; } function map(func) { return func(this); } and then: (1).map(n => n+1) .use(console.log) .map(n => "n = " + n) .use(n => console.log("str = $n")); Introducing a new operator instead of a library is a huge effort. I don't think this proposal will succeed, especially that current custom operator support in JS is nil.

Keyboard shortcuts

/Search
j kNext / previous blog
EnterOpen selected blog
vVisit the blog site
fFollow / unfollow
lSwitch grid / list view
dSwitch dark mode
g hHome
g pTop posts
g tTopics
g fFollowing
g lLiked
g yHistory
g qFAQ
EscBack / close