← Back to context

Comment by toolslive

2 days ago

IMNSHO: Yes.

It's a sign of the design quality of a programming language when 2 arbitrary features A and B of that language can be combined and the combination will not explode in your face. In python and C++ (and plenty of other languages) you constantly have the risk that 2 features don't combine. Both python and C++ are full of examples where you will learn the hard way: "ah yes, this doesn't work." Or "wow, this is really unexpected".

Well, there is also a question of attitude. Most of the Python programmers don't overload << or >> even though they technically can, while in C++ that's literally the way the standard library does I/O ― and I suspect it leaves an impression on people studying it as one of their first languages that no, it's fine to overload operators however quirkily you want. Overload "custom_string * 1251" to mean "convert string from Windows-1251 to UTF-8"? Sure, why not.

  • I've seen >> being overloaded in several libraries/frameworks. From the top of my head:

       - Airflow: https://airflow.apache.org/docs/apache-airflow/stable/index.html#dags
    
       - Diagrams: https://diagrams.mingrammer.com/docs/getting-started/examples