743 points · by pbui · 12y ago · 359 comments
If we then look at the table of actual data to filter a little bit, the story changes. There are certainly some schools, big ones, that use Python in CS1. But a lot of the Python representation is coming from CS0 at schools where CS1 is taught using Java.
(I can also clarify one of his other comments: he says of the AP exam using Java that "it's unclear whether that will change anytime soon." This is untrue. It will not change in the next 3-4 years at the very minimum---and that would be the time frame if the College Board said right now today that a change was happening. In fact, though, although the idea's been mentioned, there has been no study or apparent motion on that front, so a more realistic earliest-date-of-change would be around 2019 or 2020. And I wouldn't count on it, given how many CS1 courses are still taught in Java.)
I'll address each of your paragraphs in turn:
1.) Re: CS0 vs. CS1. Like you mentioned, I was very upfront about the methodology for this analysis. And I am very aware that most CS majors do not ever take a CS0 course. But please also be aware that there are a minority of CS majors that do take CS0 before moving onto CS1, usually because they feel ill-equipped to take CS1 right away. I harp on this point because even though this is a minority population, it's a very important one since those are students who, without CS0, would not major in CS. These students are more likely to be female or from underrepresented minority groups. On a related note, a larger and larger fraction of non-CS majors are taking CS courses because they recognize the value of programming and computational thinking. (Again, these non-CS majors are more likely to be female and from underrepresented minority groups.) So I would argue that CS0 is just as important as an "introductory programming" course as CS1, if not more important, due to the rise of the non-software-engineers-who-want-to-learn-programming population. [Edit: And I think that a CS department's choice of language to offer to the CS0 student population is still very significant, and a decision that is not made hastily.]
2.) Re: Python CS0 and Java CS1. You are absolutely right, and in my original article, this sentence appears in the discussion section: "Some schools have fully switched over to Python, while others take a hybrid approach, offering Python in CS0 and keeping Java in CS1."
3.) Re: AP exams using Java. Thanks for the clarification. I will remove "it's unclear whether that will change anytime soon." from the article.
[Also, as to cyorir's comment that the chosen data may have been cherry-picked, please rest assured that I tried my best NOT to cherry pick. If I had cherry picked, wouldn't I have made Python look even better? ;) Any incomplete data is strictly due to human error or oversight on my part, and I gladly welcome any correction requests via email.]
Indeed, I expect that when they're broken out, Python will be the overwhelming top choice for CS0, and a respectable second in CS1; but then, that's not as big a change as you might think. I'd be surprised if Java was ever a majority or even a plurality in CS0 courses. One subgroup of what you're calling CS0---the ones focussed on programming, often called a "service" course and targeted at engineering and science majors---have long been using things like C or Matlab, and never really had a strong movement towards Java. The other subgroup, what I'd call the "true" CS0 (i.e. based on what the ACM/IEEE curriculum guidelines used to call CS0) may have had no programming at all, or if they did, a short unit in a relatively lightweight language, certainly not Java.
Basically, the things that make for a good language in either kind of non-majors course are not always the same as what makes for a good language in a intro-for-majors course. That doesn't make the non-majors course unimportant and it doesn't mean that decisions are made hastily, but it's still not super helpful to conflate the two.
None of this is to deny the fact that Python is highly popular as an intro language.
I'm curious - would the group be less important if they were less likely to be female/non-asian minority? I get this impression from your text, though you don't actually state it explicitly. As a result I'm curious what your actual view is.
You can delete this sentence -- These students are more likely to be female or from underrepresented minority groups. -- and the meaning of the previous sentence remains unchanged. The key point is that CS0 is important for attracting people who didn't have prior background in computing and thus could have a latent interest in CS that would otherwise go unmet. Now, it turns out that a larger fraction of those students are from certain underrepresented groups, but even if that weren't true, it wouldn't make the case for CS0 any less important for the "group" that I think you're referring to, which is "students who have latent interest in CS but not enough prior exposure to know that they would love CS." (I wish I could've expressed that in an elegant mathematical equation!)
[Edit: when I wrote "even though this is a minority population", I didn't mean "minority" in the underrepresented minority sense ... I meant that this is a small population compared to all CS majors. Again, English != set logic]
As an example, take Northwestern. At Northwestern there are several intro routes you could take, depending on your major. CS Majors are not required to learn Python - it is used in some 300-level classes but not in very many 200-level classes (although that may change in the coming years). I've actually taken classes with projects using Python without ever taking classes teaching Python. CS majors will likely take C, C++, Java, MATLAB, or a variant on scheme for their first language, depending on which sequence they take, whether or not they are double-majors, or course scheduling.
In contrast, non-CS majors may learn C++, Python, MATLAB, or a variant of scheme as a first programming course, depending on why they are learning a programming language.
So while schools like Northwestern may offer introductory courses in Python, I think the truth is more something along the lines of "students may learn Python, or they may learn any of a number of different languages as their first language, depending on what their academic goals/requirements are."
A fair point of warning is that, having been at Georgia Tech 2008-2011, most of my friends in engineering and physics freshman year hated CS 1371, and spent many a late weeknight complaining about Matlab. The common wisdom, often picked up too late, was that engineering students would have a better time if they switched into the Python course, iirc CS 1301.
For my part, I had placed out with AP credit, but took CS 2110 using a combination of LogicWorks (circuits), LC-3 assembler and C. I thought it was awesome; that course is probably the reason I have my current job, but many of my friends never considered taking another CS course, or only did so several years later, because they hated Matlab so much.
Ask any non-CS Engineering professor interested in engineering undergraduate education whether engineers should take an intro course using Matlab or Python, and they'll always say Python.
This argument seems pervasive across many institutions.
As a clarification, a CS0 or CS1 course usually has no CS prerequisites, so if a course you're trying to mention has other CS prereqs, then it's probably not CS0 or CS1.
ha, feel free to DOWNVOTE so that this appears at the very bottom, so that it's visible :) but don't downvote so much that it disappears.
http://python-history.blogspot.ca/2009/02/early-language-design-and-development.html
It says a lot about our understanding of our field that new languages generally do not formally test their syntaxes (and other "mental model" features) for usability.But that's not how languages have typically been selected for 15 years or so. The direct vocational skills argument has held much more sway.
But every place isn't MIT, nor is every course a common core requirement for a college or department with diverse majors. Does a civil engineering student really need to implement lazy evaluation?
Felleisen's paper and subsequent book as well as the work of the PLT group show the current state of Scheme as a pedagogical language.
http://www.cs.brown.edu/~sk/Publications/Papers/Published/ff...
I just remembered some people i learned with who struggled along time to get behind the concept of pointers and how to use them when they thought us c/c++ as an intro language to programming.
C++ would be absolutely horrible. Is anyone doing this?
https://docs.python.org/2/reference/datamodel.html#emulating...
Or, the earliest I could quickly find:
https://docs.python.org/release/1.5/ref/ref-5.html#HEADING5-...
The access pattern is probably the right aspect to make consistent (at least in the context of duck typing). If the access isn't generalized across various types they might as well use named methods.
edit: I corrected the anchor in the second link.
So the question is really: can you use Python to get most of the benefit of teaching using Scheme while at the same time giving the student a practical tool for future use? I haven't taken the new Python courses, so I don't know how well the material bends to the language, but I remain skeptical of the "most of the benefit" part. Maybe I'm just a curmudgeon, but I sort of think they should keep Scheme and then just have a short (e.g. over IAP) course on practical programming techniques using Python (or whatever). Or maybe someone should rewrite SICP in Clojure? Finally, I know Scheme has continued to evolve, and I wonder if it's really still true that Racket is impractical as a day-to-day language.
Edit: some additions for clarification
The irony is that I teach a lot of Python programming classes. And despite that, and my love of Python, I think it's a shame that they no longer use Lisp (or Scheme, or Clojure) for the equivalent of 6.001.
Python is easier to understand and get into. And Python has some amazing features that you want, such as first-class functions. And it's a real-world language, which you can't say about Clojure, even with its growing popularity. And Python is my strong recommendation for everyone's first language, because it's so easy to get into.
But there are some things that are just easier to understand in Lisp than in other languages. Implementing Lisp in Lisp (metacircular evaluator) is a fabulous way to think about programming languages that is harder in Python than in Lisp. (Not impossible, but harder.) Lisp allowed us to think about programming in all sorts of new ways, because it handled so many of those paradigms so well.
So I still think that the intro CS class should be in a form of Lisp, because it opens your mind up to possibilities. But if you're not going to go that route, then Python is a terrific first language, and I'm quite happy to see it getting the attention it deserves.
It's relatively new, but I'm really excited about it, and that is what I'm learning, it allows you to get the benefits of learning lisp and python at the same time. It's compatible with python in both directions, so you can use it in any practical project - with django or with machine learning libraries, etc.
I think it's really cool =)
Or is it to teach the fundamentals of programming? Then Scheme is the ideal choice, but they should map concepts to mainstream languages. I.e., here's how OO works in Java, now we'll simulate it in Scheme. If more people took a course like this, we'd have fewer language fads IMO.
SICP is such a great book, it is a must have for programmers...
1) I hope they are teaching Python 3.x instead of 2.7.x.
2) A good portion of the schools cited in the Appendix are not "computer" schools. UC Davis for example, is the last place I would attend for a CS degree (I know many students at UC Davis -- it's much better suited for other degrees).
3) My school (CSU Sacramento) does not even offer any Python courses, but there's a lot of Java and C courses (depending on your major concentration).
I would say that compared to learning how to write and understand a small program, the difference between Python 2.x and Python 3.x is trivial.
(I'm talking about learning the language; for a large Python 2.x code base, the transition to 3.x is likely to have unclear payoff.)
The developers have said multiple times there will be no 2.8 and the 2.7 line will only receive security fixes. Python 3 is the future of Python and not teaching it to students would be a disservice to them.
I agree that simply learning some programming has no bearing on the language version, etc... however, as students get familiar and start to experiment on their own, they may learn "the old way" of doing things.
There is no downside to teaching Python 3.x, there might be a downside to teaching 2.7.x.
Not me. Are you a professional Python programmer for your day job? I don't think it matters what they're teaching as far as version. As an enduser programmer the difference really isn't that significant (not worth a breaking change in the language at least). But whether they learn 2 or 3, they'll be able to move to the other without any major issue.
I would recommend anyone pick 2 over 3 at this point in time. Everything that says 'Python' supports 2 so there's just never any worries or concerns there.
As for whether or not they are computer schools, that criterion was determined through USN&WR, as mentioned in the article, which is where your criticism of not being a computer school should lie. Davis is listed at #34 though, so there may be a sharp decline after the first 10, first 15, etc...
[1]: http://grad-schools.usnews.rankingsandreviews.com/best-gradu...
ECS10 (Intro to CS using Python) was my first formal CS class. Took it as a filler elective and was hooked. It was definitely geared toward first-time programmers and used Python to ease into fundamental CS/Programming concepts. I found it successful in that.
Following that was ECS30 which is in C and the first major-track CS class. The difference in difficulty/workload substantial, mostly due to the introduction of things like pointers, dynamic memory allocation, etc. But the intro class helped a lot. From ECS30 on, it's primarily C/C++ for OOP/Software design, Data Structs, systems, algos, etc. I don't think Python is used much if at all in major track CS/CSE classes I can remember.
I'm a little surprised at the dismissive tone toward UCD's CSE program relative to CSUS. I've audited classes at CSU in consideration of applying for a master's there, and while not outright disappointed, nor was I impressed.
I got the feeling that the CSUS programs are not as geared toward fundamental research and "CS" to the same extent as UCD and are slightly more skewed toward developing employable skill sets. That's not a bad thing, just a different goal. I also disliked the general push toward MS stacks.
Having peers at Cal that took I took summer sessions with at UCD, the feeling was that UCD was less challenging in the sense that there are smaller class sizes, better professor access (especially in classes taught by excellent lecturers like Sean Davis who devote lots of time to students), and less competitive nature of grade curving. I didn't hear anyone say it was easier, simply that it felt more collaborative. Though, that's not hard to imagine when they were in classes with nearly 1000k students split across two simulcast lecture halls in freshman CS classes at Cal.
Being in the shadow of Cal and Stanford makes it harder for UCD to get noticed, ut it has world-class faculty, smaller class sizes and great options for research. I have friends/acquaintances that ended up at Goog, Twitter, MS, SpaceX... etc. Is it MIT, Stanford, CIT? Perhaps no. Is it more known for it's Bio Sciences? Sure. But it's far from the 'last place' I would matriculate into for CS.
Just presenting (an admittedly verbose) alternative opinion.
CSU Sacramento would probably be the last place I would attend for a CS degree.
As long as signup to the class is open for all (and not just CS-students) there will be healthy benefits for other departments (economics, biology etc.)
Aside from that I've always kind of defended high level languages as entry level teaching tools. The closer to pseudocode/natural language the better. Once you start to think about solving problems like a programmer you can switch languages relatively painless anyway.
With the advent of RubyMotion etc. I'm starting to wonder if there would be some value in starting to teach programming on mobile platforms in a high level language as 101 (i.e. the first ever code they write is mobile code). From my experience the "app classes" are always popular because there's a certain cool factor in being able to show a friend stuff you did on your own mobile device. If you'd tailor those classes to low-level phones it would be pretty helpful for certain areas of the world where many families have at least one cell phone but often no computer. Writing the code on the cellphone itself is pretty painful but at least one could write it at a university/school with a computer and carry the stuff that was built home.
I don't think there's any harm in learning Python first. I think they may be harm in learning C first - it's much more likely to frustrate people and potentially even put them off programming.
This is the same reason I dislike Java as a teaching language: having to tell people "don't worry about what public static void main(String[] args) means just yet" when teaching "hello world" isn't a great introduction to programming.
This is exactly why I have always thought that the move to Java for intro courses was a terrible idea.
C/C++ were never ideal for beginners, but it was still possible to strip it down to building blocks without immediately resorting "don't worry about this now."
I agree. Except during that first C lecture when reading console input and was told 'don't worry about the ampersand, just remember to use it for scanf variables, we'll get to that later'.
C is important to know, but there's lots of stuff you need to learn before that.
I've just started learning, please tell me If it's best to learn python (I'm not looking for an easy language, but for a powerful and versatile one :) Something to develop some ideas I have..
First post on HN!! :D From the center of Spain!
While Python has a healthy web dev ecosystem, Ruby's feels much larger to me. That's almost certainly because Rails is so wildly popular. And Rails is an excellent, mature framework. So for web dev, I would consider Ruby the winner.
Python is the clear winner for scientific computing. That's not really due to anything inherent in the language. It's an ecosystem thing. If you were using Fortran before, you might be working in a problem domain where Python dominates.
Both are excellent for miscellaneous scripting work. E.g. reading in a CSV file and doing something with each row; batch-processing a bunch of images; renaming 1000 files according to some ruleset; gathering some system data and sending nightly status emails.
In terms of syntax and features, they're very very similar. Python has meaningful whitespace, which you may like or dislike. (I think it's good for enforcing proper formatting, but you're free to disagree.) Ruby has multiple ways of expressing the mathematical concept of a function (methods, blocks, and procs), which has its pros and cons. Both have metaprogramming facilities, though I find Ruby's more pleasant. If I remember correctly, it was in large part the metaprogramming that made DHH pick Ruby for Rails.
But many other readings and the fact twitter and groupon were coded in ruby, made the choice! I've read that twitter now is moving to scala, but as there are a lot more resources out there for learning ruby/python, I kicked it out of the list.
I like ruby, sometimes it seems a bit confusing when there are many ways to express the same thing, but it's approach to natural language is helpful.
Thank you all for your quick responses! It's a pleasure to join the HN community!!
It's funny because I actually feel the opposite: Ruby is mostly a niche language for the web community, whereas Python is now mainstream in so many different areas (graphics, scientific, sysadmin, financial...).
I've yet to see a non-webdev tool embedding Ruby as a scripting language, while Python is now featured in office suites, spreadsheets and enterprise software. Anywhere simple and clear syntax is more valued than metaprogramming features, Python is likely to appear at some point.
What is there in, say, rails that would not be available for django?
The difference is in the size of the ecosystem as a whole. The Ruby web dev world appears to have more (or more visible) participants. Which affects things like Stack Overflow, web-specific packages on Github, blog posts, etc.
It's not an order-of-magnitude difference, as far as I can tell. But still significant.
I much prefer Python/Django, but when I get stuck, it always lasts longer.
Which is more future proof: Python v2 or Python v3?
I figured that I was least likely to regret Ruby for a green-field data analysis project. So far it's been a delightful experience.
After learning those picking up Python will be fairly easy. Again, you'll be comparing with what you know, finding differences and similarities.
Don't worry too much about finding the perfect language, it doesn't exist. Spend your time building nice things in languages and frameworks that are good at at what they do. Be ready to try new things, you might like them, they might work well for a particular task or have a great ecosystem to accomplish specific things.
One reason is that Python is used for system programming (e.g: the Linux apt system), desktop applications, big data (thanks to numpy) so you might find it a better investment for general purpose software development.
Another reason, which maybe explains the first one, is that Python looks more similar to C++/Java. Basically it's a simplification of those languages (the {} pair traded for a single colon, no type declarations, etc) plus some handy shortcuts. Ruby is from a somewhat different lineage (Smalltalk) and it shows in many places (e.g. the do |variable| ... end blocks). It can be used to write more natural language looking programs and combining that with some metaprogramming sometimes both amazes and unsettles programmers that come close to the language for the first time.
I suggest that you learn a little of both of them, working on the problem you want to solve, and decide by gut feeling what you would like to work with. I went the Ruby way because I can't stand some of the syntax of Python, not that Ruby is perfect.
(a) already know HTML/CSS/JS and now want to learn a server side language, or that (b) you are going from no experience straight to server side programming?
Regardless of whether you learn Python or Ruby, there is practically no way around having to learn HTML, CSS, and JavaScript for building web applications. You will be reading/writing HTML/CSS/JS in your Python or Ruby projects.
So if you have no prior HTML/CSS/JS experience, I would prioritize those skills first. Otherwise you will learn Ruby or Python then be disappointed to discover that browser technology is a giant hole in your skillset, impeding you from doing the useful things that got you to start learning in the first place.
You can do great things with just HTML/CSS/JS, especially since the browser environment supporting dynamic client-side applications in JavaScript has become so powerful.
Then when you're finally doing something that genuinely requires that logic and/or data be hosted on a server, managed by server-side tools, your knowledge of browser technologies will provide a solid foundation for stepping into that ecosystem.
If you already know HTML/CSS/JS, Ruby vs Python comes down largely to personal taste and whimsy. There are indeed differences, but the differences don't matter till much later, if ever. The greater danger is not that you will learn a language that isn't future-proofed, but that you could waste far more time picking what to learn than you ever might have wasted by picking the wrong language, especially since there isn't truly a wrong choice between two great languages. The debate between them is largely a religious war.
Since you seem focused on web apps, and have already started learning Rails, stick w/ROR. You're on a great path and your current choices won't hold you back. Good luck.
PS If you're interested in learning HTML/CSS/JS, I am thinking of teaching these subjects to beginners (no charge of course). PM me with a contact if interested.
I've started with the ruby course on codecademy, it seems it's just like a fun introduction to the ruby syntax. When I finish the codecademy course I'm thinking about going into "onemonth.com" for learning rails, and codeschool after that..
Thank you! I'll get started with those languages as well :) I'm focusing on web apps, but I'll have to use JS to take the idea to phone app (using Titan from appcelerator)
By the way! Thanks for the invite to the course! I'll contact you as soon as I find out how to send a PM haha
By the way, since it happened to me: if you find Rails to be too complex for what you need, there are more lightweight alternatives. Don't get me wrong, Rails will get you up and running fast; but when I was a beginner, it left me with the sensation that I didn't really know what I was doing. Using more lightweight frameworks, like Cuba or Sinatra, can help with that.
The main content of the course hasn't changed. Complexity, Big O notation, sorting and searching are introduced in the first two or three weeks. Students work through the usual implementations of arrays, linked lists, stacks and queues (both array and linked-list based), trees, heaps, tries, etc. All these data structures are explained first as chunks of data with external functions for the operations; then a second time as objects with methods for operations, once object orientation is introduced in week 5 or 6. Iterators are introduced as an abstract interface to list-, array- and tree- walking. Where relevant, we explain every operation twice, showing the iterative and recursive approaches. The course ends with two weeks of lower level work, where the students hand-compile pseudo-Python to working MIPS assembly.
The move to Python gained us, among other things, the freedom not to have to explain Java's generics and access modifiers. Many of our students have never programmed with a text editor before our unit, and dropping them into the big boilerplate world of Java micro-management was not good for them or for the course. We used to spend too much time on syntax and other details ("native types are like this, reference types are like htat") that we should have been spending on data structures and algorithms.
With Python, we even have time to explain idiomatic Python iterators and generators, and to discuss Python scoping rules (which come up again when we work on local variables in their hand-compilation tasks). So we still teach a bit of language-specifics, but we don't feel we are shackled to have to teach them. Also, teaching them idiomatic Python is a good deed after spending the first three or four weeks in a not very idiomatic subset of Python where we maintain explicit indices, update them by incrementing or decrementing them manually, use while loops the condition checking on the index value, etc. as required by the course content.
I don't have data on the results, because I was only the adjunct adapting the tutorial materials. The only difference I noticed was that students had less support from their IDE, and that some common errors (attempting to access attributes on None is the top one) that used to be picked up statically are now runtime errors, as expected. There didn't seem to be any big problems from Python's lack of lexical typing. Type errors are still caught, again by the runtime instead of the IDE and, if anything, this is a better exercise for students, since fixing them requires better understanding of what the program is doing.
If anyone is interested, I can ask the lecturer about the outcomes, but just from the fact that neither she nor anybody else teaching the unit has raised any issues the second and third times the unit was taught I can tell it's all going smoothly.
This means that we have ten weeks to take people who may have never programmed by typing text into an editor and teach them enough CS and programming that they can implement their own hashmap in Python and reason about its big O performance in one week, start programming in MIPS assembly the next week, and implement function calls in assembly and reason about stack frames the following week.
Anything we can do to make their learning curve less steep is good. You say that your Data Structures course was graduate level, and that you were already familiar with C from a lower course. These are two big differences between you and our first year intake.
Now, like Spolsky, I too have a bit of the Yorkshireman in me, and I wish our students would be forced to work with simple text editors and the command line, instead of having the IDE to do some of their lifting for them. I wish they were taught more maths too. And spelling, now that we are at it. And C, why not.
But when you say that in your course you "just had to focus on our algorithm and nothing else", it echoes exactly our intention when we picked Python for this unit. We wanted the language that would allow our students to focus on the fundamentals, and spend the least time and effort on the incidentals. We were already running the unit in Java, which was an inherited decision. I think Python was the best of our available choices.
But the next course would be a hardcore introduction to C, embracing the language peculiarities instead of shunning them and trying to stick to concepts. I think at least once in an undergrad's career, preferably sooner than later, they should go through the process of learning the nuts and bolts of C.
I've probably been doing my own thing for too long to know for sure whether C is still the best choice, all I know is that NOT having the sort of class I describe, early in my college career, made things far more difficult later on.
"Now, I freely admit that programming with pointers is not needed in 90% of the code written today, and in fact, it's downright dangerous in production code. OK. That's fine. And functional programming is just not used much in practice. Agreed.
But it's still important for some of the most exciting programming jobs.
"Pretty much saying that everything he just spoke to us is purely for the "exciting programming jobs". And let's face it, most of us do not have that unless we go out of our way to pigeon hole business problems into being fun and exciting.
The truth is, universities shouldn't care what industry does, because "real-world" computing is more about fashion than it is about any sort of science. And if you do it right people can learn any language they need (case in point, I learnt FORTRAN at college, now I do Python for a living and OCaml as a hobbyist).
that seems utterly pointless to me.
Remember that if this is a 4-year curriculum, they may eventually be expected to write code for a hashmap in C or some other low-level language as part of a data structures or algorithms class. And often, a class like that will spend time on analysis and algorithm design tradeoffs. The best way to understand why accessing a hashmap can be done in O(1) time is to actually code one for yourself.
This may simply be a preview.
We moved from Java to python this year and I miss a few things. Due to the absence of explicit typing the students don't bother to understand types anymore and it leads them to a lot of mistakes and misunderstandings: confusion between simple types, lists, dictionaries, instances of a user created class, etc. Besides I think the verbose and rigid syntax of Java forced them to understand what their wrote and for a first language that was a good thing.
Overall I found that since it is easier to write code in python they rush to writing anything without understanding the algorithmic problem first. Thus they are less able to decompose a problem in sub-problems and write atomic functions to solve each of them.
Note that I think teaching python as a first language is a viable option but in our case the course needs to be intensively rewritten and the labs adapted. For instance my lattest point about algorithms is not a problem with the language: it could be resolved by having a part of the lab being pure algorithmics and then an implementation part.
I graduated from Monash Clayton a few years ago when the Java train was in full effect and the focus on Java was a big source of frustration for me. I distinctly remember an algorithms & data structures assignment about Markov chains which had to be done in Java. I spent a good 40 minutes writing what was effectively boilerplate to load the provided files into a meaningful representation and then just snapped and did the entire assignment in Python in maybe 15 minutes. Its crazy how much Java gets in your way for small projects.
Even though it was made clear that Python submissions won't be accepted, my tutor was very understanding and gave me full marks after I stepped him through the code. If that tutor was you, I owe you.
My first year CS data structures class was in scheme, as used to be popular. I enjoyed the class a lot, leanred a lot, and also found it very challenging. I think scheme was perfect for it. But I had no particular desire to continue with scheme afterwords, which is fine. (Not because I have anything against scheme, but on to other things).
It's important to remember we're talking about an introduction, here. Creating the spark of interest in students is the most important point in this class. There's always time after this to move them toward more expressive languages.
Maybe you felt you had to jump in and defend high level languages, and maybe slash the other guy's tires on the way out, but this reads as trollish. Plenty of people working in C find it plenty expressive. Is it "more" or "less" expressive to choose to express different things? I don't think so. This comes off as uninformed C bashing, sadly very common and accepted around here.
The rest of your comment, that it is good for learning or as a first language, makes more sense to me.
Python can be circuit bent into any semantic you desire, so I think it is a great introductory language.
I haven't taught an introductory Python course in years, but with Ipython Notebook I think it would be a blast.
Secondly, it makes for an easy transition from Python to Matlab, and Matlab is used a fair bit throughout UQ's Mechanical and Mechatronics departments. They both share very similar syntax (the major issue for most mech engineers, who deal with little more than loops, is that Python is 0-indexed whereas Matlab is 1-indexed).
The above makes Python a great introductory langauge for non-programmer beginners like mech engineers. It is ridiculously simple and human-readable, and when you're outside an IT/EE department then you don't end up spending excess time explaining the quirks of a language to those who will never care for it. On the other hand, it still gives more than enough rope for those that do end up wanting to run with it and they can end up doing some pretty fancy stuff with it.
Does Monash align there in that it's used in the non-IT related technical degrees?
Curious. Why is object orientation introduced in a data structures and algorithms course?
I find that incredible. Long before I got to university I was been programming by myself with whatever editor I could find, edt, vi etc
I hedge that many of our students have never programmed "with a text editor" before because:
1. Many of them have used spreadsheets in higschool to build quite complex formulas, and spreadsheet formulas are turing complete, so they have programmed in some form of another.
2. I didn't want to discuss this here in order not to muddle the debate, but our introduction to programming course is now ran on Scribble[1], a dialect of the Scratch family. So many of our students in this data structures and algorithms unit have previously done just 12 weeks of programming instruction, and understand many of the concepts, but our unit is the first time that they have to deal with (for instance) syntax errors in textfiles.
Many people here in HN were teaching themselves programming by age 6, but to repeat myself: you are not our first year intake. We teach the students we get. These are not bad students: they are often hardworking and smart, and do well and learn a lot in our unit.
They may be ignorant of programming, but that's also ok, because that's what we're there for. And, to go back to the OP's topic, using Python as a teaching language lowers the barriers for access to the concepts that we really want to teach: complexity and big O, searching and sorting, etc.
I love python - used it for years, but I am dumbfounded that people enter a CS degree without having ever first tried to write a program. That's like taking english lit without having read a book before.
This by analogy with "lexical scoping", where you know where a certain name will be bound just by looking at the program's text, while with dynamic scoping, the stack is what determines where a variable is bound, and you can only know about it at runtime.
I guess I should have said "static typing". I probably made the mistake because lexical scoping is also called static scoping, and I was writing in a hurry.
That said, I believe that pylint could statically catch some of the type errors that are being referred to.
How sad, not that you only do array and linked-list implementation of data types but that you think this is an exhaustive list. Inductive data types?
If you don't drop context that's a perfectly reasonable thing to say.
At my university I feel that proprietary scientific programs and CAS like Matlab, Maple and Mathematica are still the preferred problem solvers for students in the hard sciences (except CS).
That said, Ruby includes a lot of interesting concepts, and while I don't believe it's an ideal first language, those concepts certainly belong in a CS program.
(I have to say that it was extremely good !)
I'd say that blocks might be easier to grasp for a true beginner that hasn't been "contaminated" by the notion of anonymous functions as fundamental objects.
If you've got an explanation that would work in week 2 or 3 of a CS1 course, I'd love to hear it. I never found one better than "It's shorthand for a function."
But at the end of the day, if you teach someone Python, they can turn around and write Python code to solve problems in their science classes with minimal friction, or they can go on to be software engineers, or write web scrapers, video games, whatever. Python's arguably not the best at any of those things, but it's good enough at all of them.
This is my best guess as why Python VS Ruby.
Much has been said on this topic. So, I'm just going to post two links that I think are interesting.
Joel Spolskey claims that Java isn't hard enough to separate good programmers from the bad: http://www.joelonsoftware.com/articles/ThePerilsofJavaSchool...
This article claims that competency of CS grads is going down: http://www.education.rec.ri.cmu.edu/roboticscurriculum/resea...
CS1 should be an introduction to the nature of the discipline. I can think of many things more important and more representative of the nature of computing than the semantics of C.
It is not that I don't agree with your point, actually I think It makes perfect sense. Eventually, anyone who considers him/herself as a serious CS student has to get his/her hands dirty with those relative low level languages in order to have a through understanding of what computer really is and in reality how it works.
Ironically, it is this very same reason that makes C++ as a entry point into programming a horrible idea. Because in order to understand it, IMO, a solid understanding of computer architecture is a MUST. Things like how memory is allocated, how call stack works, and why IO interfaces looks like it is now are unrealistically hard to take in a single course for those new comers with definitely zero programming knowledge, who probably would scratch their head out all night wondering why the following code snippet doesn't work (which wasn't valid back then in my freshman year, don't know whether it is valid now):
http://stackoverflow.com/questions/737240/c-c-array-size-at-...
And as it is a entry level course, usually a lot of details are skipped which makes it even more confusing. Telling from my personal experience, it is really frustrating that I once want to quit programming for good.
Luckily enough, I got to know Python at that time. In relatively short period of time, I could come up with a simple web crawler to scrap and download movie torrent files from the web. This is important to me that for the first time I realize I could do something both INTERESTING and USEFUL with programming language, which in turn gives me the motivation to go back and look at those lessons I run away from.
They will make mistakes, sure. But they will get the work done, and that's pretty much what most businesses need. Eventually, as problems creep in, the messes created by lack of knowledge get resolved/cleaned up.
Programming is incredibly easy and powerful, when made simple. The problem is that learning programming in C/C++ is anything but simple! And the only reason we'd think otherwise is because we already went through it, somehow.
I've seen non-technical minded people learn programming with C/C++ as their first language. They get frustrated because they don't know why certain things work magically while similar things don't. So they end up learning to memorize what works and what doesn't, and copy-pasting what the book tells them. Eventually kludging together a working solution to a problem in the book. With no hint of understanding why.
#Yes I pulled that statistic from thin air.
Besides, most of what is being asked of four-year-degreed individuals is not really worthy of it. Which is why I keep mentioning stuff to the effect of "to a client's expectation" to most of my comments on this.
I see 2 domains where this level of depth matters:
- performance (speed, resource consumption) - security
If you're not doing one of those, you shouldn't have to care about them, especially if this is your first programming language ever.
1. It is weird to take the top graduate schools and ask about what they teach to undergrads. I'd rather see this done with the best national universities list - http://colleges.usnews.rankingsandreviews.com/best-colleges/... - as the basis for this study since that's where the top undergraduate students will end up.
2. I'd rather see trends than raw numbers - the fact that python has grown quickly over the last decade in terms of adoption is more interesting than it being "the top," to me.
3. It is sad that Java still has such a stronghold both in terms of being the intro language and being on the College Board curriculum. It is not the right language for beginners, or, really, anyone.
4. While I didn't take "CS1" in college (thanks AP exam) - I did take CS2 or whatever, and it was taught in scheme with SICP. Scheme was the great equalizer in that it was unlike any language anyone in the class had ever seen and that syntax no longer mattered - only concepts did. I hope it continues to keep its place in second-level courses.
5. It is unfortunate that garbage collected languages are extremely highly represented on this list - memory management may be unpleasant, but acknowledging that we are programming on limited-resource devices should be acknowledged early and often. Forcing students to experience this first hand seems that it serves both the purpose of teaching them abstraction (isn't this garbage collector great!) while maintaining a respect for the fact that resources (cpu, memory, power, network, disk, etc.) aren't free.
I'd be interested to figure out the whole intro sequence. For example, my college begins with Java for the first class, then the next two classes can be taken concurrently, which respectively consist of functional programming/basic CS theory in SML, and Data Structures/Advanced Programming (memory management!) in Java and C++. I'm sure a number of other colleges follow similar procedures.
Also - I don't think that "CS0" classes should be included on this list as most are not taught with the intention of further CS education. For example, we have an "intro" CS course that is taught within the context of cognitive science (in Python).
Even more off topic, horizontal scrolling can be less of a pain if you just hold shift and scroll up and down.
Here is the issue I feel goes unnoticed as most people place out of 110 and never take it - CMU moved both courses to Python. While this helped 110 in a way by making it more accessible, it also resulted in people getting out of 110 with far less OOP principles than they did before. On the other hand, python works great in 112 because you spend more time building datastructures rather than running into the wall with Java OOP layers over and over. It's also cleaner so how a datastructure works becomes more transparent. But since the curriculum assumes OOP mastery from that point on, with no software engineering course required - I always wonder if replacing Java from 110 (a course for people with no coding background) was a mistake.
They put the transition to vote and Python won very clearly. But I always wished they continued 110 in Java (or shifted to Scheme, or anything that follows a stricter regime than python - so one gets comfortable with one way of abstracting problems, be it OOP or Functional) and taught 112 with Python. It probably isn't worth even discussing given how few CS majors take the course, but it always makes me wonder why we needed same language for both courses.
The other problem is that the farther you get from being a freshman, the farther you get from understanding which concepts are necessary in an introductory curriculum. As a senior you might say that OOP must be taught to the freshmen because so many freshmen don't get it, as a junior developer you might want the program to teach the standard library, and as a senior developer you might want to teach people about testing. This is all wrong. The most important things to teach freshmen CS students are very simple. Control structures, data structures, references / pointers, and recursion. Never forget that while OOP is warm and fuzzy and makes you feel good, the number one priority of the intro CS courses is to get the freshmen to write programs that work correctly.
Or, since OOP is a design aesthetic, it is only useful once design becomes important. Design is not important for small programs that freshmen write. Let them get off the ground with correct programs, and teach them paradigms once they have enough context to understand them.
I learned BASIC first and started hating GOTO before I was even in my teens. Who likes GOTO, seriously?
> The other problem is that the farther you get from being a freshman, the farther you get from understanding which concepts are necessary in an introductory curriculum.
I don't know, the farther I've gotten from being a freshman, the broader my experience of other people learning programming has been (and, even though I've never been an instructor in a formal introductory course, the more experience I have teaching other people, including programming.) Even if my freshman classes were my first introduction to programming, I don't think I would have had a better idea what an intro course needed then than I do now.
At the end of the day, Python won because it could be used to express programming concepts quite clearly in both an imperative and, to a slightly limited degree, functional manner, in ways that were appropriate for a variety of domains. And it did it in a way that substantially reduced the "boilerplate" syntax burden, which most of us take for granted, but is a large pain for newcomers to programming.
print "hello, world"
is very easy for a beginner.
Depending on what your background is,
[(i*3) for i in [1, 2, 3]]
may be a very clear way to multiply every element of an array by 3. Or it may be confusing as heck. :)
Our general hope is that by the time our current first years make it through the program that there will be even less of an emphasis on OOP needed. C0, for example, introduces an additional component of formal reasoning, and my shift of 15-440 replaced C++ with Go, which has a modestly less "OOP"-centric flavor. The big drawback now is that the transition from 110/112 to the formality of C0 and the functional intro with ml is rather jarring. That's partly by design, to get people to think about computer science differently than what they might have learned about "programming" in high school, but we'll see if we can optimize it.
(I'm posting about this because I'll be teaching 15-112 with David Kosbie next Spring.)
You should go back to teaching Distributed Systems in Go next semester. Pretty please.
The "introduction to CS" course, CPSC 201, is taught in MIT Scheme. It's interesting because for CS majors, the first class is functional programming. A sizeable minority (including myself) skip that class though, since it's only offered in the fall. I chose to skip it because I started the major late, already had programming experience, and Scheme isn't actually used outside of education. From what I gather, I missed out on some valuable lessons in simulating circuits and binary logic. My knowledge there is still weak.
After that course, the rest of the core curriculum is taught in C. Scripting languages like Python/Perl/Ruby, you are encouraged to learn on your own, and will often help in assignments. But they aren't explicitly taught as the focus of any course.
I absolutely hated some of my programming assignments in C, but I think learning systems programming in such a low level language is timelessly valuable and makes picking up new, higher level languages significantly easier, since you already know the tradeoffs of the underlying data structures and algorithms. For example, if I had not been exposed to pointers, I would not understand the difference in Python between "is" and "==" when comparing strings. In general I think learning c is a valuable albeit masochistic move.
We don't even touch data structures, algorithms, composition, inheritance, etc until "CS 2," which is also in C++. When I first tried Python as part of a 1-week assignment in "CS 2.5" (a lab course), I was blown away and hooked pretty quickly. We don't get formal Python experience really until the extremely work-intensive upper division programming languages course. From my perspective, I think a large number of people are discouraged by CS 1 and how it's more of a programming class than a CS class. The only benefit of a C++ introduction is that it's easier for people to transition to C and lower level code for the operating systems class. Still, C is pretty well covered by our "CS 2.5" and "CS 3."
Other fun facts: our CS 0 (programming for non-CS majors) is split into three classes and is also in C++!
I accidentally took a C++ at a community college during high school and was forced to skip "CS 1" when I enrolled for my first quarter. I felt so unprepared for "CS 2" that I actually audited a good number of "CS 1" lectures and did half of the projects for the class even though I didn't take it.
Actual course numbers:
CS 1 -> CS 31
CS 2 -> CS 32
CS 2.5 -> CS 35L
CS 3 -> CS 33
CS 0(a-c) -> PIC 10(a-c)
I definitely saw it scare some people off though. So if your only criteria is "what is the passing rate", it probably does worse than python.
Since I'd been programming since I was 11, it seemed a little arduous to sit thought classes explaining what a variable was, etc..but in the end, I understood they had to do what was best for the whole lot, and obviously couldn't teach something more advanced to an underprepared set of people.
I think Python nowadays is really the better choice: although C has its own merits (and it should be taught at a later course, possibly together with embedded systems) , it introduces more complexity than necessary.
Python, with its readability and "batteries included" is really the ideal language for an introductory course, not to mention that it has potential lifelong use as a "Swiss Knife" type of language.
I say this knowing I hate a lot about Java, but thinking about how I would teach concepts and techniques while making a student employable and fostering the ability to experiment on their own.
I think the mission here is to ease people into coding so if they don't want to progress any further up maybe they'll just manage a companies small PHP website or something and have the knowledge to do that.
For EE major etc I would still recommend the plain C stuff though. For web-design etc Javascript might be a better course. Overall Python is a nice choice for the generic public.
Rust is a horrible choice now, because it hasn't stabilized. When it has stabilized, it may be a suitable choice (at one point, it looked like it would be too large of a language to a be a great intro language, but since then its been getting smaller, so I'm less convinced that it will remain unsuitable for that role.)
Python's a pretty good intro language; as is Scheme, and Haskell might be, though I haven't seen any good intro-to-programming material built around it, and while I think a good intro should prefer a largely-functional style (as the best Python and Scheme-based courses I've seen have), I'm not convinced that a pure FP language is ideal for an intro to the field (though it certainly a good thing to learn in the course of an education in the field.)
The students move on to Java, C++, Perl, Prolog and others after that; not sure about Python.
I think a strict language in the ML family would even be nicer, because students wouldn't have to reason about laziness.
Also, a lot of colleges (at least the best ones) offer functional programming in a second semester intro course (Berkeley does Scheme I believe). My own institution uses SML.
Python 2.7.1 (r271:86832, Apr 22 2011, 16:34:07)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> type(5)
<type 'int'>
>>> type('hello world')
<type 'str'>
>>> type({'key': 'value'})
<type 'dict'>
>>> 5 + 'hello world'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'
It just has dynamic typing.I could show this to my 80 year old grandmother and have her understand what it does with minimal help on my part.
word_list = ["hat", "dog", "cat"]
for word in word_list:
print(word)
The same example in Java isn't extremely hard to understand, but it definitely is a decent jump in complexity from the almost plain English syntax of Python. String[] word_list = {"hat", "dog", "cat"}
for(int i=0; i < word_list.length; i++){
System.out.println(word_list[i]);
}
EDIT: Forgot about Java's foreach operator, but even so with java you then have to explain what String[] means and the keyword "in" makes for an easier read than (String string: strings) and System.out.println vs print String[] word_list = {"hat", "dog", "cat"}
for(String word: wordlist){
System.out.println(word);
}Types dont make things more complicated. Most languages have types and I prefer dealing with them explicitely rather than letting an interpreter do random coercion like Javascript.
Types lead to cleaner programming,instead of shoving random stuffs into an untyped list,a dev has to think about data structures.
Furthermore,as a non native english speaker,I dont find python more readable than staticaly typed languages like C# or Java.Especially when a codebase grows larger. I wish python was statically typed.
mapM_ putStrLn ["hat", "dog", "cat"]
I'd say the above is pretty simple if explained after: putStrLn "hello world"
You don't really have to go into Monads for this to be understood/used. You can just leave it at "you use functions ending with an M if they do something like print out to the screen or get stuff from a web page".print(word) means it's even easier for grandma to understand!
String[] word_list = {"hat", "dog", "cat"};
for(String a: word_list)
{
System.out.println(a);
}
extra brackets but pretty identical asList("hat", "dog", "cat").forEach(System.out::println)Transitioning first classes from C to go would make great sense, but it looks like a lot of schools already replaced C with Java and C++ as first languages.
Personally, I do think there is merit in teaching a primarily imperative language first, if only to appreciate other paradigms later and get an inkling of what is really going on beneath your code.
I won't say anything about Python.
> I won't say anything about Python.
I will try to learn from your wisdom.
Really? I thought good old imperative programming was the best starting point. Concepts like assignment, branching, looping. IMHO goto is actually useful at that point and structured programming is an abstraction that takes a little while to wrap your head around. Perhaps it's due to the way I learned that I think some things are more basic (no pun intended). Either way I don't think high level abstract concepts like functional programming are even relevant in the real world of software development - abstract stuff is CS, basic stuff is for everyone else who has to take a programming course.
x = 1
x = 2
that's immediately very confusing for a beginner - are we saying that 1=2?If we stick to immutable values and recursion, and functions that are, well, functions, we get something that corresponds quite closely to first-year mathematics, which makes it easy to learn at the same time.
This is nothing but FUD and you should be ashamed of yourself.
As much as I like static typing, I agree that showing people run-time errors seems to do a better job of teaching than letting them know ahead of time via the compiler that their code will likely blow up.
Functional still isn't that popular, in spite of a few vocal supporters. Even MIT went from scheme to Python for their sicp training.
European computer science has traditionally been more theoretical than American computer science, but even in Europe you'll find that a lot of 101 courses teach in Python.
Other Portuguese top level universities offered similar choices.
Rust would probably be too strict and annoying as a first language. Maybe the same is the case for Haskell, but maybe it isn't such a big deal for those that haven't been "spoiled" by imperative languages and thinking already.
No. Most languages are whitespace sensitive, though what whitespace differences matter varies from language to language.
> When students eventually move to Java/JavaScript/C#/Swift/whatever, will this be more difficult?
I doubt it. If anything, the indentation discipline they've learned will make their code in those languages more readable.
I really feel like I'd have rather had Python or Java first instead, if only because being concerned about all of the strict formatting and structure in a C++ program puts a level of unnecessary complexity in front of the goal: to introduce a person to programming logic and solving problems with programs.
Those complexities are certainly important, mind you. But not as important as clearly opening the mind to the way a programmer thinks, IMO.
there is also cs61as which is entirely in scheme (but no lecture) https://edge.edx.org/courses/UCBerkeleyX/CS61AS/2014_Spring/...
Show me a sane person who succeeded to grasp these few big ideas behind SICP after Berkeley CS61A or another similar Scheme or Racket course, who had any regret for spent time and effort?)
btw, AIMA and PAIP are much better in CL than in Python.)
PHP is all about magic.That's why it is popular at first place. And its popularity is an accident we'll have to live with for decades,given the amount of PHP code deployed outthere.
But if you are meant to be a CS student,you need a proper multipurpose language.You can do almost anything in python,from 3D games,to complex scientific computation.
PHP is merely a templating language,with enough good syntax to be bearable for advanced programmers.
PHP popularity is quite unfortunate if you ask me.Not because it is easy to start with or because it's a templating language.But because it could have been way better regardless of its execution model.
It could have been cleaner and more elegant if its original author had a clue about how to design languages.
most of PHP syntax is due to Rasmus inability to write a sophisticated parser.
Contrast[1] with python:
mkdir cgi-bin
cat <<'eof' > cgi-bin/hello.py
#!/usr/bin/env python3
print("Content-type: text/plain")
print()
print("Hello, world")
eof
#try to run:
./cgi-bin/hello.py
bash: ./cgi-bin/hello.py: Permission denied
#fix error:
chmod u+x ./cgi-bin/hello.py
#test in console:
./cgi-bin/hello.py
Content-type: text/plain
Hello, world
#Ok, does it work on the web?
python3.4 -m http.server --cgi 8000 --bind 127.0.0.1
#open localhost:8000/cgi-bin/hello.py
So, how can I claim that this convoluted mess is "simpler" than php? Because everything is right there, and everything can be explained conciesly (contrast with apache configs, getting the www-user right etc). You could build on what the students know of print() and string interpolation/concatenation to output html/use templates etc.Is this how I would start teaching web programming in python? Probably not -- but it might be useful as one approach, assuming we've started with doing some stdin/stdout stuff, and showing how we can do the same on the web. Crucially showing how if you know how to read a csv file with values, do some aggreation and format it as a text table, you can output it as html, as text over the web, or even as json paired with javascript. That again generalises to database access ... etc etc. It's python (and "invisible" c) all the way down.
[1] Comparing using a fully wrapped up install of webserver+php (either mod-php or fcgi or what not) would a) not be fair, because if you really learn python, you have all the tools to examine the whole stack (well down to the OS level anyway), and b) fair comparision wouldn't be to python but rather with something like web2py, that also bundles a lot of infrastructure.
YMMV and all that, my only point was that there isn't really anything "simple" about web development -- it's distributed development with not very clearly defined security, state or even messaging semantics -- it's a mess. A useful mess, but a mess.
[edit: formatting, spelling. Aslo I agree flask is probably a much nice place to start, if one isn't building on an introduction involving text/console i/o]
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__": app.run()We should not be teaching impressionable students that whitespace has semantic significance. This is a fundamental design flaw of Python, and it's just a Bad Idea.
Sorry, Guido.
That sounds like a gut reaction and not a reasoned argument. I was skeptical of it at first, but after coding some Python I decided all my reasons for hating it weren't valid. Turns out it's very practical and makes the code prettier. I don't like the language for other reasons, but the significant whitespace never gave me any problems, headaches, or weird spurious bugs.
The only negative thing about it for me was that hitting TAB in Emacs doesn't indent to the "proper" place (since it's impossible to actually determine the proper place). Instead, it would alternate amongst the valid tab points from most likely to least, which felt like a reasonable compromise to me.
Interestingly, I never hear anyone whine about Haskell's use of significant whitespace…
However, when a language comes around that actively enforces and promotes these rules... you say it's a "Bad Idea". Could you elaborate on why you think it's so bad?
Not particularly, no. Or at least I think that should be the IDE's problem.
You still have to tell the IDE what to do with your code, which you do with brackets, I guess?
So now your code is full of brackets and parentheses, which are naturally less readable (how many levels of parentheses do you use in natural language?), and their role is almost entirely to... help the IDE indent your code.
http://alexander.kirk.at/2010/02/16/collapsible-threads-for-...