I'm the author of Python Crash Course, from No Starch Press. A few years back I was teaching an introductory programming class to high school students, and at the time all the resources I could find were either aimed at kids or made too many assumptions about what people already knew. So I wrote a book that assumes nothing about what you already know, but doesn't treat you like a little kid either.

The guiding question for the book is, "What's the least you need to know about programming in order to start working on interesting projects?" It's really two books in one - the first half of the book introduces you to the basics of Python and programming in general, and the second half walks you through three in-depth projects. The first is a Space Invaders clone, the second is a series of data visualizations, and the last project is a fully functioning web app. People go from knowing nothing about programming, to building fully-functioning projects in an area they're interested in.

I hoped the book would work for people of all ages, and it has. I've heard from older elementary students, middle and high school students, college students from all kinds of majors, working adults of all ages who are trying to switch careers, and retired people who've always been curious about programming. It's worked for a wider range of people than I ever imagined, and it's been translated into eight languages as well.

I've taught math and science for 25 years, and I've been a programmer all my life. AMA, especially if you've always been curious about programming but haven't known how to get started. I also live in southeast Alaska, so if you're curious about life in Alaska I'm happy to share a little about what it's like to run with bears.

proof

Comments: 74 • Responses: 28  • Date: 

-Kobart-11 karma

Why is it that so much amazingly succinct and communicative material exists for Python but for many other languages like C++ the surrounding literature is so dense and arcane?

ehmatthes25 karma

That's a really good question. In the early days of computing, everyone who wrote about programming was a programmer first, and probably had very little experience teaching. So people were primarily writing to communicate technical ideas to each other, and the communication style was less of a focus than the technical information.

When Python was developed, one of the core ideas was valuing programmer time over computer time. This core philosophy resulted in a language that tends to be cleaner, and less verbose than many other languages. Python programs tend to be much shorter than equivalent programs written in other languages.

This cleanliness and clarity makes Python really well suited to beginning programmers, and to people who work primarily in another field but need to do some programming in their work. For example, the science community has fully embraced Python, for a variety of reasons.

There's a saying in the Python world: "I came for the language, but I stayed for the community." The leaders in the Python community have cultivated a welcoming community as well as a strong technical language. A lot of people have paid attention to how easily beginners are able to pick up the language, which has resulted in some higher-quality learning resources than what you see in languages where there has been less of a focus on building a welcoming community.

That's a bit of a rambling answer, but I'm happy to expand on any of these areas you're curious about.

KarateKid19849 karma

Question, if you're teaching pythons to code, aren't you worried that people will start to resent snakes for taking high-level jobs? They seem to have a bad enough rap as it is.

ehmatthes24 karma

Well, I for one welcome our reptilian overlords.

ccr102030404 karma

Python seems to have a lot of options available. I want to learn it so I can get into Machine Learning and Deep Learning later on. Any sugesstions as to how I could achieve so? Healthcare applications with NLP and OCV really catch my eye. Best regards.

ehmatthes2 karma

You are absolutely right. The core of Python has been around for a long time, and a large community has built up around it. If you want to do something in Python, there's a really good chance that someone has written a library that does a lot of the grunt work for you. If it's a common problem area, chances are people have refined the libraries to the point that they are really efficient and relatively easy to use.

Python has a very active Machine Learning community. So if you don't know Python, start with a book like PCC, because you need to know the basics of Python before you can jump into specific Machine Learning libraries. Once you know the basics of Python, you can start to follow some of the people who are developing the ML libraries you're interested in. With areas that are changing rapidly, you might want to look for more recent talks on the subject. All of the talks from PyCon are recorded, and you can find this year's videos here.

If you want more specific references, I'm happy to find a couple to get you started.

hoopdady4 karma

Does your book cover frameworks? I had a pretty thorough knowledge of python about 10 years ago. Then I moved into management. Every time I think about leaving management and going back to development the jobs always require some sort of framework knowledge (usually django) and I have not found any good tutorials for frameworks.

ehmatthes4 karma

Yes. The game project uses Pygame. The data visualization projects use Matplotlib, Plotly, and the Requests library. The web app project uses Django.

One of the most satisfying parts of the success of this book for me has been taking people from knowing nothing at all about programming, to deploying a fully functioning web app. I was surprised to see as well that people who already know another language have really enjoyed PCC, because it gets them up to speed about Python quickly. People who already know another language fly through the first half of the book, and then spend their time focusing on the projects they're interested in.

jraw19954 karma

If you would have to advertise your book to people who typically don’t work on computers all day, e.g. mechanics, farmers, non-tech-teachers etc. what would be your argument to start learning python ?

100k+1 , also obligatory greetings from Germany

ehmatthes4 karma

That's such a good question. I don't feel that everyone should learn to code, but I firmly believe that everyone who wants to learn should be able to. That's why I wanted to write an introductory book that's accessible to as wide of an audience as possible.

There are two main reasons: the first is to solve the problems you know about, and the second is to better understand the world around you.

When I went to my first programming conference, I expected to feel out of place because I was a teacher first and a programmer second. I thought everyone else there would be an amazing programmer, and I wouldn't fit in. I was suprised to find that about half the people in attendance were professional programmers, and half the people were non-programmers who were looking to solve some important problem in their field. People from both groups were really welcoming to others, because many of the programmers didn't know what problems to focus on.

If you have spent your life as a mechanic, farmer, store manager, etc, you know that line of work better than most programmers. So your choice is to hope that a programmer builds a tool that serves you well, or you can learn to program and build the tool you know people in your field need. These days programming languages are so well developed that you don't need to be an expert programmer to build a tool that's useful to people. You then have the choice of using the tool just in your own work, or trying to make it available to others in your field.

Almost everyone on the planet is affected by code. To people who know nothing about programming, the internal operations of Twitter is an impenetrable black box. When Twitter says, "It's really hard to know who's a white supremacist", these people have no way to evaluate that claim. If you have a basic understanding of programming, you have a sense of how you might build a monitoring system for Twitter. Developing a basic understanding of programming also helps you identify which aspects of your work could be addressed through code, and which aspects are really non-technical issues.

To close, here's a quick story in this area. I emailed with a guy a while back who had spent most of his life as a truck driver. He said his knees were going out and his body was starting to break down from a life of physical labor. He wanted to learn to code because he had some ideas about how to schedule drivers and trucks better, in a way that would allow drivers to know their schedules more in advance, and allow companies to use their resources more efficiently. He was able to start writing that software after working through PCC. He probably couldn't make a robust system that the entire shipping industry uses from PCC alone, but he has a clear understanding of how to think about the problem and how to move forward with his idea as much as he wants to.

jraw19952 karma

Thanks for the great answer :) Just bought your book a couple minutes ago, actually stumbled across your IAma while browsing r/python for recommendations and found a comment of yours. I’m a aviation mechanic myself, got interested in coding through early iPhone-Jailbreak Lua scripts and an unhealthy amount of Zachtronics games.

I mainly want to automate some of the stupid amount of paperwork I have to do for work. Changing parts for 15mins is sometimes followed by an hour of documentation, most of it being predictable and repetitive copy-pasting

ehmatthes2 karma

Yes, that kind of automation work is often really straightforward, and really satisfying! Many paper-based systems persist because no one working in the field has enough technical expertise to automate the work, and no one from the programming world has considered that specific set of tasks interesting or significant enough to address yet.

Good luck!

Antonnnr4 karma

How does it feel when a happy soul achieves it's dreams by learning to code?

ehmatthes10 karma

That's a fun way to ask that question! It feels pretty good. :)

I learned to program on a kit computer in the late 1970s. My dad was a software engineer, and he had built a computer with a bare motherboard, a monitor that was just a cathode ray tube with no case, and a keyboard with wires sticking out everywhere. He showed me a little about Basic, and I wrote a simple number guessing game. I will never forget the feeling of watching my parents play the game, and seeing that it worked. It was magic.

It's a great time to learn how to program. If you have an idea, you can build something and make it available to everyone in the world with little cost, and you can develop your idea as much as you want.

_Shahnawaz3 karma

What is your opinion on C++ as a language? What sets it apart from python?

ehmatthes6 karma

I learned C a long time ago, when I was in college in the early 90s! Over winter break or spring break one year I wrote a 3d graphing program. I didn't know enough about programming at the time to make it a general-purpose graphing library, but I did learn a lot about how C-style languages work.

C-style languages were written to optimize for efficient use of computing resources. So when you want to store a collection of items, you need to specify what kind of information you're going to store and how much of that information you're going to store. Then the compiler sets aside exactly enough memory for that information. When you're finished working with this information, you typically state that you're done with it, and free up that block of memory. When you do this right, you can write really efficient code. When you do this wrong, you can have memory leaks and really inefficient code.

Python was developed at a time where computers were starting to have way more memory and processing power than most of us will ever need. Python does a lot of the memory-management work for you. When you want to store a collection of items, you just put all those items in a list. You don't have to say what kind of information you're going to store, or how much you'll store. Python just grabs a little more space in memory than you currently need, and grabs more if you need it later. Python examines your code and identifies when information is no longer being used, and frees up unneeded memory for you. This means it's often quicker to write Python code than code in other languages, because there's less code to write and there's less to keep track of.

When it first came out, Python was criticized as inefficient. That was true to some extent, because it was prioritizing developer time over perfectly efficient use of computing resources. But the Python ecosystem is so well developed now that much of this issue has gone away. There are numerical processing libraries that let you write Python code, but end up compiled to efficient lower-level code.

C++ is still better in some contexts, such as writing code for a device that has limited storage or limited processing power. It can also be better in applications where your code is pushing the limits of the system it's running on. This is why many high-FPS games are written in C-style languages.

For most people learning to program, Python is a great place to start because you get to focus on the problems you're trying to solve, rather than focusing on things like memory management.

_Shahnawaz3 karma

Thanks for that insightful answer!

The reason I ask this is because CBSE (the national board for education in India) took a decision to change the language from C++ to Python for the Computer science students in 11th and 12th grade.

I happen to be the last batch learning C++!

ehmatthes4 karma

If you know you're going to be a programmer, you should certainly learn a second language at some point. No language is perfect, and learning a second language helps you understand why certain design decisions were made in each language.

If you learn a C-language first and then move to Python, you'll have a better sense of what Python is doing automatically for you. If you learn Python first, C-style languages will be interesting because you'll get a better understanding of how Python works under the hood. Python itself is written in C.

radicalwavebrah3 karma

Thank you for taking the time to do this, much appreciated. As an adult with a career in finance I am looking to diversify my skillset with a goal of earning a position as business analyst or product manager one day. I don't necessarily need to be a 100% competent programmer, but it would be greatly beneficial to understand programming on a more basic level so I understand strategy and the way tech interacts with the business side. Would your book be a good starting point for me? Or would you recommend a different path?

ehmatthes4 karma

Yes, PCC would be a great starting point for you. I say that with confidence now because for the past few years I've been getting emails from people sharing that the book has worked really well for them in making transitions like what you're describing.

The first half of the book takes you through the fundamentals of programming:

  • How do you store information in a program?
  • How do you store large amounts of information?
  • How do you connect pieces of information?
  • How do you get input from users?
  • How do you repeat actions?
  • How do you work with files?
  • How do you handle errors?
  • How do you write tests, so you can prove that all of your code is still working, even after you've made significant changes?

These are the concepts you'll have to learn as a beginner in any language. One advantage you'll have as you work through this material, is that you'll be thinking about the problems you know you want to solve. So when I'm saying here's how you store a number of motorcycles:

motorcycles = ['honda', 'suzuki', 'ducati']

you'll be thinking about the kind of information you're going to want to store and work with. You'll make better sense of what you're learning because you're constantly thinking about how you're going to apply it.

You'd probably skip the Space Invaders project, but the data analysis projects are accessible and they'll get you off to a really quick start in some of the analysis work you want to do. If you're interested in how you can make your code accessible to others, you might want to work through the web app project. Even if you don't want to build the next Twitter or Facebook or Reddit, a small web app is a great way to share your code with colleagues.

You might find that this book is enough to get you started on the real-world projects you want to do. If you need to dig into deeper programming concepts, you'll be familiar enough with the basics to work through more advanced books, even if they aren't written quite as clearly in a pedagogical sense.

radicalwavebrah2 karma

Thank you for such a well though out and directed reply. The information you replied with is 100% on point with the way that I would be approaching problems. This gives me hope, as someone who gets a little intimidated by the ever evolving tech landscape. Your book sounds like a great starting point, I am definitely going to be checking it out.

ehmatthes2 karma

That's great, feel free to reach out if there's anything in there that doesn't make sense. Even if you don't end up writing software for your work, you'll come away with a much better sense of what the programmers around you in the finance world are doing. I imagine you'll be better able to collaborate with them, when the opportunity does come up.

PS Just be careful, a coding mistake in the software world can be really costly! But I imagine you already know that. :)

WolfFlightTZW3 karma

I live in Alaska as well, what more do you think we can do as professionals to help encourage the youth of Alaska to take advantage of things like learning to code to either expose them to the chance to see the world at large or to help their communities? I'd love to see youth in villages for example get Raspberry Pis or Kanos machines.

ehmatthes4 karma

That's a hard question. There are lots of programs and kits around to help people get interested in programming. Ozobots are great, 3d printers are fun and inviting, Makey-Makeys are interesting... But what does a young person do when their interest has been piqued but there's no one around with actual expertise in programming? I'm not quite sure. Part of the reason I wrote PCC the way I did was to give motivated young people a resource they could use to gain meaningful competence independently.

I think it's critical to develop technical expertise in rural areas, because people know their own problems better than people living in urban tech centers. Solutions that start locally have a better chance of working, and of avoiding bad unintended consequences.

To close with something concrete, I think anyone who has technical expertise should consider making themselves available to young people in their area for mentorship. Many times young people who are interested in tech just need a little guidance. "Learn this language first", or "try this book", or "here let me help you get your development environment set up so your Hello World program works".

PCC is starting to be used more in schools, and I am hoping to work with teachers and community leaders more over the coming years. I appreciate the thoughtfulness of your question.

not_a_droid3 karma

do you think it is likely that a person in their mid 40's could learn coding, and find viable work?

are "coding bootcamps" worthwhile?

how long until you have decent enough skills to find work? make 50K plus a year?

ehmatthes3 karma

do you think it is likely that a person in their mid 40's could learn coding

Yes, absolutely; I have met and heard from many people who have done so. The hard parts for many adults center around making time to learn a new field while juggling work and family life, and not burning out. You will probably never be as strong of a programmer as someone who starts out in their teens or twenties and then builds a life around programming, but you can learn the basics at any age and start to work on meaningful real-world projects. If you have a field where you have developed expertise in your life, you can hold your own as a programmer in that field. And if you want to totally switch careers and just be a generalist programmer you can, but that's probably about as hard as switching into any new career.

and find viable work

That's a different question. When people hire you as a programmer, they aren't hiring you to write code. They're hiring you to solve problems. So you need to understand programming well enough to write code that solves other people's problems. If you've spent your life learning to communicate with others, code just becomes another tool you can use when working with others around a common problem.

are "coding bootcamps" worthwhile?

In general, no. There's this idea that we can all learn to write a little code, and make a bunch of money. If that were the case, every programmer would be rich right now. It's a stereotype, and it's not realistic. Many coding bootcamps use this stereotype to get people to pay a fair amount of money in hopes of making a bunch later. Many of these programs don't deliver on their actual promise, whether they were set up with good intentions or just to make a quick buck.

There are a few that do help people transition to a tech-focused career. But the people who do well in these programs have typically started learning on their own, and the good programs help them network and refine some of their skills.

If you are thinking of trying a bootcamp, make sure you research the program well. Find people who went through the program, who are not referred to you by the program, and ask them about their experiences before and after the program.

how long until you have decent enough skills to find work? make 50K plus a year?

Some people do this in a matter of months, but those are typically people who have some other area of expertise and they're combining their new programming skills with their extensive prior experience in another field. Some people spend several years learning, and never land a tech job. It depends on your prior knowledge, your adaptability, your time commitment, the quality of your learning time, and your communication skills.

TLDR; Yes, many people make significant career transitions in their 40s. No, there is no easy path to get there.

iammaxhailme1 karma

About the coding bootcamp thing. I self-taught a large amount of python, and some C++, while doing grad school for computational chemistry. However science research absolutely sucks as a career, so I quit my PhD (well, there were a lot of reasons, but that's a big one). I have a masters though, also a bachelors in math. I don't have formal coding education, but I have done a lot of projects that were used for actual research. I'm trying to get a tech job in data science or data analysis, but nobody will give me interviews, probably becuase I don't have a CS degree, or experience at a dedicated coding job (even though my grad school was basically a coding job, and I try and make it sound that way on my resume).

In a situation like mine, where I already have some of the tech but need the networking + resume stuffer, do you think a boot camp is worth it? The few people I know who did it basically said that they didn't really learn anything except how to monkey-see-monkey-do, but the bootcamps had good connections.

ehmatthes1 karma

I know there can be many good reasons to quit a PhD. I have a BS in Physics. I was going to become a particle physicist, but I didn't want to be a student forever so I took a break after undergrad to try working for a while. I started teaching, and found that the intellectual challenge of trying to reach every student was as difficult and satisfying as hard science. I ended up staying in teaching. Physics was a great background for teaching, because it gives you some insight into just about every field. So I always had some line of thinking to fall back on when answering students' questions, even if it was something I hadn't paid too much attention to in my own learning.

There are a lot of people moving from computational physical science fields to the data science world. If you are not currently getting interviews, I doubt a coding bootcamp would do a whole lot for you. I would guess that the companies looking down at you for not having a formal CS background would look down at you for doing a coding bootcamp instead of a formal CS degree. The one I would consider is Lambda School. I'm not sure what to make of them overall, but the income-sharing agreement is pretty interesting, and keeps you from the trap of taking out loans and then not getting a relevant job.

I try to walk a line between offering some perspective on questions like this, while making it really clear that I'm not a job coach. Have you considered asking some working data scientists to look at your resume, and share any feedback about how to break into the field? Have you used your current skills to do any data analysis that potential employers would find interesting and compelling? Do you have a list of specific skills that would make you appealing to people hiring data science positions?

Timothymusenga2 karma

Thanks for the opportunity to ask, Eric. Your book has been it possible for me to learn python without losing enthusiasm. My goal is to use python to develop web applications, particularly hospital management systems. What do you suggest as the best way forward after finishing your book?

ehmatthes3 karma

If you liked the Django project at the end of the book, I highly recommend looking into William Vincent's work. He's producing the most up to date Django resources that I'm aware of, and I've heard good things about his work. Also, the official Django tutorial is really worthwhile, and it has the advantage of immersing you in the Django documentation, which is thorough and accessible.

Any software that touches the health care system needs to be carefully thought out. There are many areas where you can spot an inefficiency, and write a little code to try to address that inefficiency. If you mess up, no big deal, you learn from your mistakes and try again. You have to be much more thoughtful in addressing health care issues, and you really need to know the legal requirements around the specific areas you're working in. Security is critical in health care applications as well. So I'd suggest learning as much as you can about these areas, and finding potential partners who already have expertise in some of these areas.

bestminipc1 karma

the old edition of this was higher rated. this is lower rated. do you think it hasn't gotten better in a significant way?

there are better books that are higher rated that were made recently. has this book not kept up with the times or progress?

ehmatthes5 karma

It has definitely gotten better. Here's summary of what's new in the second edition.

Ratings are interesting. I assume you're looking at Amazon ratings. No Starch Press produces really high-quality physical books, which have a lay-flat binding so you can keep them open near a computer as you're working through examples. There was a bad batch from the printer where some books had the bindings come loose. The publisher worked with the printer to have these books replaced for anyone who had this issue, but some people give a low rating because of that.

You also have to be really careful looking at books with almost all five-star ratings. Here's a book that is a complete knockoff of my book. The description is copied verbatim from the back of my book. If you read through the reviews, it's not hard to tell that all of the five-star reviews are fake, and the one-star reviews are from people who thought this was a legitimate book. If you search "python crash course" on Amazon, you'll see my book and a bunch of cheap imitations where scammers are hoping people will click on the wrong back. This happens for many popular titles. Amazon knows about this issue, but does nothing about it.

If you have questions about a specific book that is legitimate, I'm happy to share my thoughts. I've learned a lot from many programming books over the years, and I'm happy that people have a number of good books to choose from.

th3suffering1 karma

Ive been learning to code self taught for the last few months now, brand new to programming aside from dabbling in some HTML and javascript almost 20 years ago in high school. Decided to start with Swift, and have been following some courses on udemy, as well as a few web resources. My problem is, ill get burnt out and its hard to get myself back into it. When I am following a course, and making things actually work its really exciting. I want to hold onto that feeling, but i start feeling overwhelmed and lost and then i forget even basic things. And then i take a day off. A day later its a week. Couple that with work and family...its tough. Im committed to making this work though. What can I do to fight burn out?

ehmatthes1 karma

That's a hard question to answer generally, because burning out is a really personal experience. But I'll share a bit of my thinking.

In learning a new field while working and having a family, burnout can come from not having a clear path forward. If an end goal is too vague, it can be really hard to stay focused. A really specific goal can be really helpful in refocusing, because you know exactly what you're working toward.

A goal can sound specific, but actually be vague. Consider a goal: "I want a new job in 12 months." That sounds specific, but it's not specific enough to be motivating when things get difficult. That could be made more specific by:

  • naming a specific role or company
  • listing the qualifications for the new job, and checking off each as you gain that skill
  • building a portfolio to show potential employers

In programming, there's a recurring conversation about how we all love the excitement and joys of a new project. But once we get through the initial exploration phase, a lot of the work just becomes...work. And that's not always fun. So you are certainly not alone in this experience!

Is that helpful at all?

th3suffering1 karma

It is. You are right, my goal was/is "get a new job and get the hell out of the job im in now". Ive never thought to actually narrow down to job qualifications and focus on those, and rather ive been "learn swift and by the time you get through with it you should meet those qualifications" but theres no real end in sight with that.

Given your experience in the field, should I stick with Swift since ive already been doing it for a few months, or should I change to a more in demand language? I picked Swift because I have a Mac, Swift came up multiple times as a good beginner language, and I thought my son would think it was cool I could make things that actually work on his iPad.

Ultimately my end goal is to get educated enough to get out of my current dead end career and into software development. Should I focus on a different language or can Swift still be a good place to start?

ehmatthes2 karma

Keep in mind that people are going to hire you to solve problems, not to write code. When programming professionally, code is a tool to solve real-world problems. It's fun and satisfying at times, but in the end the code has to serve a clear purpose.

So you need to learn the basics of whatever language you choose, and then you have to dig in and build a project or two that demonstrates that you can use what you've learned to do something meaningful, that goes beyond what the tutorial tells you to do.

Everyone thinks you learn a language and then get a job working in that language. But once you learn a language and start to use it, it becomes easier to learn the next language. I don't know Swift, but if there was a company I was interested in working for who primarily used Swift, I'd still consider applying for that job because I'll pick up the language pretty readily, especially once I'm working in it full time. A good interviewer would look at what I've done in other languages, and ask some questions to sort out whether I can transfer that work to a new language.

Python is a great first language because it has fairly simple syntax, it has a vast ecosystem of libraries you can use in your projects, and the concepts you learn in Python will carry over to just about any other language you learn. Swift will only set you up for working in the Apple world; Python or JavaScript will set you up to work anywhere. But building something interesting and meaningful, that shows original thinking, is more important than what language you use. So if you're getting there in Swift, follow through on that. You have to be careful not to start language-hopping, and never building anything significant.

Have you done a job search in your area to see what languages people are hiring for locally?

chayblay1 karma

Hi Eric, I've heard rave reviews of your materials and personally love the artwork. Thanks for your time and attention to the community.

My question is which of your resources would you suggest to complement learning the basics of Python syntax through Dataquest (similar to CodeAcademy) without becoming redundant in material or exercises?

The title of Automate the Boring Stuff sounds appealing, and so do your GitHub and Udemy courses, but I'm already a few lessons into Dataquest and don't want to try to learn too many things at once.

Thanks for your contribution to the field!

ehmatthes1 karma

Hi, you are thinking of u/AlSweigart. People get us mixed up sometimes. :)

chayblay2 karma

My mistake, don't judge an author by the cover I guess...

Not sure if the objective behind my question would still apply to your book PCC? Would you suggest PCC to students to complement their learning on a DataQuest-like platform or do you think there would be too much overlap?

ehmatthes2 karma

If you're curious, Josh Ellingson does the artwork for a lot of No Starch Press books.

If you are understanding the basics of Python - variables, lists, dictionaries, loops, functions, classes, files, testing, etc. - then you probably won't get a whole lot out of the first half of the book. If you're hazy on any of that, many people have said that the first half of PCC helped clarify these concepts after working through another resource and not really being satisfied with their overall understanding.

The second half of the book is three in-depth projects - a Space Invaders clone, a series of data visualizations, and a simple web app that you deploy to Heroku. If any of those projects are interesting to you, you might get a lot out of the second half of the book.

Bo0kerDeWitt1 karma

I'm really enjoying the book so far; I've just started Chapter 9.

On page 39 you describe pop() as a method, and then on page 125 you describe pop() as a function. Is there a difference?

Thanks!

ehmatthes1 karma

Thank you for bringing that to my attention! I tried really hard to be consistent about that, but that one slipped through. I'll have it corrected next time the book gets printed.

There is a slight difference. A function is a block of code that has a name, that you can call. A method is a function that's part of a class. So a method is always a function, but a function isn't always a method.

Practically, this means you can never have a line that just says pop(). It must always act on an object, such as primes.pop(), acting on a list of prime numbers.

Beachsurfer1 karma

How long does it take specifically to become proficient at coding to become employable? Thank you.

ehmatthes2 karma

I think this answer addresses your question as well. If you have any followup questions from that answer, I'm happy to be more specific.

AWESOMEJ271 karma

What are your thoughts on ‘import antigravity’?

ehmatthes2 karma

That pretty much sums up my first experience of trying Python. I was using Java in the mid 2000s, and a friend said I should give Python a try. I grew up on braced languages, and I had decent formatting habits, so semantic whitespace was a really foreign concept. But what people said was true, my Python programs ended up being about 1/3 as long as equivalent programs in Java. I was hooked.

User_100M1 karma

General coding question: given the same hardware, networking, etc., isn't there always a best coding structure for any given object/function, such that computer resource usage is minimized, speed is optimized, etc.? If so, would it not make sense to simply have open-source libraries of complex objects/functions that are not copyright-able, since they necessarily are the best method for achieving the result? Example: why reinvent the wheel for video game character models each game, when one method will emerge as the right way to do it-->the developers should just always use that base code as a template and modify details in that code only without being forced to use an inferior method for the purpose of avoiding copyright infringement.

ehmatthes2 karma

That's an interesting question, because it gets at the idea of code reuse. People do some of what you're describing already.

Game engines, or frameworks, do provide base objects and functions that we can build on top of. For example, in simple 2d game engines each character is represented internally as a rectangle. That makes the calculations for a character's position, and whether that character has collided with any other character or game element, fairly simple. This is enough precision to make many games smooth enough that we don't notice that all the characters are being treated as rectangles. More sophisticated engines allow you to fine-tune the degree to which your character is treated as something more complex than a simple rectangle.

I don't think "best coding structure" is quite as simple as you're describing. You also have to take into account what's going to be done with that particular object in the game. People try to generalize for classes of game elements, to keep the balance of precision, smoothness of motion, and efficient use of resources as optimal as possible.

Some of these engines are free and open source, and some are proprietary. The proprietary ones may be available for licensed use, or developed completely in-house for that company in an attempt to retain a competitive advantage.

Everything I've said here applies to other fields as well. In building web apps, there are a number of frameworks available that address the common tasks of managing memory on a server, and handling incoming requests in the most appropriate way. I said in another answer that now is a great time to learn to program. Part of the reason that's true is that the resources available to all of us are more than most of us will ever need. So you can go a long, long way writing code that isn't anywhere near optimal. If you have a problem you want to solve through code and you write code that solves that problem, you then get to choose how much to continue optimizing that code. If the code will be used by many people, or worked on collaboratively, or used in life-safety applications, that it is well worth the time (or even mandatory) to optimize it to a certain degree. But if it works well enough for your end purpose, there may be no need to optimize further. Some people spend their whole career out of developing experience and expertise in optimizing other people's code once it has been proven to be mission-critical.

Does that address your question?

User_100M1 karma

Short answer: yes, thank you. Long answer: I mean for similar use cases, won't the best set of lines of code be just one way of doing it? For example, why would I intentionally write inefficient code that has 1,000 lines, when the simplest way takes only 432? Or why integrate modules into the main code, when the module method works best for...eh hem...modularity? I guess I see coding as math. You can get the result 8 by adding 2 plus 2 plus 2 plus 2. Or, you get 8 by building the first set of twos as 1 object and then the second as another object. Then add them. At complex coding scales, I'm certain that one way of getting certain categories of objects to interact with each other is a repeatable operation that does have the mathematically-best way of doing it. If so, copyright restrictions on using the best techniques would be akin to patenting crossbeams to support bridges. You literally should not build a bridge w/o crossbeams because physics dictates what will support the bridge, not intellectual property laws. In the same way, that's what code is: commands of electrical signals/light that get physically recorded. The machine will work best for a given operation by physics limitations, so IP laws might force inefficiencies. It's like patenting math. Everyone can and should use math. Euclid did not patent his theories, for example.

ehmatthes2 karma

Oh wow, patents! Software patents are a mess. People have tried to patent lots of really obvious ideas in software; some of them are predatory in nature and some of them are defensive. Our judicial system is hardly equipped to properly assess the validity of many of these patents.

A lot of the coding I've done just needs to work once. It's complicated enough work that there's not one obvious way to do it, but simple enough that I can get through it in a reasonable amount of time. So I try a few ideas, and find something that works. I know that my code isn't optimal, because it's still got some exploratory parts, and my looping isn't perfectly efficient. But I have the result I need, so should I go back and rework the code?

For example, I've been doing some analysis of some weather data. I wrote a routine that looks at every point in a data set. For each point, it looks back at the previous 20 or so data points. It flags the data points I'm interested in. A loop that looks at 20 points for every point is not very efficient. I could go back and add a few tests to see if each point really needs all of the previous 20 points checked, or if there are some ways of ruling out some comparisons. But I'm working with a 5-year data set, and my code runs in a few seconds. At this point I won't gain anything by bringing that down to 0.5 second or so. I will gain way, way more by sharing the results of my analysis with people who know more about this weather phenomenon than I do, and figuring out what kind of analysis we want to move forward with. This is an example of how the abundant computing resources we have at our fingertips now, means we don't always have to spend time optimizing our code.

This kind of story plays out all the time. There is so much code that's just written to explore a problem space, and isn't worth optimizing. For the problem spaces that are well-explored, and critically important, people are working to make steadily more efficient code.

dracomatic1 karma

what programming language do you think is the best "base" to start learning? so u can apply the logic to the other languages.

ehmatthes2 karma

That's a question that comes up pretty regularly in conversations about learning to code, and it's a good one to keep asking. I have always enjoyed introducing people to programming, and I don't ever want to get stuck on one language just because I know it best.

I think Python is currently the best language for most people to start with. It runs on all systems, the syntax is clean and relatively uncluttered, and you can do just about anything with it once you learn the basics. You can make games, do data analysis work, make web apps, automate many tasks, interface with robotics, etc.

If you start with Python, most of the concepts you learn will carry over to any other language you learn in the future. Some of the data structures are named a little differently, and the syntax will certainly be different, but the core ideas are quite similar.

Some people say to start with JavaScript, because it runs in web browsers. That's true, but JavaScript has some syntax that's a little difficult to get used to, and some overall design issues that are simpler to learn in some other languages. Many schools use Java and C because they force you to learn about types and memory management. If you already know you want to be a programmer that's fine, but for many people it's simpler and more enjoyable to start out with a language that takes care of some of that stuff automatically for you.

If I see a better first language than Python come along, I will jump on board. But I haven't seen anything better in the last ten years.

bestminipc1 karma

an extremely big problem with all/almost all books are:

  1. extremely wordy, tiring, and long-winded

  2. uses technical terms that basically nobody would understand

does this book have either or both of these problems?

ehmatthes2 karma

My guiding principle for the book was "What's the least I need to teach people in order to start working on interesting projects?" With that in mind, I avoided overly technical explanations. That said, I also want to give people a foundation they can build on in the rest of their lives as a programmer, so I did explain core concepts clearly. I aimed to simplify things, without dumbing things down.

Each technical term that's introduced is explained pretty clearly. That said, you can't avoid some degree of complexity. So if you get to a point where things are just becoming jumbled, it's important to step back and do something else for a while, and let yourself work slowly through some of the material. Once it does start to make sense, you can move forward and things should continue to get clearer as you use the concepts in a number of different ways.

viront71 karma

After going through your book (assuming one has understood and can implement everything that was learned at least semi-well), how much more work or learning would there need to be before getting some sort of programming job? I'm looking at getting into learning python to have work on the side, but I'm trying to figure out how long and what I'll have to go through to get there self taught.

Thanks!

ehmatthes1 karma

That's really hard to say, because getting (and holding) a job depends on so much more than just learning to write code. Can you use what you've learned about code to solve other people's problems, even when their situation doesn't match exactly what you read in a book? Can you communicate well with others? Do you have expertise in another area that you're bringing to the table? How readily can you build on what you've learned from one resource?

A book like PCC offers a solid foundation in learning about programming, but you have to go beyond what's presented in an introductory book to get a job in the field. Some people follow a book like PCC up by working on projects that interest them, and pushing their understanding of the language by studying the things they need to expand on their projects. Some people read a series of books at more advanced levels. Some people never really manage to use code to solve problems in a way that will get them hired.

The only thing I can say with confidence is that most people who work through PCC will be much better off in realistically assessing their interest in pursuing programming as a professional career. But even if people don't make it the focus of their work, I believe it stays with you. You end up understanding the world a little better, and many people end up finding ways to use programming in their non-technical jobs.

That's a bit of a non-specific answer, but this is a hard question to answer without knowing a person.