Live data from Hacker News

The Python Paradox (2004)

paulgraham.com

241–250 of 275 posts

Re: The Python Paradox (2004)

#241
post #168

Earlier quoted context omitted.

There is no point in statically typed Python, it's useless. Just a lot of people from other programming languages coming in and trying to make the language more familiar to them.

I moved from python2 to python3 to typed python3. It makes refactor much easier, I can easily understand what parameter a function wants, without having to read the docstring or worse, the body of the function. typecheckers do find a lot of errors that would otherwise be runtime errors.

> typecheckers do find a lot of errors that would otherwise be runtime errors.

This is a claim I see repeated over and over without much evidence to support it. In my experience type checkers find a lot of errors that would still be found at later stages and a lot of tiny errors that don't matter and can be dealt with via much cheaper tools.

Shorter feedback cycle is nice, and occasionally it does catch a real bug, but the benefits of static typing are vastly overblown.

There probably are teams where typecheckers do catch a lot of important runtime errors. Those are the teams with a horrible engineering culture. In those environments typecheckers are a bandaid, not a cure. If anything, they are hiding the real problem: you shouldn't give a perfume to someone who doesn't shower.

Re: The Python Paradox (2004)

#242

It's called "anecdotal evidence", the only thing that makes this post credible(-ish) is that PG wrote it.

It's not just PG: https://news.ycombinator.com/item?id=20212869 Although I do think between Python and Java, just pick your poison, they're not night and day. Unless you're writing 1990s Java consisting of factories of factories which is more to do with library style and over-conventionalism (back then when people were writing APIs after reading GOF). Even in 2004 I don't think there's much credibility in knowing bot…

> Unless you're writing 1990s Java consisting of factories of factories which is more to do with library style and over-conventionalism

But I still see this happen more than 20 years later when brilliant ex-Java folks are doing Python.

Java has this weird cultural inertia which reminds me of "Five Monkey Experiment".

Re: The Python Paradox (2004)

#243

Earlier quoted context omitted.

Or just write in Python like Quora, Pinterest, YouTube, Dropbox, etc

YouTube is almost entirely C++ and Dropbox rewrote their sync engine years ago in Rust because of how ridiculously slow their Python implementation was. No one is saying you can't make a web site using Python. Just that it is inherently a slower language that is far poorer at concurrency than many other languages.

Both of those became unicorns before rewriting. It is quite likely that they were able to grow so much precisely because they chose Python.

Google emails prior to acquisition happen to confirm that.

Re: The Python Paradox (2004)

#244
post #226

Earlier quoted context omitted.

Does your code check every single variable is not null before using it? That every function argument is of the expected type? That every attribute exists before it is accessed? And do you have unit tests for all of this too? If so - then you're writing a whole lot of manual checking that a strongly typed language would perform for you, at compile time. If not - well then you're doing less testing than a strongly type…

I don't actually care about any of that stuff. You are confusing technically wrong with not working. If the code works in production it doesn't matter that the code is technically wrong. Testing via typing is very weak testing. Almost worthless. Type checking doesn't find many bugs in general. Strongly typed languages have 2.5 times the number of bugs as dynamically typed languages per software feature. Why would you…

> If the code works in production it doesn't matter that the code is technically wrong.

This is actually very insightful, but I'm afraid you won't be able to convince most people.

The only valid metric of code correctness is empirical: how many times code ran successfully in production. Everything else (unit tests, static typing) is theoretical and often close to useless.

I remember seeing a talk where someone analyzed all Github repos to find which languages produced most reliable software. He found C++ to be the most reliable. But not because C++ itself is great as a language. The main reason was that lots of the dependencies that other languages are using were written in C++. C++ software happened to be the most battle tested.

Re: The Python Paradox (2004)

#245
post #168

Earlier quoted context omitted.

I moved from python2 to python3 to typed python3. It makes refactor much easier, I can easily understand what parameter a function wants, without having to read the docstring or worse, the body of the function. typecheckers do find a lot of errors that would otherwise be runtime errors.

Typed Python code on average takes two times the time to develop and contains two times the number of bugs per delivered software feature. It's bad, really really bad. Refactoring can be done just as well via a good IDE and unit testing. Using typechecking creates far more errors then it finds. They are a necessary evil in compiled languages. It's been measured that it creates more errors. That is not open for debate…

What is this based on? I have a lot of trouble believing untyped python code has half the bugs of typed code being someone who has written and read a lot of both

Re: The Python Paradox (2004)

#246

Earlier quoted context omitted.

Typed Python code on average takes two times the time to develop and contains two times the number of bugs per delivered software feature. It's bad, really really bad. Refactoring can be done just as well via a good IDE and unit testing. Using typechecking creates far more errors then it finds. They are a necessary evil in compiled languages. It's been measured that it creates more errors. That is not open for debate…

What is this based on? I have a lot of trouble believing untyped python code has half the bugs of typed code being someone who has written and read a lot of both

Actual measurements.

I don't think you should be surprised. Untyped Python code is a lot shorter and more concise than typed Python code.

The easiest way by far to reduce the bug count is to reduce the lines of code.

Re: The Python Paradox (2004)

#247

Earlier quoted context omitted.

What is this based on? I have a lot of trouble believing untyped python code has half the bugs of typed code being someone who has written and read a lot of both

Actual measurements. I don't think you should be surprised. Untyped Python code is a lot shorter and more concise than typed Python code. The easiest way by far to reduce the bug count is to reduce the lines of code.

That's a good point I hadn't considered. where did you find these measurements?

Re: The Python Paradox (2004)

#248

It was right then, but it's kind of dated and misses an evolutionary lesson: beautiful code isn't enough, it has to be safe, beautiful, maintainable, productive, understandable, and resource efficient. Ruby is still great for throwing something together fast and maintaining it until it runs into scale problems. It added gradual typing with sorbet and RBS. Crystal is a neat typed, compiled Ruby-alike but it's buggy. R…

Type arguments, union types, and a sound type system: pick any two.

For example, imagine the following in an imaginary version of Rust with union types:

    #[derive(PartialEq)]
    struct Option {
        value: T | (),
    }
    impl Option {
        fn some(value: T) -> Self {
            Self { value }
        }
        fn none() -> Self {
            Self { value: () }
        }
        fn is_none(&self) -> bool {
            match self.value {
                _: () => true,
                _: T => false,
            }
        }
    }
What does `Option::some(()).is_none()` return? Is `Option::some(()) == Option::none()`?

Re: The Python Paradox (2004)

#249

Earlier quoted context omitted.

Actual measurements. I don't think you should be surprised. Untyped Python code is a lot shorter and more concise than typed Python code. The easiest way by far to reduce the bug count is to reduce the lines of code.

That's a good point I hadn't considered. where did you find these measurements?

https://games.greggman.com/game/dynamic-typing-static-typing...

Re: The Python Paradox (2004)

#250
post #11

Earlier quoted context omitted.

I too tend to agree with the sentiment. What isn't mentioned though is that is quite possible to run out of people to hire. Which mostly happened to us, where we had grown and everyone in the relatively small Python community who could and would work for us was working or had worked. We had to move on to another new language (Go), although that did rub a number of the Pythonistas the wrong way.

Can you hire people who know other languages and train them in python? Why would you need to change languages?

I worded that badly sorry. Only one project switched to Go (a rewrite), and a few new projects where Go from the start. There was still a lot of Python.

We hired from Open Source communities (mailing lists, conferences, our own website), and applicants always had at least basic language skills and more importantly a desire to work with it. Once you start hiring people from outside, who are not interested in you or your tech and just interested in a job, you lose the benefits being discussed in the article. One of the reasons we expanded to include Go was to increase the size of the recruitment pool.

Post reply on HN