5 ms·
I 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
by pdimitar 6y ago
I 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 hood when necessary. This has led me to Rust and I find it to be the better natively compiled strongly & statically typed language, but YMMV of course.
These days I reach for dynamic languages for personal projects and experiments. I want to sketch an idea and see if it works in the interval of 15 minutes to a day. Languages like C, C++, Rust, D, Nim, Zig, Fortran, Pascal, Haskell, I found to be generally terrible for when I am in a flow state. Using Elixir / JS / OCaml I found that I could iterate much faster.
I never will participate in a language war (although all of us have slipped on that ice more times than we'd like to admit, let's be honest). But to me C++ is simply not productive. It feels like having to learn a 10x5 meters of control panel with dials, blinky lights, keys and levers. I know there are many who enjoy that -- more power to them. But I am not in that group.
- auggierose 6y agoI find it very interesting that you put Haskell in one camp, and OCaml into the other. I am more of a Standard ML guy instead of OCaml, but can you elaborate a bit why you feel you can iterate faster in OCaml than in Haskell?
- eru 6y agoOCaml is quite a lot more pragmatic and 'loose' than Haskell. But that's just my impression. They even have for-loops in OCaml.. (I would be really slow writing code in vanilla JavaScript. There's no static checking, and not much dynamic checking. So you need to watch your step very carefully---in some sense, very much like in C++.)
- pdimitar 6y ago> OCaml is quite a lot more pragmatic and 'loose' than Haskell. But that's just my impression. Mine too. I still dislike the lack of Unicode strings by default, and the somewhat confusing tooling (initially) but outside of that I quite love the language. It has a huge potential and I can only hope that the arrival of Multicore to the upstream language will kick it forward and put it in the same league as Rust (although due to GC it can never be that fast I'd think; but who knows).
- eru 6y ago> (although due to GC it can never be that fast I'd think; but who knows). Well, in theory GC can be made very fast. Though you sort-of have to decide whether you want maximal throughput or real-time latency guarantees. In practice, we aren't quite there yet, alas. The way to get really fast code is just to avoid allocation, I'd guess? OCaml allows you to use mutation, and it's relatively easy to peak under the hood to see what your code gets translated into. The main technical innovation of Rust is the borrow-checker. But that piece is very related to linear types / uniqueness types. There's some interesting work going on with linear types in Haskell. And just like Generalized Algebraic Data Types also eventually made their way to OCaml, there's no fundamental reason they couldn't add linear types to OCaml, I guess? (Linear types can basically be used to encode the FP equivalent of manual memory management.)
- pdimitar 6y agoCheck my reply in another comment that's sibling to yours.
- jokethrowaway 6y agoI love this concept! I think it's more linked to experience than anything specific language feature. I used to think it was typing, then I became more proficient in Haskell and the type system actually saved me time. My in-the-flow languages right now are Haskell, JavaScript and PHP, but I'm trying to add rust to it. I have a friend who reaches out to C for quick prototyping. I know many more going for .Net or Java (which are not that far from C++)
- pdimitar 6y agoI am still having a hard time adding Rust to my flow-state-coding. Sadly, like C++, it does require you to learn quite a bit before that point. But I still find it more pleasant than C++ so I reach for Rust instead. Plus the experience really starts to pay off from one point and on.
- jnxx 6y agoWhat are the cases where you would use specifically Ocaml instead of C++ or Rust?
- pdimitar 6y ago(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 just want to try something quickly. It kills the motivation intrinsic to the flow state.) --- (Original reply:) I'll admit it's not a factual and clear-and-cut distinction. OCaml has warts (no multicore, although that's claimed to be very close to complete now; also no UTF-8 strings by default, and a somewhat surprising tooling, the first time at least) but I found Haskell to ask too much of me to even start -- I almost immediately grokked monads and lazy evaluation but it seemed to be too much effort for something you'd like to quickly play with. And when I saw the list of all compiler variants I almost gave up right there and then. OCaml, as mentioned in the parentheses above, isn't without problems too but I found that I could get to a working dev stack and the ability to make a quick program and run it, much quicker compared to Haskell. Also, it's very terse. Not the most compelling or factual of reasons but this is how I arrived at that place where I prefer OCaml for sketching ideas and not Haskell.
- eru 6y agoOCaml is a much smaller language than Haskell. Similarly, Erlang (and thus Elixir, I guess) is also comparatively small and simple. Surprisingly, C would be in the same category, if it wasn't so primitive and likely to make you shoot yourself in the foot. I've programmed professionally in both OCaml and Haskell (and Erlang and C etc). I find that Haskell is generally more terse than OCaml. They are both fine languages. Subjectively, Haskell feels a bit more fun to me. But if you want to really get into it, it helps to have some people around who know what they are doing.
- 6y ago
- bsdubernerd 6y agoI 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 like several other modern/newer languages do, making it vastly more applicable from anything from embedded to large-scale programs without restrictions. Modern C++ has smoothed a lot of the rough edges in terms of productivity, but it's still an overly complex language that cannot shed any weight due to backward compatibility, and it's a shame. Contrarily to many other guys tough, I'd take a dash of C++ compared to "simple" C/C99 any day, especially in embedded. C++ can be vastly simpler and more readable, while retaining 100% control over memory and layout. Most of the memory/threading issues essentially disappear with very little fanfare, but few people talk about that. I don't want to detract against static checking though! But I feel like newer languages such as Rust are still too young and idealistic, and haven't been beaten by implementation requirements or a system's programming language yet where your silly requirement is somebody else's essential feature. This is how it gets ugly, and this is where C++ has probably something to say. I still like modern languages though. I like Rust, but won't be able to use it effectively until they get rid of static compilation. I wish I had D's metaprogramming over C++ templates any day, but the GC is a again non-starter. Nim has no static checking, but it should deserve much more consideration than it currently has: it's much more pragmatic than Rust IMHO, and it's also much easier to integrate into existing programs will less hassle.
- steveklabnik 6y agoWhat is "static compilation"?
- deleted 6y ago[deleted]
- abdulhaq 6y agoIt's not just-in-time compilation. Maybe he wants a kind of REPL for Rust - I guess?
- chromatin 6y agoI general I agree with your broader point about when to select dynamic language, flow state etc., and specifically with C, C++, Rust (although of those I haven’t done C++ in years except to tweak others’ code). However I find D can be written in a very script like manner, using the GC. Only when chasing performance do I need to go GC-free. The fast compilation means I can iterate as fast as python, and it has replaced a lot of python in our group. Side note,I would like to learn OCaml and am interested you drew a distinction between Haskell (former group) and OCaml (latter group).
- pdimitar 6y agoCheck here: https://news.ycombinator.com/item?id=24809623 https://news.ycombinator.com/item?id=24809623 (sibling comment).
- eru 6y agoOCaml and Haskell share a common ancestry, but I would also draw a distinction between them. (Though not the same that the other commenter did.) OCaml is a bit more of a drop-in replacement for something like C++ or D. Mostly because it's strict by default, so it's easier to reason about performance even for a non-expert user. OCaml's approach to side-effects has now entered the mainstream: it's considered good style to avoid them, but they are still used pervasively. That's very similar to what good modern C++, Java, Python etc style advocates. Of course, Haskell also allows side-effects. But generally, you track that they are occurring with the type system, you generally stick them in some kind of Monad or Applicative Functor.
- pwdisswordfish0 6y agoOne of the issues with this comment is that, while it aims to elaborate on certain aspects of C++ that make it unattractive, it tacitly promotes the idea using C++ gives a person "complete control over certain aspects of your program". Given the intent of the message, this is actually kind of harmful. There's a certain class of chest-thumping/-puffing programmer who sees this as vindication for the language. So, perpetuating that idea is bad news, especially since it's only true if applying very, very loose criteria of what it means to give a programmer "complete control".
- pdimitar 6y agoThis is what I heard several seasoned C++ veterans claim and so far I didn't have a reason to doubt them. As already stated, I'm not a fan, but apparently a lot of people out there manage just fine with C++ and claim that it's actually easy and possible to attain complete control. I'd imagine that could be somewhat true if you invest decades in that language.
- pwdisswordfish0 6y agoIt isn't true unless that investment includes tons of bespoke and unrealistic compiler work and an open side channel (e.g. in the form of command-line flags to the compiler) to get it to lay down exactly what you want it to. When people write those kinds of things, they're being hyperbolic. It's best not to assent, in light of the chest thumpers. Complete control just isn't possible in C++. More control than many of its contemporaries, yes.