
Learning to Program: Why Python? - camlinke
http://www.udacity.blogspot.ca/2012/05/learning-to-program-why-python.html
======
hkmurakami
_> The similarities between these languages are as complete as the
similarities between driving in Europe and America: In the same way an
experienced driver from one continent can improvise with a reasonable degree
of safety on the other, an experienced Python programmer can be up-and-running
with C# in a day or two._

Absolutely love the analogy. It's a great display of leveraging the English
language to convey complex concepts in a down-to-earth fashion. Even as
engineers (or perhaps _because we are engineers_ ), getting our ideas across
in understandable, layman terms is a potent weapon.

(though admittedly, the latter part of the excerpt could perhaps be
simplified)

~~~
villagefool
But that doesn't explain why Python and not C#. Can't a C# programmer be up-
and-running with Python in a day or two too?

~~~
cgh
Probably because not everyone is learning to program on Windows.

~~~
jiggy2011
You can use Mono to program C# on Linux or Mac.

~~~
spamizbad
Yeah, but chances are your Linux or Mac users will already have python
installed via their OS.

The biggest challenge for Windows users is remembering to go to python. __org
__and not python.com to obtain their version.

~~~
eichin
And if you look at any of the udacity office-hours videos, when you see
laptops, they're almost always Macs :-)

------
Wickk
Thought the article was going to be a question as to why. But I wholeheartedly
agree as to why Python is a great forst language.

The simple fact that it's syntax light will always be the #1 reason it's a
great introduction. Worry about the syntactical hangups once you have the core
concepts of programming down.

I never understood those CS courses that have you diving in blind with C++

~~~
commandar
>I never understood those CS courses that have you diving in blind with C++

C++ made more sense to me than all the CS programs that were switching to Java
for their intro to CS courses when I was coming up a decade ago.

C/C++ may have overhead that's confusing to a beginner out of the gate, but
Java just amplifies that.

~~~
Wickk
Everyone learns differently, so hey to each their own. I dabbled for years
throught my HS life in php, but when it came time to actually learn I was
completely put off by my first intro to CS course that used the aforementioned
'Dive head first w/ C++!' method and left the course, and was one of 18 to do
so.

Started learning python on my own around age 19 and everything just skyroketed
from there. I'm much more comfortable using( saying that lightly ) C++ these
days but I can't imagine ever recommending it to even an enemy as their first
language.

An aquaintenance on a board somewhere put it best, " C++ is like a hurricane.
Gorgeous but incredibly destructive". Personally I think it all looks hideous
but I get the point now.

~~~
commandar
Oh, I agree that C++ doesn't make much sense as a first language in 2012. I
was just pointing out that a few years ago, the trend was toward teaching Java
which is, in my opinion, even _worse_ as a first language because you're
forcing people to immediately dive into dealing with classes before they even
understand what a class is.

Today, I'd agree that Python -- and possibly Ruby -- is a better first
language, but when this was happening they weren't particularly mature. You
just didn't have the kind of mature, syntactically-clean, object-oriented
languages available that you do now. Even so, I never understood why you'd
choose Java with all its excess syntax to teach a beginner.

~~~
Wickk
Prob the age old reason because it's what most programmers end up using
throughout their buisness life. Always been my guess anyway

------
10098
I never quite understood why people think that teaching beginners programming
through languages like Python and C# is a good idea. It's really hard. Think
about it.

It may seem easy to start writing programs in those languages, but
understanding what is actually going on is sort of difficult for someone who
has no idea how things work. When you're implementing a linked list or a
binary search tree for the first time, it's important to understand how your
data structure is laid out in memory, otherwise it's a pointless exercise.
Higher-level languages are convenient, but they hide a lot of what is going
on, and that, in my opinion, is bad, if you are learning.

I think the best language to start with is C (and not C++, of course). One
must understand pointers and bytes and bits and memory management and all that
shit that leads to segfaults and many hours of debugging to be a programmer. I
would even go as far as to say that one should start with an assembler and not
C, but given the immense complexity of contemporary hardware, I understand
that such approach is infeasible. However, teaching kids programming with a
physical (not emulated), really simple, toy CPU is probably a good idea. Too
bad I don't know any such CPUs.

~~~
hsshah
IMHO, this is bad advice. It is like saying if you want to teach how to change
oil in the car, teach the entire automotive engineering curriculum.

Introducing extreme complexity so early in the process turns off people; they
give up easily and (falsely, in many cases) start believing that programming
is not for them.

The first introduction should have enough fundamental programming concepts to
enable the students to make something useful and tangible, by themselves. As
the interests and the objectives grow, they can delve deeper into the domain.

I think with Khan Academy, Udacity and others, we are entering a new paradigm
of "Just in time learning". Schools should focus on teaching smart learning
techniques, critical thinking etc instead of cramming more and more topics in
their curriculums.

~~~
fusiongyro
Is it true? It's easy to spout platitudes about what learners should and
should not have to learn and why, but have they been tested? A lot of people
who went to my school would have preferred a curriculum based on Python and
writing games, but the ones that graduated seem pretty glad they instead
endured a curriculum based on C and culminating in compiler writing.

I'm happy to live in a post-Alan Kay world, but I think maybe it's time to
dust off that sculpture of Dijkstra we keep in storage and move it out into
the foyer. Programming is hard; glossing over what makes it hard in the name
of doing stuff sooner may or may not help, but as long as we debate it without
testing it empirically we're sure to get nowhere.

~~~
hsshah
That is indeed a good question. One of the key challenge in reforming
education field is the feedback cycle is big. Very time consuming to track
experiments. So I have add that what I stated was my hypothesis reinforced
with a small dataset of my experience teaching 'Computing & Internet' to
middle school kids.

I have to clarify that my comment was targeted towards current Udacity (other
MOOC) participants who wants to learn programming as a value added skill or
hobby.

If you want to graduate with CS major and/or want to pick CS as a profession;
I do believe you need to have a good understanding on the entire stack. There
are no shortcuts to being a good professional and achieving mastery in any
field requires committed hard work.

------
simonh
I've been playing with Codea on the iPad for a few days. I'm a big Python fan,
but having never used Lua before I have to say it's a great little language
and Codea is a lovely learning environment.

My daughter (8) was watching me play with it on the couch at the weekend and I
let her change some of the variable values, pick colours, etc and see the
difference it made when we ran the program.

------
wizardhat
Here's one reason why not: no anonymous functions longer than one line. Which
is a pretty lame limitation for a modern high-level language, all due to the
dumb whitespace-as-scope design.

~~~
simondlr
Honest question: If you are making an anonymous function longer than one line,
shouldn't you just make a normal function? What are the use cases for large
anonymous functions?

~~~
chubot
I wrote a nonblocking library (for pipes/processes/signals) in Python like
node.js. So many of the callbacks end up being inner functions (they don't
when you decide you can make all the necessary state object-level, and thus
make the callback a method).

The anonymous syntax actually reads better than defining an inner function and
then calling it.

I think the real reason why they were never added is syntax, and honestly I
can't think of a good syntax myself.

~~~
simondlr
That makes sense. Callback methods. Thanks.

------
cageface
It's too bad Javascript's faults are so grievous. The sane subset of JS + a
web browser makes a pretty good beginners environment.

But when you have to blow so much time on screwy things like "this" scoping
and unwanted implicit conversions it kind of tips the balance.

~~~
jerf
You can always do something like this: <http://www.skulpt.org/>

None of the disadvantages of such an approach matter in a learning context.
Sure, it's slow relative to a real implementation... but so what?

(I'm also not saying that particular link is a drop-in solution, as I've never
heard of it until I went googling on the theory that something like it must
exist. But if you were building a business on this, it looks far enough along
that you could adapt it as needed.)

------
tikhonj
I can't help thinking that almost everything he lists applies _more_ to Scheme
than Python. Scheme also has the advantage of being much simpler, smaller,
more concise, more flexible and more elegant than Python. It actually does
functional programming _well_ rather than half-heartedly, and is rather nice
for OOP as well.

Additionally, Scheme has one very important property that Python lacks--there
is almost no magic. Even definitions and assignments (define and set!
respectively) look like normal function calls. It also makes it clear that
very little is fundamental to a language--with Java and Python things like
classes and control structures are special and built into the language; with
Scheme they do not differ superficially from normal functions. With Java I
thought classes and objects were somehow the only way to do it; Scheme clearly
showed me that they do not even have to be part of the core language.

Now, Scheme does have some complicated ideas like macros and continuations,
but there is no reason to teach those to beginners--it's an eminently useful
language as is, and _extremely_ simple. The very first CS course I took in
college used Scheme; we spent something like just _two_ lectures on the
language itself. Now that the professor retired they've changed the course
over to Python; I think they're still learning the language half-way through
the semester.

Scheme is also great because, being very simple, it is much easier to
implement than Python. And once you have a basic Scheme implementation, you
can modify it to see other potential languages. For example, in our intro CS
course, we talked about writing a memoizing interpreter and even a lazy
interpreter. It's hard to imagine a lazy Python! We even reused Scheme syntax
(but not really semantics) to cover logic programming à la Prolog.

That course was one of the most enlightening semesters I have ever spent. I
really think that Scheme is the perfect introductory didactic language.

~~~
driax
I never really accepted the argument that Scheme/Lisp is simpler than a
language like Python, simply because everything in the language is reduced to
constants/terminals (what's the right terminology here?) and functions.

Many language differantiate between statement and expression, and compile-time
and runtime and lots of other stuff.

Saying that we can express C-structs in a language by reducing them to
functions is not a simplification, instead I would argue it's worse when
trying to grok C. While coming from Python it would be easier since we already
have classes, and C-structs are simply compile-time final classes without
inheritance.

I agree though that learning Scheme can teach a lot, just not necessarily how
to grok every other language well.

------
Permit
>Python’s type system is more flexible than C#’s (for better and worse). It is
important to keep in mind a few concepts from Python that are not directly
translated to C#:...

>Dynamic typing, a.k.a “duck-typing” (this, too, can be accomplished using
libraries built around Delegate.DynamicInvoke).

I'm not super familiar with the keyword, but I'm fairly sure this is built
right into C# 4.0 via the "dynamic" keyword, is it not?

~~~
davidlumley
From what I understand, yes. I believe the point the author is trying to make
however, is that Python allows you to think more about the structure/function
of your code rather than worrying if a variable should be an integer, a float,
or a double making it easier for new programmers to "jump in".

------
smortaz
The author mentions that C# has a nice IDE (Visual Studio). I'd like to
mention that a couple of OSS & Python enthusiasts at msft have produced one
for Python as well (free/apache 2.0).

It supports both CPython and IronPython, along with intellisense, debugging,
profiling, etc. : <http://pytools.codeplex.com>

------
gbog
Liked the fair simplicity of the post but I am disappointed by the Wikipedia
links. Like many design pattern they look like Java special idioms used to
overcome its limitations. So dependency injection is just "if x import y"?
Like any other conditional, it must be used only if necessary but does it need
be a Design Pattern?

~~~
evincarofautumn
Design patterns tend to arise due to linguistic limitations, but not always.
They’re mainly a shared vocabulary for talking about software architecture and
design, regardless of paradigm.

As for dependency injection: DI ⊆ inversion of control ⊆ decoupling ⊆
factoring, where ⊆ = “is a kind of”. Roughly, DI means externalising
dependencies and giving them as parameters in order to reduce coupling. Which,
when you put it that way, is obvious, and something we (should) do often in
any language.

------
idleloops
Title is misleading. The article discusses why learn Python instead of C# as a
first language.

Missing: Python being cross platform (arguably more so than C#.)

------
horsehead
I just want to say that I've been learning Python as my first language. I've
found it to be fairly intuitive and a lot of fun. Of course, learning any
language, especially your first, is going to be difficult, though.

One of the drawbacks I've heard is that Python subscribes to the idea of doing
something 'the right way,' although i've found a few times where i did
something the 'not right way' and it was still functional (although maybe a
little longer or not as clean as it could have been).

Edit: I've also been involved a little bit with Ruby lately, and it seems thre
are a few similarities between the two. Though that could just be that there
are many similarities between any two langauges, and I'm just not familiar
enough with multiple languages to realize that :P

Still, it's an excellent first language, IMO

~~~
fusiongyro
A lack of freedom can be a good thing in a first language. Of course, Python
doesn't _always_ have a "right way" or they wouldn't be on their fourth
command line argument parsing library. ;)

Ruby and Python will seem more similar after knowing a lot of languages. But
they are different enough too. If it's not intimidating you it's probably a
good second language.

~~~
slurgfest
Why do I keep reading about this? I don't see how any command line argument
parsing library is relevant other than argparse. Do you have some concrete
complaint about argparse? I am seriously wondering what I am missing, it seems
so simple to me yet this seems to be a burning perennial complaint.

~~~
gvalkov
Why shouldn't they be relevant? Getopt is still very useful for short scripts
and optparse does everything it was meant to do, even if it's not as full of
features as argparse. Maybe argparse really should be the canonical choice,
but I certainly wouldn't want to see the others gone.

As for a minor complaint about argparse - setting up a custom help formatter
[1] is not straightforward, not in the slightest in comparison to optparse [2]
(which is much simpler, implementation wise).

[1]
[http://hg.python.org/cpython/file/default/Lib/argparse.py#l1...](http://hg.python.org/cpython/file/default/Lib/argparse.py#l144)

[2] <http://hg.python.org/cpython/file/2.7/Lib/optparse.py#l155>

------
salimmadjd
Right idea, but bad execution. This could have been a great post had the OA
had expanded on his examples instead of just linking to wikipedia.

Here is where he failed. We need to ask, who is this article for? Programmers
who already understands some of the patterns and paradigms OA touched upon, or
newbies.

Given he seem to be responding to a new programmer, it would have been more
effective if OA had displayed the C# implementation vs. python, at least for a
few of the more interesting examples.

On a personal perspective, the first language I thought myself was BASIC.
Remember line numbers and goto? I later learned enough C to understand how
things work behind the scene. So I personally like the high-level first
approach, especially python. It's like a swiss army knife.

