News for hackers. Stuff that matters.
Re:C++ has become a scripting language by ctz on Wednesday October 16, 2013 @08:20AM (#6559183)
> Would be great if somebody could post Python/Ruby/.. code here that achieves the same, just to compare.

It's actually really hard to completely rewrite that program in most scripting languages: they tend not to have the same concept of undefined behaviour.

'sys.argv[2]' in python (with sys.argv = ['thing.py']) is fully defined (raises an IndexError). 'argv[2]' in C++ (with argv = (char*[2]) { "./thing", 0 }) is undefined.

If you scripting language has an FFI library (ctypes in python, say) then you could probably do something equivalent.

Re:C++ has become a scripting language by stinos on Wednesday October 16, 2013 @08:28AM (#6559220)
good point about the UB. Together with shin_lao's comment about the error/exception handling bascially sums up why the author's claim only makes some sense, but not a lot.
Re:C++ has become a scripting language by mikeash on Wednesday October 16, 2013 @05:46PM (#6562331)
Defined behavior is a subset of undefined behavior. Specifically, "raises an IndexError" is a perfectly legal thing for a C++ implementation to do in this case. Approximately zero real world implementations do this, but nothing says they can't.