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?"
There are lots of things you can write in two hours man!! :)
voice recognition software, compilers, parser generators , browsers , OS kernels etc etc.
Come on, be creative...
Slashdot Sig. version 0.1alpha. Use at your own risk.
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.
ah, no trivial ?
...
sorry
It takes 40+ muscles to frown, but only four to extend your arm and bitchslap the motherfucker
Try to get your hands on some programming exams. The programs there are usually designed and written within one or two hours (to fit into a typical lesson). Also they touch all subjects that are of interest in your case, for example the 8-queen-problem for recursion, simple algebra (prime numbers) for number handling, pointers, etc without going to deep into details not necessary if you are not writing productive software.
Keep open minded - but not that open your brain falls out...
My suggestion is not to focus on a particular problem -> solution, but to think more open-ended. In essence, think of some general functionality that can be continually extended. Maybe an example will help clarify :)
When I taught myself python, I first wrote a program that determined the word-wrap properties of a text file. It detected wrapping behavior across lines, and then constructed a range of possible wrap settings. I then added tabwidth detection. After this, I began to think about interpreting text structure from a document. So, if a block of lines exhibit wrap behavior, they're a paragraph, otherwise perhaps a section of code or a title. Then, I wrote a parser that accepted call backs, so, for example, it could (very roughly) convert etexts into html. Of course, this all took place over a week or so, and my knowledge of python evolved accordingly.
So, my suggestion is don't think "final product," but rather work on a general library of functionality that you can extend as you go.
Or War (the card game), or a slightly more complex turn-based card game.
Or, if you're terrible at programming or the programming language or compiler sucks, "Hello World!" might take a few hours.
Alex.
A friend of mine suggested a reverse-polish notation caclulator. It's a pretty good project since you'll have a chance to use a common data structure (stack) along with all the basic features of the language.
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
My issue is not that I can't think of anything to write, but that I have writers block.
Or any other simple game.
Nim would work nicely also.
Once the basic two human player version is done you can have them add a simple ruleset to let the computer play the game.
Stop the world; I need to get off.
Because it's fun, and the knowledge might save your ass some time in the dystopian future.
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.
A random idea generator?
I'd still consider that a trivial problem. Things don't start getting interesting until you are dealing with Staff Years to develop them. Anything under that and you can actually keep the full design in your head
I have mod points and I am not afraid to use them
Card games, some sort of parser, math tools, maybe a text-based web browser. Think back to some of your CS 101 days.
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
How about solving NP-problems in polynomial time? That should keep you busy for a few hours.
I implement a simple irc bot in whatever language i test. Usually takes few hours and you can write it as top down script or as oop monster, up to you.
The good thing is that you can use this irc bot to test just about every aspect of the language later on. Its not a project which is just done and discarded. Possible enhancements are user recognition or even something fancy like cvs commit reporting.
For example when i decided to play with sqlite took the ruby version of the bot and added a funny quotes database.
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.
The game Mastermind. The computer chooses a random string (generally of colors or numbers), the user then inputs a guess. As feedback, you get a number of black pegs (one token in the right position) and a number of white pegs (one token in the wrong position). The user's guess history should be displayed, and they should try and solve it in a given max number of guesses.
Gets some simple algorithms, simple data structures to store things in, and a UI of your choosing (can be text only, or graphical)
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
When I wanted to see what Java was all about, I wrote a little ROT13 converter. It was straightforward (simple algorithm), but somewhat useful in that I did not have a converter on my Windows machine at the time. As a bonus, I think I was trying to convert someone's sig on /.
The nice thing about something like this is that you can extend the project as you learn more aspects of the language. For example, your first try might open an input file and dump the results, with the next version adding code for the program to print the results in a window.
My little Java converter eventually had two text boxes where I could copy/paste input and output, buttons to start the conversion, an icon in the jar file so it would look like a Windows program in the task bar, and other little things that I wanted to know how to do. A lot of what I did was relatively trivial, but when trying to learn a new language, it helps if you learn what you want to learn.
did that already. My version splits your directory of stuff to be burned into seperate DVD sized pieces, ready for burning. I plan on adding automatic SFV generation and some other stuff, and making it possible for other people to use it
http://blackice.whitetrash.cx/ProjectMayhem
of course, my goals are quite a bit more lofty then what I have now, but it will split files in a few different ways. I use it for all my archiving.
Another issue is that noone besides me can use this project - no documentation etc. But it will get there eventually.
Not that this helps the original poster, as he's looking for a project and not a solution - but I thought you might be interested.
Oh, btw, it's entirely perl based so it will probably behave friendlier on a unix-ish system. Note that this is due to my laziness, and not Perl's fault.
Check out these sites:
o ductions.net/ruby_quiz/
http://perl.plover.com/qotw/
http://www.graypr
They are for Perl and Ruby, but you can use any language of course. Just read the description and see if it's an interesting challange. Code it up and then go back through the mailing list archives to see what other people said about it.
If you are actually learning Perl (boo) or Ruby (yay) it's more fun of course. But it can still help you learn any language, because you have to go look up how to do stuff, etc.
It's not exactly the same as writing an ad-blocker or an http server or whatever, but if you like puzzles you'd probably like playing around with them.
And if you're the creative type you can then extend your program with opengl graphics, SOAP service, whatever, just have some fun.
Now try doing that without looking up things in a book -- obviously I cheated here and just used the GCC. You see what I mean, though: Writing a mail program in assembler is somewhat more tricky than Python.
Write a porn collector that will crawl through unlinked collections on free porn sites. I'll bet you've done this by hand already (no pun intended). It will have to figure out the directories and filenames from evidence in the linked parts. You'll be using simple AI and network stuff, but if you also want to look only for redheads, you'll be doing some graphics work too.
If you use my idea, you should send me some redhead pix. Thank you.
The latest Slashdot meme.
How bout a worm which exploits holes in Internet Explorer or Outlook?
If you're that bored and that good at coding, consider become a developer for Debian or one of the BSD projects. I mention these projects in particular because they have very specific membership procedures for accepting new developers and excellent tools to help you document and package your code into new packages. NetBSD is particular really could use some more developers, and the people on the netbsd lists are low-key and friendly. There are also many open source projects for Windows, DOS, MacOS X, and web platforms, so don't feel that this is a UNIX-or-nothing answer. The FreeDOS project is a good example.
You might learn more and make more tangible progress working on pre-existing, concrete problems with an open source program. Trying to find your own worthwhile problems/projects to work on out of just your own head can really just be a form of procrastination.
Democracy. Whiskey. Sexy. Pick any two.
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.
Try the Code Katas on the website of one the Pragmatic Programmers.
I usually write a version of a knowledge base (for web apps anyway).
They're pretty strait forward - a couple of tables and a couple of pages. But they have enough to cover the bases.
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.
I'm a server guy, so I usually write an HTTP server or an SMTP server. This gives me a feel for how I/O is done in the language, threading, exceptional cases, parsing, regular expressions, etc. Everything a growing boy needs. HTTP and SMTP are pretty simple protocols, and are actually useful to have once you've completed them -- my need for an RPN calculator or an eight queen solver or a wandering ant trail follower or a trainyard simulator or a Pavlov's triangle solver or a Towers of Hanoi seems to be less. I learned Java and Python this way, and my plan is to do the same in C# with Mono.
1) Today
An old program (may had different names on different OSes) that, given the system date, will spew forth a list of things that happened in the past on the same date.
Tricky part: you can augment its files adding programmable stuff like "on the third sunday of august, show this message" or "if the 4th of October is a Saturday, print this" plus reminders that appear n-days before the actual event.
2) Simplistic accountancy
This is even easier. Write a small program which consumes
Example of a record:
Make it work for single files, or for all files matching a regexp:
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!"
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.
I'll skirt around your question and instead suggest after you get done with helloworld.lang you go straight to something interesting even if it's huge.
Why? Well most 1 day projects aren't very challenging or interesting. But most major projects will have subsystems that you can do in one day, and the project in its entirety can hold your attention long enough that you may eventually complete it, by which time you're an expert in the language.
This is pretty much the approach I had to take to learn C++ and OOP. I started a job knowing only C and the basic ideas of objects, and took on small bits of the C++ project until I could handle larger chunks.
Burn to the Brim does not work the way I described. When I last checked it, there was no way to put the files in alphabetical order. That makes them difficult to find. There were other problems, too. I wrote to the author, but he did not want to make changes.
Hhmmmm....You'd figure somebody would have made this lame remark already.
But seriously, a good project for learning a language depends on the language itself and the problems you yourself face. You're not gonna write a simple 3d engine in python and you're not gonna write a log parser in C (actually you could, but that wouldn't be the easiest/quickest solution).
Just pick something trivial that bugs you at any given moment that's the right job for the language.
Write some sort of lisp interpretter. Most people perfer some sort of Scheme sub-set but each his own. If afterwards, if it looks promising you can continue, release it, or whatever. People actually do this.
Does anyone know any projects to get one started with c/c++? It doesnt matter which one i'm learning them both at the same time, but most of the above sugggestions involve gui libraries, which are built into some languages like java, but theres really no standard for c/c++. what library would someone suggest learning to be able to start a simple project?
Every new language I learn, I code a program that takes a simple command-line input to download all pornographic images off a given site. Given the variability of porn-site layouts, etc., and also given that some languages don't have a standard or easy-to-use networking library, this isn't quite trivial.
Programmability is the thing that makes computers cool; if you have a problem to be solved, like I do, you just code your solution. Let the machine do the work.
write a program to automate your pr0n downloads!
Grab some library written in C and write a wrapper perl module. Keywords: XS, Inline C, SWIG.
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.
Graph algorithms are good for testing out a language's data structures. Dijkstra's single-source shortest path function is a good one to start with.
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
When I'm studying a language, I like finding an open source project I care about and looking for something to tweak. Advantages of this include feedback from other developers, an instant framework to fit your small changes into, and the warm and fuzzy feeling you get when you make something other people will use. You can pick up the idioms of the language quickly by reading code used in real life. Participating in an open source project also connects to a lot of other people who already know the language you want to learn, and you can ask them for help.
Don't be intimidated by the size of projects. Pick a project, browse through the source code, try to get the feel of things. You can usually find a bug report small enough for you to work on. If not, think of a feature you'd like to have and try to implement it. =)
Great way to get into a language.
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!
it depends on what you WANT in a language.
:) ). This tests networking APIs and multithreading features.
Like recently I was frustrated with how difficult it is to whip up a UI in Java with existing tools. So I wrote a simple issue tracker in:
- VB
- Java w/JBuilder generated Swing
- Java hand coded Swing
- MS Access
Though MS Access won hands down (even though I don't know that much about it), my hand coded Swing was better and faster to generate than using JBuilder's Visual Creator (which proves my point).. I couldn't figure out what to use for loading data in VB (too many options : and I'm not a VB programmer). This tests UI generation capabilities (how easy/quick is it to get a nice UI out).
Another alternative is writing a web server. I did it in less than an hour with no experience in Java (108 lines, mostly catch blocks
Back in the 1970s a little game came out called Master Mind. It's still available today, uses a plastic board and colored pegs. Great game -- except that if the person who creates a puzzle for you to solve makes a mistake in handing out clues, it is very upsetting. So the first significant program I wrote (BASIC) was Master Mind. Keyboard input, graphical output, clue algorithm, etc. Took me about a week, but back then I was just a beginner. NEVER makes a mistaking handing out clues! As years go by and I learn more languages, I usually turn to Master Mind as something significant to write. Clipper, C, Delphi, and Javascript. I like that last one because just viewing the page means you have loaded the program. Save the page and you can play the game offline. (Ok, so the output of that version isn't graphical. Feel free to improve as you like.)
I usually write a tetris clone.
Basic operation is 400-1000 lines typically
For those that have asked the question. I am currently learning Python. However, I wanted to keep the question general enough so that if I came up against a new language then I would have an "arsenal" of small problems that I could throw at it quickly to tweak out the difficult areas to code in and to highlight the strengths of the language.
I one had a coworker who said he always writes an address book as a first project when learning a new language or api. It covers a fairly broad range of stuff--common ui components, collections, sorting, searching, file io, etc--while being conceptually pretty simple.
Usually I start with the Mandelbrot set in ASCII or graphics, depending on the abilities of the language/system. This is also the first thing I did for the 3 CPUs in embedded systems I had to deal with lately... Manddelbrot in ASCII over 9600 baud line, well, not pretty but nice :-)
http://pragprog.com/pragdave/Practices/Kata
For the lazy or doubtful, here's the list of descriptions:
KataOne: Supermarket pricing. Pricing looks easy, but scratch the surface and there are some interesting issues to consider.
KataTwo: Karate Chop. A binary chop algorithm is fairly boring. Until you have to implement it using five totally different techniques.
KataThree: How Big, How Fast? Quick estimation is invaluable when it comes to making design and implementation decisions. Here are some questions to make you turn over the envelope.
KataFour: Data Munging. Implement two simple data extraction routines, and see how much they have in common.
KataFive: Bloom Filters. Implement a simple hash-based lookup mechanism and explore its characteristics.
KataSix: Anagrams. Find all the anagram combinations in a dictionary.
KataSeven: Reviewing. What does our code look like through critical eyes, and how can we make our eyes more critical?
KataEight: Objectives. What effects do our objectives have on the way we write code?
KataNine: Checkout. Back to the supermarket. This week, well implement the code for a checkout system that handles pricing schemes such as "apples cost 50 cents, three apples cost $1.30."
KataTen: Hash vs. Class. Is it always correct to use (for example) classes and objects to structure complex business objects, or couple simpler structures (hash as Hashes) do the job?
KataEleven: Sorting it Out. Just because we need to sort something doesnt necessarily mean we need to use a conventional sorting algorithm.
KataTwelve: Best Sellers. Consider the implementation of a top-ten best sellers list for a high volume web store.
KataThirteen: Counting Lines. Counting lines of code in Java source is not quite as simple as it seems.
KataFourteen: Trigrams. Generating text using trigram analysis lets us experiment with different heuristics.
KataFifteen: Playing with bits. A diversion to discover the pattern in some bit sequences.
KataSixteen: Business Rules. How can you tame a wild (and changing) set of business rules?
KataSeventeen: More Business Rules. The rules that specify the overall processing of an order can be complex too, particularly as they often involve waiting around for things to happen.
KataEighteen: Dependencies. Lets write some code that calculates how dependencies propagate between things such as classes in a program.
KataNineteen: Word chains. Write a program that solves word chain puzzles (cat -> cot -> dot -> dog).
KataTwenty: Klondike. Experiment with various heuristics for playing the game Klondike.
KataTwentyOne: Simple Lists. Play with different implementations of a simple list.
mahlen
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.
As described, there's a major problem with your algorithm for deciding the splits. It would result in lots of wasted space on the backup media.
As an example, let's say we have three directories we want to back up. Directory A is 100 MB, Directory B is 610 MB, Directory C is 100 MB, and the backup medium is CDRs.
If a human were to decide what directories should go where, it would put A and C on disk 1, and B on disk 2. Your algorithm would put A on disk 1. There isn't enough space on disk 1 for B, so that goes on disk 2. But now, there isn't enough space on disk 2 for C, so because everything has to be in order, C must go onto disk 3. You now have two CDRs with over 500 MB each of wasted space.
Burn to the brim (mentioned by another poster) appears to do the same thing that the human would do.
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.
we're paying 14 cents for CDs now. We don't care if some space is wasted. Also, for many data sets, there are no huge files. We have about 5.8 gigabytes of miscellaneous software that we and our customers may need. We don't put anything over 50 Megabytes on the hard drive.
Burn to the Brim doesn't work well when you need one single file from 110,000 small files. It could be on any one of the backup media. There is nothing wrong with my proposed algorithm for that kind of data set.
Pick a project from http://www.elance.com/, http://www.rentacoder.com/, or some other freelance platform to test your coding skills. If you have an account, you could even earn some money.
8 of 13 people found this answer helpful. Did you?
Make a program that can determine the exact size, shape, and position of everything in the universe by examining how the atoms in a piece of fairy cake are arranged. While you're at it, bake a fairy cake. And create something capable of measuring every single atom's position in that fairy cake.
Yep. little math bits are a good choice because typically I/O programming [which tends to be steep learning curve in a new lang.] is, or can be minimal. and though its certainly a trivial exercise, one of my favorites was to type in an infinite loop Fibonacci number generator...its as small a program as you can write that lets you find out how the language handles printf, arrays and arithmetic overflow for integer types.
SLASHDOT: news for people who can't concentrate on work or have no life at all and got tired of yelling back at the TV.
Adric F
Last Xmas I got a little puzzle that involved arranging 16 cards, each having one of about 9-10 images on each side so that each image was next to a similar one. (Maybe a wee diagram will help)| __|__|__|
__________
__|__|__|__|
__|__|__|__|
__
__|__|__|__|
I'd just started learning Java at the time and thought it would be fun to try and solve the puzzle using Java.
It was great for learning purposes. It required fairly complex logic (a brute force alg would take weeks), used a couple of classes, and also made use of most of the control structures that Java has to offer (break, switch..etc as well as the usual for/while loops)
I can't remember the title of the game off hand but I'm sure there are loads of games like this around - especially now we're getting close to xmas again.