7 ms·
So, the argument is that C++ is too hard to learn for the average programmer, and that's why it's not "back"? I don't get it, isn't that win-win is many situat
by jxi 14y ago
So, the argument is that C++ is too hard to learn for the average programmer, and that's why it's not "back"?
I don't get it, isn't that win-win is many situations. I'd rather have a solid developer who can master C++ or at least understand the concepts when explained to him/her, than someone who can't. Basides dealing with compiling/linking (but scons greatly simplifies this), I really don't feel like it limits me much compared to other languages like Python once you know a bit of STL.
- anuraj 14y agoNo. There are increasingly lesser avenues where the raw power of C++ will make a difference. C++ need not be a main stream language when many simpler more elegant alternatives exist. Use it where it is abosultely necessary - where active memory management, access to hardware and performance are absolutely required.
- z3phyr 14y agoIs C or haskell an elegant alternative?
- verroq 14y agoWriting both performant and readable Haskell is difficult IMHO.
- z3phyr 14y agoDifficult does not mean not elegant. For example, I find ruby more elegant and pragmatic than python though ruby is relatively difficult. Now the real part : Is haskell difficult or is it strange?
- tikhonj 14y agoThat's a complicated thing to say. Even unoptimized Haskell tends to be very good when compared with other high-level languages. (Space leaks are more of an issue, but they're not that bad and are more than made up for by Haskell's other relative virtues.) So for most of your code--the parts that aren't tight and performance critical--it's good enough as is and you can just stick to writing normal, concise and (at least in my experience) very readable Haskell. However, there are always going to be the sections of code that you absolutely must optimize. And this is certainly not trivial. However, even this isn't too bad, for two reasons. The first is that much of the difficultly comes with a lack of familiarity: you may know how to optimize C++ or C well, but that knowledge is not going to apply too much. Haskell is very strange, but some people clearly manage to make it perform well consistently, so it's probably a matter of experience. A new C++ programmer will find writing heavily optimized C++ code difficult as well. The other reason it isn't as bad as it could be is that it's possible at all. You simply can't write very performant Python, so you essentially have to drop down to C. In Haskell, this is also always an option; however, even the hard-to-optimize Haskell is still usually friendlier and easier to work with than C! In some cases, by using the right libraries and rewrite rules, you can actually maintain most of Haskell's elegance (like being able to express your program as composed maps and folds) while still getting good performance.
- fayden 14y agoThat is actually one of my concerns about Haskell. It's a bit off-topic to this HN post, but it's relevant to your comment and you seem to have some experience. I find Haskell's syntax very elegant and concise, but I am scared about performances. Often, I read about three or four different ways to do one thing. If I were to pick Haskell as my go-to language, and let's say I wanted to build a performant (memory wise and speed wise) program, would I have a hard time? Now obviously, for day to day applications, the performance topic is irrelevant, but how would Haskell compare for the example above instead of, let's say, Ocaml?
- tikhonj 14y agoI think you would have a hard time, but not entirely because of the language's faults. Rather, the core issue is that most of the things you have to keep in mind to write fast Haskell (like dealing with laziness) are very different from what you would have to keep in mind with more common languages that you are already familiar with. That said, as I noted, the performance is usually good enough even with naively written code; you would only have to spend time optimizing a few select parts of most programs. Another little problem is that there are not many resources on how to optimize Haskell code. This is a little annoying if you're learning on your own; however, I think it's offset by the Haskell community. I've seen some of the best Haskell programmers give very detailed responses on StackOverflow and the mailing list, so there is always somebody to help you while you're learning. There are also some advantages to OCaml--it's a very fast language itself and it behaves in a way that's easier to predict especially since you can leverage more of your existing experience. OCaml is also a very nice languages; while I prefer Haskell, I would be perfectly happy with OCaml (and, in fact, I've only used OCaml and not Haskell in production). I should add a big caveat to this whole post: while I've used both Haskell and OCaml a fair bit, I've avoided doing anything super performance sensitive. I usually care more about having correct, readable code quickly than I do about how fast it runs. So I am definitely no expert on optimizing either Haskell or OCaml!
- fayden 14y agoThank you for your answer.
- z3phyr 14y agoAnd Haskell is pretty much readable :) The most readable fp language out there, at least for me! (I would also like to say, that it is one of the most readable programming language, I have dealt with)
- lallysingh 14y agoThere isn't just a single axis for developers. A developer who knows the details of C++ may just be (or possibly, probably) a language lawyer. That doesn't mean they know much about how to put out readable, maintainable, performant, simple code in a reasonable time frame. One could argue that many developers know better than taking the productivity hit of C++. Disclaimer: I do C++ as my day job, and my MS thesis was in metaprogramming. I still think C++ usually doesn't apply, even though in some important cases, it very much does.
- recursive 14y agoThe fact that a developer can master C++ doesn't imply that C++ is the best language for that developer to use.