Hacker News new | ask | show | jobs
by hedora 2260 days ago
Python is a terrible choice as a first language. Idiomatic python is just glue code that obfuscates the underlying algorithms.

Object oriented programming (implementation inheritance) is increasingly regarded as an antipattern, and it encourages that too.

The massive performance penalty of writing logic in python vs calling out to external libraries mostly forces developers to program by lego-brick assembling external modules instead of reasoning about algorithm design.

There’s no concept of types, either, and instead of attempting to detect programming errors early on, it leaves them to runtime.

It’s not surprising that Java and also C/C++ are more popular than python for introductory CS courses.

(I could see using python as an intro course for non-CS majors, fwiw.)

7 comments

Python is a great first language, because you can learn the basics in an afternoon, but it is still capable of handling (and actually used for) many real-world tasks from robotics to games to scientific computing.

Its low barrier to entry, high reward/effort ratio and quick feedback loop make a good way to recruit potential CS majors!

As others have mentioned, Python's slowness can also require you to pick good algorithms, and its minimal compile-time error checking means that you really need to test your code well and also handle unexpected runtime errors. ;-)

BASIC is a great first language for similar reasons.

I'd say that Python is a good language to learn on your own, but not a good language for teaching computing at higher lever.

Low barrier to entry and quick feedback loop are shared with Racket in this case, and Racket offers much more to learn.

Performance is largely irrelevant for the first teaching language. You can completely ignore OOP (unlike Java) if you want, although you probably should teach students about it at some point. Python doesn't have "no concept of types".

I have TA'd different intro classes that started with those languages, and Python IMHO makes a way better first language than C or Java. Start with it, introduce other languages and their concepts later. I've heard mixed things about starting with functional languages, but I think it can work too.

> Performance is largely irrelevant for the first teaching language. You can completely ignore OOP (unlike Java) if you want, although you probably should teach students about it at some point. Python doesn't have "no concept of types".

That's how my college (Macalester) teaches it. We have two levels of CS class. One in Python, that only covers OOP at the end of the class in regards to GUI/Games.

We have another OOP class where we use Java and we go a little more deeply into CS concepts + Software Engineer Practices.

The first course is intended for anyone wanting to have some view of what CS is. I think it's a good balance.

It also helps that there are good job opportunities with both Python and Java(more so).

> There’s no concept of types

Python is strongly typed, and while it doesn't mandate static type checking, it has several AOT static type checkers available.

It's not Haskell, but then neither are most languages that mandate static type checking.

I disagree, I think python is fine.

Yes, you don't have to complete bonkers OO with multiple inheritance, but in general OO is a win.

Also, python has a pretty good standard library and a pretty elegant module system.

There's also a practical consideration. After you learn python, you will know python. It is a useful language with hooks into just about every endeavor you could do on a computer.

It doesn't matter it’s slower than C/++ or Java . In fact, that’s an advantage; you want your algorithms to be fast because they’re actually good, not just because your hardware is fast. I think you completely missed the point on what algorithms are.

You might look at this answer: https://www.quora.com/Why-is-Python-not-a-suitable-language-...

Object oriented programming is an antipattern?

Can you explain this? I am not a CS major, but I find using classes quite useful.

I suggest searching google for "problems with object oriented programming". There have been countless discussions, articles and videos.

Examples: https://www.youtube.com/watch?v=QM1iUe6IofM https://medium.com/machine-words/the-rise-and-fall-of-object... https://medium.com/@cscalfani/goodbye-object-oriented-progra...

Python has typing as of 3.5, although it’s limited to third party tools. Still useful.

https://docs.python.org/3/library/typing.html

Also why is OOP considered an anti-pattern?