Short Coding Projects?
sapped asks: "Whenever somebody advocates a new programming language for you to try, they will usually suggest writing something in it that will take you an hour or two to code, so that you can get a feel for it. My problem is that I tend to go from extremely trivial ideas straight to stuff which will keep me busy, for at least a few days. I don't seem to have a handy in-between size project that I can test stuff in. The closest I came to this was writing a little ad-blocking proxy for my browser, a few years back. Any ideas on neat small non-trivial projects?"
I usually start of with implementing some simple math related things. For example, a prime number generator or a program to calculate pi. The algorithms that you can use to write such a program tend to be heavily documented so you don't have to worry about the design and can concentrate on the implementation in that specific language.
I know you were kidding, but a parser generator really can be written in a couple of hours with a logical programming language like Prolog.
-twb
What I do first of all after the basic "hello world" examples and stuff when learning a new language is a simple "guess the number" game - computer randomly generates number between 1 and 100.
User then guesses, and computer replies if the guess is higher or lower until number is guessed. Teaches use of loops, random number generation, text input & output etc. Can also go on to store lowest number of guesses in "high score" table etc, or use TCP to make it playable over telnet, if you so wish.
Linux Wireless Hardware in the UK
Something simple like a basic Webserver (GET/PUT/HEAD) or a FTP server.
You get:
a) simple string parsing/processing/manipulation
b) File I/O and filesystem manipulation
c) Network I/O
Optionally or language dependent:
d) Threading
e) Packaging
If a dynamic language (e.g. lisp):
f) Write something like JSP on top of it: dynamic dispatch to handling method/function
Optimizations are easy as well. Caching will give you a good overview of data structure speed.
Here's a simple program that would benefit the whole world:
Make a program that shows what parts of a huge folder fit on individual CDs or DVDs. The output of the program would say, for example, that all the files from sub-folders A to Information would fit on the first CD, and all the files from sub-folders Installers to Netgear would fit on the second CD, and so on.
It is necessary to store backup sub-folders in alphabetical order on the backup CDs or DVDs because then they can be found easily.
Right now there is no good way to decide how to apportion the data. Breaking any file into two pieces just causes problems later, so the Easy CD Creator method does not work well.
Later, it would be excellent if the program made
--
100 Facts and 1 Opinion -- The Non-Arguable Case Against the Bush Administration
I've written variations of this in a few languages. This small example exercises classes and operator overloading, collections and iteration, math, graphics, modularization, so it gives a pretty comprehensive view of what the programming system is like in real use. But the real reason I like it is because the output is mesmerizing.
Fuck the system? Nah, you might catch something.
My preference is the OSIX GEEK challenges, but anything with decent complexity will do fine. Solve the challenge first in a language you know, then reimplement in the new language. Just note that the first few geek challenges don't require much/any programming skill, and the first one could take a while. Take a look at Hackergames for more sites with the same type of challenges.
-ReK
md5sum -c reality.md5
reality: FAILED
md5sum: WARNING: 1 of 1 computed checksum did NOT match
You can try to reproduce some classic arcade games. Many of them are very easy to code in an afternoon.
Here's an asteroids clone I wrote in javascript. It renders everything with divs.
If the language has compelling semantic separation (usually object orientation), I'll write some form of random song guitar tab generator. That's a personal project of interest to me.
Then I go back to Python.
Which brings up the point, can IE be changed to use Gecko as the rendering engine?
For its own benefit, the world should give Burn to the Brim a try!
"Nae Kin! Nae Quin! Nae laird! Nae master! We willna be fooled again!"
Also, I don't think you want to change IE, because Windows Update doesn't work with Gecko.
However, I think I DID find a way to get Gecko working in IE. Make it a Gecko plugin that associates itself with everything that IE does itself, without handing off to a plugin. I don't know if that will actually WORK, but it's worth a shot.
For the first hour (or whatever) it takes I have them write a four function calculator (FFC). Once they get that done, I have them extend it to add trig functions like sin / cos in the last 30 mins. If they can't do that, they are not going to be happy with harder assignments.
I also use this as a mini-test of a new language. Try my new language COAL, better than Cobol, faster than VB, a true OO language with VM's that run on any Timex watch!! A short stint creating a FFC lets me know how well it works out.
The FFC is also good since you can use it for GUI checkout to see if that new tool rocks as much as Freshmeat would like you to think.
A serious suggestion --
Look at your favorite text, sound, or graphic format that you've had trouble converting to or from some other format. Write the converter.
This can range from 1 hour to a week's work, but it's always instructive and usually fun.
Do "Towers of Hanoi".
You've got three posts, and up to 64 disks, with the largest disk slid down to the bottom of the first post and the smallest disk at the top, and the diameters of the disks tapering.
You have to move all the disks from the first post to the third post in such a way that no disk is ever placed on a smaller disk, and only one disk is moved at a time, one post at a time. It's harder than it looks.
Your goal: model the three posts and the 64 disks. Write a program that moves the disks from the first post to the third via the middle one, without ever violating the rules. Record the sequence, and let it run, finding the shortest sequence that works.
It's kind of a fun one.
Farewell! It's been a fine buncha years!
I like writing a chess game... there are sufficient enough ways to implement a two-player (human) game, and enough corner cases that it's an interesting problem with well-defined rules. Have fun!
--Robert
I do numerical modelling for process engineering and my first programming exercise with a new language is to write a cubic equation solver based on that in the Numerical Recipies books. This exercises all of the basics, particularly math funtions (square roots, powers and trigenometry) as well as basic conditionals. The resulting code is actually useful in my work - I now have versions in Fortran (the original NR Fortran book didnt actually supply code), C, C++, Java, Tcl, and Python!
On a related note the very first significant program I ever wrote was as an exercise in Fortran programming on punched cards - a quadratic equation solver. Most of the same elements were there - mathematical functions and conditionals, with the additional complication of requiring formatted output - you had to decide if the roots were real or imaginary and print them in a suitably formatted way, so the exercise also taught you how to do output of strings. I seem to remember it took about three days to complete the exercise, but in those days of submitting batches of punched cards the compile - run - debug cycle was 24 hours!
Use a simple data file format and allow for CRUD operations. Write a network server and GUI clients. Covers file IO, collections/data structures, networking and GUI. Bit boring, mind :)
In this world nothing is certain but death, taxes and flawed car analogies.