15 ms·
I've developed quite a bit in C, C++, Python, Go, Ruby, and Java/Coffee script and a hand full of others. The thing is, of all the languages I code in C++ is m
by lettergram 10y ago
I've developed quite a bit in C, C++, Python, Go, Ruby, and Java/Coffee script and a hand full of others.
The thing is, of all the languages I code in C++ is my favorite. It is the most performant (using C where necessary), and is as easy to code in as JavaScript IMO. C++14 (and higher) feels like coding in Go or Python.
I feel most people don't actually have experience enough with modern C++ and are trying to use the 90's version of C++. The 90's version is awful, and even the modern has a few quirks. However, when you need performance and something less than C it's amazing.
- deleted 10y ago[deleted]
- WildUtah 10y agoC++14 (and higher) feels like coding in Go or Python. C++17 is so full of good stuff I'm considering beta compilers just to get it. Soon Python and Ruby won't have any advantages left in writing beautiful, clear, correct, bug-free, and easy to read code and C++ will still run 200x faster.
- EamonnMR 10y agoCare to share any resources where you can learn about the new features that take it there?
- WildUtah 10y agoWish I could. The hours I've spent reading the formal committee proposals and specs would have been better spent on video games and junk food. But there will be books, and good ones. Next year probably. The compilers aren't even ready yet.
- VodkaHaze 10y agoThe best I found are CppCon youtube videos, really
- justin66 10y ago> Soon Python and Ruby won't have any advantages left in writing beautiful, clear, correct, bug-free, and easy to read code Come on, it's not like they've added garbage collection.
- corysama 10y agoNo garbage collection. But, modern C++ recommendations pretty much deprecate manual memory management for 90% of situations. std::vector and std::make_unique for 80% of everything; other containers and make_shared when you really have to; malloc and new for specialty situations.
- gowld 10y agoThat's still a lot more work and error-prone than using garbage-collection.
- sqeaky 10y agoit more like 99% of the time and as long you don't go near new or malloc you generally can't leak. Then with RAII you can clean up any kind of resource. Most languages have pretty rudimentary tools for closing files and worse for releasing mutexes. These tasks are almost easy to get right in modern C++.
- WildUtah 10y agoI still love 'with-open-file and its sisters in LISP. Get that resource in one line and it's guaranteed to be cleaned up right without ever thinking about it again. Then you have total freedom to use it however you want and the results destructure themselves.
- civility 10y agoYou could implement something comparable: int main() { with_open_file_for_writing("foo.dat", [](FILE* fp) { fprintf(fp, "old style I/O, automatically closed\n"); }); return 0; }
- santaclaus 10y ago> C++17 is so full of good stuff Structured bindings are going to be amazing! Yea we didn't get modules, but I for one am psyched about this feature alone. If only they were faster to upgrade compilers at work...
- contravariant 10y ago> Soon Python and Ruby won't have any advantages left in writing beautiful, clear, correct, bug-free, and easy to read code Does that mean C++17 will finally get support for the generator pattern?
- tathougies 10y agoThe generator pattern is really not that fundamental a language construct, and, in general, is quite straightforward to implement in languages with powerful enough abstractions. C++ is one such language: http://www.boost.org/doc/libs/1_62_0/libs/coroutine/doc/html/coroutine/coroutine/asymmetric.html http://www.boost.org/doc/libs/1_62_0/libs/coroutine/doc/html...
- gpderetta 10y agoI wouldn't call it straightforward, boost.coroutine requires custom assembler for its implementation. Then again, stackfull coroutines are significantly more powerful than generators available in most other programming languages (notable recent exceptions are Go and Lua). Boost.asio provides stackless generators [1] implemented purely in C++, by (ab)using the preprocessor and the switch statement. [1] http://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/overview/core/coroutine.html http://www.boost.org/doc/libs/1_62_0/doc/html/boost_asio/ove...
- pjmlp 10y agoThe problem, as Bjarne also complains about quite frequently, is that regardless of what we do to advocate modern C++, that "90's version of C++" is what most developers at companies scattered around the world bother to write.
- gcp 10y agoI'd rather debug some 90's C++ than someones' template meta-programming gone wrong, though.
- hellofunk 10y agoBut template metaprogramming is not at all what is meant by modern c++. We're talking about using smart pointers and lambdas with the algorithm library and other major conveniences (like simplified multithreading), which are all really great since C++11/14.
- kevin_thibedeau 10y agoSome of us don't have a choice. Some compilers don't even properly support namespace std.
- pjmlp 10y agoI know, still there are quite a few things that are possible, like not using C strings and vectors, making use of RAII, references for out parameters and wrapping C like APIs in stronger types. These were already possible even before C++98 got released.
- mschuetz 10y agoC++11, 14 and 17 finally made me fall in love with C++. It's almost like having a nice and easy scripting language with the added bonus of static typing and a huge performance boost. There are a few things that I'm still not quite happy with. * It's still incredibly cumbersome to set up a project * Setting up a proper build system is tedious, especially if you're targeting multiple platforms. * I'm missing some "functional" methods attached to the collections, e.g. find, filter, map, some, each, ... Afaik some of them exist as functions that take 2 iterators and a lambda but that's just plain ugly and unreadable. Instead of std::find_if(list.begin(), list.end(), condition}); I'd like something like list.find(condition);
- godelski 10y agoThis might interest you then http://www.modernescpp.com/index.php/the-new-ranges-library http://www.modernescpp.com/index.php/the-new-ranges-library
- Koshkin 10y agoAlthough I agree that it would seem natural to have such a method in a standard container class, I would like to make a couple of observations. First, there are containers that do have a find() method, std::map, for example (although not on a condition). It could be a wrong impression, but to me this tells something. Perhaps, if I intend to do a search, I might be better off using a different structure (rather than a list) that is more suitable for searching, or maybe a different - more efficient - algorithm (such as binary_search(), if applicable). Second, if you use a container as a part of your own class, defining a find() method is trivial. I have no doubt that there are other, more technical reasons for the standard library being the way it is, for example, the idea of separation of algorithms from containers by means of iterators.
- chubot 10y agoI would agree with you except for build times. It's not anywhere close to JavaScript or Python in terms of iteration speed and prototyping. C++ 11 and 14 don't do anything in terms of build times AFAIK -- they probably make them worse. I'm hopeful that modules will make a difference, but at first glance they seem awfully complex. And also metaprogramming. In Python, I use Python for metaprogramming. In C++ I have to switch to this weird template language. I'm a template user, and they are mostly great to use, except for build times. Template authors are a completely different kind of C++ programmer.
- shakna 10y agoI use Cling [0] a fair bit. That might help with your iteration. [0] https://root.cern.ch/cling https://root.cern.ch/cling
- cjhanks 10y agoWhen you find that C++ templates are taking unacceptably long compile times, you often benefit from declaring an `extern template`. Some times I have CPP files which do nothing but declare `extern template` instantiations for types I infrequently change. This was added in C++11. In the header you state something like: template <typename _Tp> class Example { }; extern template class Example<int>; In some CPP file you write: template class Example<int>; At that point any calls to Example<int> will not be resolved by callers. They will simply expect the template to be available at link-time. Theoretically this could be slightly slower (I think), since method calls will cross translation units rather than being inlined. But it does cut down on compile times.
- ndh2 10y agoExcept that extern template is unfortunately completely useless for any STL or Boost classes, which produce 99% of all the code bloat: https://msdn.microsoft.com/en-us/library/by56e477.aspx https://msdn.microsoft.com/en-us/library/by56e477.aspx > Note: The extern keyword in the specialization only applies to member functions defined outside of the body of the class. Functions defined inside the class declaration are considered inline functions and are always instantiated.
- bogomipz 10y ago>"I feel most people don't actually have experience enough with modern C++ and are trying to use the 90's version of C++." I understand what you are saying but for a newcomer it's hard to discern the differences as in "oh thats a very 90s way or thats a very C++ revision xx way of doing things." I think this is part of what makes it so overwhelming to learn. The scope of the language is already quite large and then when you pile the different versions on top of that. I am curious if you could share any advice on that for a newcomer to C++? Is it practical to only learn the most recent revision/standard? I would thing its good to know the good and bad if only to understand what rev or style you are looking at without being confused. But maybe that's not necessary or practical?
- DoofusOfDeath 10y agoSomewhat off-topic, but I was wondering if you could explain something about your phrasing. This is a serious question, not snarky. I think I've been out of the loop on this one: What do you mean by "most performant"? Is there some meaningful difference between that phrase vs. "fastest"?
- swift 10y ago"Performant" is basically just a buzzword but I've always viewed it as encompassing a bit more than "fastest" - something like "most efficient in real world use".
- deleted 10y ago[deleted]
- YZF 10y agoI use C++14 extensively and I have to disagree. There are no channels, there are no lightweight/green threads, there's no standard HTTP library, no standard crypto libraries, no standard test framework. For certain classes of applications this makes Go significantly more productive and significantly less bug/error prone. Not to mention compile times. Even the nicest things in C++14 suffer from backwards-compatility-ism i.e. awkward syntax, and endless incomprehensible garbage output from the compiler when you make an error e.g. inside some complex templated code. As C++ devs we manage to live with that stuff but it still sucks. Even if your code uses some nicer subset with standard libraries you typically need to interface to a whole range of things that do not comply with that subset. Be that something like a Cassandra driver that uses libuv or OpenSSL with its native C interface. Any C++14 beauty that may have existed is gone and your code is now subject to all those subtle memory management, buffer overflow, and concurrency issues. I used to think garbage collection was garbage but I've start to appreciate how much simpler it makes my life (Even over RAII smart pointers) for very little cost in Go. Python, Ruby and Javascript are a completely different kind of language so I'm not sure it's worthwhile comparing those to C++. There are many things you can do in Python that you can't do in C++ and that's mostly a good thing ;) That said there are certainly some classes of applications where there's no substitute to C++. It's also much nicer than it used to be. But it shows its age.
- HeavenBanned 10y ago>and endless incomprehensible garbage output from the compiler when you make an error You took the words right out of my mouth.
- lettergram 10y agoIt sounds like you're doing web dev and for that I wouldn't use C++. As you pointed out, languages have different advantages and disadvantages. I was just trying to point out most people don't seem super well versed in modern C++ so it gets undue hate. I usually build embedded systems, desktop apps, and even some higher end computing applications. I use QT in conjunction when I need most of that stuff you mentioned, as that framework makes it easy. Also, > there's no standard HTTP library I mean, there isn't a standard library, but cURL is easy to use.
- WhitneyLand 10y agoI don't get people describing C++ as their favorite. My favorite language is one that is the most productive for the problem at hand. What language/framework/environment gives you the best set of tradeoffs if you want to: - Code new work or updates in as little time as possible - Let a large group of devs of varying skills produce a high quality code base with the least amount of overhead/rules/babysitting - Achieve the the best defect rate/quality given finite time - Require the lowest cognitive load to reason about things - Performance is high enough to meet a point of diminishing returns given the problem at hand
- hellofunk 10y agoThat's a strange comment. You don't understand why someone would enjoy or have as a favorite C++? Just because it doesn't work for you, it shouldn't be awesome for someone else?
- WhitneyLand 10y agoThe point is that when goals are pragmatic it's hard to find room for subjective preference. Do people "enjoy" C++ because they weighed the important concerns and thought it was the best objective choice for their work overall? If so I understand it, otherwise we're talking about a hobby language.
- hellofunk 10y agoI assume you would have the same reaction to someone proclaiming any other language as their favorite, also?
- WhitneyLand 10y agoYes, how can anyone disagree w.r.t. professional development? Again, I only see how subjective judgments are relevant for hobby projects, which is fine when nothing is at stake.
- civility 10y ago