9 ms·
Learning Python Without Library Overload
- the_duke 9y agoWhile I understand the argument, I also have a big counter-point to offer. Python is one of the top beginner languages for people new to programming, and rightfully so. But beginners often want to build something "cool" and tangible, and need that to stay engaged. Printing out the first 100 prime numbers after implementing a sieve of eratosthenes or a command line calculator do not fall into this category for most. Building a website or a GUI application is way more exciting, and you need libraries for those.
- gr3yh47 9y agotheres an irc with 2000 python devs ready for instant feedback. it's like a live chat stackoverflow for python or better. given the python community imo there's no reasons for beginners to shy from libraries. ESPECIALLY python libraries and frameworks, e.g. django is magic and can easily be learned/used by a dev who only has basic python knowledge
- reificator 9y agoMagic impedes learning. Magic is great when you know enough to be able to peek behind the curtain when you need to. But abstractions leak, and magic abstractions more than most.
- mercer 9y agoI think leaky abstractions are not really something to worry about when you're learning. Maintaining interest while learning, especially at first when everything is strange and new, strikes me as a much bigger problem. Magic addresses that.
- reificator 9y agoSure, but when you encounter a leaky abstraction someone has to pull back the curtain for you and help you get past it. Magic inevitably has brick walls behind the curtains.
- icebraining 9y agoIsn't Python itself, like most high level languages, a large collection of abstractions, some quite magic?
- reificator 9y agoAbsolutely it is. I'm a believer that learning programming with a high level interpreted language with a weak type system is a disadvantage in the long run. That doesn't mesh with people who want to do something valuable out the gate, which is fair enough. But I've seen so many people start with the "easier" path and run into a brick wall they can't surmount later and just give up. It makes me sad to watch every time. EDIT: Substituted "learning a high level" with "learning programming with a high level"
- icebraining 9y agoI wonder if the transition is the problem, or if some people just have difficulty with the low level stuff, regardless of previous experience. I can't say I have data, but from my college colleagues, I don't remember the people having trouble with, say, pointers being mostly the ones who already programmed in Python or JavaScript.
- reificator 9y agoThat's a good point, and it might indeed be a self-selection kind of thing. I'm not an expert and I don't have the data there. But I don't even mean making a transition, you can do nothing but Python or JS and still hit the wall. Because eventually you'll need to understand the lower level concepts to do better, even with higher level languages and libraries. It's the reason that learning to program, and program well, is not 100x faster than it was 50 years ago, despite all the claimed benefits of this or that language or framework or whatever. Eventually you need to know what's going on under the hood. Also worth noting that I primarily use JS in my day to day work, and it does what I need it to do. Not saying super high level languages aren't useful, just that they're not a good starting point IMO.
- BrandoElFollito 9y agoCould you expand on how /where to join this irc?
- grzm 9y agoLikely #python on FreeNode: https://www.python.org/community/irc/ https://www.python.org/community/irc/
- giancarlostoro 9y agoI never was huge on Python but always preferred it to Ruby. One web framework that always fascinated me was CherryPy[0]. On my first (and current) real programming job I was asked to work on a RESTful type of project, and was given free reign to research a language and stack. I initially was asked if I liked Python, once I spotted interest towards Python I suggested CherryPy. I stuck with CherryPy and 4 months later, my RESTful service had a front-end using the Mako[1] templating library alongside it's RESTful back-end. All the code is done in an Object Oriented fashion. I can't imagine doing the same work without any external libraries. [0]: http://cherrypy.org/ http://cherrypy.org/ [1]: http://www.makotemplates.org/ http://www.makotemplates.org/ Note: Mako is used by Reddit for their template library. https://github.com/reddit/reddit/blob/master/r2/setup.py#L62 https://github.com/reddit/reddit/blob/master/r2/setup.py#L62
- sprt 9y agoHow does CherryPy compare to Flask in your experience?
- giancarlostoro 9y agoI can't say too much about Flask since I have not used it as much as I have CherryPy. I would like to try out Flask at least once for a big project for comparison but don't have the time to do so yet.
- anc84 9y agoI really like the CSV statistics example project in the post. That IS a cool tool if you are learning in a science or data processing context.
- nlawalker 9y agoAs I read this, I originally disagreed with the author - for me the challenge of a new language is not the language itself but becoming familiar with the libraries that everyone uses and understanding how to get things done with them - but then I saw this: >> packages that alter its syntax and behavior Is this kind of thing common with Python? I'm used to C#, where libraries are just libraries. Sure, you still have to learn your way around them, but they don't change the language out from under you. Even in big frameworks that completely dictate the overarching organization of your code, it's still C# you're writing.
- SwellJoe 9y agoNo, it's not super common, IMHO. Python doesn't really even lend itself to altering syntax in significant ways (though some of the libraries he mentioned have low-level C implementations that can/do alter Python syntax). If you're doing scientific computing you're going to see some new things that don't entirely look like Python. Things like matrix math and the like have new types and (mildly new) syntax. But, I don't think it's surprising for people who know Python. I guess there may be some cognitive dissonance that comes from using projects that paper over Fortran and C++ libraries with light Python wrappers (a lot of scientific computing libraries, again...so, not often new syntax, but not very Pythonic, either). The specific example mentioned of matplotlib (and SciPy and Numeric, etc.), probably comes from the origins of the library...it was intended to make it easy for people coming from Matlab to switch to Python for the same sorts of tasks, so it's conceptually a mashup of the two. But, maybe the argument should just be "walk before you run", rather than singling out any particular library. Particularly if those libraries might be the sole reason the person is learning Python. Sounds like the person he was helping out with her matplotlib problem really wanted to be working with matplotlib and the scientific computing ecosystem Python offers. You've gotta learn them eventually if that's the kind of work you want to do with Python. They might be a little weird, but they're not a whole new language.
- paultopia 9y agoDefinitely in the data science stack though. For example: how pandas behaves with slicing, and copy vs view semantics are totally different from vanilla python, and are confusing enough coming from vanilla python. God help you if you learn pandas and python at the same time.
- maweki 9y agoThe author suggests that while learning python one should stick to using the standard library instead of using additional libraries that sometimes come with archaic baggage or domain specific constructs that hinder learning. I think the author could have done with calling the standard library by name instead of just calling out specific packages. And of course missing are functools and itertools and collections which I find essential in writing concise and pythonic code. Instead they single out json and csv which are special purpose
- u801e 9y agoI'm not sure if it was just me, but the contrast of the article text was so low that it was pretty difficult to read.
- happy-go-lucky 9y agoI found it difficult to read, too. It strained my eyes :)
- vram22 9y agoThis has become a tendency in many web sites from some time now. I dislike it too, it's a pain in the ass. I sometimes have to select some text with the mouse so that it goes into reverse video so that I can read it easier. (Downvoted HN comments are a good example, but in the case of HN, low contrast is not the norm, except for comment headers.) Not sure what's the exact reason for this trend. Some ideas: - someone started it off, maybe a so-called high-profile designer, and others blindly copied it. [1] Designer doesn't necessarily mean an individual one. It could be for example Twitter Bootstrap that was copied, since I know that a lot of web sites use it. [1] Blind copying (without regard to appropriateness) is a common trend in some people since probably the start of mankind. Not sure much can done about it. People have to learn for themselves that they need to think for themselves. - the monitors of the people creating these low-contrast sites may be very high resolution and/or high brightness, so the low-contrast still is readable to them. - could be it is an example of what I call (just made up the term) the C++ syndrome, where newbie C++ developers use C++ language features liberally and where not required, or where they may not make sense, just because they can do it, or sometimes just to get to apply it and learn about it (which should not be allowed by any good project managers in production software, just tell them to play in a sandbox they create). Though I called it the C++ syndrome, it is equally visible in other languages and stacks.
- vram22 9y agoIn fact I now have started dumping such sites as much as possible - unless they are essential, I stop visiting them.
- chris_conlan 9y ago
- systems 9y agoone of the better advice i read on this topic is to focus on creating something (in this case) using python, rather on learning python, and then find something to do with what you learned another personal point for me, was the focus of learning on the logical modeling for a programming and treating the physical modeling as an after thought most book and tutorial focus on creating functions, classes and module (programming in the small), but spend a lot less time teaching how to group those in file and how to compile, package, distribute and deploy the program (programming in the large) for those reasons i have to disagree with this article, since it seems to promote learning by focusing on programming in the small
- nether 9y agoAll of the modules he suggests avoiding are the ones that make up the standard data science tech stack. So, IOW, learn Python before doing data science. Your usual beginner Python tuts don't mention Pandas or matplotlib, so this seems like a non-issue.
- Nvorzula 9y agoHe points to a graduate student who had to pick up Python for some task and wanted to learn both the language and the tools necessary for that task. I can throw another anecdote into the ring and mention a web data mining course I'm taking right now where a lot of students are having to pick up Python along side both scikit-learn and scrapy.
- ameliaquining 9y agoI notice that the article says not to use urllib, but doesn't say what to use instead if you need an HTTP client. The correct answer, of course, is requests...which isn't in the standard library. So there's a tradeoff between a good API that you have to figure out how to install, and a lousy API that's universally available. (This tradeoff isn't as bad as it once was—the Python package management experience has improved a whole lot over the past decade—but getting packages installed is still a barrier for new users, especially on Windows.) It's not just a matter of saying "use the stdlib"; the stdlib is imperfect and its flaws are not limited to the concerns of power users. Also, it's worth separating the issue "this library has an overcomplicated API surface" from the issue "this library uses Python magic in ways that make its semantics different from the default expectations for a Python API". For instance, there's nothing remotely magical about urllib; it's just unwieldy to use. Most of the other listed packages, like pandas, have the opposite problem.
- bsmithers 9y agoI see quite a few people disagreeing with the author but I think there's a key difference between: a.) Learning python when you are also a beginner to programming b.) Learning python when you're comfortable in another language If, like the student in the story, you are in category a.) then I think the author is definitely right. The distractions of myriad libraries isn't helpful. However, for category b.) it depends a lot more. I think there is value in understanding the core of a language but - depending on experience, familiarity with similar languages, end goal etc - I think we're talking between a few hours and a first sketch at a project before you're hindering yourself by ignoring the rest of the ecosystem.
- lucideer 9y agoA lot of people here are disagreeing on the basis that new language learners want to make something cool quickly. I agree, I've certainly taken the path of trying to teach fundamentals to people who very quickly lose interest. However, while absolute beginners do need a hook, there's a transition phase that isn't filled: it comes between being able to copy paste SO answers together effectively enough to build a functional product, and actually understanding how that application works. Coming from a JS background, I'd say a close equivalent in the past was frontend devs (gainfully employed as such) who didn't know any javascript; they just knew jQuery. I'm not sure how that's changed today, but I'm guessing the node package ecosystem breeds similar results. I'm no beginner when it comes to programming, but my exposure to Python has been relatively limited up until recently, and as I'm now quite suddenly running some django installs, and trying to work backwards from learning django initially to properly grokking actual python, these are the kind of dedicated resources I can see being of value.
- reacweb 9y agoI wanted to learn python by myself, a few years ago, it was not easy (difficult to justify to use it at work when you know perl enough to do the job in 1/10th of the time). To keep motivation, I have followed https://www.coursera.org/learn/interactive-python-1 https://www.coursera.org/learn/interactive-python-1. IMHO, it is very good for beginners. It avoids the library problem and allows to have funny results.
- _pmf_ 9y agoPython is one of the languages that are heavily used by people who do not want to do software development, but want to get stuff done. It's patronizing intellectual pedantry to tell those people to actually learn programming when they can just use the few numpy commands required for their immediate work. Sure, give a man a fish etc.; but sometimes, people just want the fish already and don't want to mine the ore required for building a fishing rod from scratch.
- BerislavLopac 9y agoIMO, the Empire of Code is one of the best, and definitely the most fun, way to learn Python: https://empireofcode.com/ https://empireofcode.com/
- iammyIP 9y agoPython itself is already too much abstraction. Everyone interested in programming should learn the basics all the other stuff is built out of: Hardware, binary, assembly, C That doesn't mean to get full on embedded hacking, it means to get some basic grasp of how C maps to the hardware. Then it doesn't matter how to continue learning, everyone individually has to find out what kind of further abstraction suits best. Too much programming is taught from the top abstraction layer just to make awful soft more quickly.
- TeMPOraL 9y agoI agree about starting from the basics[0], because programming - as a practical art, not theoretical mathematics - is just about making computers do things. Commanding computers to do things is straightforward - everything else in programming is just managing complexity, which is, in my opinion, best taught as solutions to problems you encounter when simpler methods start to get out of hand. -- [0] - With a proper, simplified dose of hardware, basic amount of binary, maybe some assembly. Not sure about C itself, but something on that level is the right basic abstraction.
- oliwarner 9y agoI disagree. Teaching works best when your pupils can see what they're making quickly. The more interactive and iterative a process can be, the less bored they get. Many tools call this gamification but you really don't have to attribute scores to things for people to enjoy a chunked process more. But with C, a complete novice spends most of their time getting beaten up by boilerplate (how do I build and run and debug this?) and syntax issues. You missed off a semicolon. You didn't declare this in the right place. You haven't allocated memory for that. All important things for C developers but to a novice it's all just jibberish error messages and take a long time to find and fix. By comparison, abstracted languages give you a decent REPL environment which can be ideal for teaching programming basics. Every layer of abstraction you remove is another layer the novice has to handle. If you just want to get a foot in the door, and keep things fun, why bother with that? They can learn about that stuff tomorrow. (I'm not saying this stuff isn't important to know, just consider the order that you teach it in.)
- SeanDav 9y agoI like the list of potential projects to attempt, in order to learn a language. I would add a Battleships program to that list as I find that provides an interesting challenge to learn to program without being too complex in terms of data structures/algorithms.
- ManlyBread 9y agoThe color of the text in this article makes it really hard to read, light gray on a white background is not a great idea.
- cwyers 9y ago> I was once tutoring a Master’s candidate at the University of Virginia how to use Python. She was interested in learning Python to interface with the OpenCV API via the cv2 module. I had recommended her many educational resources from complete beginner texts to advanced OpenCV texts. > After a week of self-teaching, she had not made much progress in learning Python, mainly because she was trying to debug a specific script she found online. The script would read images via OpenCV’s cv2, then use matplotlib to display the images. The script used a strange matplotlib function I had never seen before for displaying the images. So, when she came to me with the error, I had no idea how to fix it. But… I did know how to accomplish the same thing with purely cv2. > All the while, she had learned nothing about Python itself, because she was busy trying to debug a matplotlib function. Obviously, her time would have been much better spent reading the first few chapters of an introductory Python book. I wouldn’t say that this student was unmotivated, rather that she was working a little too hard to fix an archaic and unnecessary matplotlib function. TL;DR: Instead of me learning enough about this one matplotlib function to help her, she should learn enough Python to write her own graphing library to use with OpenCV. I'm surprised he was onboard with her using OpenCV. This is also probably the worst advice I've ever seen offered on Hacker News. Good lord.
- module0000 9y agoLearning python without 3rd party libraries is great if you aren't already a programmer. The author's view is likely to change after he works professionally as a programmer for a period of time. It's good advice for non-programmers just starting out though.
- cwyers 9y agoNo it's not. It is so much easier to do his CSV example with Pandas than with the standard library components he mentions. There are many, many settings where doing so with Pandas are how the experienced people are doing it. If you are a non-programmer trying to learn enough Python to do your non-programming job, learning how to do it the easy way that everyone that's your peer is using is a better answer than doing it this harder way.
- BrandoElFollito 9y agoLearning Python via time and datetime is a sure way to hate the language. I am an average amateur programmer and used Python almost daily for a few years. Just today I needed to convert an epoch timestamp to its ISO counterpart. I tried without using arrow. After 3 min reading the convoluted doc for datetime I failed. arrow.get(timestamp).isoformat() fixed that in a few seconds. Yes I am weak. Yes, I should learn the library. But I do not want to suffer when there is a great lib helping me. Same goes for requests and a few others.
- rhlala 9y agoBy not using libraries you will write it yourself, if you are learning your code will be worst than the library.. . And it will take you a lot more times than learn how the library works. As advice, if you want to do something, always check if someone have done it before. (i think most of hn readers have this habit.. ) If you find big active project like opencv or numpy with good doc and a lot of stackoverflow threads go with it. Thats not python, but it is better than python. If it is less famous or active look the code.