Hello World!
Language choice can be quite a hot topic amongst us geeks. In the preface Warren defends his choice of Python with a bullet list I'll summarize here.
- Python was created from the start to be easy to learn.
- Python is free.
- Python is open source software.
- Python is not just a 'toy' language.
- Python is multi-platform.
- Warren likes Python and thinks others will like it too.
I think the list is pretty solid. The only one I think may not be directly applicable to the case it hand is the FOSS angle. Warren explains that being open means that more can be done with the software and that there is a large set of corresponding code out there freely available. A case could be made that this is also true of more closed languages. The one thing I think that could make this important is if the teacher of the material is interested in not just teaching the technical side of programming but is also interested in communicating the philosophical values of freedom. In light of the amount of closed source software and ignorance in regards to FOSS options I've seen in the public school system where I live, I think this may be more important than some think.
The rest of the reasons though I think make Python an incredibly solid choice, and above all else is the simplicity. My daughter has been able to have fun typing code into IDLE without having to get hung up with a complicated environment. The syntax is clean and simple, there is no compiling, it's very easy to just jump in and start making things happen. I think this is important, the younger the student. I was concerned that nine might be just a touch too young for this undertaking. The book itself does not make any recommendations concerning age. The more I've thought about it, the more I agree with that choice. Children vary so greatly and any number chosen would be rather arbitrary. My nine your old has done well so far, but she is already quite a book worm and leans towards more academic pursuits. An older child may struggle and there may be some that are even younger that would be fine with the material in Hello World! So rather than focus on age I think a parent needs to come at this from a perspective of ability, proclivity and experience.
In the ability area, a child is going to know how to read, work with a mouse, and type things via the keyboard. Of course the mouse is optional strictly speaking but most will probably want to use it. Some math skill would be good as well as the ability to understand the use of variables. The book tackles the necessary material in a kid friendly way but it is not dumbed down. In fact the learning potential here is huge, as one may imagine. The book is formatted with lots of visuals and fly-outs that give information on how computers operate and how programming languages deal with information processing. My daughter and I have already had interesting discussions on subjects like integers and floats. An example that draws a sine wave lead to a great teachable moment about amplitude and wave length. Then there is the constant need for approaching problem solving in a structured manner using logic. I think that taking on programming brings a wide number of benefits.
One of the features, is a little caricature of Carter that is placed throughout the book with observations that the real Carter made as he learned with his dad. These are things that a real kid noticed, and so they are likely to stand out to a child working through this book. For instance in the chapter on "Print Formatting and Strings" Carter says, "I thought the % sign was used for the modulus operator!" The book explains that Python uses context to choose how the % sign is used. There are other little cartoon characters that appear throughout the book drawing attention to important points that need to be remembered. Learning is reinforced through quizzes at the end of the chapters. The chapters are not too long but I've found that my daughter and I have to break them into sections because of her typing speed. I've been tempted at times to move things along by typing for her but I know that she will not get the same benefit from the exercise if we do it that way. I will also let errors slide by at times to allow her the opportunity to look at error messages and find the problems.
As I mentioned the book is billed as being for kids and "other beginners." I'm going to say that the primary focus is rightly on kids, and probably kids who are in grade school or maybe junior high. This is not to say that the examples and information wouldn't be great for anyone brand new to programming. There are even some nuggets for someone who has written some code but is new to Python. I am going to guess though that the average high school student will not be as taken with the cartoons and puns. I'd have loved to have written my own lunar lander game at that age though, so maybe I'm selling this short, or maybe it would be something a teen would be happy to work on away from the eyes of others, so as not to appear childish. (I may take heat for this but even as a teenage geek I was immensely worried about the perceptions of my peer group.) I think an adult that was serious about learning to program, even if they had no prior experience, would do better with heavier material. All that said, I think for children they've really hit the sweet spot and as much as marketers would like it to be so, no book can be everything to everyone.
Things start simple with print statements and loops that took me back to good old days of watching messages scroll endlessly by on display computers at Sears when I was a kid. The move towards games starts even then with text and quickly moves on to leveraging Pygame for games that utilize graphics. I think this is important as it keeps things entertaining while teaching important concepts at the same time. I have to say it is quite a bit fun to sit with my child discussing nested loops and decision trees. By the end of the book examples will have included a simple virtual pet, a downhill skiing game and a lunar lander simulation.
I've discussed a child's ability a bit but I think the last two things I mentioned must be taken into account as well. They are proclivity and experience. I've let my daughter drive the time we spend working on this. Just like the parents who project their sports dreams on their kids, I think there is a possibility to do the same with my love for all things digital. It may even be easier to do so as I view the ability to do some amount of programming to be an important life skill. The thing is I don't want to push her too hard and have her back away from it completely. This fits in with the experience part. We take it as it goes, and if things stop being fun, we will back off. I don't do this with her core disciplines from school like reading and math, but for something that is extra right now I'm not going to push. It would transition from being a joy to being work. That brings up a last and unexpected benefit from Hello World! I'm rediscovering a lot of the fun and excitement that drew me into this industry in the first place.
You can purchase Hello World! from amazon.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.
Thanks for the review, you just gave me an idea for what I'm going to be getting my nephews for their respective birthdays. Awesome! :)
Going to be very disappointed if I get stuck. "This is so simple, even a child can do it! Someone get me a child, I can't make heads nor tails of it!"
Kwisatz Haderach
Sell the spice to CHOAM
This Mahdi took Shaddam's Throne
That something like this had been around when I was a kid!
You went out of your way to praise your Dad for having the foresight to move beyond his comfort zone by bringing home a computer. Isn't computing simply your version of "sports and cars"? Shouldn't you be trying to emulate your father by moving beyond your comfort zone and bringing home something that will inspire your kids to pursue their own interests rather than yours?
Oh, I remember my first days of trying to get anything to work in C. (This was in the days of DOS, before Windows). Hopeless! I'd be trying to program Hello World or a very small addition to hello world like type in a character, and have to reboot the PC because I overwrote system memory :-)
I see your reasons and they aren't too bad but I wouldn't have picked Python myself. Maybe grab something from the top 3 most popular languages Java, (C, C++, C#) or PHP. As far as popularity goes though you could definitely do worse than Python.
There is a really nice, free alternative available in "How to think like a computer scientist". Despite the title, it's aimed regular school kids and is being used to teach a class on python programming. It's just come out in a second edition. http://openbookproject.net//thinkCSpy/
TCAP-Abort
Here's a question: If we teach our kids to program, do we start them on:
10 N=N+1
20 PRINT N
GOTO 10
or OnClick="doHelloWorld"
After learning to program on a TRS-80 and later GWBASIC but now doing ASP.NET, I find myself looking at code (ExecuteSacalar()) as if every step takes 1/100th of a second, thus slowing performance. When in actuality, it takes a microsecond. Are we better off teaching them how to write an algorithm (How much is 1 + 2 + 3 + ... + N?) or to start with finding what they need in a library? I've seen advantages and disadvantages to both my career.
Much of what I do now is finding the best canned operation (GridView) and toying with styles, rather than rolling my own Repeater. Seldom, but not never, does knowing how to step through a string get used. Although rolling my own DDL's is faster than letting .NET do it.
Should we teach our kids how to ride a motorcycle where pedaling isn't needed? Or do they need to learn to pedal before they ride a motorcycle?
Why, Lord, Oh why are blocks defined by indentation!
is that not only does it teach programming but as a side effect you're kids are guaranteed to be safe from pregnancy, STDs, or any form of social life.
FOSS doesn't mean there is a lot of freely available code to look at, FOSS means there is source code for the INTERPRETER that you can modify. I suspect it is written in C or C++, so you don't get any advantages in having the source for the python itself. Now, FOSS is a good argument for using gcc, since you get lots of example code ...
Even "closed source" languages have freely available code to look at. MATLAB, e.g..
What..? Are you sure you weren't coding assembly? I didn't realize printf/puts had that much power!
Some jackass moderator's having a laugh and modding everything down. Please fix this mod to insightful to make up for his karma being screwed (funny is neutral karma).
This isn't a Troll, it's Truth! Teaching a beginner to program in a sloppy language is like teaching them to drive a car with GPS, traction control, anti lock brakes, collision detection and rear-view camera. That's all fine until they have to know what they are doing. (Picture driving an MGB)
"Hitting middle age has been an interesting time. I catch myself thinking about how well kids have it today and sounding a lot like my father. One difference is while my dad was happy to teach me about horses or goats, we never spent any time hooking up pipes together. I think he did realize that indoor plumbing was important and I will always be grateful for the commode he brought home one day. It was a substantial purchase for our household. I spent many days excreting feces and flushing the results down the toilet. In my home today we have a considerably better situation, plumbing wise. There are usually a couple showers running as well as the jacuzzi upstairs. My kids take for granted what I found to be amazing and new. Still, that's all pretty normal and I'd like to give them an opportunity to go deeper if they are so inclined, just like we give them opportunities to explore other skills and pursuits. With that in mind I brought a copy of Hello Plumbing! home a few weeks ago, and the response from my oldest has been surprisingly enthusiastic."
The expectations of today's 9 - 14 year old is very different than for those of us learning BASIC on a Commodore or Atari in the early 80s. I tried Scratch and Kidsprogramminglanguage with my now-13 year old. As soon as he saw the creations we could make he said "at what point do I get to make a game like on Xbox or my computer?" He just wasn't satisfied making lines on the screen or adding numbers or helping to solve his math homework (when it would be easier to solve it in his head). So, yes it would be cool to make lunar lander and I would have also been soooo happy to have such a game in 1983.
Then again, his favorite games now are often on Kongregate - sometimes the simpler the better, like launching a stick figure out of a cannon and solving various puzzles of angle, thrust, bounce etc. So maybe it is possible, but it needs to be graphic, challenging and most of all fun.
This post brought to you by your friendly neighborhood MBA.
To whoever modded the parent down as "Troll": I really think you're off the mark.
Hand your kid a copy of The C Programming Language. If they can't handle that, they are not ready.
You drew an analogy to parents projecting sports dreams onto their children. Do you see this as a positive phenomenon? Sure, if you value programming as the absolute best thing a child can be familiar with, this makes sense. But what if your child would naturally have favored or have talent in some other area - say physics? The activity you are pursuing with her could lead to relative underdevelopment in physics when naturally she might have become a great physicist.
An article featured on Slashdot a while back, titled "A Mathematician's Lament", described how, instead of prescribing a course for children to follow in Mathematics, a more effective way to teach math would be for each child to organically discover math on their own. I see that you are attempting to do similarly with your child and programming (instead of math). But that article also brought me to wonder, why favor one subject over another? Why not also let the child organically and naturally discover her talents and interests? Best results might come from doing this with "Hello World", as well as doing similar activities with art, music, physics, language, and sports, in equal proportions.
Back then, if you wanted to play a game you often had to copy programs from source code listings. So you had things like line validators (checksum as you entered each line) and whole sections devoted to programming. The projects, I think, were also very different. I remember building a WeFax device to decode satellite weather facsimile images. There was also the Ciarcia articles that talked about everything from building a micro-computer to assembly programming.
Sure, there are still programming magazines, but we don't have to solve the same things we did then. Now it's just a matter of running CPAN, downloading a Flash or Java snippet, or just a #include.
That's why I'm super grateful for the availability of Linux, free software, and the suite of compilers. I remember saving up for weeks to purchase Megamax C and later GFA BASIC. I remember borrowing a Z80 card so that I could run Borland Turbo Pascal. Now it's a quick download and every language I want is available within moments.
The downside is that it's a lot more complex now. If I wanted to make a graphics program back then, for example on TI BASIC, it was a relatively simple matter to redefine a character set with a bunch of POKEs. Now we have to worry about initializing a window, internationalization, acceleration, etc.. Sometimes it's a bit daunting for non-professionals. Sure, there things like SDL and TCL/TK and a raft of IDEs, but still I don't think it is as easy as it was back then. (Of course, today's software does a lot more).
because it makes sense. Back in the 1960s & 70s I was working for IBM, when PL/I appeared. It uses Do... End to delineate blocks, and I was OK with that but then found it wasn't enough. So I developed an indentation scheme, jogging right at a Do and jogging back left at an End (white space is ignored in PL/I). This made it much easier to grasp the logical flow at a glance. Unfortunately I didn't keep any examples when I quit programming, but I think it would look remarkably similar to Python (except for the Do & End keywords).
So you had things like line validators (checksum as you entered each line)
:)
Wow, now that brings back memories. I remember typing many, many lines of numbers (with the checksum at the end) and then finally having a stick-figure or something dodge falling balls...
Of course, the real fun began when I finally learned what those numbers meant
It seems to me if I had a child and wanted to teach them programming, I'd do it using these three techs in this order. You don't need any special software to write any of them, they are easy to learn, and there are millions of free examples available to you. The best thing is, no compiling, no need for a server. You can write a bit of code, open it with your browser and get instant gratification.
Taking guns away from the 99% gives the 1% 100% of the power.
because it makes sense.
No, it doesn't.
Whitespace (by definition) is blank - it has no visual representation. You're trying to tell me that something you can't see should control how a language works?
Brackets, Braces, DO .. END, etc. all perform the same function in computer languages that punctuation does in human languages. It makes as much sense as punctuating human languages with whitespace. (Which we don't do, for obvious reasons.)
I got into computers because I could hack the BASIC games on an Apple ][+
Accessibility is king! But finding which thread to grab amidst the jumble of a modern GUI OS is tricky!!
I have just started playing with "Processing" and it seems to have a nice mix of understandable code and super powerful libraries to take advantage of: cross platform, modern hardware and complex meta-behaviours that we might expect.
As well, I am "sandboxing" with "Parallels" on top of OSX and I have found it to be very stable. (It allows virtualization of Windows flavours, OS X & varieties of linuxen concurrently) The images can be booted Read Only or not. Creating a bulletproof, clean starting environment is what kids(and productions) need, and virtualization images might be part of this.
I'm new to virtualization, but it feels like the future to me. Since I have taught in hands-on Lab settings I think this is a better solution for a shared use lab than straight up disk imaging... It would allow week by week, class by class customization of the Boot Image, and changes could always be rolled back.
Spoken language is (more or less) punctuated by whitespace. Tone certainly plays a role, but I can (lamentably) understand Ben Stein well, whether he's selling me eye drops, or calling me a latent Nazi.
I understand the philosophical rejection of whitespace as a control, and the argument appeals to a part of myself I have respect deeply, but at the same time, you -can- see it. Space and Tab have ASCII codes, and they are represented in whatever interface you're using by a region of white pixels, the same way an "A" is represented by a region of white pixels interspersed with a specific pattern of black.
If the language occasionally required a couple of spaces in a row before a line of code, and other times required a single tab, the result would certainly be horrific, but as it is, the requirement is both functional, and visually informative.
Sane people use tabs to separate blocks for the purposes of readability, anyway. At that point, curly braces become redundant information.
Python was created from the start to be easy to learn But I think BASIC on VIC-20 was even easier to learn then Python : no need to use colons or indenting! And what about the dreaded ==, impossible to understant for a kid! Mod me troll.
Since compilers and interpreters don't have to SEE your code, the "visually informative" requirement exists ONLY for humans. It should not be a requirement for proper execution of the code.
Nor is whitespace a functional requirement -- unless you've defined your computer language to require it, and then you're arguing in a circle. "It's a requirement because I decided to require it" isn't enough to claim it is a functional requirement. Many languages do NOT require it, because they were not defined to require it. The vast majority of languages need whitespace only to separate tokens.
Space and Tab have ASCII codes, and they are represented in whatever interface you're using by a region of white pixels, ...
No, they aren't. They are usually represented by SPACE -- a gap -- which usually appears as a section of terminal screen in whatever color the background happens to be. (Black, white, grey, yellow, pink, blue, orange, whatever...) In SOME editors, and on some systems by default, tabs are represented by a specific character, similar to the way an 'A' is represented. Some systems even have a mode where spaces are represented by a special character on the screen (like an underscore with serifs on the end.)
They aren't represented on all systems by the same amount of space, either. Some systems expand tabs to every 8 columns. I set vi to 3 or 4, usually, so that my columns don't run off the edge of the screen as I indent them.
And the same number of characters (space and tab) can result in vastly different "whitespace" representations, even assuming the same interpretation for a tab. "sp/sp/sp/sp/sp/sp/tab" will look VERY different than "tab/sp/sp/sp/sp/sp/sp", even though they are both the same number of characters.
Sane people use tabs to separate blocks for the purposes of readability, anyway. At that point, curly braces become redundant information.
Wow. Programmers who don't use tabs are insane?
No, GOOD programmers use whitespace to make their code readable by humans; they use the syntax of the language to make it readable by the compiler/interpreter. Using the VISUAL representation of the code as input to the compiler leads to nonsense like a language that says "a red flashing italic FOR compiles this way, but a blue flashing bold FOR compiles this other way...". That's just plain stupid, and anyone who defines a language like that would be laughed at.
No, it doesn't.
Whitespace (by definition) is blank - it has no visual representation.
Wrong. Oh so wrong. Try removing all redundant whitespace from a well-formatted program in a language of your choice (other than Python!) and see how readable it is compared to the original. Then try to tell us that the whitespace has no visual representation.
Quidnam Latine loqui modo coepi?
Sane people use tabs to separate blocks for the purposes of readability, anyway.
Not anyplace I've worked at. People constantly differ as to the number of spaces per tab, and it is common to prohibit tab characters in code altogether. This is not because the compiler/interpreter cares, it doesn't. It is for human readability. Even in languages with curly braces, erratic indentation is difficult to read and gets in the way of code analysis and programming. This promotes bugs and errors.
The suggestion that the programmer make the visual distinction between tabs and spaces while coding is foolhardy, even if the spaces and tabs are visualized with different characters. For code to be of high quality, the programmer must remove whatever noise or clutter is keeping her from correctly grasping what is going on. To add gratuitous indentation constraints works against this. Python would be just as great a language if it had curly braces. Nothing would be lost, and clarity would be gained. This indentation gimmick makes it a rebel without a cause.
Yourexactlyright.there'snoreasontousewhitespacewhendealingwithhumanlanguage.
Wait, what language is this that already uses red/blue italic flashing FORs?
My UID is prime... is yours?
I write JS for a living and I wouldn't let that crap loose on anyone. It's an awful language to learn - the runtime environments give little feedback about errors (and often incorrect feedback at that) it runs differently depending on which browser you use and the free tools for programming JS are crap.
I'd go for Java instead: all the FOSS advantages claimed for Python apply to Java as well, AND it performs very well ( typically 80% the speed of C), it has a ton of game specific libraries written for it but you can use it 'out of the box' for writing games as well just with the standard libraries. BUT - and this is the really big issue for me - it is *very* vocal about errors and the 'fail-fast' design philosophy really helps finding errors quickly. There's nothing worse than doing some coding on something that already works and finding it no longer runs and you have no (correct) feedback about what the problem is - and this happens to me all the time in Javascript (even with good tools like Venkman or MS's script debug tool).
I love C with a passion, but I agree - I wouldn't let a kid loose with it :o) Maybe a Uni student, but not a 9-12 yr old you're wanting to not hate programming =)
No, make them design and build their own.
---- Booth was a patriot ----
I think the point is that it IS still readable by humans and functional to the computer, where the python code will not be functional or readable. In fact, if you do this to C code, you can run it through "indent" and it will come out clearly indented for you. It sounds like such a program is impossible for python because it depends so much on how things are indented to start with.
Now now Steve, put down that chair !
I don't know what it is, but any discussion of Python brings about in me an almost primal reaction of disgust, I just can't help myself. ;) Syntactically important whitespace, what...the...@#%!?
You know, if he had decided to make either spaces *or* tabs to delimit blocks, Python would suck so much. I mean, it would still suck, but just not as bad. Who doesn't love a language whose programs can be destroyed by the slightest whim of text editor or paste into a web comment field? Or destroyed by one developer using spaces and another tabs? Lord knows you can't just run indent on a C program to make it formatted exactly the way you want it instead formatted like the insane designer of the language proscribes, except you can use both tabs and spaces to do it, of course. :)
BTW, I think this is next version of Python: http://en.wikipedia.org/wiki/Whitespace_(programming_language)
In fact, if you do this to C code, you can run it through "indent" and it will come out clearly indented for you. It sounds like such a program is impossible for python because it depends so much on how things are indented to start with.
Yes, it's impossible in Python. And also unneccessary. The "indent" program solves a problem that doesn't exist in Python.
Quidnam Latine loqui modo coepi?
When I had my CBM64 I really wanted my dad to join in the fun of me learning to program - he seemed quite interested but this is how the conversation went...
ME: So, dad, we're going to print the phrase "Hello Dad" on the screen then print loads of them - it'll be fun
DAD: OK
ME: To print something we use the PRINT command so to print this phrase we type 10 PRINT "HELLO DAD" - 10 is the line number - like a number in an instruction book.
DAD: OK - But why PRINT?
ME: Errr, because that's the command...
DAD: Hmmmm, OK
ME: To print it loads we then type "20 GOTO 10", this means it will GOTO line 10 and print it again..
DAD: Why GOTO
ME: Errr, because that's the command...
DAD: OK
ME: now we can run it by typing RUN (Hello Dad scrolls up the screen)
DAD: Why RUN?
ME: Oh FUCK OFF - you're like a 3 year old!
That was the end of my dad's programming.
In fact, if you do this to C code, you can run it through "indent" and it will come out clearly indented for you. It sounds like such a program is impossible for python because it depends so much on how things are indented to start with.
Yes, it's impossible in Python. And also unneccessary.
Let's see how smart you are when you get someone's code that isn't so clean in the whitespace department, and won't run anymore once you've opened it and saved it...
The whitespace requirement of Python sucks. I don't like programs whose behaviors are dictated by characters that I can't see and that aren't standard across editors.
If you're so into white space, be a man and use Whitespace.
I'm a fan of perl, Ruby, and bash when it comes to scripting.
Long live the BSD license
I also remember my first days as a teenager using C, but this was in the days of Unix, before MS-DOS. Wonderful! Yes, my programs would constantly print the wrong answer, core dump, and (mysteriously to me) produce strange errors when run from "make". But I never overwrote system memory, and I never had to reboot the machine. (Good thing -- it would have annoyed the hell out of the other 40 people using it!) Don't blame C that DOS reboots -- blame DOS.
Let's see how smart you are when you get someone's code that isn't so clean in the whitespace department, and won't run anymore once you've opened it and saved it...
Can you give me a scenario in which this might actually happen? People pass Python code around all the time, and whitespace simply doesn't cause the problems you imagine.
The whitespace requirement of Python sucks. I don't like programs whose behaviors are dictated by characters that I can't see and that aren't standard across editors.
Except you can see them because oh, look, those lines are all indented and they wouldn't be without whitespace. So you don't like it? Fine. Don't use it. But don't try to pretend it has all sorts of problems that it doesn't, in order to rationalise your dislike.
If you're so into white space, be a man and use Whitespace.
I like honey, but I don't want to live on a diet of nothing else.
I'm a fan of perl, Ruby, and bash when it comes to scripting.
Liking Perl and Ruby seem to go together, because Ruby is essentially a tidied-up Perl. If you're not coming from a Perl background I don't see the point of Ruby. If Python whitespace is a problem for Python, punctuation marks with completely non-obvious meanings is a problem for Perl/Ruby. Oh, that and OS-tie-in: Programming Ruby states that "Ruby is written for POSIX environments", and despite attempts to fit it to Windows it remains a poor fit because it really is written around the OS. Although I have to admit that when I came to the line in Programming Ruby that said "Ruby, unlike less flexible languages, lets you alter the value of a constant" I found it hard to carry on with a straight face.
Quidnam Latine loqui modo coepi?
The advantage of Python has nothing to do with OSS. C and C++ is at least as open source as Python, and both have a definitions superior to Python. In fact, many would use the same OSS IDE, Eclipse, for any of these, on any platform. No, the advantage of Python, as with the advantage of other higher level languages, is that, as the poster indicates, protects the user from the complications of the hardware. In addition, it simplifies the GUI design which is the basis of most modern programming. The disadvantage is that if a kid wants to know how to do more than connect widgets to databases, they may be SOL.
Of course the same could be said about Ruby and Rails, which seems to be even more modern and useful for modern programming. In particular Ruby implements the MVC methods, so at least the kid learns good programming.
"She's a scientist and a lesbian. She's not going to let it slide." Orphan Black
In DOS, without a memory manager, if you use pointers / arrays you have unrestricted access to every byte of RAM on the computer. Completely raw. Think about every time you get a segfault or a "Program performed an illegal operation" - that could easily be a dead system right there.
-- All your booze are belong to us.
"...common to prohibit tab characters in code altogether."
This seems rather backward to me. Who cares if it looks different on my computer vs. another persons computer? I'm happy, the other person's happy. I've never worked at any place that would out-right ban tabs.
It sounds like someone simply has a holy-war going on there. I mean, seriously, why should it matter what another person is comfortable with? As long as each developer has the code in a format they are comfortable with (by setting tab widths), I would think that would result in an increase in productivity.
Forcing people to learn every weird pet format and have to work their brain around another persons preference seems like it would waste time. Very strange behavior IMHO.
There were a bunch of programming students at a course I was attending who kept seeing the Borland copyright message.
char c;
printf("%s", c);
09F91102 no, 455FE104 nope, F190A1E8 uh-uh, 7A5F8A09 that's not it, C87294CE no. Ah! 452F6E403CDF10714E41DFAA257D313F.
<quote>It sounds like someone simply has a holy-war going on there. I mean, seriously, why should it matter what another person is comfortable with? As long as each developer has the code in a format they are comfortable with (by setting tab widths), I would think that would result in an increase in productivity.</quote>
.indentrc, and if you wanted to see it in a different style, you'd have your own .indentrc you could run the code through before you worked on it. Then you'd convert it back and everyone would be happy. Python? No.)
Well, it apparently does matter because some shops have programming standards that are enforced. Indent like this, put elses here, ifs there. All the code looks the same, and you don't have to deal with one section of code done one way and another done another.
But to answer your "why", here's an example.
/tabfor(i=0;i<5;i++) {
/sp/tab/sp/sp/sp/spdoThat(i);
/sp/sp/sp/sp/sp/sp/sp/spdoThis(i);
/sp/sp/sp/sp}
On my terminal, with tabs set to 4, looks like:
for(i=0;i<5;i++) {
doThat(i);
doThis(i);
}
On yours, tabs set to 8:
for(i=0;i<5;i++) {
doThat(i);
doThis(i);
}
It's still valid C, but looks awful. Nothing lines up. If this was python code, I'd see the two calls as being part of the for (if python has such a thing, I dunno), you'd see only the doThat call as part of the for. Two different interpretations of one piece of code BASED SOLELY ON TAB STOP SETTINGS IN THE EDITOR! That's absolutely nuts!
(In many C shops, there would be a "standard"
If any parents are reading this, just wanted to mention I've (+other's help) written an article on wikipedia covering the educational programming language domain:
http://en.wikipedia.org/wiki/Educational_programming_language
do it yourself fireworks - always fun for the whole family!
Ask Me About... The 80's!
I once forgot to write an EOF to an open file on the hard drive, and bytes got corrupted in random files all over the place. We were finding single corrupted bytes for weeks, like when you smash a glass in the living room and never quite find all the bits. There were some good points about having so few abstraction layers between your code and the hardware, but a lack of memory protection was not one of them.
Start with C and a lack of want to understand will result.
C is one of the worst languages to start with. What it teaches you is frustration because you can't even begin to understand just WHY your programs don't run. What it teaches you is bad coding practice because it WILL accept almost any harebrained spaghetticode you cram down its compiler. And once you got used to 'if (i=a%2)...' to test a for being odd or even and store that fact in i at the same time, so you can later just add/subtract i from something else, you are already lost. Not to mention the countless hours spent figuring out why 'if (i=5)' is always true even if i isn't 5, but oddly i is always 5 after the branch...
Start in something that enforces some strict rules while at the same time offers enough training wheels to enable you to find your bugs. C is very powerful indeed, but finding bugs can be a daunting task for an inexperienced programmer. And I'm not even talking about obscure run time bugs (like, say, buffer overflows because you count from 1 instead of 0) or bugs that don't show in the line where the actual problem resides.
Give your newbies a language that, while not powerful or fast, makes debugging easy. I have met a fair lot of programmers, and interesting how many of them lack in the debugging department. And don't say your programs have no bugs. That only means you never found them.
We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
My dad isn't a computer person either. His relationship with computers is best described as 'hostile'. But he realized his son has a knack for mathematics, has an analytical mind, loves logic puzzles and can think that way too, so a computer would be the perfect match. He was no rich man back then and computers were expensive toys, but he didn't question the wisdom of spending a thousand bucks on something he doesn't have the foggiest clue about because he was also sure that this is where the future will go.
It's odd. On 99% of the things my dad decided would be 'good for me', he was wrong. I'm glad he didn't fail at that one.
We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
About 5 years ago, I was lamenting the apparent lack of programming books aimed at children. I posed the question "what would be a good modern language for kids to learn?" and almost every response I got was "Python." So this is perfect! Too bad I didn't get the chance to (1) learn Python, (2) write a book, (3) get it published. ;)
If you have the luxury of only working with your own code, and if you stick to your own conventions, then the whitespace issue may not be a big deal.
But, when I work with somebody else's code, I have to wonder: "what I am I looking at? Spaces? Tabs? Some combination of spaces and tabs?" I can not tell just by looking at the code, I have to do a hex dump, or something.
Then, if I want to put somebody else's code into my own, I have to muck with the code first to make sure I have the exact combination of spaces and tabs.
If I want to email Python code, or post Python code to a news-group, that is another potential headache.
Being able to use curly brackets makes the situation even worse. If somebody else uses curly brackets, and I don't, then I have to muck with the code even more.
I especially can not understand why Python 3.0 allows the use of spaces and tabs. Python 3.0 was supposed to fix long standing problems with Python. Even Guido has commented that indentations should be four spaces - so why not make that mandatory? Such a standard would go a long way towards mitigating the whitespace issue, and Python 3.0 is throwing away backwards compatibility anyway.
"it was a relatively simple matter to redefine a character set with a bunch of POKEs"
A bunch? Hello... Understatement of the Month Club?
I've been seriously considering using C++ and XNA to teach programming to my kids; sure, printing 'Hello World' is cool, but printing 'Hello world' on the Xbox is cooler.
Vintage computer games and RPG books available. Email me if you're interested.
And don't say your programs have no bugs. That only means you never found them.
One of my favorite examples of this is the fact that (as various people over the years have discovered), the original "Hello world!" program in the C bible has a subtle bug.
It can be fun to challenge people to find it. My favorite clue to get them even more puzzled is to tell them that the bug doesn't affect the behavior of the "Hello world!" program itself; it affects the behavior of other nearby programs.
Those who do study history are doomed to stand helplessly by while everyone else repeats it.
OK, thanks. I only work in C# the last few years, it handles all of this quite elegantly, but I do see your point now.
Its funny I find myself reflecting upon how different things are these days, even looking back to the 70's and 80's. Technology advances so fast, which is good, I just think we sometimes get a little left behind. Guess that is what happens with old age!
100% Mortgage