Hacker News new | ask | show | jobs
by oytis 382 days ago
Puzzle-solving languages are rather Lisp or Haskell. Both C++ and Rust are very practical for their problem domain.
2 comments

IDK about Haskell, but iterating in REPL with Lisp is the most practical form of programming I've experienced. In other mainstream practical languages this approach is reintroduced as a productivity tool like Quokka, etc.

C++ was practical some decades ago (hardware-friendly variant of OOP for GUI), but it failed as a library language and the domain where it's practical on modern hardware is much smaller. I will not say anything about Rust.

> but it failed as a library language

This is very inaccurate. Essentially every high-performance library, user-mode driver, desktop application, and more is written in nothing but C++. Give me any library you can think of, and I assure you it is written in C++ (or maybe C, but this is masochism on the part of the developers). Even libraries for other languages like numpy, pandas, pytorch, etc are written in C++.

> or maybe C, but this is masochism on the part of the developers

C is the better choice when interoperability with other languages is needed (technically: a C API, the implementation language doesn't matter - but if a C++ implementation is wrapped in C API as an afterthought the result is usually a shitty C API). Personally I switched to C from C++ for writing libraries ca 2017 and don't regret that decision one bit.

Also, many C++ coders only have a foggy idea how convenient working in modern C can be, because their idea of C is usually the 'common C/C++ subset' that exists in C++, and this is stuck deep in the early 90s (for instance the designated-init feature in C++20 is a mere shadow of what C99 designated-init can do - to a point that the C++20 version is pretty much useless for real world usage).

> only have a foggy idea how convenient working in modern C can be

Here is a list of C++ features that C doesn't have, that are an immediate deal-breaker for me:

  - reference and move semantics
  - templates, and type constraints with concepts
  - namespaces
  - `constexpr`, `consteval`, and other compile-time magic
  - `auto` type deduction
  - trailing return types 
  - RAII (can't believe I put this this late, but eh)
  - a passable (although still not perfectly complete) standard library that blows the C standard library out of the water
  - improved semantics that allow programmers to reason about the logic in code better, than obsess over pointer arithmetic
  - built-in virtual functions, function pointer tables, etc
I can list more, but this is going to end up as a list of 'essentially every feature in C++ that isn't in C', which is the very reason for the former language to exist.
...now who's the "masochist" here ;)
Repl is cool, but Python also has a repl, and has a much more intuitive programming model (and much fewer braces).

Totally agree about the domain - no one is writing enterprise applications in C++ these days, luckily. It still does have its domain though, where there is not much choice apart from C++ or Rust (or C if you are a dinosaur)

Oh no, C++ has template meta programming and the ability to mask a DSL as advanced architecture, and then you can even implement Lisp or pick your favorite while claiming you're coding in C...++