#pedagogy
1 messages ยท Page 10 of 1
the only "missing feature" is variable-length lookarounds
and unicode character classes, annoyingly
The regex library has the latter and maybe the former
!pypi regex
So I have a classmate I'd like to take under my wing
He's a smart enough guy, but his fundamentals are really lacking
So the way I see it, I can either encourage him to go back to the basics, or push forwards with a focus on unambiguously clean code
Wondering if anyone has ever been in a similar situation and if so, what they'd recommend
@lusty geyser what fundamentals is he lacking?
Well, we're entering into our second term
So being able to work with arrays is going to get pretty important
This in C++ btw, but the teaching is more or less the same
And he still couldn't tell me the difference between pass by value and pass by reference, let alone what's actually going on with the data
And honestly, some other pretty serious mistakes like egregious syntax errors
He's just trying to go along to get along, but he's got no idea what's going on
And I'd like to start with the basic idea of what data actually is in memory, how it relates to declaring our variables with their types, and how it moves around
But that's how it makes sense to me. And I'm not a good example because, and I don't mean to come off as conceded here, but coding has always been as clear as water to me
I don't struggle to understand things the way most of my classmates do and that makes it hard for me to know where the sticking points are
So I worry that starting with "what data actually is" is like trying to tell someone how atoms and molecules work without first explaining to them what chemicals are
If that makes sense
I think things come naturally when your initial assumptions just happen to be correct. I see it as a random chance thing.
do you have any examples of the assignments from the previous term/semester?
I can show the assignments, yeah
But not his assignments
Did you just want to see the specifications?
just a general sense of what he's expected to be able to do. my thinking is that if he can't complete them, it's unlikely that things are just going to come together in the context of more difficult assignments.
I'm not sure I'm following. Are you suggesting that "if he just doesn't get it, there no way he can get it?"
I'm certain I must be misunderstanding ๐
so, second term of first year of university?
Yeah
Also, I'll ask you to bear with me. I've been getting progressively more congested since I first posted my question, and I've taken some cough syrup
has this friend talked to TA's or professors about what he's struggling with, or availed himself of office hours?
I think so. I know he was on close terms with his teacher last term
And he's focused, I know he's been reaching out for tutors
and despite all that, he's struggling to grasp the basics of the material?
when you say "egregious" syntax errors - can you give some examples of the egregiousness?
void some_function(int& x, int& y) {
x = 10;
y = 20;
}
int main() {
some_function(int& 1, int& 2)
}
hm, ok. Well, that's... ballpark, at least.
for (int i = 0; i < 10; i++) {
somearray::name[i]
// what he was trying to do...
// somearray[i].name
}
ok. that's not so bad.
does he have any previous coding experience, do you know?
C++ is an exceptionally hard first language, I think...
it seems like he's got all the ideas, tbh. just needs more practice
my general advice here would be to let people with more teaching experience - the professor and TAs - take the lead. If this person's asking you for help, that shows that they really want to learn the material, but I don't think you're the best person for them to learn it from.
if you decide you want to be more involved, I'd start by going back to previous homework assignments, and sitting down to pair program them - him at the keyboard, and you available to ask questions as soon as a question pops into his head, or to correct a problem soon after you see him starting to make it.
I agree, though - it seems like he's having trouble remembering the syntax, but has a reasonable grasp of the ideas (beyond the fact that he was passing references to temporary variables in the first one, but references are a bit hard to grasp at first, and at least the compiler will catch that mistake)
Sorry for vanishing โ laptop pooped out on me
And you're probably right
That said, I want to become someone who can teach (tutor) ๐ I definitely have the knowledge base, but I want to get better at the teaching part. Maybe I should start with some reading on teaching
Beyond that though, our school is a joke
He won't get much from the instructors
Anyway, thanks y'all
pair programming is a great educational tool - if you decide to stick with this plan, that's the tool I'd reach for
it gives him a chance to get immediate feedback to validate a strategy or correct a mistake, and lets him practice his skills in an environment that should hopefully be less frustrating than if he were working alone
๐ Perfect
and rather than starting any new material, I'd revisit past assignments, since you know he doesn't have the basics down yet
or slight variations on past assignments
question
i've been programming for months and wondered what its like to be a master programmer
like you can really do things in front of computer creatively with googling things reasonably?
Lol old timers can dispense with the googling things we grew up without it
define "master programmer".
but using my definition, a master programmer would be able to take on almost anything comfortably. they'd still have to learn when trying new things of course, but they'd know how to do it efficiently and where to start (the docs for example)
I wouldn't expect anyone to have memorized everything. But I would expect someone to know a handful of useful design patterns, to understand most "gotchas" and caveats, to know where to look up information, and be able to understand more advanced documentation and put it to use.
Well, there are two ways to become a master in something
Either someone you and everyone else recognise as 'master' proclaims that you are, indeed, a master of the craft, inviting you into this society
That's basically the way academic degrees work
Or you have some measurable notion, which gives yourself a measure how good you are, a fuzzy degree of how much of a master you are, like the percentage of time you spend googling instead of writing code
That is more important in job interviews
But it would be strange, if not stupid, if a self-proclaimed master would never google for existing solutions
Especially in a fast moving field like CS the most important skill imo is the ability to keep learning, staying curious and never assume that you're 'done'
And you also need to distinguish between being creative and being productive
The highest productivity is achieved by the contrary of creativity - repetition
If you want people to be productive, you teach the bare minimum of a framework, like a GUI framework, how to do things, and nothing more. Then you give some spec and expect them to realise those specs without any deviation
That was the idea of management of many big companies a few decades ago, how to outsource coding jobs to India, Russia, China
Then they realised that good, creative, individual solutions can't be build like a car
But creativity is hard to control, requires time for research, experimentation
And always comes with an element of risk
So, mastery.. hard to define.
In Hagakure it's said that one is a true master only when you are useful and recognized as one, but also realize that you never will be done training and learning
So, I guess coders are like Samurai in that regard
I hated pair programming as an undergrad, but I was usually paired with bad programmers ๐
Pair programming is most useful for people with a similar level imo
it is a very reliable method to get someone up to speed on a new technology
I think good error messages are more reliable 
Pair programming is cool, but have you tried pear programming ๐
amogorkon you must be familiar with the concept of "beginner's mind" -- I think it could be of great value in teaching / learning programming, don't you?
I recognize pair programming as useful, but I really really hate doing it, because it exhausts me profoundly whenever I do it.
I much prefer being able to work on a problem at my own pace, and then have my work be reviewed asynchronously by someone else.
hey
something about OOP
@rich mural and @pure heron have raised good points about how OOP is taught
When teaching about OOP we should properly show that replicating real-world examples isn't always the best use for them
and in fact can be downright problematic like dementati said
While I don't disagree with the issues outlined, I don't think presenting such intricacies is useful to someone who is trying to understand how to write code with this new tool and why it's even useful
Starting with half truths is fine sometimes
A lot more programming teaching should be problem orientated and not feature orientated
Well, even if we don't bring these things up in OOP 101, we will need to find a way to break these half-truths down at some point.
I agree
And maybe there are still things we can improve in how we teach the basics.
a fundamental concept of examples
Sure, I can agree with that. But if someone who is still trying to understand the basics is asking for a primer on OOP, I'll probably go for the Animal -> Dog example, because it's very easy to chew. Yes, it glosses over a lot of what OOP is about, but everything that OOP is about is not necessarily what this person needs right now
It gives them a starting position to hack away from
it also has the added bonus of not being dumb like Squares and Rectangles
Yeah, this is how OOP 101 is taught right now, I'm just wondering if maybe we can do better.
Or at least more.
Bringing up the Rectangle/Square problem is a good example of something you could put in an introductory OOP class and provide slightly deeper insight into what designing class hierarchies in practice is like.
#python-discussion right now lmao
I think as long as you're imparting them with the idea that it's a popular way to tie together structured data and behavior, and then show various good/bad examples of where it can be used, you're probably doing an ok job at explaining it
Yeah, that is ok. But maybe we can do more.
What is missing?
You also don't have to teach inheritance for a while, it's a very specific part of OOP
I feel like we are talking about different things here. Yes, you don't want to discuss the subtleties of class hierarchy design at the same time as you first introduce what a class even is, but I'm not arguing that you should, I'm talking about what should be included in an introductory OOP class, something that does cover inheritance.
Hmm ok, but let's say we taught them some OOP, gave them various examples, some more abstract than others, and we now want to teach them about inheritance. Is there a fundamental issue you want to address? from the screenshots above I see Rectangle->Square as a counter-example, but in the end it's just another example you can show
The issue I want to address is that there seems to be a lot of students who understand that inheritance is about ontological hierarchies but lack understanding of the practical implications of translating such hierarchies into code, the Rectangle/Square problem being a prime example.
As a tangent, this conversation made me remember the time I wrote a chess game for the terminal, and made the queen class a subclass of the rook and the bishop classes so that I could use their code ๐
Multiple inheritance??
I think it was in C++
Blasphemy
it tires me out, but I pair with this one dev semi-regularly at work because it's just more efficient than hunting down all the bugs he'd have introduced otherwise
๐ฅด
@weak mortar see #โ๏ฝhow-to-get-help
ok thanks
has this channel been here always?
Brand new, like a few days old.
Not sure exactly what you mean by that, can you explain?
@sudden thorn This channel is for discussing the teaching of programming. This is not a help channel.
If you have a C++ question, you can ask in an off-topic channel, or find a server dedicated to C++:
Communities
The communities page on our website contains a number of communities we have partnered with as well as a curated list of other communities relating to programming and technology.
Topic: One of the hardest questions on here to answer, in my opinion, are those about environments and dependency installation. The reason being that figuring out which environment something is installed to and which one is being used to run some code requires command line skills that beginners typically don't have. How can this be answered effectively? When should command line skills be introduced?
One approach that I use is "please put import sys; print(sys.executable); exit()' at the top of your program", which at least gives us the execution environment without touching the command line.
hm is the command line that unapproachable ?
My impression is that this is more a matter of people not knowing what their IDE is doing behind the scenes (creating venvs), or not knowing that they have multiple python versions installed, than it is of them not knowing how to use the command line.
but using command line to determine your sys.executable is what helps the helper diagnose the issue, i think that's what stel is getting at
or in his suggestion, having the user put that at the top of their script
most novice programmers have a lot of experience with consumer software and start their Python journey with some kind of editor that "runs" the program, the novice not knowing that the Python executable exists separately from the editor.
A friend once sent me a screenshot of a conversation we had years earlier, where I was confused as to how I could even run a program without PyCharm.
anyway, I remember being intimidated by the command line at first, and for those who are doing all their Pythoning in an IDE, I think this often works out to be their first problem that is best diagnosed from the terminal.
First contact, it might be useful to post a video or animation on how the computer executes things on general
Understanding how a text file gets turned into executable code can be quite confusing, but relevant general knowledge, considering viruses etc
We can't use pycharm at work because of seucritry reasons. We only ahve spyder. Apparently spyder is bad ( i only use terminal and vim w/ extensions) and I have to deal with this guy who does nothing but bemoan python because it doesn't have a good ide availabe on oursystem unlike Matlab.
Some context, we're moving our tooling from Matlab to Python
I personally think IDEs are bad for beginners
Even in C/C++
Install GCC and go to town
wdym security reasons? PyCharm community is open source
PyCharm is owned by Russian company... JetBrains is Russian
๐ค its code is still openly available
DoD doesn't care
Why do you think so? Imo, that little red underline, syntax highlighting, and more are so valuable, especially when you're just trying to figure out how things work.
because like Stelercus is pointing out, you aren't actually learning basics of the language
it's a Czech company. Not all Slavs are Russian ๐
Headquarters might be Czech Republic
Well regardless, Security doesn't allow it on the classified systems, and part of that is mandated by DoD
Aren't you? Typing terminal commands is one part, but writing code is certainly another.
I would say if you come under the expectation that you have to fire up your IDE to run the code, you haven't.
Especially the scripting languages
I'm of the opinion that for beginners, it's much more encouraging to learn with a run button, and then tie in the terminal after.
Now if you were doing large C/C++ I wouldn't expect beginners to be making their own MakeFiles for that but imo its an important part of the compilation process that the IDE just takes away
IDEs have a lot of bells and whistles which confuse/intimidate beginners
Thonny is extremely good for beginners imo
plus most guides instruct people to pip install packages without considering venvs
yeah, that's what I've heard too
Yes, that has to be learned at some point, but trying to tackle that in the beginning could easily result in someone giving up since they can't even see the results of the code they wrote.
So i first learned python from Zed Shaw's book
I know a lot of people aren't a fan of it
But it teaches you bare bones python and imo you'll be better for it
i think I would unironically recommend IDLE over PyCharm for absolute beginners
I find thonny's debugger very valuable for prototyping, even still
Watching step by step what code is doing is awesome
IDLE has both a repl/shell and editor
it's really important to point out to beginners that they are 2 different things
Its not in the basic python install?
it's bundled with python yes, at least on windows
Ah im trying to fire it up on WSL
It doesn't come native with linux
its probably bc I am using Ubuntu through WSL2
the reason i bring this up is bc IDLE REPL allows you to file>save your session as a .py file, and then i've seen people try to run those py files
Usually when I experiment I do it in ipython and then output the session to a file using %history -n
which imo is terrible lol (of IDLE)
do you have a screenshot that shows what that looks like?
The output of %history?
yeah i'm not at a computer to try it and was just curious haha
been programming for years now and pycharm is still extremely intimidating lmao
same
all my coworkers use PyCharm, but I am immediately lost in there
oh and it comes with a terrible type checker
and -f for filename. handy, ty!
you need to either install tk through your package manager first or something
I dont remember now, let me check
~ idle
** IDLE can't import Tkinter.
Your Python may not be configured for Tk. **
~
~ sudo pacman -S tk
@real oar This is not a help channel, this is a discussion channel about teaching programming.
@silent goblet where can I find one then?
@real oar You already claimed a help channel. Just be patient
@silent goblet alright thanks
also you can ask questions in #python-discussion to start off
it's like starting off at the Graveyard in a text adventure game
@ancient siren Sometimes I can feel pain when I think about this problem, because I am waiting for 4 days.
oh i am sorry to hear that, i'm just a learner myself
Can someone help me with (what i assume would be) simple problem with bs4?
@dusky mirage This is not a help channel, this is a discussion channel about teaching programming. If you have a question, you should see #โ๏ฝhow-to-get-help and claim a help channel.
Ope sorry. Just was suggested to this channel. Thanks
I would too
hell, I do it all the time to people at school
The advantage of IDLE over Thonny is that it comes preinstalled.
But Thonny is very easy to install, so I prefer to recommend that.
I've never done this myself, but I think it seems like a great idea, not just because you don't have to use the command-line but because it works no matter how the code is run. Even if you were to teach someone how to find their executable through the command-line, that doesn't guarantee it'll find the same environment as is used when they run their code through whatever IDE they use, but if you put that output in the code, it'll definitely locate the right one.
Hello everyone, I'm now in the midst of grading analytics students but it seems that performance has been poor and that they are not well-versed in various parts of Python... any tips?
The questions were reasonably advanced, but it seems even their lack of mathematical skills creeps into the code, so that issues also comes up.
I am holding a tutorial session and interest remains low (~25% respondents), but I think among this group, interest is higher. What are good topics to cover? The assignment has a lot of use of numpy, and I think numpy can speed certain python-only loops up (which they wrote), but I'm really wondering what other things I need to say. If possible I'd like to teach the art of 'just googling,' but even on this I can see that they might not know keywords to google
I think I could also try to direct them here, but I don't know how gamery they are (or basically if they use discord), and more importantly if that is a good idea to persuade non-discord users to try discord, especially help-related communities like this one
I'd be interested to see those tasks
Btw, to speed up regular python loops, there are even better tools than numpy, like numba jit
It's always a good idea to know where to ask for help. Google isn't a one-stop shop, especially for more advanced topics. It will mostly return stack overflow results, which often are outdated
Telegram and IRC also have python communities that are very alive
fwiw the userbase of discord has grown far beyond gamers by now, if they're young there's a pretty good chance they already use it
Why would it not be a good idea to persuade non-discord users to join help-related communities?
If you install a Python interpreter, it comes with IDLE.
If you install Thonny, it comes with a Python interpreter.
Hey guys! Where can i learn the pktinker module in python??
Is this the correct channel to post this?
... Touche
No, this is for discussions around how best to teach programming. You can just ask in #python-discussion
Thanks for all replies! I can DM them to you
It might not be a good idea in the sense that the students may not be receptive. In that case, it would have been pointless to suggest to them. You can say they are not heeding good advice (whatever this means) but I really do want them to improve, rather than feel good about myself
This is a bit beyond me, so I can't teach them this since I don't know it. I could mention this but I'd like them to master numpy vs pure python if I can
I think this will help. I should persuade them to be more active in seeking help, from me or from general coding communities
what sort of mistakes were they making?
Well depends on which algorithms you want to get to know and how well
For datuastructures and algorithms I mainly used hackerrank (but codewars/leetcode etc are options too) and just take an example, see if I can solve it myself
And often it required the code to be a certain time complexity
which meant you had to use dictionaries or sets or binary trees etc. to make it efficient
The sites also show solutions of other people (sometimes only once you solved it) and you can always open wikipedia or a yt video if you really get stuck
@lethal raft
not sure if that means practicing your skills on problems but sure!
practice makes perfect
I would definitely recommend learning the basics, that'll keep you from making big mistakes, but for a lot of jobs you don't need to know more than that.
If you're struggling to figure out how other people are coming up with their leetcode (or whatever) solutions, you should probably read a textbook on it. To a certain extent DSA is inherently dense and mathematical.
Hi Everyone! I am new to python. I want to understand the "[parent=f1]" in python. Why do we create another python function inside of a original python function. What is the purpose/advantage of using this?
Code Example:
def sum(n, lst,):
def sum2(m,k,lst):
pass
hi, this channel is for discussion about how to teach CS, you can grab a help channel in #โ๏ฝhow-to-get-help or ask your question in #python-discussion
Thanks a lot! ๐
this is probably better suited to #algos-and-data-structs
I don't have the full frequency yet but
- Not checking constraints fulfilled (Variance equality, or approximately equal at least)
- Submitting scripts (notebooks) that would error on trying to run
- Not understanding RNGs
I was also asked a lot on iteration and they seem to have a tendency to usewhile Trueloops and sometimes do not know how to break out of such loops themselves
when helping someone with pandas, how do you usually balance between "spoonfeeding" and "rftm"?
most of the questions can be resumed to one or two functions (or how to use .loc properly), which I usually do not mind going a bit over on spoonfeeding, but even when it's something with multiple steps, most of the times each of these steps is still just one function
(ping on reply btw)
Part of the skill known as programming is being able to find the tools you need for the job, and understanding how they play together in fixing your problem. I think there's a connection between being able to use the right data structure and knowing how to manipulate it to achieve the desired result, and understanding what library functions will help you with your problem
So I really don't mind just showing them the right page in the documentation and telling them that they should focus on that
Because half of their problem is even understanding what to focus on out of the hundreds of available functions
hmm, yeah - most of the time there are some User Guides I could link instead, but if I link the exact function it's not much different from just giving it away?
that feels a little bit on the 'rtfm' side, with how large the User Guide pages usually are, but not too much
Well, I understand the aversion, but this is the kind of thing where it's either pointing them in the right function or letting them continue to wander the maze that is the documentation. With numpy for example, if you're familiar with a set of basic operations you'll probably do pretty well, I assume it's somewhat similar with pandas.
At the same time giving a user guide feels kind of artificial, it's like saying "I'm giving you the answer, but I'm not telling you where exactly"
I'll link guides when it seems they need a more general overview
The core issue here really is that they're not familiar with programming enough to know what keyword to search for
And to recognize whether a page they find is relevant or not
I think entry into either is fairly low but there is a big curve
I think with both of them the difference between intermediate and advanced is large
yeah, true. But what I mean is that if for example you have a solid understanding of magic slicing in numpy, you don't have to rely on a function like np.where
A lot of functions are just special cases of other features, so you if you have those basic features down it'll save you a good amount of googling
where can I find someone to practice with
Ah. Well I'd argue logical slicing and that function have very different use cases
They do the same thing but the np.where let's u treat it as first class and pass it around like operator module
Sure, my point is that at some point if you know a few of the basics of the library you'll stop searching so much even if there's a very specific function to deal with your specific case
Right you can get a lot done by learning some fundamental topics
So being shown those fundamentals can go a long way
Would it be alright to post a question regarding Python and Vapoursynth here?
My remote server has Ubuntu 18.04 installed that comes with Python 3.6.9. Anytime I try to install Vapoursynth R57 it just doesn't get anywhere
Vapoursynth folder ends up in usr/local/include instead of usr/local/lib. Also, ffms2 gets installed to usr/local/lib instead of in the vs folder.
See the pins for what this channel is about
Will do, thanks.
anyone here good at working with git just to ask a question?
This channel is not for asking for help.
This channel is for discussion about teaching practices or methods..
See #โ๏ฝhow-to-get-help
Hmm.. I think a crucial but undervalued skill in programming is speed reading
It also needs to be trained
It would be best if you could hand someone the numpy book, tell them to read it over the weekend to get a general overview
Teaching is "giving things away". If you don't like to explain concepts yourself and help people, then it is not for you.
There are different skills that need different approaches. Problem solving skills aren't taught by telling the answer right away
There is a difference between "giving things away" / solving the problem for them, and "explain concepts / help people" / teach them how to do it.
And if you try to first give the solution then explain how it works, sometimes it works, but sometimes they just disregard your explanation (or even close before you explain) and walk away with code they won't even try to understand
Even I don't read the numpy book, not sure if it is reasonable to ask others to do the same
But yes I think they should take an effort to improve their own skills if they seem lacking, hmm...
Well, you should
Not in depth, but to get an overview of what's there. It's the first thing I do when getting into a new framework - check for books, even if outdated, quickly read through to pick up important concepts, keywords etc and have an inventory of the tools
Then it's much easier to ask and look for help
Basically solves your initial problem, that your students don't have the lingo to formulate their qurstions
Having the book online, in a browser lets me kick back and autoscroll nonstop for an hour or two
Books are better for that purpose because they're easier digestible than the docs that come with the code, which aren't intended for excessive consumption
Once you have a general overview, youtube videos with animations etc can be very effective to drill down
๐
They way I learned to code was just to play around with it. Once I learned Lua I moved on to JS, then Python. Right now Iโm trying to learn Java. Anyone else learned this way?
Learning multiple languages is very instructive and something every aspiring programmer should do. The question is mostly just when you should move on from your first one.
What is RFTM?
it stands for read the fucking manual
So they put the T and the F in the wrong spot?
no you just got the acronym wrong im guessing
the problem with "read the fucking manual" mentality is that novices typically don't understand how to use docs to solve their problem
And that a lot of stuff has garbage docs
yes
ironically, I like the discord.py docs, even though they're widely hated. and tbf, it shouldn't be one big text dump.
Documentation is not targeted at novices, nor should be targeted at novices.
garbage docs or not, people should put some effort into reading the docs
this isnt school
And also SO is wildly toxic to beginners
Since half the answers for beginners boil down to that hostility
its not, SO is not a beginner place
they're not toxic to beginners, they're toxic to bad questions written by people who don't read the instructions
stop posting duplicates lmao, its a repository of answers, they dont want duplicates
I don't know that I agree what "SO is wildly toxic to beginners". beginners just have incorrect expectations about what SO is.
its not a Q&A place and its not a forum, stop using it that way
the docs thing is close to my heart because i write docs at work for the tools we use and i specifically ask people to suggest improvements to them, to do with structure, wording, examples, images, code samples, and the interns still wont use them
helping them with the most minor things when they could open an html page and read from it would be so much faster
If it's not a Q&A and not a forum then what the frick is it
How else do you classify questions
its a repository of answers
the same way you would close down duplicate issues on projects, they close down duplicate questions that already have answers
And I also don't get how asking a basic question gets you crucified
it doesn't, if it's not a duplicate and not badly written
But then it's filled with things like this:
https://stackoverflow.com/questions/61981569/how-can-i-write-a-python-program-to-print-the-sum-of-a-string-of-numbers-that-ar?noredirect=1&lq=1
if its a basic question it should be resolved in the docs, why are you asking on SO
what's wrong with this one?
Because it's in the docs:
https://docs.python.org/3.8/library/functions.html#sum
that doesn't make it a bad question
the accepted answer doesnt use sum, but i would close it down anyway because that probably is a duplicate
But that's a duplicate of this:
https://stackoverflow.com/questions/11344827/summing-elements-in-a-list?noredirect=1&lq=1
thats missing an element in the question
sum of comma separated strings, is more involved than sum of ints/floats
theres splitting strings, theres mapping int over that, then theres summing
just because a question can be answered by looking through the docs doesn't make it bad
yea, one part out of three
why are they widely hated?
why do you say it's not a Q&A place
I disagree
it's more that most people think SO is something it's not (and also most people expect spoonfeeding)
Not all questions have 1 answer - when you discuss the pros and cons of each answer that's a forum
Those types of questions will often be closed, since SO's question-and-answer format is not a good fit for them. See https://stackoverflow.com/help/dont-ask - subjective questions will usually get closed.
As that link points out not all subjective questions are removed:
Some subjective questions are allowed, but โsubjectiveโ does not mean โanything goesโ. All subjective questions are expected to beย constructive. What does that mean? Constructive subjective questions:
inspire answers that explain โwhyโ and โhowโ
tend to have long, not short, answers
have a constructive, fair, and impartial tone
invite sharing experiences over opinions
insist that opinion be backed up with facts and references
are more than just mindless social fun
And objective questions (although honestly in software it's pretty difficult to answer many questions objectively) can still have multiple correct answers
I said "often" and "usually" ๐
for having the whole thing on one giant page and not having examples.
what attributes of the api reference would you put on a different page?
idk, break it into categories, or something?
it's annoying when I have to control + f my way around the whole page
Exactly. It's a bit of a skill to be able to know where to look in the docs or how to formulate a topic in google such that you find a stack overflow post. If reading the fucking manual was so easy then everyone would be learning from books
I prefer book learning too but I recognize it's not for everyone
I think of it more like a skill, like you can surely learn it with experience.
It can be learned
yeah but surely it would take efforts :)
The issue imo is that learning is both a passive and active process. Book learning is highly passive and being able to translate that into an active process (doing examples) is difficult for a lot imo
Makes sense.
I've got a couple of issues with SO but the biggest for me is that there is no mechanism to get answers updated. If you search now for some non-trivial problem with python, the accepted one is for python 2.6 with convoluted code because that's how it was done. There is no incentive to post a modern solution for python 3 at all - no points, no community interest. On the contrary, it's similar to a forum with people complaining about raising zombie threads
And if you post a question specific to a new version, it gets shot down as duplicate
my idea of a Q&A (which probably is different to most) is that of a reddit Q&A where you have a whole bunch of questions that possibly and probably contain duplicates, some might go unanswered but theres no cleanup/closing mechanism afaik
what trips up beginners is that their duplicates/badly formed/irrelevant questions get violently shot down and purged from the site
multiple answers to a question isnt exactly a discussion
!split
This is a great topic.
Back when I was writing my books, I was very worried about how to order topics, how much to cover, how much knowledge to pre-assume, ... it was very difficult.
Since, I've been noticing that very little seems to be written about pedagogy.
It seems suprirsing, because we've been teaching each other for thousands of years. But what do we know about the teaching process? What do you knew about how to structure complex material, how to present abstract ideas, how to help learners?
it happens in servers like this all the time that people will ask "what's the best way to learn Python?" or "please recommend the best materials for me?" or "how long should it take me to learn Python?"
These questions have no answers.
What did you write?
I wrote some C++ programming books.
Meta learning is a whole topic, I think the more a person is aware of learning processes the better they can help themselves and others.
Many times I get asked if they should get a paid course, learn from a book or take a video course.
I always try to ask questions before answering them, and of course mentioning how I like to learn
This is the face of obsolescence: https://www.amazon.com/Professional-MFC-Visual-C-6/dp/1861000154
Yep, everyone wants to learn differently. I don't think that's wrong.
You wrote a book on MFC?
God you must be tired, good job ๐
OTOH, there's some adaptation in teaching method that has to happen for each person's preferred learning approach, right?
The way I explain something in a video is different than how I'd explain it in prose. (Isn't it?)
It's not just personal preference but reaching into the persons abilities and curiosity.
Maybe people don't really know their own learning style best, though. Maybe it has to be diagnosed or checked. Here's an interesting video on that subject: https://www.youtube.com/watch?v=rhgwIhB58PA
Learning without curiosity is not learning but memorizing
I think that's a good point. If I write a book, it's not up to me to keep you motivated... though maybe my book should try to be interesting and not boring. OTOH, at what point is it distracting?
If I give a seminar at a professional conference, it will be interesting. But your motivation is ont my concern.
If I'm a college professor, though, should I be working to help you with your motivation?
Books have their own record as well - like you want to keep it "Information" only,
Or people to keep your book as reference (Like documentation), so you have to write it differently
"Curiosity" implies, though, that there's more to the subject matter and it's presented in such a way that people learn diagnostics, testing, fixes, workarounds, troubleshooting for the material, in addition to the material itself.
I like Head first design patterns - they simplified the whole process with various textual and graphical additions
It seems like a lot of students who take a programming course never, ever use a debugger as part of the course, for example.
For me it's very personal because it depends on how much you want to "influence" another person
Because it's basic communication - Do you want the other person to understand you?
I would also make the distinction between the motivation and making the material interesting
lol, many don't know how, it takes time to practice
It was long ago. I'm very old ๐ And i've reseted, since.
Meanwhile, count how many times people post wherever, asking for help. The first thing they'll say is "the professor is terrible" or "lazy" or "not teaching anything".
How would you define it?
An interesting aspect is "The student effect" [I'm not sure if that's the name].
That even professors when taking a course act like punny students
motivation has more to do about what brings me to it and make me want to acquire that knowledge
interesting has more to do about the pedagogy and how the materials keep me interested and not make me want to switch to a more rewarding activity.
I may be very well hyper motivated to learn something from the presenter, but if the materials are dull or not relatable, I may pay a lot less attention or just leave the room
You mean teachers need to make things more interesting but students need to be motivated?
if the teacher is actually doing a bad job, students usually don't complain about it, it seems ๐ค
I always try and relate to real world applications as much as possible instead of "If billy has 5 apples..."
(at least in this community)
I would imagine its because theres little a group of students can do even if they do complain, its easier to move on and self learn
like, sometimes you see a problem or a quiz so terrible your hair starts dancing
Like repurposing a quiz from a different language
I've never known students not to complain. Socrates himself could teach the class, and they'd be pissed about something.
recent example:
Python
we don't know the answer
but none of the options make sense
First, the statement "a variable occupies N bytes of memory" is nonsense. In Python, every variables occupies the same amount of memory. But objects is what they're probably talking about.
It's actually not defined in the language spec how much memory each of them occupies. So the question does not have an answer, even if phrased correctly
Heh
Second, there's no such thing as "integer variable" in Python. In Python, variables don't have types, values have types.
I had a similar question in a Java class. Most of the same problems: we don't know the size of any storage, since its below the implementation line in that language.
It seems like professors often don't review their materials, hand-outs, quizzes, tests.
I do know that every Python list is allocated with enough space for 4 items. I'm a bit annoyed that I need to know that, though.
You dont need to, and isnt it 8
I do need to, because I'm using Python inappropriately and I have to care about low-level details. And it is 4.
Mm yeah its 4, 8, 16...
Yes, I mean when the list is first allocated. And the growth is a funny schedule that starts out exponential but then changes. Fortunately I don't need to know that.
Something like that.
I often see the presenter/teacher giving their talk without putting themselves much in the shoes of the attendees. At the end of the day, it's a multi-party system.
As an example giving a deep dive to a non-technical audience is a recipe for disaster, and so is giving a broad overview to a technical audience.
Yes I agree,
Undetstanding the audiance is the first key
Hm actually it does start out as 4, 8, 16
https://github.com/python/cpython/blob/main/Objects/listobject.c#L66-L68
Objects/listobject.c lines 66 to 68
* The growth pattern is: 0, 4, 8, 16, 24, 32, 40, 52, 64, 76, ...
* Note: new_allocated won't overflow because the largest possible value
* is PY_SSIZE_T_MAX * (9 / 8) + 6 which always fits in a size_t.```
not sure if it starts out with 4 items preallocated though
can you elaborate on why you need to know that lists start at 4 elements?
I'm using a whole lot of short lists, and it's nice to know that they get pre-allocated to that size, and won't be reallocated.
i see, you are nearing the limits of your RAM?
No, but I'm writing code for performance, and allocations cost cycles.
it's unusual to count cycles in a Python program, but I'm glad list allocation is working for you
I told you I was using it inappropriately ๐
have you run your program with PyPy?
hm, how is this pattern explained?
also I think we're moving into #internals-and-peps
Is it counting the size of the integers? I don't know what Python's integer implementation is like, except that it's some kind of BigInt, which must secretly be an array
That is not included in the size computation (and generally doesn't make much sense, because an object stored inside can have have multiple references)
sys.getsizeof([[[[[]]]]]) is also 64
odd, and it started doing that in 3.9. 3.8 gives 56, 64, 72, 80, 88, 96, 104, 112, 120, 128
Were there some changes to BUILD_LIST and related opcodes maybe?
It seems like it just stopped preallocating exact chunks, following the standard growth rates
sounds like a good sign that one shouldn't be relying on this ๐
it also looks to me like it doesn't start at 4, however I make a list, the first append changes the size. @green warren might be relying an a false belief.
I didn't make a claim about the number of bytes, but the number of elements. I was wrong in that an empty list is created empty. But as soon as you add one element, it allocates space for four. At least it does on my system in Python 3.9, where 56 jumps immediately to 88 (and 88 - 56 = 32, or four 64-bit pointers)
56 is kind of an amazing size for an empty list, to be honest.
every object has a pointer to its type, and a ref count, and lists have a length and a pointer to the vector of references.
though i can only see 5 8-byte members: ref count, pointer to type, length of list, pointer to vector, and size of vector.
Yeah. This is interesting, but it's pretty far off topic.
yeah
this exists?
No, you are dreaming. Wake up!
Though strictly speaking, you can't prove that anything other than yourself exists, though if that were the case, you already have all the knowledge you could possibly obtain, and the experiences you perceive yourself to have are only unlocking knowledge previously unavailable to your consciousness.
haha funny
the other 16 bytes are probably from the gc next and prev pointers
Include/internal/pycore_gc.h lines 11 to 20
/* GC information is stored BEFORE the object structure. */
typedef struct {
// Pointer to next object in the list.
// 0 means the object is not tracked
uintptr_t _gc_next;
// Pointer to previous object in the list.
// Lowest two bits are used for flags documented later.
uintptr_t _gc_prev;
} PyGC_Head;```
I've had a few profs who taught CS in python who barely knew the language themselves. Basically used it as pseudo code, but not pythonic at all
And those questions about mem allocation of variables also feels very much resulting from this
You need to come up with some questions to check if people paid attention, you pick some seemingly interesting tidbits you found on the internet
Without realizing that memory allocation is not straightforward in python at all
I always encourage people to think of python as a general tool, think of questions or problems that might've been bugging them that could be solved or automated by a machine
And then come from that angle as motivation and goal, then start the journey in that direction
Teaching DS and algos, general functionality etc without a goal doesn't trigger the dopamine system as much
Yeah, this whole discussion about how many bytes are allocated for a list is of course missing the fact that the Python memory model is way more complex and is not really based on allocating one thing at a time. Python grabs whole chunks of memory and then divides them up into pieces.
Well, so does C
https://paste.pythondiscord.com/sazoqegoxu.py this broke me i was inspired by codebullet's video and an mit github post to make my own but i ama broken man today do check out my code
This doesn't appear to fit the channel topic at all. This channel is for programming educators to discuss ways to better approach educating students.
i am so sorry i didn't kknow am new here
No worries. Check out the #โ๏ฝhow-to-get-help channel to learn how to work our help channel system.
wah
the thing is its so nonspecific, and it teaches people to generalise
But in C, you're getting memory -- not objects.
I worry that it's much more serious than that. In computer science, we deal with abstractiosn and representations. We need them to hide complexity that we're not conerned with at the moment.
Python makes a promise about memory that excuses programmers from needing to worry about that level of memory management. There is no contract that guarantees any particular answer to that question.
Sure, you can go look at the source and figure out what pattern List uses when growing or allocating memory.
But you've also got to understand that implementation detail changes on a whim. It's not guaranteed, it's not documented, it's not the part of any kind of contract.
A professor who's asking these kinds of questions doesn't understand that fundamental fact of implenntation and dependency and complexity management.
They don't understand computer science, funamdentally, really.
Maybe that's harsh ... but, at least, one of the very fundamental tenets of applied CS.
Hello, has anyone deployed mediapipe pose detection python code using flask for websites. I am facing a problem that the output video streaming with landmarks is lagging on the website. I am trying multi-threading, however, I am facing difficulties. Can someone share their experience on tackling such a problem
That depends on how you define "objects", really. That's either trivially true because the C language doesn't have anything that you'd consider an object, or untrue because you can malloc the space for a structure, or an array of structures, or whatever.
But my point was that, just as CPython allocates memory from the system in big chunks and manages it in pools, so does malloc.
BUT! I think we can all agree this is the wrong way to teach. Focusing students at some trivia like this doesn't help them build an understanding of the language, or programming in general. It's the wrong thing to cover.
While this case is obvious, what other cases are sublte? When do professors or cousewear-writers make the mistake of teachnig the wrong thing? How can we identify those cases? How do we fix them?
Yeah, the CPython growth strategy for lists can be interesting as a case study for a production quality dynamic array, but beyond that it's trivia and implementation details
malloc() returns void*. It doesn't return any kind of usable data type. malloc() may or may not allocate in large pools and suballocate; there's no standard for that. The only contract is that you got the memory you asked for.
Sure. I agree it's implementation details, but every real world malloc implementation has arenas and manages memory in pools. You could make an implementation where every malloc() call makes a syscall to allocate new memory, but it would be terrible, so no one does.
Same's true for Python; maybe List() gets just enough memory for a list object; maybe a lot more, maybe less. What it does at that level isn't any part of the language defintion.
every real world malloc implementation
Sorry, but this is objectively false. You need to look no further than the tiny C compilers for Atmel or Microchip microcontrollers, for example. And it's really irrelevant to this discussion and the topic of this sub, even if it were true.
Hm. Well, fair enough, though in the embedded case there's no "system" to allocate memory from.
But I agree it's not exactly on topic. I was just pointing out that the fact that Python uses memory pools is not different from malloc() in a typical userland C application
I agree with your points about the dubious value of teaching students anything about implementation details, beyond as an interesting case study.
I don't think it's dubious; I think it's unambiguously without merit.
i agree that question is premised on a category error but to play devils advocate, maybe there is some value in just getting beginners to make the connection python objects are data literally stored in memory
That connection can be established in a much more direct way.
yeah for a beginner class trivia about implementation has no merit
And it should be obvious, anyway: if a program stores data, then it's using memory. Where else would it store data? How could Python objects possibly be anything but memory?
Asking a question about the storage size doesn't establish that relationship because it draws focus on the exact size ... at least, the relative size of different objects, from the the way that question was worded.
Beginners don't exactly know what memory is.
its obvious to anyone moderately experienced in programming or computers, but kids are abstracted away from those things in every day computer use, and many beginners struggle to understand the concept of objects apart from the literal python syntax in the py file
When you learn a C like language, you learn an abstraction where memory is like a big array, and pointers are indices into that array. When you start with Python, the entire concept of memory is foreign and needs to be introduced.
I've been trying to find the same question in the class I took. It was for Java. I wanted to burn the place down -- so frustrating!
Maybe. But then I think that means we're teaching things in the wrong order. Students are being asked to write programs when they don't even know how memory is organized, what the processor does, what the machine architecture is or what the computing model is.
well... it's just wrong ๐
if it was (True), ("True"), ["T", "R"..., (1)
the problem with trying to teach that first is that a younger person is probably going to get extremely bored by it, and introducing them to making stuff right away is much less boring
that'd be better. but it isn't even a good question because it'll never be helpful!
Here it is. Now, I can finally vent! ๐ This was in an Algorithms class, which my school for some reason separated from Data Structures. Taught using Java, and the Java version of the Sedgewick book.
...or which frequencies correspond to off/on
i dont think it's always necessary to reopen concepts neatly dealt with by abstraction
Frequencies? Wha ... ?
or voltages or whatever
see? i dont need to know anything about EE
Voltages, yes. You could use a frequency (or a phase, even) to represent a one or a zero in an RF signal.
I'm not so sure I agree. People who use computers know that data takes memory. If a one-page letter in Word creatses a 350 megabyte file, they know something's up. Look at any forum where people bitch about how much memory Chrome uses, for instance. They think 1.5 gigs is too much, but they have no estimate for how much it should use. They're unaware of everything the browser is doing, how memory works ... but they do know that data takes up memory.
Python code like ```py
x = []
x.append(x)
print(x is x[0])
Either way, it seems like teaching CS majors should start with what's usually in a "Systems Architecture" course. What's the processor really doing? When I think of a program or algorithm, what am I really asking the machine to do?
That's usually a second or third year course, for good reason I think.
What would be the point of showing a beginner such code?
For what good reasons?
yeah i disagree with that, the connection to what they see as the final product of programming will be totally missing
You can't reason about how a processor runs a program before you've ever written a program and interpreted it in your head.
isn't that exactly what an architecture class teaches?
If you don't understand the concept of a conditional, learning jump instructions is a bad place to start.
Sounds like you're thinking of the ordering of specific small topics within an architecture class, now. I can't figure how that supports your claim that the architecture class should be taught later rather than sooner.
There isn't necessarily one, beyond that, once people are ready to outgrow their incorrect mental model of how Python object references work, it's an incredible self contained example to show that they've had it all wrong.
I'm not. I'm saying that assembly (or machine code, if you prefer) is a bad first language, which doesn't seem like a controversial claim to me.
Are unis that teach systems architecture in year 1 common? I don't think I've ever heard of one
mine was year 2
Mine too.
Nope -- and I suggest that's a problem. The ACM's standard curricula (which is what accredited colleges mostly use, in the US) puts it in the 3rd year.
So... What makes systems architecture the ideal level of abstraction for introducing computing, in your mind? Why not something lower level, or higher level?
"ideal" is your characterization, not mine.
You said "should", which I understood to be your opinion about how things would happen in an ideal world
I think that intro to programming classes -- CS110, or whatever it ends up being -- can be augmented by architecture learning in a very useful way.
Books like Code or Understadning the Machine have an important place at this level of the curricula.
why?
Straight to one of the Patterson books? I don't think that's necessary. But discussing the underlying concepts of information theory and computer science seems like the obvious place to start.
Why?
Because they establish important concepts about programming: information representation, system organization, computing model, and so on. The explain why so many concepts are important. Why do we use binary, for example?
In conventional curricula, these ideas are left for later -- either for the student to swallow whole, or for them to reason out themselves later.
Grade school students don't learn why we use decimal before they start learning arithmetic. Why should computer science students learn why we use binary before learning about functions and control flow?
For that matter, history classes don't start with Babylon.
at the risk of committing heresy, i think the comparison is even more apt because the use of binary in computing is almost as arbitrary as the use of decimal in grade school arithmetic
Assignments in those classes are usually pretty simple. They're intro classes, after all. Read a file from disk, sort it line-by-line, print it out. Or get a number from the user, n. And print out a christmas tree with n rows. n == 3:
*
***
*****
Students with no understanding of the computer -- what does it even do? How are programs structured? -- don't understand what means to "read a file" or "loop". Yet we expect them to jump right in to Java or C++ or Python or whatever language the class is using and solve these problems.
Their natrual ,and understandable reaction is to wonder why it's so hard. The have no framework for decomposing the problem into smaller problems or steps becaues they don't understand what those steps might look like. Why isn't there just one step: "print the tree"?
I think you've assumed an ordering that I didn't suggest.
You need to start at some level of abstraction. You've asserted that starting at a very low level would be better, but you haven't explained why you think so, or why you've chosen that level instead of an even lower one, like the subject of electricity and transistors.
for simple tasks in an intro course, you don't need an extremely detailed low level understanding. a simple "layman's" high level understanding is enough. a loop simply repeats some actions. there's no need to know exactly what machine code is produced, because they understand it at a high level
Right -- I'm suggesting a high-level understanding of the low-level concepts.
When we teach people how to drive a car, we don't start by explaining how a drive train works.
I think that's pretty obviously a broken analogy. CS isn't teaching people how to drive cars. It's more like teaching them how to build them.
i'd even say that a python loop is a self-contained concept on it's own, that's why the python language doesn't need to specify an implementation
Simiarly, elementary kids are learning basic mathematics -- not number theory. CS students are a lot more mature in thinking, and are a lot closer to learning number theory than learning simple mathematical operations. (In fact, Discrete Mathematics is often a part of CS curricula.)
When we teach people to build bird houses in wood shop in school, we don't start by teaching them how to fell trees or process them into lumber.
Or why birds like bird houses ๐
Sure. But we still need to explain that the computing machine is discretely executing instructions step by step. Maybe the instructions are larger or smaller; maybe the organization of memory is more or less abstract. But explaining those things is absolutely critical to building a usable understanding of what program execution means.
Perhaps a better analogy: when we teach people to cook, we don't start by explaining the molecular reactions that make eggs whip up or steaks brown.
Of course not -- because we're sensible about choosing the abstractions we use, and those we take for granted in the context of the class. The only reason someone would suggest otherwise is to make an absurd argument to the contrary.
Sometimes, we do: Chemistry of Cooking or Cluinary Reactions, for example. Salt Fat Acid Heat, too.
what are you arguing about?
the proper abstraction level for CS beginners
I know you're being glib, but it does depend -- different people learn in different ways. But the educational system and the curricula it delivers doesn't care about that: it's invariant for each stduent.
Ok, but I've asked you why you think the systems architecture abstraction is a better abstraction to start with, and you haven't really answered that.
You're asserting that we should begin at some particular level of abstraction, but not supporting that claim at all, nor explaining why it would be worse to start at a higher or lower level of abstraction than the one you favor.
I think my assertion is a little simpler: that an exposure to fundamental system organization and architecture concepts has a place earlier in the curricula for CS-path than is usually delivered today. I make this claim because I think it's important to acknowledge these topics as a key to understanding even simple programs, rather than deferring that understanding to after those concepts are delivered.
This assertion came back to me with various disingenuous analogies, but I think it holds water. I'm not suggesting that we start with a hard-core architecture class; instead, that something like the first chapter of Structure and Interpretation mushed up with topics from Code and Understanding the Machine be covered at the same time (just before, I guess) students are introduced to their first programming language.
Would you put "what is memory and what is a CPU" ahead of "print('hello world')"? Ahead of x = 1 + 2? Ahead of functions? Ahead of recursion?
I never said I would.
You haven't said anything concrete, that's why I'm asking
Instead, I'm suggesting they're used to teach each other. If we start with x = 1 + 2, we're obliged to explain what x is.
Sorry, but this is a suggestion. It's not an implementation. I can't point you to my textbook or lesson plans just yet.
Intro to programming books will typically talk about data types and assignments and xpressions; then hurry on to loops and branching and conditionals.
Instead, why not take a beat? Introduce expressions. Explain where they're stored; explain the difference between code and data.
Explain that, after each step, we're in a known and consistent state.
Then introduce what other steps there are -- loops and conditionals and so on.
hm would you pick python for the language in this curriculum?
I think there's a lot of ways to reach that goal, which is why I've talked about the goal rather than the concrete steps to get there. The goal itself (cover the organizational and model fundamentals) is more important than the prescriptive steps to get to that goal.
I don't think the approach I suggest is incompatible with Python -- or any other language, really. So, why not?
So, at the point of explaining x = 1 + 2 to a student, how would you explain what x is?
i think that python is a great first language, but it's further away than some other languages from the stuff you'd be trying to each alongside it
so I'd be worried that you'd be introducing unnecessary complexity by using python and erasing its benefits
It's an entry in a globals dictionary with a reference to "x" as the key and a reference to 3 as the value, which is an explanation that I don't think can be brought down to a level a beginner would understand.
i.e. the relatively clean separation between python and its implementation
explains why I had so many accidents at first
would be nice if the projects were usually shown as projects (how theyre organized, how to make Python version work only for this , how to read the documentation, its a foreign "language" and its being taught like math)
Generally we are constantly talking about almost bare beginner stuff, but there is already so much out there for it. I suggest we talk about intermediate python and advanced python.
There is almost nothing or rather splintered or bad stuff out there for anything above beginner.
The first thing to talk about could be what is actually beginner, intermediate , and advanced python.
I think the distinction between them is useless to make. My personal division of resources goes simply as "beginner-friendly or not so much?"
Like Alton Brown of Good Eats fame
Accidents scare off people from driving and likewise minor accidents in a computer class might turn off students from the topic ... my mom studied how to drive then hit a tree then never ever took to the wheel again....
(for the record, I've never been in a car accident.)
i agree with dawn here. what's the point of making these divisions past the beginner stage?
I read that as "how to drive a train" and got really confused ๐
The difference between driving school and learning to be a mechanic....
Dont mix the two lol
Python is great for learning to drive...aka programming...less accidents waiting to happen unlike C , Java...focus on the road....eg core logic, variables , loops, etc
it is actually quite analogous to driving manual vs automatic
at least here in the states, almost no one drives manuals anymore
C, C++ For mechanics who want to build cars like compilers and interpreters
And those that have a need for speed and are not afraid of 'accidents' like memory leaks
Lol manual vs automatic memory management /garbage collection
dynamic typing though...
That's one manual bit
"We don't need street signs or road markings, drivers should just know how fast to drive and where the road is. And if they park in the wrong spot, no worries, we'll just remove their car"
My mom learned to drive with a manual and I think it was a bit of confusion with the reverse of a stick shift that made her hit a tree and never drive again
To be fair, there is an idea that making the road appear more hazardous can lead to more safety. But not sure how well that applies to complex codebases
to be fair, if it looks like a parking spot, is big enough to park in, then it is a parking spot.
(but that's taking it a bit far)
until you get towed
garbage collected*
Although in the context of that analogy, that would only be a runtime exception, no different than when trying to mix the wrong types together
I don't think it's so hard. A "dictionary" is a pretty familiar concept to build on in explaining it.
I'd do so in a way that's compatible with the future concepts of main memory and memory allocation. The goal is to lay a foundation that can be built upon and tied together, rather than to leave vague pockets of information (or unknowns!) as gaps in the framework of the student's understanding.
I think the globals part is whats gonna trip up most beginners
Then we find a way to explain it, and help.
The negativity seems remarkable. Maybe the overarching "can't do it" and "shouldn't do it" attitude is why teaching seems so difficult; why few are interested in investigating and experimenting with improvements in the pedogeological arts.
Me, I think scoping is a bit harder to understand than global visibility.
aren't they related
But it highlights the issue of finding a path. We have to talk about functions (and modules, or whatever other scoping the language offers), then talk about variables, then talk about lifecycles, then describe variables in the first place ... all with a mind towards erasing the lies we've told when we need to findally describe low-level addressable memory and machine stack.
What's the best order for doing that? I've been questioned that it's difficult to describe A before B. And sure, it is -- or it can be, without care. But in what order should things be described?
So many students learn about pointers in C, and get stuck. They have no idea what the concept means or how it can be applied.
All those students are saying is that they don't know what memory really is, how it works, how to manage it (or how it might be managed for them).
When I was in second grade, I claimed that there was such a thing as negative numbers.
My teacher insisted they didn't exist. That 2 minus 5 was just impossible, and I shouldn't engage in such nonsense.
I brought in a pocket calculator -- at the time, worth probably $50 or $80 -- and demonstrated: 2 then - then 5 then = showed -3 on the LED display.
Despite my demonstration of a concept at least two millenia old, I was sent to the principal's office.
A few short years later, kids who demonstrated that 8 * 17 * 39103 == BOOBIES were subject to no sanctions.
And so I think we must be careful with some abstractions. If a student isn't pursuing a CS degree, maybe they just want to use Python abstractly to analyse results from their physics or chemistry equiment, or try to run simulations in the stock market or anaylse stats for a psych study.
They don't need the details. But a CS student must come to understand the machine architecture, sooner or later.
Why unwind lies?
Might it be for the sake of progress? If the entry material is more challenging/difficult to grasp, the overall progress could be slowed
is it quicker to teach a simpler concept, and then unwind it to explain deeper, or is it quicker to jump right into the deeper ideas?
It depends on the audience ...programming has gone beyond CS....many Science Majors like Physics, Chemistry and economics use computers to model physical systems and use Python, Matlab , Fortran and even sometimes C and C++ but the latter two are rare since memory management is a hassle
WEll, sure. We all use abstractions for progress. We use them to ignore things and focus somewhere else.
But an abstraction -- even an insufficient one -- isn't a lie.
It might have them forming a different mental image of the concept, but that's ok
To a point. If that mental image is incompatible with reality, then it's harmful.
For a general audience Python is easier
If it's a little off, not perfect, no bigs. But wholly incompatible? I insist we can do etter.
but it's compatible with their current tasks
Python is easier ... than what? Not sure of your point.
The mental image they have should be solid enough for completing their current tasks. As we dive into deeper topics, we can slowly replace pieces of that image
I must have missed the part where "lie" is used, where is it mentioned?
For a beginner ease of use is important
Indeed, that's why I contrast between CS-track people and others. For sure, if I'm doing analytics for whatever, I just want to learn the language and whatever library I've got. No need for more ... even when I hit a performance problem, I can get help without learning the deets.
I'm purely a python coder. I know there's deeper knowledge out there if I go the path of the C languages, but I'm happy in my ignorance
OTOH, if I am a CS (or maybe Systems Engineer, or Electrical Engineer, maybe a few others) I do need to understand the details.
CS track people should indeed dive into C but for a first language at High School Python is better since not all will major in CS
That's one of the few places where manual is so much worse (imo, anyway).
wait no what
I don't know what I'm saying
manual is worse a lot
please ignore me
Note I learned C before Python
Who's next to the right? Gauss?
Yes they do
Sure. I think that very first class should help set expectations about the degree paths.
People who love that course are likely to be natural born CS-killas. People who hate it are probably better off with another path, another vocation.
I had a Java class in highschool and hated it
Many others had that experience unfortunately I think
Why Python at high school is better
I'm taking a Python class in HS right now, and it's kind of annoying how the course doesn't use proper python idioms
e.g. the number of times they use camelCase istg
I feel like that part is really important (the idioms), because they help with reading code and writing readable code so much
And programming is just as much reading as it is writing, if not more
And programming is needed almost everywhere
You dont want to turn off people from programming with a hard first language when they are still uncertain of their majors
Let me rephrase that:
There a bazillion tutorials about how to unpack a tuple and stuff.
Almost nothing for:
-
Meta-classes ||I know
Metaclasses are deeper magic than..., but at the same time a lot of heavy used and praised libraries and apps use them and nobody is complaining there|| -
Mixins ||same as above, they are vilified as
badbut a lot of praised libraries use them, I even saw django mentioned as a library that is perfect to readgood codeand it is completely Mixins|| -
correct multiple inheritance ||same as the two above||
-
python tricks (ala descriptors and dunder stuff) ||I repeat myself, people say this is bad but will use any ORM all day, that does this||
-
protocols and ABC's
-
more advanced decorators than just time the function or print the args
-
extensions, via hooks or via runtime importing
-
importing stuff that is more than
import os -
packaging as a whole, but just a well structured and mostly complete packaging tutorial
-
peripheral stuff like cython
-
Project structure that not only goes beyond
use this cookiecutterbut also maybe shows different approaches to it -
In-depth GUI
-
correct documentation that goes beyond just generally saying how you technically do the documentation, but also what to write with real life examples and package documentation (ala sphinx/pydoc/...)
-
type hinting, omg a real good type-hinting doc ||please do not say the mypy docs as they are quite confusing see #type-hinting ||
-
Concurrency in all its forms with examples that aren't just
sleep(10) # this should simulate work
...
- And last but most important: Performance considerations, that are not only up to date, but also collects all the tidbits in a place and give concrete tips and examples
Don't care what it is called, but this is what I mean and everything beyond the basics is basically a desert in regards to good courses/tutorials/docs.
that's just not true
there aren't really any "intermediate programming tutorial" videos, sure, but that doesn't mean there's a lack of resources. they just tend to be more specific to a specific idea. they're also less approachable, stuff like docs or blogs
thats what I meant with fractured
Docs are less approachable? Than ... videos?
so what are you suggesting?
If you want to write a tutorial, do not write another basic tutorial but maybe do something like collecting those fractured ideas (maybe as a group effort) in one place and rewriting them to be less abstract (explaining instead of reading the docs for a class that just also does the thing)
In that case, why not focus your efforts into improving the docs?
If they're not helpful at the current moment, then you should leave the docs as the single source of truth, and just make them better.
I argued that docs for a library aren't really useful in teaching more than to use the library. I am arguing for exactly what you suggest.
public static void main argued for
you can find that in some docs and ...
Once you get past the "basics," a tutorial is only so helpful. To make something useful, you need to know how to take the build blocks and apply the glue. That's not something you can teach. The best you can do is make the building blocks nice to use.
If it wasn't clear, the metaphorical building blocks could be the "more advanced" features or various libraries or whatnot.
Ok then in the spirit of this channel :
how do you identify the blocks of various "advanced" concepts and how do you approach recombining the blocks for use?
Maybe my analogy was unclear and only makes sense to me. My metaphorical blocks are different features or libraries or anything you use, really, and the metaphorical glue is the code you use to combine them.
Each application will require you to write different "combination" code, so tutorials aren't really useful at a certain stage imo (unless you're doing exactly what the tutorial was made for).
That's not a skill that can be taught, it takes time to learn. I think that the only thing we, as a community, can do to help with that is make the individual "blocks" easier to use.
Timing the function decorators were very helpful for me when learning decorators, I'm not really sure what you'd mean by teaching more advanced decorators
I think you mostly just teach the concept by basic decorators, decorators are more of a case-by-case basis
Amen brother. My coworker told me one "like what the hell would I ever use a descriptor for". Then he goes and uses param library which uses them extensively
Understanding descriptors is a key to a deep understanding of Python because they are the basis for many features including functions, methods, properties, class methods, static methods, and reference to super classes.
Doesn't everyone use descriptors?
no, not really
I only ever make descriptors for fun, it's not a need-to-know concept or anything
Sometimes the icing on top is all you need, no need to dig into the cake
but almost no one needs to make their own
Melen's coworker didn't make their own, did they?
huh?
Yeah, they didn't make their own.
I SAID: MELEN'S COWORKER DIDN'T MAKE THEIR OWN, DID THEy?
oh, i missed that context
@coarse thunder Hi, this channel is for discussion of the teaching of programming. #python-discussion or #user-interfaces or #game-development would be a better place to ask.
@coarse thunder you are continuing to write off-topic messages. please refer to dawn's message about which channels to refer to, and DM @viscid mural if you have any questions about that.
You don't need like 9/10s of the python data model, but didn't make it any less useful
@sage estuary thank you for your willingness to help this person. Please do not prolong off-topic discussions.
in this case specifically though, you don't need to anything at all about descriptors to use classes and methods
Reread what I said
This specifically
He wasn't talking about know how a descriptor works at all
But why would he ever use one
Much to omar's point we all use them all the time and then he goes and uses one specifically from a library
param.Parameter is a descriptor and is literally the point of the library
Wow, deleted and everything?
Why do descriptors have such a bad rap? (Or is that off-topic, too?)
Also: my eyesight is terrible. I can barely see emojis, so all I have is the descriptive text. Which is "scboplaugh" and "pepelaugh". What are those symbols meant to convey?
Sorry @coarse thunder, I am unable to provide help in DMs.
Wait, what? Why do I deserve that?
https://www.latimes.com/politics/la-na-pol-pepe-the-frog-hate-symbol-20161011-snap-htmlstory.html
They don't have a bad reputation as fair as I know, I love what you can do with them. It's just that it's an unnecessary topic to teach so early on imo
It seems like there are many strong opinions about what to teach earlier or later.
They range from "A should be taught before B", or "X is a terrible beginning language and that's not controversial".
How do people arrive at such opinions? After all, they can only learn programming once, so it can't come from experience.
Is there any more subjective information about these things?
People will draw analogies. "We teach children J before K, and that's sthe same as B before A!"
But what research or studies are done on these subjects?
It can certainly come from experience that's not just you.
Teaching others can also provide the experience necessary to make such judgements.
Can it? That implies everyone learns in the same way.
Or, at least, that we identify people who learn best in certain ways, then correlate that against how they tried to learn, and measure their success quantitatively.
Well, nothing will work for everyone.
That sounds hard.
We'd also have to isolate history. The languages available changed over time. For a time, everyone learned machine language first, since that was the only language available. Period! It's what I learned first in the 70s, since it was the only language available to me.
Lots of people in that era learned languages that are dead or despised now: BASIC, Pascal, COBOL, for instance. Those people didn't have such a hard time learning about computers, and went on to contribute (very!) positively to the field.
There were many less layers of abstractions in these times as well.
So going bottom -> up or up -> bottom didn't matter as much
It's also reflected in the projects written by the students. a few years ago, writing a socket based program was huge. Now people are doing DL based video classification and analysis
Yep. to me that sems like an advantage. Expectations were much less, too. New developers didn't have the goal, for example, of writing a AAA game title.
What's the best way to learn or get into machine learning?
Are such projects teaching much? they're really just gluing a video management library to a cloud-based platform. It's integration, not development.
Which is valuable, at some level.
"Best"?
or beneficial way?
tbh, I didn't really thought through my example and that's not really a great example. The point I was trying to convey is the complexity and scope of today's projects are so much higher than they used to be a few years ago.
Anything you do will be beneficial. Most people fail because they don't stick with it, not because they chose some path that wasn't somehow "best".
like are there any resources that you would suggest
Why not take a class at your local college?
There are also any number of courses on Udemy and whatever other online service you can name.
I learned from Machine Learning, by Mitchell. It's a classic. It's out of print, tho, and hard to find.
Learning from Data is very good. By Mostafa, et al. Fundamentals of Machine Learning is great, especially the newer edition. Kelleher, et all.
What's your goal? Are you thinking of a particular project? Some particular problem?
Because typically, teaching the "behind-the-scenes" of something just after teaching the basics of another thing makes learning confusing.
Like teaching the print function then talking about how flushing works and buffers work etc
Unnecessary information that will just confuse the students
Well, I think it can be easy to identify what things should be taught sometimes.
Flushing probably isn't important. OTOH, if we're teaching a class in C++, and insisting that students use iostreams for input and output, it's totally necessary to teach about flushing because their programs will break in weird ways if they don't understand what's going on.
And they don't have the tools (knowing how to use a debugger, knowing how to debug into/from standard libraries) to diagnose what they've done wrong.
For other platforms not so fussy with buffering, it isn't important and would be confusing.
Is there nomenclature for this? How do we reason about identifying interedependent ideas, and ordering them in a curricula? What I worry about are situations when the ordering isn't quite so clear.
No just learning before I go to college
but thanks
I belong to the Basic, Pascal and Cobol era and yes was part of Y2K migration of a VAX cobol system to FoxPro (lol another dead language.. GW Basic in High School , Pascal and C in college and had a special project in VB 3.0 ( dead lang) in college too.. Learn Python, C# and JS after that
It is something like curriculum design and proper labeling of course prerequisites and desired course outcomes. A curriculum designer should look into these matters where the optimal ordering of the topics or courses is unclear
Does anyone have recommendations for online Python courses that also incorporate some aspects of software engineering? While I personally have tutored Python in years past to people already enrolled in classes, Iโve been asked to recommend a course for some electronics manufacturing technicians to learn Python alongside modern best practices in software construction.
I disagree - although most would agree with you, especially teachers - I really have problems understanding "magic". Like- I just can't wrap my head around something being how it is without explanation.
You're literally better off explaining less so that I think I know (the less you get me to think about it, the better), but wouldn't be able to explain it to someone else. It's why in movies, especially with science fiction plots, there's often a lack off scientific explanation and because the movie characters accept and seem to understand it, you do too.
I never understood methods for classes (like at all) and the difference to staticmethods, classmethods and properties, until I learnt about descriptors.
I think we should stop thinking about the right order of topics that will work for everyone and instead teach the tools and resources needed to drill down if they desire or require. That means debugging, documentation, profiling, introspection.
With those tools you can learn those details on your own whenever you feel curious or required by practical necessity.
My point was, that I hope that this channel gets used for teaching the full language and not just beginners.
It somehow got construed to โi want the concepts I posted taught to beginners/earlierโ.
It is not, I just think we should also talk about how this languages more complicated features get taught, when they get thaught.
Step-by-step debugging should be taught in the very first session. Tools like ast and dis in the second. And then go from there
Yes! So many people try to learn and get told to "read the docs" but don't know how!
Whenever there's a question about internals, they then are able to answer them on their own
Eh, ast and dis is more-so implementation tools and is useful for optimizations and internals but not much more. You may have included that in your "step-by-step" debugging session but reading tracebacks is an ever-so important skill to have
Too many people see errors and stop everything and think "ahhh error, but this should work" then either give up on that approach or ask in help-forums like these.
Well, ast and dis I would mention and show a quick example but not go in deep
Anyone who's curious will look further on their own, people who don't care, don't have to know
Not only is it less fun to help with (compared to other things, pointing out a typo is not as fun but undoubtedly equally helpful), it is also not as fun to ask about. It's a bit of a waste of time on their parts as they wait for an answer instead of reading their own code.
But even those will have heard those terms and can google if needed in the future and don't be completely dumbfoundef
Ah yeah that I can agree on
True. And they need to learn that a new error means progress 
running your code in your head is another important thing to learn to do
I also would show the data model page of the docs very early on. It's one of the most important pages imo and gives you a good idea what's possible in python and reduces dunder-anxiety
without fanning long cold flames,
Refering to google to solve problems in python can be confusing.
One of my first questions that I searched for:
how do I iterate through a dict as key, value pairs
Answer I found:
easy, dict.iteritems()โฆ
Or recently:
is the range function a generator?
Answer:
no it is not.
Further down
you have to use xrange
Please always make sure to tell people to check the time when the answer was posted.
Oh yeah, definitely
Exactly what I said the other day, yes
Was so frustrating when I tried to work out a problem with pyqt and all the answers were outdated and had to be pieced together
But that's definitely not a problem only beginners have to struggle with
Sadly it is rather convoluted wall of text that has many self referential links ( a link under a subheadline leads to the exact same subheadline), also some confusing structuring. It is clearly thought of as a lexicon you ctrl f to the part you need and not a learning aid.
You learn to work with it, but I wish there would be some better structured version.
Pyqt is a special case, many version and all those versions in essence times 2 (pyside vs pyqt)
True, there could be a beginner-friendlier version, but it's still the page I visited most often from the docs over the years
Maybe a wiki of sorts that link to concepts related to a certain dunder?
There is a page, need to find it again , that explains dunders real well with examples and good site design, but it is outdated. Which leads me to a related point, findig out which dunders were changed when is really hard for some reason.
https://rszalski.github.io/magicmethods/
But i am not sure if outdated or not
A guide to all the Magic Methods in Python
Hmm. I would rephrase the whole thing, sounds way too unapproachable.
But the examples interleaved are nice
I somehow have to think of the gentoo documentation
They put an extraordinary amount of work in that
!rule 6
Please message @viscid mural to request approval.
imo a general thing with teaching anything is that there isn't a way to do it that will work for everyone
there isn't just one way to teach programming that will work because different people will understand different things and be good at different things and different explanations will work better and.........
there are obviously some things that will be true for most people and are reasonable things to default to, but if you make a huge detailed plan and refuse to rewrite it according to what the person learning actually needs that you couldn't possibly have predicted beforehand, you're not going to get anywhere
so really if you want to teach programming, you need to be flexible enough to account for anything that could reasonably happen
Which obviously is true, but then it becomes a question of efficiency - I'd say only a big platform like khanacademy has the resources to cover different paths, keep track of individual progress and customize their approaches accordingly
Maybe I'm misunderstanding something, but I don't think teaching anything is within the charter of this channel.
I think that's true, but I also think using those things mean that you already know the language.
Not necessarily. If you use thonny from day one you can learn to use a debugger without even knowing the word debugger, it can be as natural as typing code in a repl
With jupyter you get a similar effect with the ? Magic for documentation, vars
jupyter for debugging? ๐
Both jupyter and thonny but also other IDEs have good introspection and documentation support
Well, sure -- someone should design the course, and it would be great if materials were reviewed and edited before they were turned loose on their audience.
I think the questions being asked here are about how to best design a class or other learning material, like a book. Various decisions are made in designing course-ware. How can those decisions be evaluated for their efficacy? Is one way really better than another? Is there a "right" way, or patterns we can identify, or ... ?
No, for documentation
Sorry, I just don't get it: how does using debugger without knowing I'm using a debugger help me learn a language I don't know?
I like jupyter for teaching as a field diary
It's incredibly insightful to watch the machine execute one thing at a time
Many concepts become self-explaining, like loops etx
Maybe empirically with a well sampled representative test audience with a beta version of the course then use feedback and course outcomes to evolve it iteratively until it is mature
Do AB testing of various approaches to see what is better
That's really impractical because it's very slow. Also, the results aren't particularly easy to quantitatively measure.
It took me about nine months to write my first book, for example; should I spend six months more or so to write the B-version, then a year of testing and revising, before releasing the book?
Oh, I see. This seems useful to autodidacts; but can it be used to teach others?
Maybe or write a 1st Edition then a new and improved 2nd Edition
So the next batch will get a better book and you obsolete old books and sell new lol
I think so. If you basically let the machine explain what it does, your job as teacher becomes primarily to find good and interesting examples that students are intrigued by
That's an interesting one -- how do instructors do that?
Oh yeah. That's the real hard question, isn't it
Well, that assumes that good feedback comes. So very often, it doesn't. Also, bad books usually aren't re-issued in a new edition because the publisher believes there's no interest or doesn't want to continue to back a bad author. So bad books won't improve simply because they don't get a second edition.
True so need to define a way to measure outcome and ensure the test and control groups are randomized so they are comparable like in a double blind clinical study..
I always try to find examples that people currently are concerned with, something they can relate to, but I haven't got a patent recipe either
Well, I'm not even sure it's possible. Or even the responsibility of the instructor. For sure, examples and themes should be relevant (and maybe that's what you mean by "good"?) but "interesting" is subjective and fickle. It can also result in material that ends up excluding parts of its intended audience.
Tbe perfect is the enemy of the good...weigh options then if the book is good enough release..perfection is near impossible
Most people have taken classes, like at college, right? How did the course material end up being as it is? What was it presented as it is? For sure, this is almost exclusively up to the professor -- they'll specify a book for the class and then completely ignore it. Or follow it chapter-by-chapter exactly. Or anything in between. Are they just shooting from the hip? Are they doing A-B comparisons like tanuki suggests? Or iterating? Or even considering their feedback? What about all of the material they have to come up with themselves -- hand outs, quizzes, homeworks, tests, labs, ... ?
Maybe one professor has a quiz every friday. Maybe another has no quizzes, and just three tests plus a final in the semester. Which is better? How do we know? If we were to write a book on Python, should we try to support the first teacher or the second teacher in the book's structure?
Or give up and go back to R because they realize they suck at python..
Sure. But I don't think I'm pursuing perfection -- just improvement, or at least avoidable flaws.
A prof of mine did, at least
We have conducted an AB test ourselves on Teaching Vector Math with the help of courseware that I made using Python in 2005. Results rejected the null hypothesis and statistical analysis showed the courseware was effective...It was published in a local Physics Journal with me as a coauthor
Neat! Do you have a link to the paper?
I like how you phrased that 
Pm me i will send you pictures of the journal soon as I return home ...it is in a paper form lol. I am in the hospital as the guardian of my mom who will be released tomorrow.. she is fine dont worry but I was stuck in hospital with her since admission
Ugh. Good luck with your mom. ๐ฆ
Thanks looking forward to helping a fellow academic contact me lol
Lol thanks I think writing for journals helps with that
It might help to get some ideas/stories/problems from other areas/departments that students already need to deal with
In pharmaceutical engineering (which I studied) python could've been used to model statistics (monte carlo) in test design or give a glimpse into fluid mechanics..
Enrich dry theory with some hands-on programming
yo ppl sup..am facing a difficulty in coding this so pls help
whats the error in here??
Yo, this chan is for talking about teaching people. Check the topic
omg am new to this
No prob
There are help channels pinned, you can claim
dude do u know anything about coding python??
Yes.
cmon man
If you ask in the main channel, there are enough people who can help you
whers the main chan??
Whats the bot cmd for that, I always forget
Ahh. It's a channel
Nvm
I want my irc back 
I know monte carlo and have helped implement models in C, Excel VBA and Python and Matlab....fluid mechanics hmm have seen in wave energy studies I have helped in
Yes cross pollination of disciplines sometimes is fruitful and might lead to unexpected collaborations that lead to an Academic Paper being published lol like in my case. I saw an opportunity to make a courseware as a Dev in a Uni IT department and I proposed it to the Physics Department. The uni funded our study after we submitted a proposal. We conducted the courseware AB test versus old style lecture without the courseware and we got published
Im actually a Chem major who published in a Physics Journal, worked in a Research lab and spent most of my career coding as a software dev ... so I think could have gone to pharmaceutical eng if given the opportunity lol
Topic: In my experience, object-oriented programming is the preeminent style taught in CS education. Does it deserve this status?
Pretty much all of my programming is either data science stuff for work, and the occasional contribution to the @worldly dew bot. Python's data science ecosystem has classes for the sorts of data structures and tools one might need to use, but doesn't really encourage you to create new Python classes, or to use classes in a C++/Java-style of OOP.
I think the way the discord.py library uses OOP in an intuitive way (there are classes for users, messages, channels, and other things that "exist" in Discord), but the actual code that you write is basically procedures that use those Discord types in response to various events.
Anyway, I think the value of OOP design principles (single responsibility, encapsulation, conceptualizing everything as objects interacting with eachother) are overstated, and that newcomers to programming shouldn't be encouraged to approach problems that way from the start.
Newcomers to programming have very little use for OOP, it's more of a tool for designing larger pieces of software while keeping them testable and understandable.
The level of abstraction is sufficiently good enough that we typically dont add additional classes in DS projects...
Maybe true...I find functional programming more appealing after doing OOP in multiple languages lol
Before the dawn of OOP many learned procedural C and had implemented a lot using it
I mean, you can do anything in C if you're patient enough
I see functional programming and OOP like tools with different purposes. Functional programming helps in the small scale and OOP helps in the large, they don't really overlap or compete much. And in both cases, it pays not to be overly absolutist about either principles or techniques. What @misty dirge said, and also, with respect to functional techniques, sometimes a for loop is better than a list comprehension, for example.
During the transition from C to C++ a couple of profs teaching numerical methods just swapped scanf and print f with cin and cout lol and did procedural in an OO lang
Found it funny that some of them couldnt define OOP and had to ask me but they were scientists first coders second and it was when OO was new
Sometimes it is simply not needed
Big framework type projects benefit from OOP but they arent the stuff many do code since it takes much effort
I mean, OOP is definitely not needed unless your codebase is reasonably large.
If I'm writing a small program in Java (maybe because the jvm is the only runtime environment available on a deployed environment), I don't bother with creating class structures unless they serve an explicit purpose, I mostly have a single class with a bunch of static methods.
Doesn't matter if the language design is hardcore into OOP or not.
I do similar and if I can dispense with the single class i do functional if I can in any lang
Yeah, I mean, I use a single class in Java because you're forced to.
In Python I don't use classes at all until the program grows to a certain size.
With functional it's a different type of consideration, some problems can be solved very neatly with functional techniques and others are simpler and more readable with imperative code.
I have done moderate sized zero class in projects in python and grouped related functions in modules
Yeah, unless you need to model shared state between many functions, that's sufficient.
Like @cosmic aspen said, you can encapsulate with modules too.
It's just that if you have shared state, you might not wanna pass it in as an explicit parameter in every call.
But having a single op vs needing to type a function name can make a huge difference in usability
A single "op"?
I mean, yeah, if you are modelling an algebraic type, it makes sense to use a type with operators of course
But that's a pretty special case
And in that case, you do have shared state, the internal state of the type.
Not only, thinking of pathlib, requests
pathlib is also a pretty special, but different case.
And it's a slightly questionable use of operator overloading
It works, but it's weird.
numpy also works with algebraic types
Yeah, they basically implement both sides
One for convenience, one for extensionability, I guess
Either being off-topic is okay, or nobody really knows what "pedagogy" means. ๐
Actually I'm thinking about pedagogy in that context
The question was whether OOP or functional style should be preferred
For teaching
I've argued before to teach dunders early on
I mean, this is all information that I would want to convey to a student as well.
But I'm torn
You can view this as a discussion of how to convey the idea of programming paradigms and if and when they should be used.
I think as important as knowing how to teach OOP is teaching what it's good for and when not to use it.
Same with functional and imperative programming.
Yeah, I think it's best to have good examples for both at hand, so discussing those is a valid point
Well, if we ignore all the personal anecdotes and think specifically about the premise:
Topic: In my experience, object-oriented programming is the preeminent style taught in CS education. Does it deserve this status?
then the first thing I wonder is: is it true? Is OOP really the pre-eminent style in CS education?
I can't really speak in anything other than anecdotes, because I haven't studied and have no information about any CS education beside my own. But in my case, I wouldn't say that. I had an OOP course and a "software engineering" course that expected us to model the high-level design using OOP, but that's about it. All other courses didn't really presuppose a paradigm (aside from my "functional languages" course).
I also wasn't really trying to respond to that premise with my previous messages.
The question is rather whether or how functional style should be more prominently taught in python, there definitely is a lack
I'm struggling to parse that. Definitely a lack of... what?
My CS education didn't really concern itself with language-specific details much. I had an OOP course, which used Java as an example language, and a functional languages course, which used Standard ML as the example language, but the point wasn't to delve deep into language-specific features but rather to just give a general idea of what OOP and functional programming means. All other courses were about general topics as well, and sometimes just gave examples in a particular language. But the message was always, the implementation details don't matter, they can be picked up quickly as needed, it's the general, timeless concepts that are important to learn. And I find that that's generally true.
So I wouldn't necessarily advocate for trying to get CS education to include more Python-specific functional features.
Teaching those features here in this server is another matter.
But I don't think it's the job of academia to do that.
It's interesting that you had an OOP course and a FL course. I don't think those are too common. [In the US, at accredited schools]
A lack of teaching functional style in python. Best practices, examples
I studied at a Swedish university and this was about 15 years ago.
I don't have too many surveys of non-US curricula.
Do you mean in schools? Or where?
In general. In tutorials, books, too
It's not surprising though, since some features supporting functional style are still fairly new
I feel like I see comprehensions and lambdas used fairly frequently in Python tutorials and articles.
Is that not what you're referring to?
So you've already answered the "wether" part, and the "how" part is "everywhere"?
Not even thinking of lambdas specifically, more general features like positional/keyword only pure functions, not tied to objects or classes. The 'everything global is bad' claim is still going strong
That's not functional programming, though.
Well, if you have pure functions that operate on functions, what else is it?
Many people are confused when they see map
Functional programming is not concerned with just functions in general, it has to do with a mode of computation that's based on evaluation of functions. It's a declarative paradigm, and a pure functional program is one where the entire program is made up of a single expression, as opposed to a sequence of statements (which is what we'd call an imperative program).
Functional programming is an entire approach to designing your program, simply having higher-order and/or pure functions doesn't automatically mean you're doing FP; with that said, teaching these things is still fairly important, as well as properly showing when to use free functions and when to use a class
"OOP" and "functional" aren't really mutually exclusive, but "functional" and "imperative" are.
I find it that some people who come from other OOP languages bring some less-than-desirable practices with quite a bit of class overuse in cases where a function would do great on its own
One (tangentially related, but still) example would be filling a class with staticmethods instead of making a module with free functions; another, more severe in my eyes, is passing instances of subclasses with an overloaded method instead of simply passing a function
It doesn't seem to be too common to override __call__ in Python, but I do the equivalent in C++ all the time.
@graceful summit please respect channel topics
if you're looking for help check out #โ๏ฝhow-to-get-help
What about flooding the code with classes when dicts would be enough
Or dataclasses even
But yeah, I agree @staticmethod should be avoided, and a class full of them is definitely a Java-ism
Honestly the fact that classes in Python are just dicts is pretty annoying. I don't want to be able to create new member variables just by talking about them.
But in any case I would argue that a dict is not an appropriate substitute for a class, because my IDE gives me code completion for member names, but it doesn't know what keys are in a dict, since that is runtime information.
My IDE can autocomplete keys too if some of them are hard defined from the start
Which IDE? ๐
pycharm
Huh, never noticed this. But I basically never user dictionaries with pre defined keys.
huh, must be new, I've never seen that
i use typeddicts pretty often to model api responses
Why not?
I have seen mixins with just static methods ๐
I don't know what-ism it is since Java doesn't really have mixins
That sounds bizarre and I can't imagine a use case for it
I think it's just "bad"
lol
It's some common methods that are used in a few classes
but yeah, it's exactly equivalent to a set of free functions
Is that really true? Aren't there scoping benefits?
not really, you can do the same with a module
Well, it's used as a mixin. So the methods are mixed in with the normal methods
I would say it provides worse scoping than a module
wow, i'm late to the party
this channel is awesome and i just found out about it now lol
Use slots
I like how this channel essentially became "OOP is confusing"
don't shittalk my channel baby 
In all fairness, quite a few of the topic prompts so far have been about OOP, and in Stelercus's initial message, it's the first example topic.
And OOP is very hard to teach, so it kinda makes sense.
True, and it's especially true for python, because it has some significant differences when compared to "Traditional" OOP languages (e.g. Java)
And since a good amount of people who teach python to others don't give enough attention to these differences, they sometimes explain things poorly or show practices that don't fit well
What do you mean by protocols?
Duck typing?
Duck typing can apparently only apply to dynamically typed languages, a corresponding concept for statically typed languages is https://en.wikipedia.org/wiki/Structural_type_system
A structural type system (or property-based type system) is a major class of type systems in which type compatibility and equivalence are determined by the type's actual structure or definition and not by other characteristics such as its name or place of declaration. Structural systems are used to determine if types are equivalent and whether a...