8 ms·
Why people think C++ is complicated?
- DevPad 11y agoOperating low-level resources makes it more complicated and because of that, - big amount of programming mistakes made there are critical.
- LoSboccacc 11y agowait, it isn't? I mean, I worked on that, carefully avoiding all the shot_me_in_the_foot features, like non pure virtual stuff, dynamic and static casts etc, but every time I engage in anything as simple as reading boost sources with templates and stuff knitting magic I just get a brain freeze and get back to java
- ndepoel 11y agoAny language you choose is as complicated as you make it yourself. Some of the cleanest, simplest and most readable code I've seen in my life was written in C, while the most horribly complex, obtuse and over-engineered projects I've seen were written in Java.
- wtf_is_up 11y agoBecause it is?
- s_dev 11y agoGoogle Cache: http://webcache.googleusercontent.com/search?q=cache:http://www.easycppcodes.com/article/why-people-think-c-is-complicated/ http://webcache.googleusercontent.com/search?q=cache:http://... It was down for me.
- eleumik 11y agogreat
- deleted 11y ago[deleted]
- pjc50 11y ago-1 for use of "codes"! (arguably C# is the "top C++" with its managed/unmanaged distinction)
- pjc50 11y agoOK, so clearly the idea that "code" is a mass noun rather than a plural is very unpopular. Or I've failed the "don't be negative" rule.
- Ma8ee 11y agoThe most favourable thing I ever heard anyone say about C++ is that it is a decent language if you only use some parts of it.
- jahnu 11y agoI think it's a true statement though. Same for JavaScript :)
- madiathomas 11y agoI support the idea of dividing C++ into two. That way people can start by learning top C++, use it for some years and start to use features which are on bottom C++ after gaining some confidence.
- frozenport 11y agoThe 'pro' features are heavily used by library designers. In practice, written C++ is indeed, along the lines you mention.
- dschiptsov 11y agoBecause it looks like a standardized set of kluges suffering from the kitchen sink sindrome? (compared to well-designed languages)
- amelius 11y agoC++ is the perfect example that shows that you can't build a language incrementally, while maintaining backward compatibility. You have to oversee all the issues, and define the language accordingly. I'm afraid after a while, Rust will see the same problems, unless they let go of backward compatibility.
- ricogallo 11y agoThat's the reason Scala doesn't guarantee backwards compatibility for major releases. Of course, there is always someone who complaints about it not being enterprise ready.
- Veedrac 11y agoI think Rust is more like early Java. If you start with a good base, the things you need can be introduced relatively smoothly on top of the existing language. C++ is the oddity, in that it is trying to become a completely different language. Rust won't have that problem.
- flohofwoe 11y agoI fully agree with the authors concept that C++ is both a high-level and low-level language, and it is important to choose the right 'sub-language' for a given context. I'd love to have the ability in C++ (and basically all other languages) to turn on/off language and standard library features right in the source code, it would do wonders for the maintainability of projects with many contributors and large code bases in general. Instead of writing a style guide in the sense of "don't use new/delete, don't use raw pointers or arrays, don't use exceptions, don't use CRT functions, don't use stl containers, etc...", and hope that everyone follows the guide or catch violations in code reviews, the style guide would be part of the source code, and violating it would result in compilation errors.
- rockdoe 11y agoLike an automatic linter/formatter?
- frozenport 11y agoSounds like a great idea for a check-in tool.
- 2bluesc 11y agoI will soon be making a library and will be used on micrcontrollers and PCs. I'd like to use C++ but past experiences suggest that using C and writing a C++ wrapper later will save me frustration with things like code size and manual memory management. If I could turn off a number of features, C++ would be great. I keep flashing back to blog posts [0][1] written by the ZeroMQ author trying to settle on C being the way to go. [0] http://250bpm.com/blog:4 http://250bpm.com/blog:4 [1] http://250bpm.com/blog:8 http://250bpm.com/blog:8
- danbruc 11y ago»General relativity has a reputation for being very difficult. I think the reason is that it is very difficult.« Leonard Susskind
- alex95 11y agoIs your next post 'Why people think keeping a website up is complicated?'
- TeMPOraL 11y agoI never found C++ complicated but I suppose it's because this was the first programming language I really learned. When you're learning your first language, you don't have any frame of reference yet to compare it to. You either grok it or don't. And then it becomes your baseline for programming, you compare next things you learn to that first language.
- crapnewdevs 11y agoC++ is not complicated, it a language that offers a range of features and paradigms, and doesn't make you pay for what you don't use, unlike some languages. However, modern "developers" are often impatient, have a frame of reference that everything is ruby or js, not to worry about any resources (they are infinite, right?) and think all their problems can be solved via gem or npm install. The modern software stack has therefore become a bigger pile of more diseased turtles, all the way down.
- TeMPOraL 11y agoIt's hard for me to disagree with that given what often passes for "teaching people to code". I don't find being introduced to a high-level web framework as a good way to begin. You end up typing magic into a file within a big folder structure you have no idea about why it's there, and installing yet another library for every trivial task. One think I loved when learning C++ (and which makes me feel it's not complicated) is that pretty much everything felt like a logical decision if you understood you're just one step above metal. Now I know I was mistaken back then in some ways (by e.g. believing that C memory model is exactly how things are done in hardware). I now believe that every language will feel logical and reasonable if you end up learning about the reasons why it looks like it does and its relationship with what your hardware does.
- jahnu 11y agoIt sure is complicated, and I say that as a full time c++ dev who sees it in a generally favourable light. There is a huge amount of knowledge that you need to pick up over the years before you can consider yourself even an advanced c++ programmer let alone an expert. In my experience it's way more complex than c, JavaScript, Python and any Lisp. However, you can use it in a c-like fashion and avoid some of the complexity but if you want to work with anyone else's code then you have little choice but to learn that complexity.
- cmpitg 11y agoPerhaps a bit off-topic but serious question. I don't understand whenever someone says language A is next to bare metal? What does a language have anything to do with bare metal or performance? Isn't it the compiler/interpreter that performance is about?
- arithma 11y agoIt's about how much the language intrinsically prevents the compiler from optimising the output. Think Javascript versus asm.js, same language, one is just a subset of the other, completely different performance outcomes for the JIT compiler.
- ziegmeister 11y agoLanguages like C and C++ compile down directly to machine code, and the resulting machine code is run from then on the bare metal without any further translation. Interpreted languages such as Python or Ruby (or languages that run on a VM, like Java) go through an interpretation step _every time_ they are run that translates them down to machine language. This gives compiled languages an inherent advantage in terms of runtime performance; programs written in these languages don't have the overhead of translating to machine code at runtime. This is typically why people advocate "next to bare metal" as having better performance.
- cmpitg 11y agoThat said, it's a about the implementation not the language itself. The phrase is technically incorrect, right? One could write a compiler that compiles Python or Ruby down to machine language without the interpretation overhead, and not necessarily faster or slower than their original interpreters, or other C/C++ compilers.
- TheOtherHobbes 11y agoThat's technically true, but I think it has more to do with the programming model. In C and (sort of) C++ you can deal with actual bytes in actual memory locations. You can find the exact memory address of a data structure, and you can read or write directly to that location. You can even prod the compiler to suggest that it uses real hardware registers for variables. You can also control how memory is allocated and released. In most languages an array is just an array. You usually don't care where it is in memory. In functional languages you concentrate more on designing symbolic operations, and the fact that there's real memory under there somewhere is almost irrelevant. But C/C++ are bare-metal-ish. In assembler you work directly with memory, but you can control program flow. You can jump/branch to any address in memory. Sometimes you can even overwrite your own code. C/C++ won't let you do that. As a former assembler guy, I find that C++ is the worst of both worlds. You get the cognitive overhead of dealing with memory management and pointer arithmetic and iterators, but the options for not working with them when you don't want to are limited - so it's hard to concentrate on the functional level, and you do a lot of the work the compiler/interpreter would usually do, but without the "do whatever you want" freedom of assembler.
- viciousplant 11y ago"Error establishing a database connection" But I would say it's because others are easy. Yes others are hell lot easier.
- viciousplant 11y ago"Error establishing a database connection" But I would say it's because others are easy. Yes others are hell lot easier.
- airza 11y agoI think having to to divide the language into two semantically exclusive sublanguages answers the question of the author. (Though the title here is not his title...) The other answer (which there was an article about a few months ago which was posted here) is "Because having exceptions is really complicated when certain object actions can't throw exceptions."
- minthd 11y agoIsn't that what happens in the arduino, where users use top-c++ ? and it works pretty well for them, in a very harsh, constrained environment.
- nadams 11y agohttp://tehsausage.com/ptypes/doc/inet.examples.html http://tehsausage.com/ptypes/doc/inet.examples.html vs http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/tutorial/tutdaytime3/src.html http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/tut... I know a lot of people would criticize the practices/styles used in ptypes - but I've yet to see another C++ library that is as easy to use, easy to read, AND most importantly cross platform. Hell even raw sockets in C is easier to use and understand than boost [1]. This is one of my favorite comments on reddit [2]. [1] http://www.thegeekstuff.com/2011/12/c-socket-programming/ http://www.thegeekstuff.com/2011/12/c-socket-programming/ [2] http://www.reddit.com/r/programming/comments/197dn1/introduction_to_c_a_series_of_46_videos_created/c8lks22 http://www.reddit.com/r/programming/comments/197dn1/introduc...
- cttet 11y agoI am a C艹 beginner from Python and C. I feel that the handling of trade-offs between performance and safety/explicitly is passed to programmers and not the language itself, which made it difficult for beginners to capture what is the best practice. Choices may be good for experienced programmers, but they are not very friendly for beginners.