14 ms·
Advice on learning Python efficiently
- hardwaresofton 10y agoPretty good advice, along with some good pointers about what NOT to do when learning a languages (ex. reading some instructional book cover-to-cover, forgetting most of the stuff along the way). I often suggest the read-a-chapter-write-a-program-based-on-it route, just to get the practice that is really important, and to solidify some intuition as to what the machine (whether interpreter or bare metal) is doing, and to make writing future programs easier. Side note: While I definitely applaud the idea of trying to create a language that is geared towards beginners and good for learning on, I don't know if I can get behind recommending such a language that is still under development being suggested to beginners. Then again, I'd consider recommending lisps to beginners (if not python), so maybe I'm not the most credible source
- mirekrusin 10y agoI read c# spec when it was in beta, going fast through it, skimming less informative parts, taking quick notes as bullet points in form of single statement or question. It was one of the best experiences, it put me in flow mode and I learned a lot in very short time. I used c# later professionally and never had problems. Great thing about language specs is that is very precise, without mistakes. The art is to read+skim+note it quite fast.
- majewsky 10y ago> Great thing about language specs is that is very precise, without mistakes. I'd also add "concise" to the list of required traits for a good language spec. If you don't believe me that's important, go check out the C++ specification. IIRC it contains some 50 pages of rules on how to choose implementations of an overloaded function.
- joatmon-snoo 10y agoAnd if you're looking at modern C++, you also get to learn about lvalues, glvalues, xvalues, rvalues, and prvalues!
- webmaven 10y agoprvalues are the ones that return a promise about a system's future state which are commonly expected to prove false, right?
- hardwaresofton 10y agoWas this not a direct (possibly knee-jerk) reaction to the ease with which you could shoot yourself in the foot, and undefined behavior C allows?
- trymas 10y ago> Side note: While I definitely applaud the idea of trying to create a language that is geared towards beginners and good for learning on, I don't know if I can get behind recommending such a language that is still under development being suggested to beginners. I second this. Especially when python itself is very beginner friendly. IMHO the best advice on learning a skill is just do some projects with it. I am not exactly sure, which should come first, the 1. or the 2. point made in the article. Though I would dare to say the 2. point is more important. By doing python projects first you familiarize with it and then if you are still on - you should read zen of python, pep8, etc..
- jacobr1 10y agoAgreed - you need to experiential context to grok the concepts about best practices. Otherwise, it is just cargo-cultism. Most the great programmers I know learn by working on increasingly more complex projects and then deep-diving into the details whenever they come across something they don't know. They make this process move faster, not by doing tutorials and writing code from scratch (after the initial bootstrapping of learning a new language/framework), but by reading code from others, especially successful project. And again diving into to understand the WHY behind the implementation and this reinforce the choice and knowledge of the HOW.
- eric_bullington 10y agoI strongly agree. Dealing with a language in development is hard enough when you're an experienced programmer, I can't imagine trying to learn programming with an unstable language.
- dwaynecrooks 10y agoI tend to agree as well. The Pyret option is probably better done with a mentor by your side. If no mentor is available like they probably have in the Bootstrap (http://www.bootstrapworld.org/ http://www.bootstrapworld.org/) program then Python is more than likely the better option. So I'd expect 99% of the people to stick with Python anyway which is fine.
- 10y ago
- voltagex_ 10y ago>I often suggest the read-a-chapter-write-a-program-based-on-it route After doing some of https://javascript30.com/ https://javascript30.com/ I want the "30 day challenges" style tutorials in every language - I love it. I'm not sure how well it works for long term learning but it's really helped with my motivation.
- DigitalJack 10y agoI get so frustrated with picking up a new language because they all seem to either be "from scratch, here is how to add two numbers" or cookbooks that assume too much knowledge. the learnxinyminutes stuff is sometimes good. It'd be nice if there was a resource that taught languages from the perspective of already knowing another (any) language in that same family. Show me definitions, modules, packages, namespacing, whatever, and get out of my way.
- hardwaresofton 10y agoI agree with your gripes here -- absolutely agree there are a lot of languages that get it wrong. I think there are some books that really get it right though, that show you how to do stuff, but also try to get out of your way. Some examples (in order of adherence to this point, to the best of my ability): - Practical Common Lisp - Learn You a Haskell For Great Good - Clojure For The Brave and True
- drivers99 10y ago> I often suggest the read-a-chapter-write-a-program-based-on-it route Learning Perl (the llama book) was great for that. At first, I would think that I understood just from reading the chapter, but doing the exercises at the end of each chapter made me actually learn it.
- hardwaresofton 10y agoAbsolutely agree! In a previous life, I was working at a company where perl was just about the most recent scripting language they were using (for better or for worse), and that book was an absolute godsend. Reading through Chapter 8 around was all I needed to be productive, and I've recommended the book ever since (especially while I was at that job)
- sn9 10y agoAllen Downey's Think Python is that book for Python, though focused more on teaching good programming habits than scripting.
- hyperpallium 10y agoSmalltalk was developed that way... Also, MIT switched from scheme to python. \tangent I agree with your approach of mixing theory and practice. So what's the best way to learn fluid simulation? It's discouraging spending so long on maths without the gratification of Something Actually Working.
- faitswulff 10y ago> Since Python isn't your first language I didn't realize this wasn't for beginners until I got to this section and read that his first application was a whitespace interpreter. Personally, coming from Ruby, I learned Python via https://learnxinyminutes.com/docs/python/ https://learnxinyminutes.com/docs/python/ after stumbling a bit on the Python 3 import syntax, which I came to love.
- geezerjay 10y agoCan someone fix the misleading title? Stating "Learn python efficiently" is one thing, but stating "My advice on learning Python efficiently" is another entirely different thing. One is a statement of fact, another is just yet another opinion. Accepting clickbait articles degrades the quality of a news aggregator.
- dwaynecrooks 10y agoThat's true, sorry about that. Thanks to whoever fixed it.
- ManlyBread 10y ago>It's called Pyret. How about just learning Python instead of learning a toy language and then having to learn Python anyway?
- deleted 10y ago[deleted]
- volkk 10y agoyeah i don't think i fully understand. my first language that got me introduced to programming was python and it taught me all the basics of OOP that were important to really get me going. it's a great language with little magic. after, i moved on to java and eventually functional languages.
- natec425 10y agoI do think Python is an acceptable language for beginners, but I wouldn't say it has little magic. It may feel intuitive at times, but Python's magic methods can be somewhat disorienting for students. This usually hits when students reach for-loops (and to some extent during branching due to __bool__). Also, Python may feel like a small language at times, but it is really quite large and complex. This can be seem by imagining a beginners perspective when Googling for help with a simple list operation. The inevitable Stack Overflow answer will almost certainly use a comprehension. I would argue that Pyret is actually fundamentally less complex than than Python. As always, the biggest issues are your goals, constraints, and resources. If you can afford to spend time in a language optimized for education, that is fantastic. If you can't afford that time, python starts to look like a good trade off relative to the languages with reasonable job prospects. * It doesn't make me an expert, but I do teach programming for a living. We use happily use python for introductory content and server-side web content, but I can easily see Pyret as a great option for an educational offering with different constraints than mine.
- volkk 10y agofair argument. this was in college, so i had a lot of resources available and very particularly picked curricula so i didn't bump into any of the magic methods until i graduated college and used python in production.
- Walkman 10y agoPyret's syntax looks far more complicated to learn than Python's for a beginner.
- jpolitz 10y agoI'm curious which parts look (more) complicated to you. For some perspective, when teaching Pyret to total beginners, we start with arithmetic and calls to library functions, then build up to function definitions and examples. At that point, there's just a handful of syntactic constructs to consider, and they are nearly identical to Python. Things like "data" and "cases" don't come till later, and do come with more overhead, but also are introduced to students who already have some "finger-feel" with the language. Python has its own overhead with "class" for defining structured data at a similar point, including things like "self" and "__init__".
- tim333 10y agoI noted the in first example in the linked into - Python: def square(n): return n * n Pyret: fun square(n :: Number) -> Number: n * n end there's extra stuff. It also kind of loses the elegance of Python reading close to normal language - if you don't know programing but can do math you'd figure the first was define a function that gives a square but be confused what (n :: Number) -> Number: was about.
- jpolitz 10y agoThe type annotations are optional, so fun square(n): n * n end is a closer direct comparison to the Python program, for contexts that don't use annotations.
- happy-go-lucky 10y agoLooks like another clickbait. Learning a language and creating a new one are not the same.
- peatmoss 10y agoWhere did you get that from? I feel like we read different articles. Are you referring to the introduction where he suggests that people entirely new to programming should check out Pyret?
- happy-go-lucky 10y agoThen he should have Pyret in the title here.
- dwaynecrooks 10y agoThis article is 100% about a way to learn Python efficiently.
- happy-go-lucky 10y agoI'm being a little wary :)
- happy-go-lucky 10y agoAccording to the article, learning Pyret is an efficient way to learn Python. It's a misleading title.
- dwaynecrooks 10y agoHuh? Where in the article did I say or imply that learning Pyret is an efficient way to learn Python? I said if you're a complete beginner then you can consider Pyret. As for people who already know some programming I didn't suggest Pyret to them at all.
- eric_bullington 10y agoFor many years, I worked on the periphery of the programming world, but with a very superficial level of programming knowledge. I was a "webmaster" back in the mid 90s, working with simple PHP, JavaScript and VB scripts. I then went to grad school for public health and afterwards worked in several biostat-oriented research analyst roles focusing on Stata and SPSS programs. All these jobs definitely involved a very basic understanding of programming, but I had no understanding of many important fundamental programming concepts, and had created very few programs bigger than a 1-page script. It was only when I started to learn Python, and then C (to write Python extensions), that everything really clicked. Something about Python made it so much easier than PHP or JavaScript for me. I think Python's relative lack of glyphs, brackets, and other "syntactic noise" (my opinion only) made it much easier for me personally to grasp big picture ideas. Python also prepared me for learning C to a pretty good level (with much help from the K&R book). These two, in turn, gave me a good foundation for branching out into other languages, eventually including functional programming languages. But Python was with no doubt the turning point for me, and even though I do little Python work these days (ironically, I'm back to JS but at a much higher level than in the 90s), I'll always be grateful for Python. If you've struggled with programming and haven't given Python a shot, give it a try! If that doesn't work, maybe try Pyret like this post advises (once it's stable), or maybe some lisp such as Clojure. I also know some mathematicians who struggled initially with imperative programming but then thrived with Haskell. Point is, we think in different ways, so keep trying different approaches until something sticks.
- dwaynecrooks 10y ago> Point is, we think in different ways, so keep trying different approaches until something sticks. So true, great advice. You have to experiment and find out what works for yourself.
- jMyles 10y agoTeaching and learning are spaces where many flowers can bloom, so I can appreciate the angle of this article (and thus Pyret). To zoom in for a second: in my experience teaching, the simplicity of the outdent as a mechanism for ending a control structure is a light-bulb moment for many people. I don't think that adding "end" is helpful for this segment of the population. And so it is with `where`, which seems to shoehorn a BDD / Rspec'ish approach which, while typical of some of the best Ruby out there, is not typical of a Python library. Again, this approach may be great for some people, but I'll bet that it won't be great for others.
- metaphorm 10y agoPyret looks nice, but I think it's misleading to say it's "Python inspired". At first glance it looks more like its cribbing ideas and syntax from Ruby and OCaml.
- jpolitz 10y agoIt's true, Pyret gets ideas from a handful of places, not just Python. From a student or instructor's point of view, it is serving a lot of the same ends as some of Python's choices: Toplevel code runs as a script without ceremony, the default behavior doesn't statically check types but is conservative about coercing types and overloading operators (e.g. "a" + 5 is an error), integers promote to bignums by default (though Pyret supports exact rational bignums as well). Pyret supports docstrings explicitly, and examples/check blocks have similarities to Python's doctest. Fields of ADT instances can be accessed simply with "." (in contrast to OCaml or other functional languages), and methods close over self on dot-access as they do in Python. Some of these things are also true of Ruby, so that's a fair comparison as well. And things like "data", and the gradual type-checking facilities, are clearly coming from other sources (though Python is moving in a gradually-typed direction as well). I know we were thinking about Python in particular when we made a lot these decisions, so I think it's a fair characterization, though Python is one of several inspirations.
- Gusbenz 10y agoI've definitely purchased some programming books with a rabid ardor only to set it down 40 or so pages later only to open another book purchased with the same rabidity.
- dimino 10y agoBe pythonic, be pythonic, be pythonic! My biggest complaint about python is how easy it is to learn (heh). It takes so little effort to write a script, so it feels deceptively easy to write great python. After all, as long as it works, who cares right? I care. Your colleagues care. Your users care. Python is an object oriented language, use it as such.
- xamuel 10y ago>My biggest complaint about python is how easy it is to learn This X 1000. Some Python candidates declare themselves professionals when their code is unsuitable for production. If you're gonna spend many thousands of hours using a language, don't use initial learn-time as the one thing to optimize for!
- dwaynecrooks 10y ago> If you're gonna spend many thousands of hours using a language, don't use initial learn-time as the one thing to optimize for! That reminds me of this wonderful talk by Rich Hickey called Simple Made Easy, https://www.infoq.com/presentations/Simple-Made-Easy https://www.infoq.com/presentations/Simple-Made-Easy.
- happy-go-lucky 10y agoIs there an easier language than Python? This is not to belittle this effort.
- pbreit 10y agoIntro to python and get a web service built in an afternoon or so: http://www.web2py.com/books/default/chapter/29/02/the-python-language http://www.web2py.com/books/default/chapter/29/02/the-python...
- agumonkey 10y agoI may suggest Julien Danjou python's book. Only skimmed through it, but it felt funnier and more in depth (covers AST for instance).
- tomquin 10y agoAs a 'code tourist' i find focusing on what i need for a specific project the best way to learn new languages.
- Groxx 10y agoHmmm.... I'll disagree on the "don't read a book" suggestion. I've hung around on a number of support chat rooms for languages / libraries for a few years, and tons of the problems we hear about are things that nearly any book would've made plain. As further evidence, 99% of Stack Overflow is filled with this stuff. In my experience, skipping the dry stuff to get started faster tends to lead to poor mastery of a system. You can absolutely waste time on the dry stuff - don't read a 1000 page book when 100 will do (or ever; huge books are usually awful) - but the details very often matter in the long run when you start doing anything not in a cookbook / tutorial. Yes, you can always go back and read it later, but very few do so. Investing a day or two in a detailed book up-front isn't that much time.
- sytelus 10y agoThis is great post and the observation is quite applicable in pretty much every subject that you want to learn and master, not just Python. In fact, "learning to learn" is perhaps the most important skill we develop as humans and a small improvement in this area translates to order of magnitude improvement in actual learning. In PhD programs they say that getting PhD is not actually about mastering specific subject but rather developing an ability to comb through vast amount of knowledge, assimilate it and synthesize new knowledge. The first two steps is where much of the effort lies which is "learning to learn". The first mistake that most people make in first step is trying to understand everything cover-to-cover of each paper before moving on to next. An experienced person would first try to get big picture (just look at the abstract and results :)) and move on to next one. So you do breadth-first-search followed by some selective depth-first-search and continue back and forth until you build "surface" that represents the usable approximation of state of the vast amount of knowledge. This is many order of magnitude efficient than try to build most of the "surface" from the get go.
- poletopole 10y agoNot sure if this will help anyone out there, but learn how to take notes efficiently first. Learning a markup language helps a lot. Be very selective when choosing a book; don't hesitate to throw away a crappy book. Avoid books geared towards getting you "up and running" despite their reviews, they're never worth it. The more sources the better. The only subjects I don't spend time on are non-core API methods; just take note that there is an API and where it is, but referring to the official documentation is better because there's never much you can add of value. Ultimately plan on spending 6-9 months of weekends or 2-3 solid months to learn the bulk of a new language if you're taking notes. If it's your first programming language picking a simple project to do is helpful because otherwise you won't know the "why".