Feedback on my programming tutorial

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Feedback on my programming tutorial

Postby Cosmologicon » Sat Aug 06, 2011 3:33 pm UTC

Hey I'm starting a teach-yourself-programming blog. I've written three lessons so far. I've got a lot more planned, but I figure I should stop and ask for feedback.

I'm doing this because I've had three friends now who wanted to know what programming is about. I looked for programming tutorials online, and I felt like even the good ones were missing something. If they solve any problems at all, they do it the hard way. There's this C++ tutorial that uses pointers to take the average of two numbers. That's just going to scare people away, I think.

I wanted to show how useful programming is for problem solving, so my first lesson ends with testing whether a number is prime, and I'm putting off "Hello world" until lesson 3.

Anyway, just wanted to see if anyone had any feedback as to whether this is a dumb idea or what. Also any pedagogical suggestions (design, wording, pacing) would be welcome. I'd really like to use some well-tested teaching techniques, but I haven't come across a good resource for them yet.

Thanks!

http://smoothprogramming.blogspot.com

User avatar
Robert'); DROP TABLE *;
Posts: 730
Joined: Mon Sep 08, 2008 6:46 pm UTC
Location: in ur fieldz

Re: Feedback on my programming tutorial

Postby Robert'); DROP TABLE *; » Sat Aug 06, 2011 4:25 pm UTC

It's a good idea in principle, but IMO, in entry 1, you spend too much time messing around with bc. I don't know about your intended audience, but I would say that people interested in programming would know how basic arithmetic works, and would only need help about how to tell that to the computer. (Such as "times" being a * instead of a [imath]\times[/imath], no such thing as implicit multiplication, etc.)

Also, you seem to have overlooked the fact that bc is not available by default on Windows. You'd need Cygwin or something.

(This is ignoring a potential debate about whether bc is "real" programming or not.)
...And that is how we know the Earth to be banana-shaped.

User avatar
Mr. Timms
Posts: 67
Joined: Sat Mar 15, 2008 12:59 am UTC
Location: Phoenix, AZ

Re: Feedback on my programming tutorial

Postby Mr. Timms » Sat Aug 06, 2011 7:03 pm UTC

Sorry, (ignoring previous aside) but this isn't programming. It's programmatic calculation, kind of like programming a TI-83, but easier, faster, and using a Linux tool, except you can't do any fun graphs with it.

It's seems more like a tutorial for math, using a "programmable" calculator.

Oh well, at least bc has a shell.

I don't think you should stop, but do you think you could transition to, say, Python? Math is used as an introduction to computer science, but this is supposed to be a programming tutorial, right?
Decker wrote:
nbonaparte wrote:You'll learn this around here. Everyone's pretty damn blunt.
I am not! Now if you'll excuse me, I'm going to go take a huge shit.

Anonymously Famous
Posts: 241
Joined: Thu Nov 18, 2010 4:01 am UTC

Re: Feedback on my programming tutorial

Postby Anonymously Famous » Sun Aug 07, 2011 5:04 am UTC

I agree with Mr. Timms. Python would be a good language to focus on.

Pepve
Posts: 57
Joined: Wed Jul 28, 2010 9:47 am UTC

Re: Feedback on my programming tutorial

Postby Pepve » Sun Aug 07, 2011 10:38 am UTC

Your first post ("Welcome") made me chuckle, that's an important box to tick. I like the premise of using simple tools to solve difficult problems. It also keeps you far away from the 'unsmoothness' of design patterns, which is cool.

I think bc is a nice choice, its limits shouldn't matter too much for your goals. But you should maybe solve a difficult problem with it early on, to validate the choice to your readers.

Sagekilla
Posts: 382
Joined: Fri Aug 21, 2009 1:02 am UTC
Location: Long Island, NY

Re: Feedback on my programming tutorial

Postby Sagekilla » Sun Aug 07, 2011 10:36 pm UTC

If this is meant to be absolute bare bones basics on programming, then bc is fine for doing some basic things. But you're
going to have to transition like others have said. The one thing that might be bad about this is you might alienate your readers.

They might think something like: "Wait, wait, now we're using python. Why do I have to use 3 ** 2 now? Why can't I use 3^2?
And why does 3^2 give such funny results?"

Sure, even basic programmers (Like a first year computer science student that never programmed before) can make the transition
easily but if you're really aiming for people who know -nothing- about programming, they might not be happy about the differences.

I can't tell you how many people (who took a few classes on this stuff already) were put off by the idea of changing syntax and so forth.
Just imagine what that would be like for someone who just picked this up five minutes ago.

You may want to do the transition fairly quickly into python, especially if you've set up an environment like cygwin. Python may be a
bad choice though, since the whitespace will matter.

Other than that, I think the tutorials aren't bad. You may want to try introducing this to someone you know who can't program and see
how they do with it.
http://en.wikipedia.org/wiki/DSV_Alvin#Sinking wrote:Researchers found a cheese sandwich which exhibited no visible signs of decomposition, and was in fact eaten.

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: Feedback on my programming tutorial

Postby Cosmologicon » Sun Aug 07, 2011 11:23 pm UTC

Awesome, thanks for the feedback everyone! I really appreciate it! :)

I probably should have anticipated that my language selection would be contentious. To be clear, python is my favorite language and I use it all the time, but I think that bc is more appropriate for this project, for the reasons given in the Welcome post. I'd be willing to consider changing to python, but it would have to be for very well-considered reasons. I don't want to use it just because it's more popular or because it's more of a "real" programming language.

The reason I like bc for smooth programming is precisely because it's such a weak language. I heard people rave about python and how easy it is, but the reasons they gave were things like "it has an interpretive shell", "you don't have to worry about types", and "it does arbitrary precision". I started thinking, "bc has all that and it's the lamest non-esoteric language I know." I started wondering if people don't realize how little they actually need from a programming language. I then went and solved the first 200 Project Euler problems in bc, to prove to myself that it could be done.

If you understand all that and you still think python would be better for this tutorial, I'd be interested to hear your thoughts. I'm also considering completing this project in bc, and if it works out, I could port the tutorials to python.

Anyway, I think it may not be clear where I'm headed with this tutorial. Lesson 1 is like my "hello world". The later lessons are going to be about as different from this one as programs in the middle of a textbook are different from "hello world" programs. Here's the list of topics I have in mind:

  1. mathematical syntax
  2. variables
  3. input/output
  4. conditionals
  5. while loops
  6. for loops
  7. arrays
  8. functions
  9. recursion

Here's a program I hope to include in one of the later lessons:

Code: Select all

#!/usr/bin/bc -lq

# Create an image of the Mandelbrot Set

a0 = -0.57 ; b0 = 0.48  # Center of the image
pa = 750 ; pb = 450     # horizontal and vertical size in pixels
sa = 0.05 ; sb = 0.03   # horizontal and vertical size in units

# Return the number of iterations needed to escape
nmax = 500
define icount(a, b) {
    auto n, x, y, nx, ny
    x = 0
    y = 0
    for (n = 0 ; n < nmax && x^2 + y^2 < 4 ; n += 1) {
        nx = x^2 - y^2 + a
        ny = 2 * x * y + b
        x = nx
        y = ny
    }
    return n
}

# Print out the image header
print "P3\n"
pa
pb
100

# Color codes
r[0] = 100 ; g[0] = 0   ; b[0] = 0    # red
r[1] = 100 ; g[1] = 25  ; b[1] = 0    # red-orange
r[2] = 100 ; g[2] = 50  ; b[2] = 0    # orange
r[3] = 100 ; g[3] = 100 ; b[3] = 0    # yellow
r[4] = 50  ; g[4] = 90  ; b[4] = 0    # yellow-green
r[5] = 0   ; g[5] = 80  ; b[5] = 0    # green
r[6] = 0   ; g[6] = 0   ; b[6] = 100  # blue
r[7] = 60  ; g[7] = 0   ; b[7] = 60   # purple
r[8] = 30  ; g[8] = 0   ; b[8] = 30   # dark purple
r[9] = 0   ; g[9] = 0   ; b[9] = 0    # black

# main loop
for (ib = 0 ; ib < pb ; ib += 1) {
    b = b0 + sb * (ib/pb - 0.5)
    for (ia = 0 ; ia < pa ; ia += 1) {
        a = a0 + sa * (ia/pa - 0.5)
        n = icount(a, b)
        color = sqrt(81 * n / nmax)
        r[color] ; g[color] ; b[color]
    }
}

halt
This program, of course, outputs the following image:
mandel.png


Do you think it would be helpful to put something like this as a demo early on, to show people what they can expect if they stick with it?

Robert'); DROP TABLE *; wrote:I don't know about your intended audience, but I would say that people interested in programming would know how basic arithmetic works, and would only need help about how to tell that to the computer.
I see what you're saying. I was really hoping to reach underrepresented potential programmers, particularly women, people not very familiar with computers, and younger students (age 12 or so). That's why I'm trying to require as little math background as possible. But I also wouldn't mind keeping more advanced people engaged as well. Do you think that maybe this could be solved by moving some of Lesson 1 into an optional lesson?
Also, you seem to have overlooked the fact that bc is not available by default on Windows.
Hmmm... I provided a link to the download and install instructions. I'm not sure what else I could do? If you mean that just by choosing bc I'm overlooking that it's not available by default on Windows, is any language available by default on Windows? I guess IE comes with a Javascript interpreter. So in theory I could have people program JS in their browser without downloading anything. That seems like even more of a pain though. What did you have in mind?

Sagekilla wrote:You may want to try introducing this to someone you know who can't program and see how they do with it.
That's a great idea. I'm realizing I don't know what stumbling blocks beginners are going to have.

Sagekilla
Posts: 382
Joined: Fri Aug 21, 2009 1:02 am UTC
Location: Long Island, NY

Re: Feedback on my programming tutorial

Postby Sagekilla » Mon Aug 08, 2011 2:58 am UTC

Cosmologicon wrote:Wall of text


When I get to work this week I'll introduce my friend to your tutorial. The extent of his programming knowledge is
he knows how to do REALLY basic stuff in Mathematica (for the research we're doing.) So I'll have him take a look at it
and see how he handles it.

Though, he may be at a slight advantage since the Physics background tends to help a bit.

Hmmm... I provided a link to the download and install instructions. I'm not sure what else I could do? If you mean that just by choosing bc I'm overlooking that it's not available by default on Windows, is any language available by default on Windows? I guess IE comes with a Javascript interpreter. So in theory I could have people program JS in their browser without downloading anything. That seems like even more of a pain though. What did you have in mind?


Why not provide a single post dedicated to just setting up the bc environment? It's one thing to link them to another page, but
it would be helpful if you provided your own explanation of this. People may forget about your website if you link them away from
it on the very first blog post.

I don't doubt your credibility, but for someone else it might give them the extra push to convince them "Hey, this guy knows what
he's talking about. That was easy to set up bc, I think I'll keep going." All speculation, of course. You won't really know til you have
some people actually try this out.
http://en.wikipedia.org/wiki/DSV_Alvin#Sinking wrote:Researchers found a cheese sandwich which exhibited no visible signs of decomposition, and was in fact eaten.

User avatar
Mr. Timms
Posts: 67
Joined: Sat Mar 15, 2008 12:59 am UTC
Location: Phoenix, AZ

Re: Feedback on my programming tutorial

Postby Mr. Timms » Tue Aug 09, 2011 3:12 am UTC

Cosmologicon wrote:I started thinking, "bc has all that and it's the lamest non-esoteric language I know." I started wondering if people don't realize how little they actually need from a programming language. I then went and solved the first 200 Project Euler problems in bc, to prove to myself that it could be done.


Never mind what I said. That's the most awesome thing I've ever heard.

I think that including that demo and install instructions would also be useful. That demographic you're aiming for usually uses Mac or Windows.
Decker wrote:
nbonaparte wrote:You'll learn this around here. Everyone's pretty damn blunt.
I am not! Now if you'll excuse me, I'm going to go take a huge shit.

Anonymously Famous
Posts: 241
Joined: Thu Nov 18, 2010 4:01 am UTC

Re: Feedback on my programming tutorial

Postby Anonymously Famous » Thu Aug 11, 2011 1:33 am UTC

Question: Does the language that you chose have any way to output text, manipulate text, or read from a file (other than being able to read a program in from a file)? Because if all it does is numbers, your target audience may have just changed to mathematicians who are beginning programmers.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Feedback on my programming tutorial

Postby EvanED » Thu Aug 11, 2011 2:25 am UTC

So I haven't read any of the thread yet (except Anonymously Famous's last post since it was there when I scrolled down) but I'll go back and do that at some point.

I'm not going to comment on the choice of bc too much; I could probably count the number of times I've used it on one hand (in the normal way!) so I can't talk about it very intelligently. However, I do think Anonymously Famous's post is right on the money: there's a lot of stuff in programming that isn't mathematical, and is more data structure manipulation, etc. I feel that the sorts of things you see in, say, Project Euler represent a relatively small portion of programming.

Take a concrete example. Suppose I want to write a program that is a phone book. Example interaction in the spoiler if you want to see what I have in mind:
Spoiler:

Code: Select all

$ phone-book numbers.txt
Enter your choice:
1. List numbers
2. Look up number
3. Add number
4. Change number
5. Remove number
> ** 2
Name?
> ** John Johnson
Number: 555-5555
Enter your choice:
1. List numbers
2. Look up number
3. Add number
4. Change number
5. Remove number
> ** 4
Whose number would you like to change?
> ** John Johnson
What is the new number
> ** 555-6666

If bc would be a really bad language for that, then I think it's a bad language for beginners. (Or least for the I suspect vast majority of people who might be interested in programming but aren't particularly interested in doing a bunch of numerical computations.)

Edit: Lesson 1
To start bc, type bc -lq at the prompt. That's bc, space, dash, lowercase L (as in library), and lowercase Q (as in quiet).

So this actually won't affect beginners, but not knowing about bc I was rather confused here, because I was in the gcc mode of thinking a little bit. My thought process when I read this bit was something like:

To start bc, type bc -lq at the prompt. "OK. I wonder what the -lq is?"
That's bc, space, dash, lowercase L (as in library),, "Library? OK, I guess that makes sense, maybe not everything useful is available by default. Hmm, I wonder what libq is? That's strange."
and lowercase Q (as in quiet). "Wait, what? Is that a libquiet (not totally unreasonable BTW) or is q a separate option? And if it's a separate option, where's the library name?"

I had to go to the manpage to find out what the options do. It's a minor point, but I'd like to see a quick statement of what the options do, or barring that, I definitely think an explicit -l -q would be good to make clear that q isn't an argument to -l.

Division uses the slash /

Perhaps mention somewhere (where you do 22/7 would be good) that if / seems to do the wrong thing (e.g. 1/2 gives 0 and 22/7 gives 3) they forgot -l. (Not that this happened to me. No sir.)

(Reading further, I see you talk about this later. That's good... though I still think that it would be good to say "If you get '3' here, see below" earlier, but that's another minor point.)

Nobody did it for over 300 years, but lots of people tried.

Maybe mention that someone succeeded.

Lesson 2
There's a shorter way to type x = x + 1

I think even that deserves some explanation, since that's nonsense from an algebraic point of view.

Really, your previous section needs to be expanded more. Right now, it basically says "the difference between algebra and programming is that the left side has to be a variable" (in other words it won't solve equations for you)... but there's a pretty large step from there to figuring out why x = x+1 isn't hogwash.

Really you need to say something like "the equal sign in programming is really entirely different from the mathematical equal sign. In programming, what it means is that the system will evaluate the expression that appears on the right-hand side of the equal sign, and then replace the current value of the variable named on the left-hand side with that new value." (I'll leave it up to you whether you want to use "expression" and "evaluate".) I'd even toss in a "Some languages write assignments differently for this reason. For instance, Pascal uses x := 5, and TI-BASIC uses x ← 5."

And then stick in an example of how x = x + 1 will change 3 to 4 or something.

but here at Smooth Programming, we prefer using the simplest one available, so a text editor will be fine. Popular text editors include Notepad, TextEdit, gedit, Notepad++, Kwrite, Emacs, and Vim. Any of them is fine.

I would like to make an strong suggestion against including Notepad in that list, and a slightly weaker suggestion to explicitly call it out as not being very good. There are a multitude of reasons why, but lack of line numbers is basically an instakiller for programming. Notepad is definitely not "fine". (You can suggest Notepad++ as a replacement. "Really the one exception is Windows's Notepad; if you're tempted to use this, I strongly suggest using something else instead; Notepad++ would make a good choice.")

Now, reading over the thread: (no comments about 2.1, by the way)

Cosmologicon wrote:I then went and solved the first 200 Project Euler problems in bc, to prove to myself that it could be done.

See my comments at the very start of this post. I feel that numerical computations are a small part of programming, and less... "hooky" then a lot of other stuff to people who don't have a pretty deep interest in math -- and because of this, the fact that you could do 200 Project Euler problems in bc is not a very good argument to me.

If you want to aim at such mathy people, that's fine as long as it's an explicit choice. (And I'm not totally convinced it is, and am less convinced that you bring that across in the "who's this for" section of the intro.)

Do you think it would be helpful to put something like this as a demo early on, to show people what they can expect if they stick with it?

Yes, preferably in the intro.

Also, you seem to have overlooked the fact that bc is not available by default on Windows.
Hmmm... I provided a link to the download and install instructions. I'm not sure what else I could do?

Yeah, there's not a lot to do there. (Though I think maybe mentioning how to add it to $PATH would be very good.) You may also want to mention Cygwin as a more fully-featured set of programs -- though I think this is less necessary and less of a good idea than it may initially seem.

You may want to provide a direct link to the setup as well as the one you have now (I grabbed a download without all dependences the first time) and I also like Sagekilla's dedicated setup page idea.

If you mean that just by choosing bc I'm overlooking that it's not available by default on Windows, is any language available by default on Windows? I guess IE comes with a Javascript interpreter. So in theory I could have people program JS in their browser without downloading anything. That seems like even more of a pain though. What did you have in mind?

That's about the only option, unfortunately.

User avatar
Cosmologicon
Posts: 1806
Joined: Sat Nov 25, 2006 9:47 am UTC
Location: Cambridge MA USA
Contact:

Re: Feedback on my programming tutorial

Postby Cosmologicon » Thu Aug 11, 2011 7:37 pm UTC

Thanks again, all! Sorry for the wall of text, but I don't want to ignore the feedback!
Anonymously Famous wrote:Does bc have any way to output text, manipulate text, or read from a file? Because if all it does is numbers, your target audience may have just changed to mathematicians who are beginning programmers.

This is an excellent point. All it can do is output text. It doesn't treat strings of text as manipulable objects. This is probably the most elementary limitation of bc, you're absolutely right. I also agree with EvanED that Project Euler is almost tailor-made for bc, and it's not representative of programming in general.

Having said that, I don't think that mathematicians are the only people whose programming needs are met with numbers.
EvanED wrote:Take a concrete example. Suppose I want to write a program that is a phone book:

Code: Select all

$ phone-book numbers.txt
Enter your choice:
1. List numbers
2. Look up number
3. Add number
4. Change number
5. Remove number

If bc would be a really bad language for that, then I think it's a bad language for beginners. (Or least for the I suspect vast majority of people who might be interested in programming but aren't particularly interested in doing a bunch of numerical computations.)

So... my sort of "philosophy" with this blog is that your phone book program is not a program that anyone needs to write, because it doesn't solve any problems you couldn't solve more easily with a spreadsheet. I understand the utility of having learners write programs that aren't useful, as practice for the useful ones, but that's just a means to an end. If you can have them practice by writing useful programs, all the better. And I think that when it comes to programs with the most usefulness in the fewest number of required concepts, the problems you can solve with bc are really good.

Now of course there are lots of useful things that bc can't do, such as manipulate files. But just because its back end is numerical doesn't mean that the only things it can do are computations. I've written programs to play Nim and Connect Four in bc, and I've even written an actual text adventure game (although I had to get a bit creative with the text input). So yeah, bc has some severe limitations, but I don't think it's fair to say that it only does math, just because its only data type is a number. I also suspect that you'll be able to handle string manipulations better if you're comfortable with arrays first, but that's just a suspicion.

I'm going to have to think about this some more. Maybe I'll try to write up a plan for a python version, and see if I feel like the ability to work with text is worth the additional complexity (and as simple as python is, it's more complex than bc).
To start bc, type bc -lq at the prompt. That's bc, space, dash, lowercase L (as in library), and lowercase Q (as in quiet).

So this actually won't affect beginners, but not knowing about bc I was rather confused here.... It's a minor point, but I'd like to see a quick statement of what the options do, or barring that, I definitely think an explicit -l -q would be good to make clear that q isn't an argument to -l.
Maaaaybe.... I really expect most people won't care, and as you say, I do go on to explain some of it later. I think I may just put a note saying I'll cover what this means later, but for now input the command exactly. Or perhaps an optional box that explains the arguments briefly.
There's a shorter way to type x = x + 1

I think even that deserves some explanation, since that's nonsense from an algebraic point of view....

Cool, I tend to agree. This section was cut down significantly from my first draft, since I figured people wouldn't care. I'll see how I can add more back in without messing up the pacing.
Popular text editors include Notepad, TextEdit, gedit, Notepad++, Kwrite, Emacs, and Vim. Any of them is fine.

I would like to make an strong suggestion against including Notepad in that list....
You may also want to mention Cygwin as a more fully-featured set of programs -- though I think this is less necessary and less of a good idea than it may initially seem.

Sagekilla wrote:Why not provide a single post dedicated to just setting up the bc environment?

Hmm, well I'm not very familiar with Windows. I've never installed Cygwin or Notepad++. I'd really just like to make the setup as easy as possible on people. I'll have to spend some time trying this out on Windows and really figuring out the simplest way. Then I'll be able to provide the post about setup instructions too. :)

Thanks again!

Anonymously Famous
Posts: 241
Joined: Thu Nov 18, 2010 4:01 am UTC

Re: Feedback on my programming tutorial

Postby Anonymously Famous » Thu Aug 11, 2011 8:34 pm UTC

I use Notepad++ on my own computer, as well as on my work computer. It's not a hard program to install, so if you add it to your initial instructions for Windows users, you won't be adding any more complexity (other than the fact that they'll now be installing 2 programs instead of 1).

If you do change this to Python, you can skip text editors entirely, as Python comes with one that highlights syntax (IDLE). It does lack line numbers (which EvanED seemed to see as the biggest drawback for Notepad), but does have functionality to go to a specific line. You would also have one text editor that you could use for all students. Having a pretty universal environment can definitely be a plus in teaching. You can even say something along the lines of "if you have a favorite text editor, go ahead and use that, but here, we're going to use IDLE, which comes with Python." (I use 2.7, by the way.) IDLE can run the programs directly, too, so no need to go to the command line (though they still can, especially if they want to test command line arguments).

Cosmologicon wrote:So... my sort of "philosophy" with this blog is that your phone book program is not a program that anyone needs to write, because it doesn't solve any problems you couldn't solve more easily with a spreadsheet. I understand the utility of having learners write programs that aren't useful, as practice for the useful ones, but that's just a means to an end. If you can have them practice by writing useful programs, all the better.


I do see your point here, but giving your students formulas that they could put into a graphing calculator, such as your Fibonacci example, may not exactly fit your definition of "useful." Also, the "find the day of the week" example is pretty trivial in any language that includes date/time functions in their standard libraries, but you could also use any language that supports integer division. Or you could use any calendar program (including the one that gives you the current time on your computer), or a spreadsheet if you format a cell to display the day of the week instead of the date.

I was actually giving this some thought last night, and you really only need a few things to be a "smooth" programmer (as you call them):
  • The ability to define the problem that you want to solve (or, in the case of a tutorial, the problem that the tutorial wants you to solve).
  • The ability to recognize patterns in your problem.
  • The ability to break those patterns down into individual instructions.
  • An understanding of how to convey those instructions to the computer in the programming language of your choice.

The great thing about Python and other feature-rich languages is that a lot of people have solved large chunks that are part of a lot of problems (such as date/time). You don't have to reinvent the wheel (though, of course, you can if you want to).

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Feedback on my programming tutorial

Postby EvanED » Fri Aug 12, 2011 4:31 am UTC

Cosmologicon wrote:Having said that, I don't think that mathematicians are the only people whose programming needs are met with numbers.

No, but they're probably the only ones who are going to be satisfied with a language that makes other manipulations hard. Back when I was first learning programming, in BASIC, I lasted a couple days before wanting to do things with strings. (And, of course, I was learning out of a couple sidebars in the math text we had -- and that didn't cover strings. Fortunately, my dad knew a little bit.)

So... my sort of "philosophy" with this blog is that your phone book program is not a program that anyone needs to write, because it doesn't solve any problems you couldn't solve more easily with a spreadsheet.

I don't fully agree here, but I definitely see where you're coming from. But what about another example... say tic-tac-toe, and a tic-tac-toe AI? Maybe later expanded to something like reversi or checkers, and later to chess or go? How reasonable would bc be for things like that, as compared to Python or whatever?


I've written programs to play Nim and Connect Four in bc, and I've even written an actual text adventure game (although I had to get a bit creative with the text input). So yeah, bc has some severe limitations, but I don't think it's fair to say that it only does math, just because its only data type is a number.

Well, to be fair, I'm not saying that... I don't know enough about bc to make that judgement. What I do feel is that if it is bad at that sort of programs I've brought up, then it's a bad first language for most people. (And your "I had to get creative" statement worries me a bit.)

I also suspect that you'll be able to handle string manipulations better if you're comfortable with arrays first, but that's just a suspicion.

Eh, I don't buy it; I think that's too much of a C outlook. There's tons of useful things you can do with strings before you even know what an array is... probably more than you get after you learn that.

In fact, I'd give serious thought (if I were designing a beginning programming curriculum) of going the other way: teach strings, move into "strings as arrays", then use that as a stepping stone to general arrays.

Maaaaybe.... I really expect most people won't care, and as you say, I do go on to explain some of it later. I think I may just put a note saying I'll cover what this means later, but for now input the command exactly. Or perhaps an optional box that explains the arguments briefly.

An optional box would be fine, but I also feel like having -l -q costs essentially nothing and helps a small amount. (You could even use that as an avenue to go on to mention that Unix-like utilities let you combine short options like that, if you want.) Like I said, it's a really small point, but I still think you should do it.

BTW, don't take my generally comments as a statement that your tutorial is not very good or anything. I'm not sold on the bc thing as you can tell, but besides that I think it's actually very well-done. It's just way easier (at least for me) to point out things I don't like than things I do. :-) (I've gotten a lot of practice complaining about most software I use on a daily basis. I tend to have a very... negative... outlook on software quality.)


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 8 guests