7 ms·
Python should not be taught as a foundational language
- smt88 6y agoI loathe Python, but I still disagree. Python is important learn, for one thing. I don't know of anyone using Java or JavaScript for statistics. For another, being unlike C is a strength. I would modify the argument to be, "Python should be taught as a foundational language, along with [insert C-like, non-GC language here] and something in the OCaml family." No one should learn CS or programming as a trade with only a few languages in the same syntax family.
- pavlov 6y ago"No one should learn CS or programming as a trade with only a few languages in the same syntax family." This is a fine ideal, but I bet there are tons of professional programmers who only know a couple of languages all from the syntax family set of { C, C++, Java, JavaScript, PHP, Swift } and it's not a career problem at all.
- jolux 6y agoI'm not sure I would put Swift in that syntax family. It doesn't have C-style for loops and most of it is pretty different from C aside from curly-brace delimited blocks. First-class functions, lots of Smalltalk- and Objective-C-isms, some ML stuff, etc.
- smt88 6y ago> it's not a career problem at all It can be a failure of education even if it's not a career problem. The article is about what should be taught in schools. Most programmers self-report becoming more skilled as they learn languages with different paradigms, so there's evidence that there's career benefit to knowing a diversity of languages.
- artemonster 6y agoAbsence of clear types is what driven me mad (and my ex), when my ex tried to learn python via interactive online courses. Constant questions like: "why this thing named a is a number and this one thing named "b" is now a list and this other thing does stuff". Switched to java, all problems immediately disappeared.
- blondin 6y agoapologies but that sounds like a poor course you guys picked. types should not be a concern for a beginner. i started programming with BASIC and even though it had rudimentary types it wasn't until later that i really learned about types. worrying about types means you already knew about them.
- jaxx75 6y ago"I'm just adding numbers, why do I need 'public static void main'?"
- jolux 6y agoPython is far simpler than Java in its essence; you aren't required to write class and access control boilerplate if you don't want to, you don't have to explain type systems, and the syntax is much cleaner. I would personally recommend Racket/Scheme as the foundational language for computer science and software engineering over Python as it is even simpler, but I can understand why Python has displaced Java as the default teaching language at many universities. Beginning programmers don't care about any of this stuff about the version split or strings, and the syntax and semantics argument is completely subjective.
- albntomat0 6y ago> you don't have to explain type systems Is that a feature though? Beginning programmers are still going to hit type errors, and having things be explicit and static I think would help, IMO.
- bluGill 6y agoThey will, but that is an intermediate topic that can be deferred out of the beginners class. Beginners can write many interesting programs without hitting those type problems.
- albntomat0 6y agoWhat do you consider as the content present in a beginners class? I'm not personally involved in teaching (possibly changing in the future!), but I can definitely imagine a student accidentally writing a function that returns different types based on the input, and having an incredibly difficult time of it.
- bluGill 6y agoBeginner means never wrote a program before (or maybe one in a computer class taught by a teacher with no computer science background and thus suspect ability to program). I can't imagine a beginner getting into that problem because they can't handle programs complex enough to get there. Now the next semester... They better be moving on to bigger things where that can happen. However they have moved beyond beginner.
- txcwpalpha 6y agoNone of these things are specifically related to teaching programming. This is just the author's personal list of things they hate about Python, and they're using "what language should we teach newbies?" as an attempt to make it seem like more. There's nothing wrong with having an opinion about Python, but for this to really be a valuable insight into teaching Python, there needs to be some introspection into why dynamic typing is bad as a foundational language, etc, and also needs to analyze the other side of the coin: the many things that do make Python attractive as a first language. Without it, this is just a rant #34929865 about Python's lack of typing and curly braces.
- FeepingCreature 6y agoArticle: "Why is Python not C++? It should be C++."
- roosterdawn 6y agoAll I see is a list of complaints about warts that Python has, and no real foundational reasons for or against using Python, such as the ecosystem, long term cost of ownership, ease of iteration, or ability to manage a codebase at scale. I think this blog post is not named accurately.
- eythian 6y agoNone of ecosystem, long term ownership, iteration, or codebases at scale are relevant to a foundational language (i.e. one that is being taught in order to teach the concepts of programming.) A simple, clear syntax that comes, as much as is reasonable, secondary to whatever the concept being taught is is most important to me.
- roosterdawn 6y ago> None of ecosystem, long term ownership, iteration, or codebases at scale are relevant to a foundational language (i.e. one that is being taught in order to teach the concepts of programming.) I cannot agree with this. Embedded in this argument is the idea that syntactic specialization towards pedagogy is a worthwhile goal rather than ramping up a pupil towards where they'd be able to function independently as a software engineer by giving them a solid theoretical and applied foundation. Part of being an engineer is learning how the quirks of the language evolved, the history of how it got to be that way, and what it means in terms of the long term evolution of the language and ecosystem as collectively reasoned through by the eyes of skilled practitioners. You get to see the decision making process of language design, and how the plan became a prototype became a battle hardened tool that can adequately work in a variety of real situations, well enough to gain a significant plurality (or mindshare) for a specific real world use case. Just because studying Latin is useful for understanding English at a deeper level doesn't mean it's a good idea to learn Latin before learning english. It doesn't change the fact that a) immersion is the best way to build fluency, and b) fluency is the goal, does it? What makes programming languages any different?
- anthonygd 6y ago
- albntomat0 6y agoI started with Java originally, but the school where I learned has since switched to Python. For those who learned Python as a first language, how well did you do with typing? My guess is that learning Java for me enforced thinking about the types for everything, and the compiler gave me useful errors, rather than at runtime. I could see a student getting frustrated with runtime type errors, especially for things returned from their own functions, which can snowball easily into a mess.
- bctnry 6y agoSomewhat reasonable title but poorly written content. > For instance, what is called an "Array" in pretty much every mainstream language, is instead called a "List" in Python. Because it is a list rather than an array (as in C). > Another issue with Python is that it is essentially two different languages, there's Python 2.7 and Python 3+. It's 2020, you are not supposed to teach Python 2 to newbies. I was expecting more in-depth discussion, and the whole article is just way too superficial.
- kzrdude 6y agoWhat do you mean by that it is a "list"? It's certainly not a linked list.
- detaro 6y agoList is pretty much an interface, and Python lists do support things you expect from a List type, but not from an Array (e.g. inserting/removing things at random positions). The interface doesn't say if it's an array, a linked list, a rope, ... underneath, and you don't need to care at this point.
- kzrdude 6y agoThis is wrong, the Python list supports random access and random access inserts and removals. It's a dynamic size array underneath, and contiguous, so it's pretty much the same as a std::vector of Python objects. Also notably a Python list does NOT have an efficent pop operation at both ends, only on the far end. Doc: https://docs.python.org/3/library/stdtypes.html#list https://docs.python.org/3/library/stdtypes.html#list
- detaro 6y agoNone of what you say seems to contradict what I said, so what exactly in my comment is wrong?
- 6y ago
- tomp 6y agoTerrible article. Looks like it's written in 2004? I've been using Python 3+ for the past few years, never looked back. > Python decided it would be a fun idea to govern blocks using whitespace, instead of wrapping everything in braces. Yeah, because using braces was a stupid idea in the first place. Just because C++ / JavaScript etc. are stuck with backwards compatibility, doesn't mean that other languages can't move to something better. > For instance, what is called an "Array" in pretty much every mainstream language, is instead called a "List" in Python. Key-Value stores that are usually called a "Map" or a "HashMap" are instead referred to as a "Dictionary". Yeah, except in C++, where it's called "Vector" (which makes even less sense, from a mathematical point of view). Also, The problem with "Map" (the data structure) is that it conflicts with "map" (the function). I prefer what Python is doing. > When creating a string in most mainstream languages you can usually just do something along the lines of var s = "string" or for a char you usually use single quotes var c = 'c' And most mainstream languages are wrong. In practice, there's no meaningful difference between (Unicode multi-byte multi-codepoint) characters and strings; Python just makes it more obvious.
- bluGill 6y agoWhitespace is a terrible idea. I'm not saying languages need to use the one true brace (which every brace you care to argue for, they are all the same, at least for this point), but there needs to be a start and end block, and white space is one of the worst choices you can make. The problem with whitespace is in real programs you eventually realize (often because of a new requirement) that you need a new block and whitespace is the hardest to change. Whitespace is good for readability and important. It should be an error if the whitespace is wrong. However there needs to be a simple start/end block marker so that programs can fix the whitespace correctly.
- falcolas 6y ago> whitespace is hard to change What text editor are you using? Select region, Tab or Shift-Tab, and move on. > Whitespace is a terrible idea. That’s like, just your opinion man. The only time I’ve had issues with blocks and whitespace is when some monster mixed in tabs. Thankfully every decent editor can make whitespace characters visible, and a quick find/replace fixed the heinous action.
- jacknews 6y agoi agree that significant-whitespace is a bad idea. It's bad in things like yaml, coffeescript or haml where mis-indentation can dramatically change semantics. Of course brackets or other delimiters are also susceptible, but they're much easier to spot, especially for syntax highlighters, linters, etc. And whitespace can actually be part of how you communicate your thinking to other developers.
- dsego 6y agoI stopped reading after "constant variable".
- rhn_mk1 6y agoThe author mostly argues that Python does not work the way they are used to. While I can understand that Python being different may pose a difficulty to someone who is used to JavaScript, C, C++, Java, and so on, there are many different languages that one can learn from. To me, a foundational language allows the learner to understand how computers work, and how calculations can be performed. In this light, SICP has proved that LISP can be a foundational language. I strongly suspect the author's notion of "foundational" is very different than mine, and that they see programming as something very different than I do. Without knowing how the author sees it, I miss the point of the article.
- guhcampos 6y agoC should be the only foundational language. People should first learn to manage their memory, ensure their typing and the boundaries of their variable allocations before having someone do that for them. It's a little bit like driving: in the US you can get a driver's license without ever touching a stick shift car, so you have this huge driver population than can only drive automatics. Which is fine for the general populace, but not if you want to be a race car driver, a machine operator or a mechanic, which is where the computer science student would fall into the analogy.
- themistokl1k 6y agoAs someone that enjoys learning by building from scratch sure. There's another huge group of us that like diving in and figuring things out as we go. I too was intro'd with C and ended up coding 2x as much in python cause I just wanted to do stuff without the overhead of low level. I did appreciate my C knowledge when I wanted to do optimizations and better understand my Python code but I definitely think that I could've learned these things in the reverse order.
- Demiurge 6y agoCertainly x86 Assembly should be the only foundational language. People should first learn to manage their registers and memory addresses, ensure their typing and the boundaries of their variable allocations before having someone do that for them. It's a little bit like driving: in the EU you can get a driver's license without ever touching the horse saddle, so you have this huge driver population than can only drive cars. Which is fine for the general populace, but not if you want to be a jockey, a cowboy or a horseback policeman, which is where the computer science student would fall into the analogy.
- bluGill 6y agoPeople should start with a pile of sand from which they extract pure silicone, then design a cpu with whatever they want. Registers are cool, but you can design a cpu without them if you want. Then the rest of the computer and an Io system (Io is not required, but the instructor needs some way to validate your cpu) The next step is to design your own language for your cpu, but so far human life isn't long enough.
- detaro 6y agoI've TA'd several intro courses, some involving Python and some don't, and in my experience these issues are not as big as the author makes them out to be, and especially the REPL and the ability to explore are really nice benefits of Python for absolute beginners. There's many ways of structuring an introduction, so I'll not say "You have to use Python", but I strongly disagree with "You should not teach with Python". IMHO the best approaches show the students multiple languages, and Python is a fine pick as the first of those. In contrast, Java in contrast brings a lot of overheads that a beginner doesn't need, and thus I'd recommend teaching it later if at all.
- l4hel 6y agoNot sure how this post reached the HN front page since the arguments are extremely weak. This is like a complain about things a Java programmer don't like about Python or alike. Disclaimer: I don't use Python.
- kurisukun 6y agoWhy do people still talk about Python deprecated version..? For me it doesn't make any sense to criticize Python based on Python 2.7 when this version should NOT be used anymore. Still, Python is sufficiently known, used and the syntax is easily accessible to claim to be a useful programming language for novices to learn and have an introduction to CS.
- achileas 6y agoNothing in this article is foundational, just stuff the author doesn't like or understand (such as the differences between arrays and lists) and it all happened to be superficial as hell. There are valid reasons to not teach python as a foundational language (and valid reasons for it as a good intro language), but none of them are in this article. As another commenter put it, it reads more like "why isn't Python C?" and still somehow misses the important teaching aspects of the C family of languages.
- Icathian 6y agoTo my mind, it boils down to whether you think static types and memory management are foundational skills that a programmer is well served to learn early and build upon, or merely cognitive overhead that distract from what the programmer is trying to do. If the former, then obviously a language that ignores those is detrimental to long term development. If the latter, then clearly you want something like Python as your introductory language. I think either stance is defensible. Actually, I wonder if the right conclusion isn't one side or the other, but that separate tracks for systems programming vs web dev (or whatever dichotomy you prefer) should be introduced earlier on in education, maybe separate specializations within a CS degree.
- skywhopper 6y agoWhile I share plenty of the annoyances this author has with Python, and I’m sympathetic to the argument, they never quite manage to spell out why Python’s choices are somehow worse than any other language other than that Python does things differently. Why is having constant variables so important when learning? Why are curly braces important? The author never says. Meanwhile, while I agree Python’s strings are overcomplex and often frustrating, the weird digression about how “most languages” have char and char[] and String is a fancy wrapper, is actually just incorrect at this point and reveals just how narrow the author’s experience actually is. In the meantime, my kid learned to program using Python and then went on to do very well picking up Java In subsequent classes. In my opinion, she’s far better off for being exposed to two very different languages early on rather than coming up thinking everything needs to look like C to be a “real” language.
- aka1234 6y agoPython works for a large swath of issues, and is much easier to learn. That's the point of it. With Python, you can more easily move from a purely syntactical focus to actually programming. If you need to go into lower level programming languages in the future, that's cool. You can go deeper into stuff like variable types, constant variables, block scope, garbage collection.. whatever you want. You already have a grasp what a string is, how to use a for loop, etc. In reading the article, it seems like the author is saying essentially "Programming is supposed to be hard. Python makes it easier. So don't teach Python." But shouldn't we be teaching people the easy stuff first? That way they can get, y'know, programming? The version split is about the only reasonable argument. And how you teach that is the following: Python 2 and Python 3 are different languages for all intents and purposes. Use Python 3. But what do I know; I'm just a self-taught coder.
- normalnorm 6y agoThe author seems to make a circular argument: foundational languages look like C++/Java, Python doesn't look like C++/Java, ergo Python is not a foundational language. There are no foundational languages, what is foundational is CS theory itself. C++ and Java are just part of the ALGOL tradition, which syntactically relies on a bunch of arbitrary choices (curly braces vs indentation is an arbitrary symbolic choice and any preference is personal and subjective), and furthermore were highly influenced by 70s computer architecture that doesn't really exist anymore. In other words: just a bunch of legacy choices. Python is the best general-purpose language there is at the moment, because of its popularity, ubiquity, actual use in a wide diversity of domains and availability of libraries for almost anything you can think of. Furthermore, the syntax is simple enough for one to be able to keep it all in one's head and not having to constantly refer to documentation. If you learn Python today, it will likely be useful to you for the rest of your life in a variety of situations. Getting used to curly braces in ALGOL-like languages is a minor intellectual challenge compared to what awaits someone taking a Computer Science or Engineering degree.
- themistokl1k 6y agoI got intro'd with C. Enjoyed learning the low level concepts but I aint managing my own memory anytime soon unless I need that heap blazing fast. Python was my vehicle to prototyping and implementing educative programs, I can hardly recommend anything else for a beginner. And arguments like other langs call this X are poor IMO. The world of programming languages isn't 1 dimensional and no one should honor this notion of implied consistency that pleases your (and a student's) limited understanding of this ecosystem. I'd rather have students question and not critique such choices, and form their own educated opinions on what language fits them for what task.
- Demiurge 6y ago> however in practice I find that it is much less legible and more kludgy to work with. Can just stop reading here. I have seen many say this only the first few hours of trying Python, and that's it. So, this "kludgy to work with" indicates almost zero actual work with the language.
- sixhobbits 6y agoReasons why Python is great to teach: * Simplicity - you can write Hello world and have a 'that's cool' moment earlier than java * General purpose - whether you're interested in web apps, data analysis, games, command line apps, you'll be able to do it with Python (the 'second best language for any problem' aspect) * Community - a lot of people know it, it's easy to get questions answered. There are libraries, tutorials, etc Reasons why Python is not great to teach: * Horrible set up even with (or because of?) modern tooling and many options. Many beginners will get frustrated and lose interest after several hours of messing with configuration * Too magic sometimes - easy to pick up bad habits by doing things that are 'allowed' in Python, but not in most languages Overall I still think Python is one of the best first languages to show someone, but I'm glad I learned Java shortly afterwards followed by brief introductions to dozens more languages.
- falcolas 6y ago> Horrible set up For the purposes of teaching, there’s very few reasons to go beyond the standard library (‘Requests’ is why I qualify this). Restricting yourself to that means that python is, most times, already set up for you. It only gets confusing when you start to use shared libraries.
- sixhobbits 6y agoThis is not true on Windows and in general even for beginners I would not recommend the default install of Python on mac.
- falcolas 6y agoWSL gives you Python 3 with an apt install, and homebrew can replace the default 2.7 with Python 3. Using Python on Windows without WSL is a bit harder, but it's really just a package install and explicit `python file.py` call in a command window. I don't believe that any of these are onerous enough to justify calling them "Horrible [to] set up".
- cjf4 6y ago
- viraptor 6y ago> In theory this might seem OK since you should already be properly indenting blocks of code, however in practice I find that it is much less legible and more kludgy to work with. This pretty much indicates the author doesn't have much experience with newbies. It's enough to look at SO first questions queue to see how many people completely disregard indentation and are ok with no-indent, 4 levels deep control structures. Then the question is "why doesn't this [if] work". It doesn't because they're completely lost in the control flow. For teaching, anything that either autoindents or forces indentation is amazing. Even Scratch does this right.
- TrackerFF 6y agoI think Python is great, because it's a very comfortable language to write in. My foundational language was C, and we had to roll out everything ourselves. Want dynamic lists? Better get down and write your own structure. Now, while that may be a great experience for learning how things work on a bit micro level, it seemed like a complete nightmare for those with zero to no previous programming experience. Lots of people end up fighting the language, rather than focusing on the big picture. Writing in Python feels like writing pseudo code. It's very comfortable. It makes beginners gain confidence, because they see quick results. They don't have to punch out code for 60 mins, hoping that it'll work once they hit compile and run.
- rglullis 6y agoHere is an article that I would be completely ready to agree with the premise, but then the author completely botches it by using only wrong reasons to make his argument: scoping, list-vs-array and map-vs-dict, whitespace?! Really? Python is not a good foundational language because it is meant to be practical. When you are learning the foundations of things, you should be exposed to the damn thing you are learning. Python's main strength is that it abstracts all of this fundamental things away from the application developers and let's you be productive on the application side. When you are studying the fundamentals of Computer Science, though, your focus should be on the basics. For those, there are so many better choices than Python. Python fails to teach lambda calculus like Scheme or Common Lisp, so you shouldn't be use it to learn functional programming. It does not have any interesting constructs for declarative programming like Prolog. It hides all of the hardware complexity under its VM, so you can't learn about data structures, file structures or algorithm analysis like you would with C, Pascal or any Algol-like language. So, yeah, of course it should not be used as a language to teach Computer Engineers and CS majors. But scoping, naming conventions and fucking whitespace are completely irrelevant.
- SketchySeaBeast 6y agoMy spouse expressed interest in learning to program and I thought the best way to start would be with Python as it would be the code structure without all that extra boilerplate, and doing simply things in Python is easy. I'm coming to realize that the boilerplate is important. She's struggled a bit with a lot of the things that are explicit in other languages. Variables are just magic in Python - in other languages there's a structure for their creation. I think that structure is important to understand and helps to formalize how things work - it helps build up mental models that just doesn't exist in Python. I don't agree with the article on a lot of thing - I think the string criticisms are splitting hairs (and aren't all string in 3+ unicode by default?), naming quirks are in every language, and the version split can be treated as a non-issue (just learn 3.8 and if you have to learn the quirks for 2.x to support that version). I do agree with the scope - I think curly braces are easier to visualize and less magic. It's the magic that's kills the beginner experience.
- colmvp 6y agoI think languages like Python (and IMO Javascript) are perfectly fine as first languages, since it's easy to setup and the basics are easy to learn which is important in not discouraging people from hating coding. That's what I recommend to people who are interested in programming but have little to no experience doing so. There's also a lot of fun tutorials out there which make learning the language feel fulfilling and enjoyable. And it can be hugely helpful in the job market. However, I'd say I didn't really start leveling up as a developer till I spent time learning a statically typed language. In my particular case, I think it was partially because C++/Rust developers spent a lot of time discussing performance implications in podcasts/forums/lectures, which inevitably lead me down rabbit hole of how software interacts with hardware. I think that's harder to do in languages which abstract away some of the complexity.
- jinushaun 6y agoMy first language was C++ back in 1998, and that was possibly the worst language you could choose outside ASM for a newbie. In addition to basic programming concepts like variables, loops and conditionals, I also had to contend with types, pointers, memory management, memory leaks, compiling, command line, .h files, typedef, magic main function, char * instead of real strings, etc. The list goes on. It’s like learning triathlons before you can even crawl. I struggled for a long time not quite understanding and just copy and pasting. My coding fluency jumped dramatically when I learned JS and Python a few months later. Once I finally mastered C++, everyone switched to Java as the teaching language which I think is almost as bad.
- the-peter 6y agoWhat a bad article. C++ shouldn't be taught either because C++-98 (1998) isn't compatible with C++-20 (2020).
- the-peter 6y agoYou shouldn't write an article telling people not to use Python if you don't really understand Python in the first place. Lists are called Lists in Python because they are just that: lists of varying and dynamic length of heterogeneous datatypes. If you want an array with a homogeneous datatype packed efficiently sequentially in memory Python also has that: a=array('i').
- deleted 6y ago[deleted]
- cnu 6y agoIt's a poorly written post. I think mostly written for SEO and traffic. One thing that I didn't notice others here didn't comment about: In the section where they write about xrange vs range in python 2 vs 3, they reference a piece of code supposedly written for py3 which isn't there. xrange was fast in python 2 because it allows you to evaluate lazily, which is what range does in python 3. So whatever benefits you got out of xrange is there in range.
- Beltiras 6y agoOk. Had to stop reading after the first paragraph. Python is not dynamically typed. Try doing print("Answer is:"+42) and the interpreter will not try to save you. Dynamic assignment != dynamic typing.
- robsws 6y agoIt is dynamically typed, because the typing is checked at runtime. Unlike a lot of other dynamically typed languages though it is strongly typed, because it does enforce type rules as you pointed out. That's not to say there's not a whole heap of other issues with this article though.