thewhitetulip / build-app-with-python-antitextbook

Aims to teach Python3 by example
GNU General Public License v3.0
556 stars 69 forks source link

Issues #38

Open TonyFlury opened 6 years ago

TonyFlury commented 6 years ago

I applaud you for trying to do this - but I have noted one or more issues :

Please - try to fix these issues - as I say - I applaud you for trying - but if you want to teach - teach best practice.

thewhitetulip commented 6 years ago

Hey, Thank you for such a detailed comment. I don't have much time to respond to your entire issue comment, I'll just comment on the last one.

CSV to sql - why not use the CSV reader module - you should be showing your students the power of the standard library rather than writing their own.

Because I don't believe that students should use the standard library. I believe, very strongly, that students should build their own libraries at the start and then slowly acquire best practices. Why do I believe that? Because programming is an art and art is perfected with time. I don't want to teach students best practices since day one because I believe that deprives them from the learning experience. Just imagine you are in the first grade and your teacher teaches you everything, how to dress how to eat and she teaches that to every student in the entire freaking world. That becomes a bland world. We don't need everyone to write code in the same way, we don't need mindless drones. We need a choice. We need to make people understand that they ought to code using best practices.

Now coming to the second part, this book is not about getting to becoming the master of Python. This is the absolute basics, students are encouraged to read the standard library (I hope I wrote it down in the book somewhere, I am sorry if I forgot that) and to read the entire documentation end to end.

I truly believe that programming is picked up from reading the code, just like writing is. So, I don't want to turn people into 'best practice' programmers, I want them to understand that this is Python and this is the way you code in it, but this is not the final book or any final document as far as their Python journey is concerned. This is the first step and in the first step, they'll learn the language.

Now the onus of best practices is on them because I won't be spoon feeding them with everything. They have to get out in the real world and find out what is the best way to code, they have to contribute to FOSS projects.

Compare this with raising a child or writing a novel. What you are asking me to do (teach best practices from the start) is tantamount to raising the perfect kid or writing a first draft so well that you publish it directly. It doesn't work in this way in the real world, in the real world there are a lot of crappy first drafts, and endless intermediate drafts until you get a publish worthy novel.

In the real world, you can't always teach your children to be the perfect adults that they should be. They need to understand the why part of it. Why do they need to not jaywalk or litter the street? Because it is a bad thing for our nation and our world.

I understand that we must have a difference of opinion on this, I do promise to put in this note there and update the examples too, asking them to refer to the countless best practices document in the world and I'll rethink my philosophy of not teaching the 'right way' of writing python code. I understand that I must be having my gaps in understanding or negative influences of controlled environment (aka reading 1984! I really believe in giving choice)

TonyFlury commented 6 years ago

On 09/06/18 16:27, Suraj Patil wrote:

Hey, Thank you for such a detailed comment. I don't have much time to respond to your entire issue comment, I'll just comment on the last one.

CSV to sql - why not use the CSV reader module - you should be
showing your students the power of the standard library rather
than writing their own.

Because I don't believe that students should use the standard library. I believe, very strongly, that students should build their own libraries at the start and then slowly acquire best practices. Why do I believe that? Because programming is an art and art is perfected with time.

But best practice is using the standard library - The art of programming is about using the resources available to you.

I don't want to teach students best practices since day one because I believe that deprives them from the learning experience. Just imagine you are in the first grade and your teacher teaches you everything, how to dress how to eat and she teaches that to every student in the entire freaking world. That becomes a bland world. We don't need everyone to write code in the same way, we don't need mindless drones. We need a choice. We need to make people understand that they ought to code using best practices.

I agree - but the best way is to show them those best practices from the start - show them the power of the language and be a good role model.

Now coming to the second part, this book is not about getting to becoming the master of Python. This is the absolute basics, students are encouraged to read the standard library (I hope I wrote it down in the book somewhere, I am sorry if I forgot that) and to read the entire documentation end to end.

So - the book is more about learning how to code in procedural language

  • rather than learning Python ?

I truly believe that programming is picked up from reading the code, just like writing is. So, I don't want to turn people into 'best practice' programmers, I want them to understand that this is Python and this is the way you code in it, but this is not the final book or any final document as far as their Python journey is concerned. This is the first step and in the first step, they'll learn the language.

I fundamentally disagree - you don't learn from reading code - you learn by experimenting.

Now the onus of best practices is on /them/ because I won't be spoon feeding them with everything. They have to get out in the real world and find out what is the best way to code, they have to contribute to FOSS projects.

No - the onus of best practice is for you to be their role model; to be their mentor and their guide. I write FOSS projects - if someone contributed to my code with code that doesn't use the std-library but uses their own code, I would kick their pull request to the curb - and ask for significant changes.

Compare this with raising a child or writing a novel. What you are asking me to do (teach best practices from the start) is tantamount to raising the perfect kid or writing a first draft so well that you publish it directly. It doesn't work in this way in the real world, in the real world there are a lot of crappy first drafts, and endless intermediate drafts until you get a publish worthy novel.

But your students aren't children - so the comparison is invalid.

In the real world, you can't always teach your children to be the perfect adults that they should be. They need to /understand/ the /why/ part of it. Why do they need to not jaywalk or litter the street? Because it is a bad thing for our nation and our world.

Agree - and you are their role model - you show them best practice from day one - you don't let them cross the road without guidance because they have to learn !

I understand that we must have a difference of opinion on this, I do promise to put in this note there and update the examples too, asking them to refer to the countless best practices document in the world and I'll rethink my philosophy of not teaching the 'right way' of writing python code. I understand that I must be having my gaps in understanding or negative influences of controlled environment (aka reading 1984! I really believe in giving choice)

Python is a very mature product, with 100s of hours of development and testing going into every change; Python provides the standard library for a reason. Please use it.

Can I suggest an alternative - rather than asking your students to cut code which tries to do some of the job of well tested code, why not ask them to consider how they might design an application that uses the standard library; so instead of cutting code to read a csv file - why not ask them to used the CSV reader library (yay - mentoring and role modelling best practice), but their application does something constructive with the data.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/thewhitetulip/build-app-with-python-antitextbook/issues/38#issuecomment-395977734, or mute the thread https://github.com/notifications/unsubscribe-auth/AOagdKAvfnq0tzJUmd1Ll3cNE--ol5YAks5t6-l3gaJpZM4Tz4bN.

-- -- Anthony Flury email : Anthony.flury@btinternet.com Twitter : @TonyFlury https://twitter.com/TonyFlury/

thewhitetulip commented 6 years ago

No - the onus of best practice is for you to be their role model;

I wrote this guide for total beginners, so my idea was that people who are totally new to Python will learn the basics here and then they'd go to learn the advanced version somewhere else. That is why this guide isn't complete! (it misses out on a lot of things that I thought wouldn't be suitable for total newbies like the magic of enumerate, it might seem silly to you now, but when I learnt Python, I was scratching my head about a lot of things, that's why I kept this book as simple as I could.)

So - the book is more about learning how to code in procedural language - rather than learning Python ?

The book is about demystifying the magic of Python. I have trained a hundred people in Python by now and for the first day they are totally blank about how exactly this for loop works and wtf are lists and all and a lot of other things. We have written code in Python so we don't appreciate the struggle they go through. It is for such students that this book was written. This guide doesn't claim to be the perfect guide, it is not. It is a beginners guide and beginners have bigger problems than writing PEP8 standard code!! They don't understand anything in the language, so I didn't put in PEP8 styling and all. That comes later, when they are comfortable and I think I have put it in the guide as well that while this is a newcomers guide, you are strongly recommended to check the best practices.

But that being said, I understand the need to teach the right way, I'll change the code and use the best practices, for if we teach them to walk incorrectly how will they run!

But your students aren't children - so the comparison is invalid.

I disagree because I wrote this book to go hand in hand with the training I give, so for me, they are like my children.

Python provides the standard library for a reason. Please use it.

Yes, in production and when you write code for real applications then you are to use the stdlib but not when you are learning the language. Just imagine if you don't ever learn how to write a csv parser and you just use the csv library then what kind of programmer will you become?

When I was learning coding, all books taught me to use the stdlib, it took me many many hours to learn programming on my own by tinkering. I agree that you learn coding by tinkering, but I learnt it by reading the source code for Python itself.

I'll probably have to mention this in the book that "While you are not using the stdlib in this book, you are encouraged to not reinvent the wheel later"

I am saying this by example, one of the worst ways of teaching how to write code is telling students to use the stdlib. Yes, stdlib is well tested and is to be used after you know the internals!!

Can I suggest an alternative - rather than asking your students to cut

What I can do is, I'll ask them to write their own version of a csv parser and then use the stdlib. That way, they'll learn to use the stdlib and know how to write actual code. Best of both worlds!!

TonyFlury commented 6 years ago

Suraj - thank for your reply - I have a few comments

On 13/06/18 04:19, Suraj Patil wrote:

No - the onus of best practice is for you to be their role model;

I wrote this guide for total beginners, so my idea was that people who are totally new to Python will learn the basics here and then they'd go to learn the advanced version somewhere else. That is why this guide isn't complete! (it misses out on a lot of things that I thought wouldn't be suitable for total newbies like the magic of enumerate, it might seem silly to you now, but when I learnt Python, I was scratching my head about a lot of things, that's why I kept this book as simple as I could.)

enumerate isn't magic - it simply keeps track of the element count. -

So - the book is more about learning how to code in procedural
language - rather than learning Python ?

The book is about demystifying the magic of Python. I have trained a hundred people in Python by now and for the first day they are totally blank about how exactly this for loop works and wtf are lists and all and a lot of other things. We have written code in Python so we don't appreciate the struggle they go through. It is for such students that this book was written. This guide doesn't claim to be the perfect guide, it is not. It is a beginners guide and beginners have bigger problems than writing PEP8 standard code!! They don't understand anything in the language, so I didn't put in PEP8 styling and all. That comes later, when they are comfortable and I think I have put it in the guide as well that while this is a newcomers guide, you are strongly recommended to check the best practices.

But that being said, I understand the need to teach the right way, I'll change the code and use the best practices, for if we teach them to walk incorrectly how will they run!

But your students aren't children - so the comparison is invalid.

I disagree because I wrote this book to go hand in hand with the training I give, so for me, they are like my children.

But intellectually they are not children - they are very capable of understanding. I, and I am sure your students, appreciate the level of care and effort you make to teach them correctly; that is not in doubt - but you can't teach them like they are intellectually child like.

Python provides the standard library for a reason. Please use it.

Yes, in production and when you write code for real applications then you are to use the stdlib but not when you are learning the language. Just imagine if you don't ever learn how to write a csv parser and you just use the csv library then what kind of programmer will you become?

A very good one - development is about research and using the available resources. I started development (in C) 30 years ago - and I never wrote a CSV parser - I learnt to ask question and use the resources available. I think your students would be far better served by using the CSV reader module as is - but then learning how to process the data - i.e. they are asked to build something new - rather than reinvent a wheel.

I did a training course once and we wrote a chunk of code (around 200 lines), and then the instructor stood up and said 'but of course you could just use this function to do everything and more' - it was very disheartening that we had wasted all of that time.

When I was learning coding, all books taught me to use the stdlib, it took me many many hours to learn programming on my own by tinkering. I agree that you learn coding by tinkering, but I learnt it by reading the source code for Python itself.

I'll probably have to mention this in the book that "While you are not using the stdlib in this book, you are encouraged to not reinvent the wheel later"

I am saying this by example, one of the worst ways of teaching how to write code is telling students to use the stdlib. Yes, stdlib is well tested and is to be used /after/ you know the internals!!

No - I have never dug into the internals of any std library function (until I found a bug in one and submitted a fix for it); not using the stdlib until you understand the internals is a very strange philosophy. You need to understand how to use it (i.e. the documentation) and why it is important (the documentation covers some of this - being a good developer will cover the rest).

I doubt many Python developers have read the stdlib - they just used it. Python is called 'Batteries included' for a reason - and you don't cut batteries apart to understand how they work before you plug them into your gadgets.

When I was writing In C - I used the compiler and linker without knowing the internals; I used printf, scanf and many other functions without knowing the internals; and I don't think I am unusual.

I agree that the stdlib is not necessarily a day one lesson, but it should be talked about and it's use encouraged from day 2 onwards/

Can I suggest an alternative - rather than asking your students to cut

What I can do is, I'll ask them to write their own version of a csv parser and then use the stdlib. That way, they'll learn to use the stdlib and know how to write actual code. Best of both worlds!!

Or they can do something useful with the stdlib and understand that writing their own is not a good use of their time.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/thewhitetulip/build-app-with-python-antitextbook/issues/38#issuecomment-396801145, or mute the thread https://github.com/notifications/unsubscribe-auth/AOagdJQxgrf2Ybm7NsZVNWw4fEOh8Uovks5t8ITbgaJpZM4Tz4bN.

-- -- Anthony Flury email : Anthony.flury@btinternet.com Twitter : @TonyFlury https://twitter.com/TonyFlury/

thewhitetulip commented 6 years ago

I am not even as old as the number of years of programming experience you have, but I have learnt a few languages and frameworks on my own and I faced a lot of challenges which made me write these guides (which are example based and cut out on a lot of theory).

The one thing I haven't been able to forget is the frustration I went through when I picked and gave up on almost every book I read about C/C++/Java.

I had no mentor, guide or teacher to help me, I didn't even know what StackOverflow was(back then). I did everything via books and most of them taught me how to use a CSV parser on the first chapter when I didn't even know what a CSV is or what a parser was. Not a single book taught me via easy to understand examples which could fit my newbie's head.

It is perhaps the greatest tragedy in the field of programming that the 'beginners books' are written by those who have 30+yrs experience in programming, who don't know how frustrating it is to not understand a word written by experts (and then feeling that you are as dumb as a soup for not understanding the classic, Dennis and Ritchie's The C Programming Language).

When you are a total newbie, everything is magic, when we learn those things, 'the curse of knowledge' sets in which makes us blind to the struggle we had lead while we were learning the language and it is for that reason even my youtube channel gets regular comments literally saying

Thankyou folks i have watched so many videos but your video made me clear about indentation

Great video. Had searched for such clear, basic to a higher level explanation, but didn't find that anywhere, until now. Thank you. Keep up the awesome work ! :-)

thank you so much for this tutorial .I did not realise how important indentation was in python because even if your code is correct it will not run if the indentation is not properly applied

link to one such video

This is because most newbie books are too arcane for newbies!!

Of course by now means I encourage reinventing the wheel, I don't encourage reading the stdlib, but I do encourage them to write code to do everything and not use the stdlib for the course, of course, I encourage them to use the stdlib strictly, but only after the course, not during it.

I am teaching them to drive but I keep the "Autonomous driving" feature off, let them understand how to shift gears first before sitting back and relaxing while the AI does the driving.

That being said, I agree with you with the fact that the examples in this guide are woefully inadequate, the students can indeed write something more using the stdlib, I'll perhaps add a few more chapters. But truth be told, I can barely finish this guide in seminars in 10 days, there is always so much content to teach and time is always short.

thewhitetulip commented 6 years ago

@TonyFlury I have made significant changes to the existing draft based on your feedback. I'll be posting them soon (within a few months). Thank you for opening my eyes! I was kind of living in an echo chamber.