9 ms·
Why I push for Python
- erikb 12y agoI'm a huge Python fan (90% of my code is Python, work and private), but I don't think any more it's still the language to push. I have not much experience but it seems Go, Ruby, and Scratch seem to be the one's people should be heading towards (which one depends on the level of skill required). But it's really just my feeling, I have no data to proof it.
- GuiA 12y agoInteresting examples you mentioned. Go, I can understand. But why Ruby? It is just as old as Python, behaves very similarly, and its ecosystem for non-web related tasks pales in comparison. And why Scratch? I really enjoy it (I've taught many workshops to kids 6-14 yo with it) but I would absolutely not use it in anything else but introductory classes.
- erikb 12y agoThe reason for Ruby is that more playful things seem to happen in that ecosystem. If you want to push something you want to be at the edge right? And although I believe Python and Ruby are equal in many qualities, Ruby is closer to the edge of where the next development happens. That was the reason behind my decision to add that.
- anko 12y agoThis. I don't know why more creativity seems to happen in the ruby ecosystem, but it really does. My preference of ruby over python comes down to elegance and string interpolation operators (ie. not much). But ruby attracts people trying to do interesting things. Some examples; Puppet, Chef, Vagrant, github, Jekyll. I'm noticing similar cutting edge infrastructure/service stuff being written in go by default.
- bjt 12y agoI think Ruby hit its peak at the same time as people were deciding what language to write Puppet, Chef, Vagrant, Jekyll, and Github in, but it's more a coincidence than something inherent in the language that led to those choices. Salt and Ansible, successors to Puppet and Chef, are written in Python. The author of Vagrant is writing his new tools in Go. The buzz and constant churn of new shiny things that I saw in the Ruby community a few years ago seems to have moved more to the node.js community these days.
- anko 12y agoI know I'm late to reply, but i'm interested. What cool stuff is happening in the node.js community. The only thing I can think of that is really cool is meteor. I think the thing that sucks about node is that javascript sucks. It's really a horrible language, it's just that it's everywhere. It's not the most horrible, but the type coercion, scoping and standard libraries really suck. When you say salt and ansible are successors to puppet and chef, it sounds like you are saying they are inherently better, but really they just came later. Out of interest are you saying you don't believe in Paul Graham's language spectrum? Blub paradox and that?
- pwang 12y ago> If you want to push something you want to be at the edge right? Wrong. You need to be at the core. In many areas that I've looked at, most of the activity happening at the edge is just churn from an ignorance of history and a naive blindness or lack of understanding of root problems. And there is plenty of interesting stuff happening in Python: compilers, visualization systems, devops orchestration, you name it. Don't mistake the noise on HN for reality.
- Igglyboo 12y agoI'd have to agree, Go is suited to more intermediate level students and Scratch for extreme beginners and younger children, but Ruby? Ruby is like a harder to read, slower, less used python. Once rails falls(and it is falling) ruby will become a niche language.
- im3w1l 12y agoI haven't been following the ruby/rails community much. In what way is rails falling?
- Pacabel 12y agoRuby on Rails apps have started causing a lot of problems for a lot of people. Any small initial gains obtained by getting Ruby on Rails web apps put together and deployed rapidly have time and time again been lost many times over due to performance problems, severe maintenance headaches, security flaws, and other issues such as those. In short, it hasn't managed to live up to the immense amount of hype that once surrounded it. Those issues, combined with many other languages now offering web frameworks that are far better than Rails, have caused a lot of developers and organizations to completely abandon it and apps written using it. Few people and organizations have time and other resources to dedicate toward something that is a liability, especially when the alternatives are so plentiful and better these days.
- rahimnathwani 12y agoWhich frameworks are far better than Rails? I've used Flask and Django, and like Python due to the large ecosystem of general packages available via pip. However, I've heard that Rails developers can be super-productive due to the much much larger ecosystem of web-related gems. If a Rails developer were to move to another framework, which ones would you recommend and why?
- bayesianhorse 12y agoI think Go isn't particularly suited for students at any level. It is a language built for applications that aim to scale extremely well in the cloud, and usually it is being used to replace small parts of a larger infrastructure. Go does not look as inviting for general web development (when runtime speed is not as essential as features) or general programming outside the web/cloud.
- Daishiman 12y agoGo is a highly specialized language made for very specific use cases and mind, and still missing features that are essential in many programming domains (dynamic linking and real generics come to mind). Ruby has no real reason to be if you're already using Python. Nothing wrong with that language (although I consider its programming culture to be inferior in many aspects) but it doesn't really do anything that Python doesn't do, even if it has a few more syntax tricks, which are at best a nice but superficial advantage, at worst another point of confusion and bugs. Scratch is impractical, and a toy language. Whatever ease of use it has is very quickly surpassed by the need to be productive.
- erikb 12y agoI appreciate your effort to explain in more detail how it actually might be. +1 for that.
- csense 12y ago> Go Requires curly braces and type declarations. These are easy for beginners to screw up. > Ruby Ruby's syntax makes me want to gouge my eyes out -- it's every bit as bad as Perl. I'm an expert and I hate Ruby. I wouldn't dream of exposing beginning CS students to that crap unless I wanted to convince them to change their major. > Scratch This is a toy language in a toy environment. I don't know the language well enough to judge its syntax, but the author's goal is "...rather swiftly bringing [students] to a level of skill where they can use computing in their other courses: to analyze data for those lab reports, to learn linear algebra, to solve problems in particle mechanics, problems involving differential equations, maybe even to write a program to control a robot." Scratch doesn't seem well-suited to this role, but there's enough language and library support for Python to be used in all these roles and many more.
- jeorgun 12y agoI feel like you're placing way too much emphasis on syntax here. From a non-superficial standpoint, you haven't brought up a single thing wrong with Ruby— or Go, aside from explicit typing. The thing about syntax is that, to some extent, it's subjective. You say Ruby syntax is awful? OK. Personally, when I first started programming, I hated Python syntax¹ so much that I called it quits. It wasn't until later, when I started learning Ruby and its "eye-gouging" syntax, that I could get past that hurdle. So I wouldn't exactly describe its syntax as an argument against using Ruby as a teaching instrument. ¹I've since grown to love it, but as a beginner this was very much not the case.
- freyrs3 12y agoYes, it's pretty universal that people find it uncomfortable to force themselves to think in a language they don't fully understand yet. Whether that's Ruby, Haskell, or Japanese. There are plenty of valid things to compare languages on ( semantics, types, runtimes, etc ) but arguments about lexical syntax are really not that interesting since they're usually just throwing opinions back and forth about which lexical construct is more "readable", as if this term had some objective cross-language meaning.
- csense 12y ago
- deleted 12y ago[deleted]
- thu 12y agoPushing for Python by comparing it to Java is a first step. But if you really want to do the right choice for all those students, you'd better compare it to other good languages. For instance I'm thinking of Haskell. Imagine that post being about PHP vs. assembly and thus pushing PHP, or about Java vs assembly and thus pushing Java, or...
- jasode 12y agoIt looks like the author's audience is applied sciences (MATLAB crowd). Therefore, the author's comparison of Python vs Java is more applicable than Python vs Haskell. This may be due to more "batteries included" in Java and Python ecosystems for scientific computing. The author had 30 existing Java programs to look at for bugs. I can't tell if his/her dataset search would have found 30 student-written Haskell programs.
- fearandclothing 12y agoI think the point the author is making is that Python eliminates a lot of overhead in learning fundamental programming concepts. I think it's easier for a beginner to grasp the meaning of something like for i in range(0, 3): than, say, for (int i; i < 3; i++) Haskell is also a great language, but not a great choice for beginners, I think, because it adds a lot of overhead in learning basic programming and CS concepts because of the whole purity thing. I certainly wouldn't try to teach first-year CS students how to implement things like stacks, queues and graphs in Haskell.
- thu 12y agoI don't understand how your "easier for a beginner" example relates to fundamental programming concepts. Are you talking about variable assignments, jumps, control structure, or about syntax ? Again how is "the whole purity thing" an overhead w.r.t. to learning the fundamentals ? If you take your loop example in Python, how does leaking the `i` variable outside the loop's scope (actually there is no such scope) a fundamental that beginners need to grasp ? What would you say about `map f [0..2]` ? So Python makes a lot of things easier than in C or in Java I get it. That in itself is not an argument for teaching it instead of, say, Haskell. If you can choose between A, B, ... Z, sure it is better to use B if it is better than A, but not choosing F because you never use it is a wrong reason (at least if your goal is to teach students).
- zobzu 12y agostarting with python is ok as long as theres a C class following. At various work places ive been to, the vast majority of coders know python or ruby or similar languages. They have NO CLUE how the memory is allocated, why some things in python are slower, etc. At some point they go 'its python runtime overhead'. But most of the time they could make the program much faster just by using better data structures in python. Most of the time they don't understand why something doesnt work the way they want and basically pray to get a premade answer on stackoverflow. While they could figure it out much faster by understanding how their machine works. C has the advantage of being close enough to what the OS does (heck even C isnt always that close with compiler optimizations but - ok). Forces you to understand how the kernel works, how the CPU works, etc. Makes you a better python programmer too.
- pabb 12y agoI started typing a really verbose and roundabout answer that really just amounted to this. I don't even really agree with learning Python first. If you can get over the hurdle that is learning C (or really even just Java), you have the benefit of learning so much more about computing and the fact that types are implicitly being adhered to, memory is being managed beneath the surface, garbage collection, etc. I learned Java for my intro programming course and luckily had an instructor who really emphasized those topics. It made learning C and subsequently assembly much simpler. Had I started in Python, I don't see really learning much more than "wow, I can do some cool things with a computer." I suppose that's okay if the class is advertised as programming for non-CS majors, but to teach Python as an introductory course for CS curriculum seems almost like robbery to me. Jump the initial hurdle of learning the (somewhat) low-level stuff, and then the rest will come easily.
- scott_w 12y agoThat's a reflection of the skill/desire of the programmer and not their initial introductory language. A naturally curious and intelligent person who wants to get better at their craft is going to learn about this stuff. Some people are happy learning enough to get by, and that's ok. Not everyone is destined to learn everything about their machine down to how disk controllers work. Personally, I barely learned enough C to even be dangerous, and it's had no negative effects on my work. I have a reasonably good understanding of how Python works at the abstractions that I need to. If I need to learn more, I go figure it out. In truth, the most useful stuff I learn about writing efficient code comes from reading articles/blogs that give medium-level overviews of how a language implements certain features and how it effects your software. Would knowing C help with that? Not in the slightest.
- ak217 12y agoOne could argue that the defining feature of the Python community and language is the focus on readability and ease of comprehension. This is why Python wins. It has lower cognitive overhead, and the ecosystem is otherwise good enough to build complex projects. Though I do wish Guido went with a variable declaration keyword in the beginning. The global/nonlocal stuff sticks out like a sore thumb.
- glibgil 12y agoIf you want to teach students to deal with inconsistent syntax and slow runtimes then Python is a good choice.
- headcanon 12y agoPython was the first language I learned in college, and I have to agree with the OP's opinion on this. While transitioning to C++ in later courses did involve some pain points, I felt like python was a great way to ease into the programmer mindset and get the basic concepts out of the way before delving into the more low-level stuff like pointers, and later with OOP. Not to mention that Python is becoming the Lingua Franca for academic research due to its powerful mathematics packages, and I was immediately able to start programming for money at a university research lab right after I took the class. The realization that I could learn a skill like this and immediately earn money with it was incredibly powerful for me. While there may be "better" languages in terms of teaching programming concepts, the fact that python is so immediately useful in a large number of disciplines relevant to students (at least in a university) still makes it the best language to start learning with right now IMO.
- pmelendez 12y ago> "I felt like python was a great way to ease into the programmer mindset and get the basic concepts out of the way before delving into the more low-level stuff like pointers" My first programming language in college was Scheme and I could use exactly the same words to describe my experience.
- derengel 12y agoPHP would be even more powerful to you ;)
- solarmist 12y agohttp://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/ http://eev.ee/blog/2012/04/09/php-a-fractal-of-bad-design/
- pmelendez 12y agoNot that I am not agree with the link but Python is not caveats free either. The fact that they have to "fix" the language in one version making it incompatible with previous versions is smelly enough to me from a design point of view.
- wilsonfiifi 12y agoNo doubt Python is a pleasant language to code with (if you don't mind forced indentation of your code). But to be fair this article should compare it to Groovy for instance and probably not Java; doing so would make the push for python a tad more challenging. I took another look at Groovy again recently (haven't played with it since version 1.8) and i'm beginning to feel that i should have invested more time in learning/adopting it back then. The only drawback for me was the resource requirements of Grails (and the JVM) but now that Linode is giving 2gb ram for $20/mth, the attraction to Groovy is getting stronger lol!
- bayesianhorse 12y agoPython and Java are too commonly taught languages, Groovy is not.
- vorg 12y agoGrails adoption share has been falling rapidly lately. It rose on Rails's coattails and it's falling that way too. Other architectures are taking over: vert.x, node.js, Play! Standalone groovy scripting isn't used as much nowadays either. I suspect Oracle's going to push Nashorn Javascript it shipped with Java 8 for your JVM scripting needs. Groovy has been getting lots of new users because of Gradle's increasing popularity, though your typical build file is 20 to 100 lines long. Gradle still ships with Groovy 1.8 anyway so you haven't missed out not keeping up!
- vezzy-fnord 12y agoI don't necessarily disagree with her reasoning, however the rundown she quotes is unimpressive. It basically amounts to "Python is Turing complete and has libraries," minus the point about it being English-like.
- selmnoo 12y agoI think I could have written this article a few months ago, when I was a huge Python fan and would spend a significant amount of time telling my friends in academia to stop using Matlab and start using Python. Then I started working in a research lab myself, and I haven't used Python since. Very simply, there's an immense amount of code written for Matlab that I can learn from in domain-specific instances, hardware vendors provide Matlab example code (and not Python code), and all of my peers use Matlab. When I have a problem they can usually help me solve it, if I'd been using Python I would've been all by myself and likely unable to finish the task. And really, these are the most important things to consider when choosing a language. As it stands, Matlab is the right language to choose, at least for me.
- bayesianhorse 12y agoBig existing codebases always hinder language adoption. But Python is becoming the lingua franca of scientific computing, owing to great open source tool and libraries. Very soon hardware vendors will always provide python example code, python "drivers" or REST-like APIs. I don't say this lightly, and this statement is hardly ever right, but in this specific instance, Python is clearly the better "language" compared to Matlab, even in scientific computing. The syntax and quirks in Python are more consistent than in Matlab and general programming is a lot easier.
- GuiA 12y ago"Research" is a wide area. I personally used Python in HCI research during all my time in grad school, and thoroughly enjoyed it. What field are you in, if I may ask?
- deleted 12y ago[deleted]
- techtalsky 12y agoWell, also consider the point she's making. So you had to switch to matlab, but you were able to, perhaps partially because you already had a grounding in programming in a language you found pleasurable.
- edanm 12y agoPython is easier for students to learn. Learning something new is hard, and Python is easier for students to learn. Really, the ease of learning should trump almost everything else. Especially since Python is actually used in the real world, so it's immediately applicable. You want students to know more concepts they won't get from just Python? I agree with you. Just not as a first language.
- _random_ 12y agoIt's very good for beginners. Just remember to move on later.
- Cakez0r 12y agoIt seems the only argument for pushing Python is that it sidesteps the need to understand fundamental programming concepts. Sure Python is easy to read and easy to write, but that's not really the point. To teach somebody print "hello world" in Python is not really teaching them much at all... Teaching someone the C equivalent would cover functions ("what is 'void main()'?"), entry points and how programs are loaded by the OS ("why do I need void main"), libraries ("what is cout and where did it come from? iostream!", "what else does iostream have?"), operators ("if cout is a function, what is this << thing?"), etc... The verbosity is helpful because it allows the student to ask questions that lead to a more holistic understanding of computer science. If a student with no programming knowledge asked me about how print worked in python, it'd be hard to know where to start explaining!
- possibilistic 12y agoWhy do you have to teach them the boring stuff first? The point is to get them interested in programming. They can learn how the hardware, compilation, linking, and algorithms work later. Above all, get them interested. If you capture their imagination, they'll be receptive to--even independently curious about--the details. I'm speaking anecdotally now, but please do not bore young students. There's no way I would have stuck with it if C was my first language. Javascript and Python are excellent starting points that easily let kids create games and websites and fun things. We probably wouldn't start someone off with Haskell, but to me C seems on the same level of impracticality for a young beginner.
- Cakez0r 12y agoWell if somebody is in higher education for computer science, I'm assuming their imagination has already been captured. I'm all for using whatever has the lowest barrier to entry in order to get young people interested in programming.
- j2kun 12y agoThat's not a very good assumption. A lot of students get their first experience with programming in college.
- MarcScott 12y agoI teach 11 to 18 year olds and I've stopped teaching them Python and started teaching them JavaScript. My main reason for the switch is to overcome the "What's the point of this?" questions that I used to receive. With JavaScript the kids instantly see a result on a platform they're familiar with - a browser. window.alert() is instantly recognisable to them and seems far more relevant than print"" where the output is only visible in a terminal or IDE.
- Cakez0r 12y agoI think that's fine to whet a young adult's appetite, but in higher education, "Why?" should be an ally, not an enemy.
- jtuple 12y agoMy main problem with Javascript is the various truthiness rules as well as the numerous implicit conversions to strings. Eg. > [2,1,3,10,6, 200].sort() [1, 10, 2, 200, 3, 6] is both unexpected, and is just one of many landmines that can completely derail beginners.
- rectangletangle 12y agoJavaScript has numerous caveats and idiosyncrasies that result in strange and unexpected behavior. It's scoping rules are also pretty broken. While Python does have some of its own quirks, they're far fewer in number. There are two that bite people pretty often, using a mutable type as a default function parameter, and accidentally typing a comma after an expression subtly converting it to a tuple.
- Pacabel 12y agoA lot of the problems with JavaScript aren't "caveats and idiosyncrasies" or "quirks". They're rather horrible and unjustifiable flaws, plain and simple.
- rectangletangle 12y ago
- deleted 12y ago[deleted]
- hcarvalhoalves 12y agoThe fact he got so many things wrong trying to make a C++ hello world from memory actually reinforces his point. All these idiosyncrasies are nothing more than friction to a beginner. These only matter if you're trying to teach C++, not programming as a whole.
- revelation 12y agoOr it means he has simply no clue what hes talking about.
- hetid 12y agoWhy do people advocate Python and not a dialect of Lisp for beginners? Are prefix notation and parentheses really that terrible in exchange for a completely unified syntax?
- hcarvalhoalves 12y agoI believe Lisp is a good choice for beginners too, but it's two different approaches. Lisp is interesting for the theory behind it - you can introduce lambda calculus, parsers, AST, stacks while you teach the language, and the student will have a grasp of how the computer understands code. Python is a more hands-on approach - you just teach some syntax that reads like english and the student can put some libraries together and do something meaningful, the barrier is low and you get instant gratification, which is important to keep students motivated.
- bjt 12y agoWhen you show someone a mathematical formula using standard infix notation, and then want them to write a program to implement it, it's immensely helpful if the syntax of the language is close to the mathematical notation. Infix operators are a huge boon to readability for beginning programmers, especially those with some science/math background. This is the subject of some extended discussion in the new PEP proposing a Python infix operator for matrix multiplication. http://legacy.python.org/dev/peps/pep-0465/ http://legacy.python.org/dev/peps/pep-0465/
- rjf1990 12y agoAgree with this article 100%. The reason I discarded programming (and went into Mechanical Engineering)sophomore year of college was because I was frustrated with the syntax issues with C++. Years later, once I learned Python, I started experimenting with other languages and learned to deal with the syntax. Syntax isn't a big deal for people who are used to it, but for people who are deciding whether to be interested in programming or not, syntax can but a huge turn-off.
- wting 12y agoIf I had to overly generalize, programmers tend to fall into the "builder" and "curiosity" camps. I grew up using a Borland C++ compiler that didn't list which line numbers were missing semi-colons. I didn't mind going over my code to find the missing semi-colon, but plenty of my classmates were frustrated. They weren't interested in how compilers worked, how code was parsed and debugging information was lost in the transition. They just wanted to build a game, a web site, something. At college I had a difficult time with Scheme and looked down at it. Where's the manual memory management? The pointers? The for loops? Scheme abstracted away a lot of plumbing and let users focus on algorithms. Nowadays I think Python is the ideal first language followed by C and Haskell. It's starting in the middle, and then moving towards opposite ends of the programming spectrum: systems and functional programming. Some make the argument that CS students should be dedicated enough to plow through an introductory course taught in Java / C++. I think that's an elitist attitude. CS is not growing in popularity despite increased demand[0], and new students should be welcomed instead of facing artificial filtering measures like "dedication". At the same time, this is not a proposal to water down the major--just a plea to ease students in instead of kicking them off a cliff and hoping they can fly. Edit: Another front page article (https://news.ycombinator.com/item?id=7760790 https://news.ycombinator.com/item?id=7760790) discusses this issue: > One might also argue that these tools are simple enough once you learn to use them. I would only point out that, emperically, that bar is too high. Despite the clear benefits, the vast majority of the world was chosen to remain illiterate. Even tools for which there is a clear need (eg version control) have largely failed to make a dent. Clearly there is a need for a less hostile programming environment. [0] http://www.itworld.com/big-data/418701/american-college-students-aren-t-flocking-computer-science http://www.itworld.com/big-data/418701/american-college-stud...
- cpeterso 12y ago> Nowadays I think Python is the ideal first language followed by C and Haskell. It's starting in the middle, and then moving towards opposite ends of the programming spectrum: systems and functional programming. I agree. My friend studied CS at UC Berkeley where (at the time?) first semester was Scheme, second semester was assembly language, and then subsequent classwork was usually C++ or Java.
- 12y ago
- increment_i 12y agoIsn't python basically the defacto OO language in undergrad CS courses today? Every CS student I've ever met did their intro courses using python. Later years would delve into C and MATLAB.
- Orangeair 12y agoI agree, with reservations. Python is great for introducing people to programming; however, it is not necessarily great for teaching computer science concepts. My 200 level data structures and algorithms class was taught in Python, and it just felt awkward. For example, we constructed an "array" by basically creating an abstraction on top of a list, which did nothing but remove features and introduce overhead. It kind of felt like teaching someone how to make a bike by taking all four wheels off of a car and only putting two back.