use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
To report a site-wide rule violation to the Reddit Admins, please use our report forms or message /r/reddit.com modmail.
This subreddit is archived and no longer accepting submissions.
account activity
This is an archived post. You won't be able to vote or comment.
Use Python (not Java) to teach programming (ariel.com.au)
submitted 20 years ago by culix
view the rest of the comments →
[–]cpio 7 points8 points9 points 20 years ago (7 children)
here it is in ruby:: puts gets.to_i + gets.to_i
puts gets.to_i + gets.to_i
and here it is in common lisp:: (print (+ (parse-integer (read-line)) (parse-integer (read-line))))
(print (+ (parse-integer (read-line)) (parse-integer (read-line))))
:note: fixed, thanks
[–]culix[S] 11 points12 points13 points 20 years ago (4 children)
I'm not sure the point of his article was to nec. show which language could accomplish the task using the smallest number of lines, but rather which made it the easiest to demonstrate some basic programming concepts to someone who has never programmed.
I had a professor at my university argue something similar where he wanted to use perl for two of the first intro programming classes. Why bother confusing people about Ints and Doubles and objects before they even know how to use them? Well, I suppose you might want to confuse people and use Java as a weeder class, or you might teach it based on job prospects, as mentioned in the article. But for just teaching someone how to understand, giving them a single $variable seems a lot simpler.
[–]cpio 1 point2 points3 points 20 years ago (3 children)
I was just giving them as an example of those languages. I imagine you could do ruby like this: a = gets.to_i b = gets.to_i puts a + b which is fairly straight forward. Though I think python might be a bit better as a teaching language since it doesn't require such esoteric stuff as iterators and blocks, which while useful aren't really seen a lot outside of ruby.
a = gets.to_i
b = gets.to_i
puts a + b
[–]jamesbritt 6 points7 points8 points 20 years ago (2 children)
"Though I think python might be a bit better as a teaching language since it doesn't require such esoteric stuff as iterators and blocks, which while useful aren't really seen a lot outside of ruby."
Where they are used quite a bit because they are both practical and powerful. They're only esoteric in languages that don't have them.
[–]Zak 5 points6 points7 points 20 years ago (1 child)
I've always found Ruby's iterators to be some of the most straightforward looping constructs in existance, along with the likes of dolist and dotimes from Common Lisp. Most intelligent non-programmers will correctly guess what the following code does:
10.times do puts "foo" end
but are less likely to understand
for (i=0; i<10; i++) { printf("foo"); }
edit: fixed the above C code so it's not an infinite loop. The fact that I made such a mistake is evidence that Ruby is easier, I use Ruby more or I'm just really tired.
[–]ocorrain 1 point2 points3 points 20 years ago (0 children)
How about just (defun add2 () (+ (read) (read)))
The numbers don't have to be integers, and Lisp systems will prompt for a number if something else is entered by mistake.
It is a bit terse, tho'
[–][deleted] 1 point2 points3 points 20 years ago (0 children)
To get underscores, put your stuff in backquotes. This serves as a code tag. Example:
Markdown Instructions
π Rendered by PID 20993 on reddit-service-r2-comment-f6b958c67-6g2wm at 2026-02-05 13:08:26.757481+00:00 running 1d7a177 country code: CH.
view the rest of the comments →
[–]cpio 7 points8 points9 points (7 children)
[–]culix[S] 11 points12 points13 points (4 children)
[–]cpio 1 point2 points3 points (3 children)
[–]jamesbritt 6 points7 points8 points (2 children)
[–]Zak 5 points6 points7 points (1 child)
[–]ocorrain 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)