Hacker News new | ask | show | jobs
by __d 1465 days ago
Different tasks, different languages.

I'm happy to use Python for a lot of stuff. I also use C or C++ for a lot of stuff. It's usually pretty obvious what the right choice is.

Using a more dynamic language for larger projects takes more discipline, and that effort reduces the productivity that is otherwise the hallmark of dynamic typing. There's a point where static typing becomes a net win.

For me, Python's type annotations extend that cross-over point. Both as documentation for humans, and driving IDE or CI-based type checks, I think they've made Python more scalable.

If I've been doing heavy C++ work for a while, switching back to Python is like throwing off a whole lot of bureaucratic overhead: it feels like you can turn ideas into running code almost effortlessly. Going from Python to C++ feels like being super defensive and precise: every single thing is nailed down hard, and has to be just 100% lined up. It's satisfying, gratifying, solid, in a way Python code isn't.

Different projects, different goals, different timescales. Both can be good.

1 comments

If coding C++ feels like fighting "bureaucratic overhead", I promise you are Doing It Wrong. The type system should be performing the overhead, on your behalf, at compile time, leaving your attention for the actual problem.

C++ coded like C or like Java will be exactly as miserable as coding C or Java, but that is entirely a matter of choice.

The work to have the type system do stuff for you doesn't happen for free. You need to define a whole bunch of scaffolding to support the application functionality. Sure, once it's set up, using it can be pretty painless, but the design, implementation and testing of the supporting code is a non-trivial effort.

In contrast, Python (and other dynamically-typed languages) avoid all of that.

In addition, the compile-time cost of all this is significant. Cup-of-coffee builds are a definite burden on productivity.

What do you see as the difference between C++ and Java that lets C++ be less miserable?
The type system in C++ as in Haskell, and to lesser degree Rust, is not just for checking arguments. It can do useful work, and routinely does in better libraries.