News for hackers. Stuff that matters.
Re:Python for Non-Programmers by ivanbakel on Friday April 03, 2020 @12:17PM (#22770791)
I'm guessing the FAQ is targeted at the non-technical audience, so I'm not surprised this doesn't show up as a question, but - why Python?

I often wonder if imperative programming is actually a beginner-friendly abstraction - in particular, because of name rebinding and interior mutability. My university's CS course is highly technical, but also targeted at non-programmers (officially, the lecturers cannot expect any computing experience at all) - and it teaches Haskell, which addresses some of those concerns.

Re:Python for Non-Programmers by kazinator on Friday April 03, 2020 @12:36PM (#22771065)
> wonder if imperative programming is actually a beginner-friendly abstraction

You know, a very common newbie Lisp question is "why is my list still the same after append".

I bet you no Python beginner asks why their list is different after list.append(3), having expected a new list to be returned and the original one left alone.

Imperative is intuitive; the real world is apparently imperative. Though it can be described by functions in which t is just a parameter, the way those functions play out is that the past values of t are not available.

To take a more level view, the expectations w.r.t. append could be conditioned by prior exposure to other languages. However, any exposure to computers at all reinforces the imperative view. Almost all content is manipulated destructively: documents, settings, you name it.

Re:Python for Non-Programmers by rovolo on Friday April 03, 2020 @01:36PM (#22771960)
On the other hand, we have to teach people about aliasing vs cloning in imperative languages.

    a = [1, 2, 3]
    b = a
    b.append(4)
    assert a == [1,2,3]
No matter which paradigm we use, there are going to be hidden traps new programmers need to learn. I think there might be fewer roadblocks in an immutable language because you can examine each function in isolation. There's a smaller chance a beginner will screw something up on line 10 which causes a problem on line 150. More moving parts makes it easier to get stuck on a buggy program.

On the other-other hand, it is a slower ramp up to doing useful things. It's much easier to read/write to files and draw graphics in an imperative language.

Re:Python for Non-Programmers by kazinator on Friday April 03, 2020 @02:42PM (#22772685)
Aliasing versus cloning can bite you even if nothing in the program is imperative. For instance, somewhere in the program you choose the wrong one among the available set of equality functions (all of them beautifully pure).

If the immutable language has a single equality operator which makes it impossible to tell whether or not a value has been cloned, you might be safe from this issue.

Re:Python for Non-Programmers by rovolo on Friday April 03, 2020 @03:24PM (#22773088)
There shouldn't be a difference between Aliasing and cloning for immutable data because you can't change the data.

Deep vs shallow operations is an issue in both imperative and functional programming. In python, you have '==' vs 'is' for different types of equal. You have deep vs shallow copy: https://docs.python.org/3/library/copy.html

Re:Python for Non-Programmers by dbcurtis on Friday April 03, 2020 @03:25PM (#22773101)
> the real world is apparently imperative.

I beg to differ. The real world is declarative. But as software developers we mostly suck at creating declarative ways to express problems. The spreadsheet being the one example of an intuitive declarative UI that non-programmers grok easily.

Your average corporate VP of engineering uses a declarative interface to issues charters to his developers: "You need to hit X performance target, Y cost of goods, and Z MTBF. By Date D. Go."

Declarative is the way the world works.

Re:Python for Non-Programmers by thelean12 on Friday April 03, 2020 @04:20PM (#22773572)
And yet, the only way to actually complete that charter is to "interpret" or "compile" that charter into something imperative.
Re:Python for Non-Programmers by simplify on Friday April 03, 2020 @05:21PM (#22774064)
Prolog is the best way to describe these constraints. Nothing else comes close to its declarative power.

The industry will catch on, eventually.

Re:Python for Non-Programmers by kazinator on Friday April 03, 2020 @05:12PM (#22773996)
The political or legal world is declarative, for sure.

Perhaps an inviting flower is declarative to a bee, or reactive chemicals are declarative to each other.

Other than that, I'm not so sure.

Re:Python for Non-Programmers by marcosdumay on Friday April 03, 2020 @04:20PM (#22773573)
People have a very clear grasp of a list of instructions to follow in order. At the same time, a set of constraints that describe something is a very advanced topic that requires a lot of getting used to and some extra focus.

Programmers tend to favor the declarative approach because it leads to simpler programs, but it's only easier to understand if you are trained in (somewhat advanced) mathematics; most people succeed in avoiding learning any mathematics.

But yes, mutability is surprising. It's something to explicitly teach.

Re:Python for Non-Programmers by reuven on Saturday April 04, 2020 @04:07PM (#22781081)
I definitely talk about mutability in my course. It's super important, I agree!
Re:Python for Non-Programmers by danso on Friday April 03, 2020 @12:41PM (#22771151)
Why not Python? It has a fairly sensible syntax, a broad standard library, a massive library of powerful and useful third-party packages, and a great ecosystem for online/interactive learning (JupyterLab/CoLab/etc).

Assuming that many of its audience are self-learning/non-CS-careerists, Python's popularity and adoption rate is also going to be a major draw. Learning Python as an attractive job skill is as much an incentive as the intellectual accomplishment.

Re:Python for Non-Programmers by reuven on Saturday April 04, 2020 @04:06PM (#22781080)
Good questions!

I'm teaching Python because... well, because I teach Python, and this is my way of helping people who want to learn.

I also believe that Python is a good first language for many people. Not everyone, but for a lot of people. It's not only relatively easy to learn, but it's practical. Many people want to learn Python because of their jobs.

Re:Python for Non-Programmers by nicoburns on Friday April 03, 2020 @01:08PM (#22771564)
Python is much more useful to know than Haskell...
Re:Python for Non-Programmers by Der_Einzige on Friday April 03, 2020 @09:10PM (#22775388)
If someone had tried to start my programming journey with Haskell I'd likely have given up and not touched programming ever again.

God forbid that the functional crowd gets their way. Most people are terrible at recursive thinking. That's why those languages have such a reputation for being difficult.

The declarative languages are also a good starting point, but the most used one (SQL or spreadsheets) are somewhat orthogonal to what one tries to do with python.

You need for loops. You need if statements. You can't just hope that they will get recursion.

Re:Python for Non-Programmers by vikramkr on Friday April 03, 2020 @12:24PM (#22770864)
I think they answered why python in the description - because it's one of the hottest languages out there and because it's one of the most popular languages out there.
Re:Python for Non-Programmers by bluedays on Friday April 03, 2020 @12:40PM (#22771130)
Because it reads like English.
Re:Python for Non-Programmers by mr_toad on Friday April 03, 2020 @10:35PM (#22775752)
Many students aren’t going to want to learn a language that hardly anyone ever uses. Many of them will be making their choices with one eye on their employment prospects, and there are a lot more Python jobs out there than Haskell ones.

https://xkcd.com/1312/