7 ms·
Nobody uses C++ for fun. Unless they're a masochist.
by peterashford 12y ago
Nobody uses C++ for fun. Unless they're a masochist.
- krapp 12y agoOdd... I feel the same way about Python.
- peterashford 12y agoNot fond of significant white space?
- krapp 12y agoHonestly, no. I get the premise, but at least with braces there's no ambiguity at all about where a statement begins and ends. It's certainly not going to be the case that one tab too many or a space instead of a tab wrecks everything. Explicit is supposed to be better than implicit, right? I can't think of anything more implicit than using whitespace as syntax. My personal bias is that whitespace is meant to make code human readable. It shouldn't matter to the interpreter, or at least, it shouldn't be critical to the degree that it seems to be for Python. Of course I say this knowing perfectly well that Pythonists look at C code with its braces and think it's redundant and noisy.
- harry8 12y agoJust so you can laugh at me. Hahaha. That's the one thing I really do like about python. It means any difference in the shape of python code tells you something other than a personal preference of a coder I shouldn't have to know or care about. The consistency of the signal you get from the shape of the code makes this signal useful across codebases. That signal has a lot more noise in it in C & Perl for example. Anyone who talks about automatic indent compensating for it has never worked with jerks using different styles or hasn't had to hack a 3rd party library source to find a bug. No really. Make clang tools will be better but that's a long bow to assume yet. I have never once ever under any circumstances had a goddamn meeting where people argued about python bracing rules for code consistency. That alone makes it a truly epic ultra-megawin, for mine. (*but they absolutely should have standardised on ONE of tabs or spaces and I hate not being able to bounce on the braces to see where that awful code's scope actually starts and who wrote this anyway sweary curse I'm a teapot...).
- tjradcliffe 12y agoThe whole "OMG it's full of whitespace" thing kept me off Python for years, in part because I'd done a lot of work in text processing in the '90's and realized, "Whitespace is not actually evil... it is just misunderstood" was a fair encapsulation of the problem of whitespace parsing, where "equivalant" and "ignorable" whitespace were perennial problems. Once I got over that, Python turns out to be pretty awesome, and while I still use C++ for performance-critical things and C for firmware, the clarity and simplicity of Python is unmatched by any of the other dozen-odd languages I've written in. I agree syntactic whitespace comes with an overhead, but it's more than worth it for the other benefits you get with Python, particularly the ease of using every other library and language on the planet, from lapack to R.
- shmerl 12y agoI really don't like the idea of using fixed length of whitespace for delimiting scope instead of using explicit markers. It's not really a language issue, just syntax preference.
- spacecowboy_lon 12y agoIt always reminds me of the old Punchcard Fortran fixed column layout " Columns 1 to 5 were the label field: a sequence of digits here was taken as a label for the purpose of a GOTO or a FORMAT reference in a WRITE or READ statement. Column 6 was a continuation field: a non-blank character here caused the card to be taken as a continuation of the statement on the previous card. Columns 7 to 72 served as the statement field"
- maxlybbert 12y agoIf you ever screw up the whitespace, it's possible that the mistake won't show up in common diffing software, because most diffing software is designed with the assumption that whitespace is insignificant (and hard to display).
- coldtea 12y agoSo they should just have made tabs compulsory. Problem solved.
- krapp 12y agoIronically, as soon as you need a tool to make whitespace visible in order to determine which delimiter you're using where, you're just using C-style braces again, only now there are two kinds of braces, which are incompatible, and otherwise visually indistinguishable.
- dmpk2k 12y agoI do, and I'm not a masochist. I use it to write small games on my own time. I used to loathe C++, but the C++11/14 dialect makes things much more pleasant. There's still a lot of details you need to worry about, but crucially these are details that other languages rarely give you a choice about. The only real alternative was C, but I'm tired of reinventing wheels and C++ has the STL. C also doesn't have the same support for value types which C++ does, and value types are really nice to use.
- harry8 12y agoValue types, as opposed to polymorphic types, ie pointers (including references)? struct IntForFoo { int value; }; when you use it you write a function that takes an IntForFoo as one of its arguments and you get type safety over other ints. Gently snarl at anyone who does a .value outside such a function. Include a constructor function, an assignment function... Remember that that typedefs just lie to you about the type, they don't change it for type checking... If you need to generate code, do it, macros and templates are just really crappy ways of generating code; you can do a lot better when you need to. But how often do you really need to and how often are you worshipping at the false idol of "must be general so can be used for 100 years" when that's really not the purpose of the code? Polymorphism and templates are overrated by C++ designers you don't actually need them and they encourage some awful designs.
- dmpk2k 12y agoOne of the problems with structs in C, is that you must explicitly call the destructor function if you have non-memory resources. In C++, a scope's closing } always takes care of that for you. As for the generated code bit, I assume you're referring to the STL. Writing my own data structures is explicitly what I don't want to do anymore. STL has it? Great, I use it and move on.
- harry8 12y agoSure use it if you understand it, ie vector where you reserve the memory up front to avoid future allocations and pointer/iterator invalidations or you don't care in which case use a friendlier or more powerful language maybe? Writing datastructures is much of what programming is, I know that's not what you meant and you use the basics of STL to build the real datastructure you want, but you care about performance and with STL it's not targeted at your case so when you get beyond prototype you have to rip it out anyway. Automatic destructor calls on leaving scope is the nicest part of c++ - shame it interacts with exceptions so nastily that nobody understands how it works. "Exception safe code" yeah, right, not in c++. Generated code - you can use macros, you can use templates. Or you can use anything that generates text and does what you want, more nicely than that.
- hendzen 12y agoI use C++ for fun. Mostly because it's actually quite nice if you know what parts of the language to use. C++ could really use a "C++: The Good Parts" book.
- harry8 12y agoIt's got one! "The C Programming Language" by Kernighan and Richie ;-) What it could really use some deprecation of the more idiotic, dangerous, useless features (eg explicit constructors should be the default, unbraced single line blocks only introduce bugs and have no positive value at all). They should also mandate that standards conforming STL implementations ship with a standard set of benchmarks you can run on the hardware you're targeting. All the C++ "anointed smart people" complain people use the wrong STL datastructures but don't show any cleverness at all in solving that problem. No 2 C++ hackers agree on what constitutes "The Good Parts" witness every single C++ style guide ever endorsing a different subset of the language. C++11/14 has not changed this. Modulo different targets make that subset different from the point of view of the very same hacker.
- pjmlp 12y agoIf anything, C is "C++ the Bad Parts. How to compromise language design to achieve adoption".
- harry8 12y agoIn fairness I think C++ has had a lot more compromise in its "design" than C did. C has a bunch of issues but it's understandable. C++, nobody understands it all, and it changes so much from compiler to compiler, accross hardware platforms and so on. Pure virtual base protected friend member functions aren't in C.
- pjmlp 12y agoC also changes a lot between compilers,specially thanks to undefined behavior and vendor extensions. A feature C++ inherited from C. Even between versions of the same compiler. Quite bad in the embedded space. Lack of bounds checking for native arrays, null terminated strings, arrays that decay into pointers, include files instead of proper modules, implicit conversions are among the inherited features. >Pure virtual base protected friend member functions aren't in C. No they are not, but as someone that knows C++ since 1993, I fail to see the problem. Pure virtual base => requires redefinition in derived classes Protected => only accessible in derived classes Friend => can be used by protected member functions of friend classes Not needed in every day C++ code, but enterprise architects love this type of flexibility, which doesn't have anything to do with safety.
- shmerl 12y agoNonsense. C++ is fun!
- pjmlp 12y agoI do. When faced with the sad fact that Turbo Pascal was PC only I had to choose another language. The year was 1993 and C already looked dated when compared with what Turbo Pascal was capable of. Also when compared against Modula-2, which was on the way out as well. So I went C++, which even with C++ ARM compatibility issues, was way safer than C. Nowadays there are plenty of compiled languages to choose from, but between C++ and C I only pick C if obliged to do so.