Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

What "application" do you write to understand a programming language? I have used a calculator (regular + equation solver). But I think it's too easy. I am planning to learn Haskell and was curious, what is your "go-to application" when you start to learn a new programming language?

One of my friend uses XML parser as his go-to application. Any other suggestions which will include comprehensive use of data structures and other important constructs?

share|improve this question

closed as not constructive by ChrisF Oct 20 '12 at 16:39

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
For learning pretty much any language that isn't Haskell, you could attempt to implement Haskell-style lazy lists. –  Joey Adams May 15 '11 at 4:24
    
I asked a similar question on SO a couple of years ago. Might give you some ideas: stackoverflow.com/questions/1289247/beyond-hello-world –  Paul Sasik May 15 '11 at 6:01
1  
Writing a calculator with a GUI should be an ok challenge in Haskell. –  user1249 May 6 '12 at 7:19
1  

9 Answers 9

up vote 4 down vote accepted

A simple backtracking sudoku solver to get a sense of the various native data structures and abstraction mechanisms. It's simple but it's got enough moving pieces that need some coordination so your hands get a little dirty.

share|improve this answer

Haskell happens to be pretty elegant for some algorithmic challenges.. I started learning Haskell by trying my hand at Google Code Jam 2010 (see here for practice problems). After barely passing Round 1, I knew how to use an immutable Array to memoize a function.

share|improve this answer
    
Can it be that the techniques you are mentioning can serve to answer this question programmers.stackexchange.com/questions/141017/… –  Giorgio May 6 '12 at 12:24

I do the basic data structures, you'd anyway almost always end up needing them -- so list, vector, binary search tree, hash tables are what I typically begin with.

share|improve this answer
2  
yes, but what sample "hello world application" might include all of that? –  zengr May 15 '11 at 6:07

It depends somewhat on why I'm interested in the language.

If I'm looking for a high level, "batteries included," scripting language, I'll do something like see how much code and effort it takes to fetch my Twitter timeline, parse the results and display them. If it takes 200 lines of code to fetch a web page and parse some XML, it's probably not what I'm looking for in that situation.

On the other hand, if I'm looking to do some more serious computation, and need to get a better feel for what data structure and algorithms look like in a language, I'll often write a simple regular expression matcher. It's complicated enough to get a good feel for what the language looks like in "real life", but generally not too difficult to code.

share|improve this answer

Check out Project Euler it has a ton of problems to solve.

Here is a sample to give you an idea of what kind of challenges you'll be set to learn in your new language:

Lattice paths

Problem 15

Starting in the top left corner of a 2x2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.

enter image description here

How many such routes are there through a 20x20 grid?

share|improve this answer
    
would you mind explaining more on what it does and why do you recommend it as answering the question asked? "Link-only answers" are not quite welcome at Stack Exchange –  gnat May 3 '13 at 16:51
2  
@gnat added a sample problem –  ioSamurai May 8 '13 at 13:06

Any single app that will challenge every aspect of a language seems a little outlandish, especially if you're "learning" that language.

I find that meeting the requirements for a coding "Challenge" for a single app is more useful.

Take a look at http://www.programr.com/challenges?lang=872&level=879 where they have coding challenges that will push your skills with C++, C# and java.

And check https://www.interviewstreet.com/challenges/dashboard/#problems which is similar to programr, these problems are similar to problems that companies are currently paying to be solved.

Hope that gives you some pointers!

share|improve this answer

I usually write a game. Possibly a simple roguelike game with a maze generator.

Things this gets you to appreciate:

  • Overall program structure
  • Event handling and control flow (user interaction)
  • Algorithms (maze generation etc.)
  • Data structures (the map, player inventory, item attributes etc.)
  • Basic GUI capabilities

Usually takes a day or so in a new language, though if you get into it you can always spend more time polishing it into something more impressive :-)

share|improve this answer

I mostly just try to write whatever I need at that point, so it will vary depending on what I am doing. Or I write a book on it, which worked out really well for learning Erlang.

share|improve this answer
2  
You write a book on a language your are learning?!!! –  Jean-François Côté May 8 '13 at 13:14
    
Yup, if you can understand it well enough to write about it you understand it pretty well. Its not nearly as crazy as it sounds –  Zachary K May 9 '13 at 3:57

Being a real Test-Driven junkie, I usually try to create a basic test API with all of the basic things that I find myself doing every time I write tests. I then use it to write tests to test and implement some of the more common algorithms that I find myself using most often.

If I can't find good support for a test framework in the xUnit style, I'll add some basic comparisons to my test API, and if I can't find a BDD API, I'll try and create something to get me close syntactically to StoryQ or something similar.

As I find myself building the test API, I very quickly start to create my tests using the Test API to effectively test itself, and in the early stages, I'll write tests to examine unfamiliar language features. When all of that is done I move onto a simple project that I have been waiting to work on. Something low risk but useful so that it encourages me to try harder to make it work, rather than assuming I'm simply going to throw away whatever I learn with. If something is particularly hard to work out in the language, I'll spike the problem as I usually would, but with a focus on learning the language more than solving a specific problem.

So to sum up my answer in terms of the OP's question, I use a collection of apps and tasks that are familiar to me, but simple enough to be useful in and of themselves, and while the core test approach is a constant, the Apps themselves will vary as needs arise so that I don't lock myself down to something that feels to easy to do.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.