Earlier quoted context omitted.
The effort required for this makes it not worth it. If I want a library in python it takes about a second to install with one command, and these libraries tend to be safe so you're not going to get any resistance if you want to try out 10 libraries in the next hour or so, which is sort of impossible with c++. Also these libraries are easily uninstalled and isolated from other python apps you have. No need to use mass…
Yeah I wouldn't use C++ for building web applications.
Does C++ still deserve a bad rap?
281–290 of 310 posts
Re: Does C++ still deserve a bad rap?
#282C++ fills a niche and probably if you use it all on your own you don't even see the problems. But if you use it at scale with multiple developers you can see it's layers of leaky abstraction laid down since the 80s that can never really be cleaned because too much is built on this foundation. This slightly over 100 page book on move semantics https://leanpub.com/cppmove shows some of the iceberg like complexities dot…
> if you use it all on your own you don't even see the problems 100x this. If >90% of your serious coding is in one language, you'll become desensitized to its bad parts but you'll be hyper sensitive to anything that seems inconvenient in any alternative. I've seen this over the years with Fortran and C coders. C++ coders do it to C all the time. Lisp coders are notorious for it. It's Selective Perception 101, counti…
Re: Does C++ still deserve a bad rap?
#283Earlier quoted context omitted.
In terms of large projects C++’s role is very much shrinking. C++’s last major strength is being cross platform, but new platforms keep excluding it. You can’t program on iOS or client side websites with it. Microsoft actively discourages using C++ on Windows, and C# took over for large projects. Essentially C++ and the modern ideas about computer security are at war.
For data-intensive applications, which are only increasing, C++ is the only game in town. State-of-the-art architectures typically rely on schedule-based safety models that are not productively expressible within Rust's ownership-based safety model, and the performance characteristics of working within these respective safety models is not comparable. There aren't many alternatives when a GC language is a non-starter…
Re: Does C++ still deserve a bad rap?
#284https://madnight.github.io/githut/#/pull_requests/2020/3
I think it's mainly due to the introduction of C++11, C++14 and C++17, which _has_ rejuvenated the language, despite the criticism.
Discussions like this one tend to be sort of skewed, because opponents of an old technology, like C++, tend to be more vocal in their opinions. Likewise, proponents of a new technology, like Rust, also tend to be more vocal. It becomes sort of noisy. Behind the noise, though, I think the fact remains that C++ is still very solid, and probably even more so than it was just a few years ago.
Re: Does C++ still deserve a bad rap?
#285Earlier quoted context omitted.
Haskell solves this reasonably well. If your data type implements the Num typeclass, you can use literals like 4. (A typeclass in Haskell is similar to what they call an interface in Java.) There's no automatic conversion happening at all. It's done via overloading literals at compile time. (You can do the same for strings.)
C++20 introduced concepts, and now it's possible to specify type constraints, like integral, in a way similar to Haskell typeclasses. What it doesn't solve that by default the compiler tries to find an appropriate implicit conversion. Sometimes it's convenient, sometimes it's harder to see what the code actually does.
Yes, the implicit conversion for all values is part of the problem. The Haskell approach only gives you magic for literals.
Re: Does C++ still deserve a bad rap?
#286Earlier quoted context omitted.
It's rather simple, can easily run on bare metal (ie no OS). You can go very low level, but it has better higher level abstraction capabilities than C. It's also really weird, which fascinates me. Eg most Forth code doesn't use variable names. I've toyed around with Forth a bit. But never used it in anger. Wikipedia says that Forth is used today in some bootloaders and outer space. I suspect the latter is a historic…
Ahh. I remember. I always get fascinated first, but when I see 2 3 4 + * meaning (2+3)*4 my eyes glaze over.
Re: Does C++ still deserve a bad rap?
#287Earlier quoted context omitted.
It does feel fun to bust out a few Project Euler challenges with OCaml; and as a reasonable experience programmer you should be able to do that after those 2-3 casual evening sessions. It's been a few years since I last did OCaml. At that point, the ecosystem was a bit more mature for Haskell. More libraries, better editor support, etc. In some platonic sense I like small languages, but I had come to appreciated all…
Seems likely Haskell will get stack traces by default fairly soon.
Re: Does C++ still deserve a bad rap?
#288Earlier quoted context omitted.
I used to work with C++ almost exclusively, but accepted to use more interactive languages for most of my work mostly for faster iteration. C++ is definitely not my main choice anymore, but still use it daily. C++ has pretty much unmatched tooling due to the massive ecosystem. I have my own long list of gripes against it's syntax and historical baggage, however it's a language that doesn't really impose a style/idiom…
What is "static compilation"?
Re: Does C++ still deserve a bad rap?
#289I have nothing against C++ per se. Used it on and off for 10 years (but most actively 3). It's a fine language. To me using C++ means you are ready to give up a lot of time and energy in order to gain a complete control over certain aspects of your program. I was very much into that at the start of my career and gradually started drifting away to more immediate productivity while reserving the right to poke under the…
I used to work with C++ almost exclusively, but accepted to use more interactive languages for most of my work mostly for faster iteration. C++ is definitely not my main choice anymore, but still use it daily. C++ has pretty much unmatched tooling due to the massive ecosystem. I have my own long list of gripes against it's syntax and historical baggage, however it's a language that doesn't really impose a style/idiom…
But unlike assembly, you don't have control over CPU flag registers and special instructions. Can you explain why and when, exactly, 100% control over memory is needed? Outside of OS kernels, high-frequency trading engines, and real-time control systems? If using assembly is too costly, why is using C++ economical?
And, do you really have control what happens at the machine level? Second and third level caches, hyperthreading, multicore, out-of-order execution, CPU affinity, NUMA, TLB, virtual memory, all that stuff, there is nothing in C++ which controls that.
And I would even argue that this in most cases is a good thing, because unless you are writing an OS kernel, it is none of your programs business - what it should focus on is the logical flow of the computation.
And this is what modern optimizing compilers do: They transform expressions into machine code which has an equivalent observable effect, and executes that what the programs specifies as fast and efficient as possible. Fi you write:
int a = 0;
for (int i=0; i
you could be tempted to believe that the CPU executes increments on a 32-bit or 64-bit register. This is not what happens on a modern optimizing compiler. Look at that link (which uses -O3):https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(fontScal...
- the compiler reduces it to a single move and return instruction. This is not specific to C++ compilers - a good Lisp or D or Ocaml compiler will to the same, while managing the memory for you.
Now, control is, as in psychology, a double-edged sword. It allows you to take influence, but too much control is not a good thing, as the example of micro-management shows. In the case of the compiler, if you control too much, it interferes with the compiler's job to transform your expression into efficient equivalent machine code. The fine-tuned code you write today might be optimized for some of the modern hardware, but while it will probably still compile, it might be much less than optimal 15 years from now, and in the case of C++ without the compiler having any leeway to optimize it because you told it way to explicitly what to do.
It also interferes with your job to produce clear, valid, and readable algorithms and code. And the numerous controls which C++ gives make for a very broad and very fuzzy interface, which in turn makes it more difficult to produce good code and hard to do that in a way which is both reliable, strictly valid, and easy to understand. The issue with non-ASCII characters in words in the original article is a good example. Here is another one:
Take
include ;
include ;
std::vector vb(100);
std::fill(vb.begin(), vb.end(), false);
is this valid code?The C++ reference says:
https://en.cppreference.com/w/cpp/container/vector_bool
"Since its representation may be optimized, std::vector does not necessarily meet all Container or SequenceContainer requirements. For example, because std::vector::iterator is implementation-defined, it may not satisfy the LegacyForwardIterator requirement. Use of algorithms such as std::search that require LegacyForwardIterators may result in either compile-time or run-time errors. "
Do you think this is funny?
Re: Does C++ still deserve a bad rap?
#290Earlier quoted context omitted.
What are the cases where you would use specifically Ocaml instead of C++ or Rust?
(EDIT: I misread your question, apologies. OCaml vs. C++ is mostly because of much less surprises to start working with it. OCaml vs. Rust is mostly because Rust mandates you to pay attention to a lot more initially (`Result`-s being a prominent example, although using `.expect()` or `.unwrap()` actually helps a lot) and even if I absolutely love that you have to iron-proof your code, it does get in your way when you…