4 ms·
The real question is why C/C++ programmers accept code like that. You can write that same code in an easier-to-follow way, and the compiler will turn it into an
by mabbo 6y ago
The real question is why C/C++ programmers accept code like that. You can write that same code in an easier-to-follow way, and the compiler will turn it into an identical binary.
Code should be written for humans.
- pjmlp 6y agoFrameworks produced by Windows dev team are a very good example of that. They could produce something that looks like Qt, OWL/VCL, or nowadays .NET like but in C++. Instead they produce libraries where one is forced to use C low level details, mixed with Win32 and COM pointer handling and casts everywhere, not even MFC escapes it. Not to count how many interactions of COM smart pointers that have come up with since COM exists. C++/CX looked like they finally learned their way and would offer something similar to C++ Builder, but no that wasn't meant for us to enjoy it. So now anyone doing UWP with C++, gets to manually edit IDL files without tooling support, and merge the generated files manually. I really don't get their macho developer culture.
- dmos62 6y ago> I really don't get their macho developer culture. I'm inclined to not recognize that as a distinct culture and rather call it an infectious habit. Auditable, maintainable code is a skill, after all.
- nyanpasu64 6y agoAccording to Steven Sinofsky, MFC being a thin wrapper around the underlying MFC was a deliberate design decision during its development. https://hardcoresoftware.learningbyshipping.com/p/010-our-billg-review https://hardcoresoftware.learningbyshipping.com/p/010-our-bi... In retrospect, do you feel it was it a bad idea to not use a heavier abstraction?
- pjmlp 6y agoI am aware of it, hence my remark. It was a bad idea versus what other compiler vendors had in their toolbox. MFC only won because Microsoft is the OS vendor, and Borland lost it trying to fly too high. Back in the MS-DOS and Windows 3.x very few would use Microsoft compilers, Borland and Watcom were the favourite.
- ghanrt 6y agoIt is. Apart from ++index, this is literally the same as: let ch = if index < strlen then str.charAt(index) else 0 Eminently readable and less boring than long if/else chains in Python.
- deleted 6y ago[deleted]
- Twirrim 6y agoYou can write in a very similar way in python too if you want to. I think I'd argue this is cleaner syntax, even. >>> foo = 10 >>> bar = foo if foo > 5 else 0 >>> bar 10 >>> bar = foo if foo < 5 else 0 >>> bar 0
- dmos62 6y agoIt's not. To be easily human-parsable you want to do one thing at a time. It's that incrementation that you've ommited that messes things up. On a side note, having gotten used to newer languages, an option type sure is a nice thing.
- jldugger 6y agoIDK, "for ch in index:" reads pretty cleanly to me.
- deleted 6y ago[deleted]
- lmm 6y agoPeople who care about correctness wouldn't be using C/C++ in the first place. The culture of those languages is performance above all else, and it only gets worse as more and more "moderates" move to memory-safe languages, leaving only the extremists left.
- naikrovek 6y agoThat is not an informed opinion at all. The C++ people I know ALL care about correctness... That's why they use C++. They want to make sure it's done correctly, and not left to some node package that barely works.