Hacker News new | ask | show | jobs
by dmicher 2152 days ago
When we are comparing C, Lua (Nginx) and C++ (Envoy). Yes C++ is better :).
2 comments

Honest question: In what way?

Platform wars are over-ish. We have the same compile targets. What they call "Undefined Behavior) is relegated to ... well ... platforms we are not supporting.

C is fast - simple - easy(ish) to learn, and easy to "fuzz" in testing.

I can't speak to LUA - but C++ looks like a mine-field (to me).

Why do you declare that C++ is "better"? (Seriously interested - I don't even know enough these days to have a debate. I just gave up on the C++ hell-hole years (decades?) ago, and maybe should have kept up)

There are many reasons which lead to a cleaner codebase, some of them are: RAII, smart pointers, constant types, reusable containers, standard algorithms library, cleaner way to define interfaces, etc.

Overall our experience is that C++ code is smaller, simpler to write/read, and has a smaller chance of mistakes than equivalent logic written in C.

Of course many of this points are relevant only for relatively modern C++ (c++11/c++14 or newer), before that the cost/benefit ratio was much less clear.

Fair enough. Thank you.

In my case - C (as a language) had a smaller footprint, and if the targets were limited, it was easier to learn, to lint and to code-inspect.

Admittedly, this was mostly before C++14. I guess this might be a case of "once bitten, twice shy".

Thank you.

I'm not declaring that C++ is better for everything. In our case it is better because it makes this part of the infrastructure more sustainable: there are more engineers who can code well in C++ vs C in our company and industry overall. Also it is easier to code in C++ as it is general purpose programming language with a lot of libraries available, open source projects, community around it etc.
Maybe we program in different verticals. I have not found it to be so. (I have still upvoted your comment).
I value your opinion.
Well, that is very gracious - esp. here.

I value yours.

You have different experiences than I do - so our conclusions will differ.

That said - I "feel" as if C++ is a dangerous serpent of a language. Maybe I need to spend 6 months re-acquainting myself in complex environments with more developers than just me, and re-evaluate that presumption on a medium-size project.

Thank you.

Your happiness is important to me.
I think what they're trying to say is that developing plugins for nginx in Lua is not great. It's not a rant about languages.

This has to do with nginx not having the required features (features blocked behind the paid edition or GRPC non existent), forcing to develop plugins in Lua to compensate (the only supported language) and Lua is too slow for this sort of stuff (processing Gbps of traffic in real time is no joke).

That makes sense. Thanks. (I still prefer C - but I am admittedly getting old and C++ sucked in the mid-90s or so)

EDIT: BTW -- I am not going to argue with LUA throughput. I'm still not sure what the thinking was there (maybe time-to-prototype?) - but C plugins run faster than Apache's do. By, like, a lot. (And I like Apache! ...Having used it since 1996)

It depends on the team. C++ can be better. It can also be worse.