Hacker News new | past | comments | ask | show | jobs | submit | more fish2000's comments login

These are good rules – as in liquor advertisements, it’s advisable to always accompany a declaration that uses `auto` with a rejoinder in the comments to Please Enjoy Responsibly


“A Variadic Template A Day Keeps The Job Security In Play”


You should see the code that variadic templates replace.


Say more! I'd like to know what you mean.


Before variadic templates you couldn't define a function template taking an arbitrary number of arguments; what you could do is define N overloads up to a finite large N. This quickly becomes tedious and hard to maintain, so you either write an external generator script, or 'creatively' use the preprocessor. These solutions were also not much easier to maintain and of course would kill compilation times.

The worst part is that often these were forwarding functions, that is, they didn't do anything directly with their parameters, but simply forwarded them to some other function (this happen surprisingly often in highly generic code). To do forwarding correctly, you have to handle const and non const reference arguments properly, which means that N overloads are not enough and you need N*2^N (someone please check my math) overloads. As you can imagine, this was impractical for N > 3.

Variadic templates plus perfect forwarding via magic references make easy, practical and possible what was impractical before.

edit: spelling


OP I believe you meant to say “q.v.” instead of “e.g.”


I am really into C++ but it has the same problem that Perl has – it does not try to stop anyone from using it to express themselves in an ugly or inscrutable fashion – and this is a frustrating aspect of dealing with the C++ ecosystem/community.

Personally I spent enough time writing Python to acquire significant coding OCD about things like whitespace, file/directory layout, documentation. When I write C++ I have two prime directives: 1, keep it compulsively tight and legible; 2, use the idioms of C++ to sort out other peoples’ APIs (as opposed to reinventing wheels). I stick to these rules like they’re a diet, it is easy to let your mind wander and find that you’ve spent half the day writing a framework instead of solving your problem; metaphorically this is the equivalent of forgetting to go to the gym and then ordering pizza for dinner. Along these lines I give myself one premature optimization a week, like as a cheat.

I find it is most productive when you are using C++ “against” something. For example I just wrote a bunch of templates that eliminate like 90% of the requisite API boilerplate the Python C API calls for – that was simultaneously satisfying in both the “I totally solved that specific problem” and “dogg check out this clever snippet I wrote” senses of ‘satisfying’. Contrastingly, the last time I created a class hierarchy it was a sprawling regrettable mess – I am more “structure-oriented”, versus “object-oriented”, but still.


q.v. another blog by a fantastic marketer-who-codes, Cody Boyte: https://medium.com/@codyboyte


Naturally, this articles’ photo of the mud-slaked Rubenesque woman was the image on my screen when my new co-worker dropped in on me… calling this piece NSFW feels a bit prudish but let my experience be your warning


That's why I read the comments first at HN. Thank you.


It is NSFW.

Saw that picture and the one of the couple in the hot spring. Then I remembered, Nat Geo was recently taken over by Fox.

Ah, I thought. Explains everything.


As much as I mourn the Murdoch sale, National Geographic has long been famous for its occasional bare skin.


Yes... When it made a point.

The bare skin in these photos have little to do with the content of the article.


q.v. The Manifesto of the Futurist Programmers, 1991 (linked) – based on the Futurist Manifesto, signatories include one Milanese painter, and 5 noteworthy denizens of Silicon Valley…

In the interest of not spoiling I leave it as an exercise to the reader to click through and scroll down


This is indeed a great intro article.

For those interested in seeing examples of LLVM hacking in action, I would recommend reading the source for Halide – https://github.com/halide/Halide – which is an image-processing DSL implemented in C++ and piggybacking on LLVM. I myself learned a lot about LLVM this way.


    holler ("Preposterous fd value %d", fd);
(I just had to debug a descriptor mess and this style of freewheeling 90’s-style documentation rejuvenated me w/r/t all of that, hah)


By “goads” do you mean “gods” (in, like, the Battlestar Galactica sense) or is that supposed to be “gonads”, as in junk? Just askin.


"Apparently, "to kick against the goads" was a common expression found in both Greek and Latin literature—a rural image, which rose from the practice of farmers goading their oxen in the fields. Though unfamiliar to us, everyone in that day understood its meaning. Goads were typically made from slender pieces of timber, blunt on one end and pointed on the other. Farmers used the pointed end to urge a stubborn ox into motion. Occasionally, the beast would kick at the goad. The more the ox kicked, the more likely the goad would stab into the flesh of its leg, causing greater pain."

Src: http://www.jesus.org/early-church-history/the-apostle-paul/h...


the phrase was translated by King James as "kick against the pricks" [1] src: http://www.gotquestions.org/kick-against-the-pricks.html


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: