Hacker News new | ask | show | jobs
by yaris 2853 days ago
Well, I can say the same about Python, Erlang, Lua, in addition to C and C++. I believe C is not worse than these languages, only that C requires different (sometimes very different) skills and discipline.
2 comments

I'm absolutely sure same skill level programmer will create less defects in Python, Erlang and Lua than in C. You really have to try to overwrite memory in those languages.

Of course you can shoot yourself into foot with stuff like metatables in Lua and Python metaclasses and whatnot. Then again you should see some C macro messes around...

Anyways I don't like when people defend C with that age old argument it requires a clever disciplined programmer that never makes mistakes. Because either such programmers don't exist or they're very rare.

> I'm absolutely sure same skill level programmer will create less defects in Python, Erlang and Lua than in C.

Fewer defects, or just different (arguably less severe) defects? It's great that you're sure, but evidence would be even better.

Ok, that's a fair point. I don't have the evidence for that.

Scripting languages do have their pitfalls. Lua and python can have type mismatches and even typos causing misbehavior, things that usually aren't issues with C.

However, you do need significantly less code than in C.

Python, Erlang, Lua = Logic Errors

C and C++ = Logic Errors + Memory Corruption + UB

From this point of view,

Σ Logic Errors < Σ (Logic Errors + Memory Corruption + UB)

hmmm... In my experience, I have had much less logic errors in C++ than in Python or JS because I tend to try to encode the domain logic into the types as much as possible, so that I can piggyback on the compiler.
And how many memory corruption and UB errors did your Python and JS code had?
none, but I hardly ever encounter them in C++ too since I always develop in debug mode with sanitizers and debug std containers, so they blow up immediately. In C that's another story...
So you are part of the 1% audience crowd from CppCon, developing software alone in C++ without any third party binary libs. :)