Live data from Hacker News

Advice on learning Python efficiently

simplydjango.com

51–60 of 75 posts

Re: Advice on learning Python efficiently

#51
post #11

Pyret's syntax looks far more complicated to learn than Python's for a beginner.

I'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__".

Re: Advice on learning Python efficiently

#52

Earlier quoted context omitted.

Pyret came out of the PLTgroup, the group of educators responsible for the Racket ecosystem and before that MzScheme. They have been studying and innovating on programming pedagogy for more than two decades. What sets the PLTgroup apart, in my mind, is that it tends to row in the same direction at the low level. This has allowed it to create a robust platform upon which tools (particularly in the form of languages) c…

What do you mean by the offside rule in this case? I presume you don't mean that Pyret can't shoot if it got the ball when it was behind all the other language's defenders.

Only if the Pyret was already in an offside position when the ball was last played by a team mate and it was not a goal kick, throw-in, or corner kick and Pyret was involved in active play (receiving the ball, interfering with a defender, or obstructing the goalkeeper's view)...but I digress.

Python's use of semantic white space in the form of indentation is sometimes referred to as the 'offside rule'.

Re: Advice on learning Python efficiently

#54

Pyret 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.

It'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.

Re: Advice on learning Python efficiently

#55
post #47
post #37

Be 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.

>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!

> 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.

Re: Advice on learning Python efficiently

#56
post #19

Earlier quoted context omitted.

yeah 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.

I 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…

I have to agree with you, Python does really have lots of magic things, such the for loop, list comprehensions and generators, to name a few.

I also teach programming for a living, and, for instance, I usually have a hard time explaining to students what a for loop over a range() means for having a index. The problem is that there are a lot of things going on behind a for-each (which is what the for loop on Python does) and it is hard to explain that to newcomers. On the other hand, for loops in languages like C are simpler to explain to newcomers, as there isn't much hidden from you, and you don't have many alternatives for iterating on an array.

I would say that the higher-level benefits of Python are best understood when you have some experience with lower-level languages such as C/C++ or Java. For students, if they have time, I would say that they would benefit pedagogically by learning a simpler language with less functionalities. If not, I would say learn Python, but expect to not understand everything at first.

Re: Advice on learning Python efficiently

#58

Pretty 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…

I 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.

Re: Advice on learning Python efficiently

#59
post #32
post #29

Earlier quoted context omitted.

Python has gotten hard to learn. It's not too bad if learning it just to learn, or learning it in a classroom setting with a careful plan, but I've witnessed people trying to learn it professionally in the context of getting testing running, and it's hard to learn when trying to use a mature Python codebase that uses Python thoroughly. There's these decorators, and iterators vs. functions, and things using introspect…

>Python used to be easy to learn. It isn't anymore. Compared to C++, C# and Java, Python is still MUCH easier to learn. Python and Ruby are the easier languages to learn. I have to agree with the other commenter, why learn a toy language only to later have to learn a real one? That is a waste of time.

Well, shouldn't it be about learning how to program. Not necessarily learning Python or Ruby? You will learn how to program with languages like Python, Ruby, Java, etc. but you will have to work with constructs/abstractions that might make sense in a professional setting but not so much in an academic setting.

Re: Advice on learning Python efficiently

#60
Hmmm.... 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.

Post reply on HN