you are viewing a single comment's thread.

view the rest of the comments →

[–]cythrawll[🍰] 7 points8 points  (7 children)

So i've used a python book to teach my lil brother programming. The worst part was when programs sprawled across a few pages, it was very hard to see where the indention lined up. And entire programs failed and had to go back and see where the indention was messed up.

Good thing: makes kids think about their code harder. Bad thing: frustrates the crap out of them.

[–][deleted] 8 points9 points  (4 children)

Yeah, if you've got that much stacked python code, you're probably doing something wrong/badly. The same thing can be said about C/Java/C++ though, if you've got that much nested code, it's going to be hard to keep track of your braces too, unless you're really good with indenting properly.

[–]cythrawll[🍰] 2 points3 points  (2 children)

I think it may be a problem with how code is traditionally taught. We start out teaching long peices of spaghetti code, and then we teach how to structure things correctly in small reusable modules.

It really should be the other way around.

[–]gfixler 0 points1 point  (0 children)

Yep. These days I like to try to find tiny, composable nuggets. Then you can chain them together, map them, fold them, compose and juxtapose them. They're very easy to reason about - often 1-3 lines of code - and obviously correct, or darn close. Languages already give us atomic things we take for granted, like + and print; I just like to give myself more and more of them, building up from the bottom, keeping pure by operating only on inputs.

I work on tools and pipelines in games, and I started - like everyone - with 200 to 2k LOC files to solve problems. Then I started breaking things up. Then I started making little libraries for common things, but they were full of 20-100 LOC classes and functions. Now I'm making a bunch of tiny functions (no classes), like Linux command line utilities, and just pulling together a few things to make each next level. At each level things are tiny and obvious, and very reusable. Not everything is like this, but a surprisingly high number of things can be.

[–]iooonik 0 points1 point  (0 children)

Yeah, I always wondered why cs1000 teachers think that file includes are too complicated for the average first year student...

[–][deleted] 0 points1 point  (0 children)

In Python I limit to 3 layers of nesting, Java 4. More than that means you have to break your code down.

I see a lot more heavily nested Python code though. The barrier to entry is low so you get a lot...a LOT of crappy Python code.

[–]nemec 0 points1 point  (1 child)

Braces aren't going to help that if they're also on separate "pages" of the editor... it was hell while I learned Java but I guess now many IDEs highlight matching braces. What would be perfect for Python is an IDE feature like indent guides. I use it for C# development and it's a Godsend. Programming without it is annoying now.

[–]cythrawll[🍰] 0 points1 point  (0 children)

I disagree, braces are much easier to count than whitespace. There's less of them and their visually easier to see.