What are some practical projects to consider in trying to learn C? - c

I've seen a lot of questions and answers on SO about why I should learn C. I know that it's low level, it'll give me an understanding of how things work at that level, and it'll make me a better programmer. I know some good books to be reading to help me learn C.
What I don't feel like I know are some practical projects I can work on to help me learn how the language is used. There's a lot of examples in the books I'm reading, and they're absolutely useful as far as reinforcing knowledge gained about the language itself. But I don't feel as if I'm gaining any insight into "real life" examples of what I can do with C.
My background: I'm a recent college grad who's doing application programming in C#. I'm enjoying doing programming exercises in C -- but I just feel like they're exercises. I know obviously I'm not going to become an expert right away and start doing amazing things. I just want some ideas for things I can do to help me become better but that feel like more than just exercises. (I want to clarify that I'm not opposed to doing these kinds of tasks to help me learn about the language. I just think I'd get more excited about learning if I was doing something that seemed more practical in nature.)
If this is "not a real question," I truly do apologize, and I know questions about learning C are all over SO. I'm not trying to be repetitive. I'm sold on the idea that I should learn the language, I just want to be able to have some real ideas of how I can start applying the knowledge.
See Also
What is a good first C app to build, besides “Hello World”

Here's some ideas for you to try:
Store a file containing hashes of every file in your music directory, and report on changes.
Solve a Sudoku in the shortest possible time.
Send a file using TCP to another computer. (Write both server and client).
A program that broadcasts a list of public files (configured in a text file) over UDP, and then accepts TCP connections to download them.
A command line POP3 client.
Write a memory allocator, and hook into malloc.
Congratulations on deciding to learn C. It is the most powerful language on Earth, and will give you the foundation you need to kick some programming butt.

The way to learn C would be to try out POSIX compliant samples from any operating system book.

My seven step guide to finding something code wise to do :)
find something you like or enjoy(preferably IT related)
find a problem with it, or some way to improve it, else goto Step 1
split the problem into logical parts, these will represent functions and structures, use a piece of paper if it helps you visualize the problem(this is what I some times do)
devise your plan of attack, ie: how will you implement what you came up with in Step 3
Code, Learn, Test, Learn, Debug, Learn, Improve, Learn and Code & Learn some more
Done, but not really, this is when you review what you've made, marvel in all its glory, and learn from all its mistakes and problems. see what parts you enjoyed, what parts you hated and what parts you can still learn more from.
goto Step 1, using the knowledge gained from Step 6 (and all the other steps along the way)
If you run out of things to do and want to be productive in a commercial sense, see if you can talk to people who work with computers/IT systems/etc as a daily occurrence in their job and see what happens them and try develop ideas that could improve their productivity and/or the ease with which they can perform their task(s), who knows, you may end up with some extra knowledge and some extra cash

See what are the things you enjoy doing in real life and try to use them in an application. For example if you like games, try to make a game or if you need an idea, remake a classic. If you like accounting, try to make an accounting application with a proper interface. If you are not passionate about the idea, then you'll probably get tired after a while and throw it away.
BTW, I think you're on a good path and I like the decisions you have made so far.

Write a compiler for a subset-of-C.

There are some Artificial Intelligence competitions that are both practical and fun. These will help you learn the language, encourage your understanding of any sample code, basic debugging and implementation of common algorithms.
Most importantly it's fun, so it keep will keep you motivated to keep learning.
For instance a few months ago I enjoyed the Google AI challenge: http://csclub.uwaterloo.ca/contest/
Good luck and enjoy :)

Related

Where should a programmer with NO static/compiled language exp start learning Go?

I'm an experienced software developer, but I've only worked in dynamic languages (primarily Python, PHP in the past, JavaScript, and a little Ruby). Last night, I found myself reading through the tour on the Go website's tour when I realized that the language (syntax, libraries, etc.) would probably be fairly easy to learn, but my lack of knowledge about static/compiled languages would bar me from easy entry. It's not that I don't understand the core concepts of a static language, namely that function argument/variable/return types are static and that a program must be compiled before use. It's more that I don't know where to begin after writing a program. For instance, if I wrote a web application using the Revel framework, it would handle these steps for me (according to the website). Is that pretty typical of frameworks for static languages. Am I worrying too much about a small part of the process that will be quick to learn, or are the (as I call them) formalities of using a static language pretty cumbersome?
As other suggested, any tutorial on Go would work, and you probably worry too much about the dynamic -> static switch. Statically typed languages can be a bit cumbersome sometimes if you come from dynamic typing world, but you'll quickly get used to your compiler yelling at you when types are not correct, and quickly fix it. Eventually, you'll start double guessing it and write (mostly) type-correct code.
Rob Pike noticed that people coming to Go where coming mainly from dynamic languages, which means this cannot be all that hard to do the switch.
There are a lot of tutorials all over the internet titled "Go for ", such as "Go for Rubyists", "Go for Pythonistas" which can help you map your existing knowledge to Go concepts. But as other underlined, the best (only ?) way of properly learning go is to take a tutorial and dive in ! For the books, the standard Effective Go or the very good Programming in Go are very good reads, no matter your background.
Well obviously practice makes perfect, and reading through the extensive documentation. I also find this book really nice Go-lang book, it has some exercises at the end of the chapters which is nice.
Just get a basic tutorial for the language you want and follow it. You will soon pick up how to structure the program. You can then apply your current knowledge of programming to make it do what you want.

Making a simplistic video game

I'm thinking about creating a simplistic video game. I'm not talking about anything fancy, but about a game like this:
Since I want to learn, I would prefer not to use libraries but roll as much as I can on my own. I'd need to know how to render the car and the track, deal with collision with other cars, etc. I'm targeting Linux, Mac OS X and iOS. I fear that using a library like OpenGL makes things "too simple".
Are there any good resources out there that discuss this? Most of the tutorials / papers I have found are based around popular libraries & engines.
" I fear that using a library like OpenGL makes things "too simple" "
Don't worry, you still have plenty of work left.
In the REAL world, programmers use as many libraries as they can, that is the only way to produce a applications that focus on how things should work and not spend years on every little feature.
Start out programming above libraries, then, if you want to divide down into details, implement your own library and replace the one you used with it.
Dividing your application into self contained parts is a good practice, makes changing it without breaking everything possible.
Also, I would recommend you learn C++ first. Being able to model your problem domain with Object Oriented methodologies will help you break down the problems into solvable units.
Sounds like you're interested in learning from the level of Simple DirectMedia Layer.
If so, this might be a good place to start: http://gamedevgeek.com/tutorials/moving-sprites-with-sdl/
Probably followed by: http://www.gpwiki.org/index.php/SDL#Creating_a_Complete_2D_Engine
Also, for that particular rendering style, see:
http://en.wikipedia.org/wiki/Parallax_scrolling#The_raster_method
http://en.wikipedia.org/wiki/Mode_7
Edit:
This information about the original Doom engine may be useful:
http://fabiensanglard.net/doomIphone/doomClassicRenderer.php
Also, Chocolate Doom is a port of the original Doom source into SDL, so you'll probably learn some useful patterns studying the source for it:
http://www.chocolate-doom.org
It will be more or less impossible to develop a game without using any library. I guess you would have to go back to good old C64 days to do that. If you are interested in learning, I would look for a more low level library, which provides access to graphics, sound, ... But it should leave the logic to you.
I would propose to have a look at http://www.pygame.org/. It makes working with graphics, sprites, ... easy, is still relativly low level and Python is a great language to get started with.

How to identify ideas and concepts in a given text

I'm working on a project at the moment where it would be really useful to be able to detect when a certain topic/idea is mentioned in a body of text. For instance, if the text contained:
Maybe if you tell me a little more about who Mr Jones is, that would help. It would also be useful if I could have a description of his appearance, or even better a photograph?
It'd be great to be able to detect that the person has asked for a photograph of Mr Jones. I could take a really naïve approach and just look for the word "photo" or "photograph", but this would obviously be no good if they wrote something like:
Please, never send me a photo of Mr Jones.
Does anyone know where to start with this? Is it even possible?
I've looked into things like nltk, but I've yet to find an example of someone doing something similar and am still not entirely sure what this kind of analysis is called. Any help that can get me off the ground would be great.
Thanks!
The best thing out there that might be useful to you is automatic sentiment analysis. This is used, for example, to judge whether, say, a customer review is positive or negative. I cannot give you direct pointers to available tools, but this is what you are looking for.
I must say, though, that this is a current hot topic in natural language processing and I’ve seen a number of papers at conferences. It’s definitely quite a complex matter and if you’re starting from scratch, it might take quite some time before you get the results that you want.
NLTK is not a bad framework for parsing natural language but beware that this is not a simple matter. Doing stuff like this is really research level programming.
A good thing that makes it much easier is if you have a very limited domain - say your application focuses on information about famous writers, then you can avoid some complexities of natural language like certain types of ambiguities.
Where to start? Good question. I don't know of any tutorials on the topic (and I presume you tried the Google option) but I'd imagine that iTunes U would have a course on the topic. If not I can post a link to a course I've done that mentions the subject and wasn't completely horrible: http://www.inf.ed.ac.uk/teaching/courses/inf2a/lecturematerials/index.html#lecture01
The problem that u tackle is very challenging.
I would start by first identifying the entities in the text (problem referred as Named Entity Recognition, google it), and then a I would try to identify concepts.
If want to roughly identify what is the text about, I suggest that you start by using WordNet and according to the words and their places in the hierarchy to identify the concepts involved.
If you want to produce a system which show real intelligence than you should start researching about resources such as CYC (OpenCYC) which will allow you to convert the sentences into FOL sentences.
This hardcore AI, approach to solving your problem. For simple chat bot, it would be easier to rely on simple statistical methods.
good luck

Have you tinkered with Rel?

I would like to hear opinions or peoples experiences regarding Rel. Is it destined for the dustbin, or is it the next big thing in programming? I haven't tried doing anything with it yet (and it looks like you really can't at this point), but I'm intrigued by a few of the concepts discussed in it. Notably:
Removal of nulls completely from the data handling part of the language.
No need for mapping types between the language and the data storage.
Nesting tables
Complete separation of design and implementation.
Thoughts?
I think it is intended as an aid to teaching the pure relational model, not as a competitor to SQL DBMSs for "real work" in the short or medium term. However, Date and Darwen make a compelling case for the proper implementation of the relational model in their book The Third Manifesto. Maybe one day someone will produce a successful product based on it. After all, Oracle was a very small, niche company once!
Right, I agree with you Tony. The interesting thing for me, though, is that Rel is a somewhat working implementation with the understanding that it is essentially a working version of Tutorial D. The thought being that some well funded enterprise takes the research and decides that something like an Industrial D might be worthwhile.
Maybe I'm wrong here, but I get the impression that while Tutorial D is primarily a data language, it has the potential to move into the application space as well. That seems pretty ground-breaking to me. Of course, after reading some of the stuff from Date, Darwen, Pascal, and others, it seems like the language may have the goal of supplanting object oriented programming in general. Right now, OO appears to rule the world of programming. Rel would make available an alternative view on programming in general.
So I guess what I'm curious about is whether this project has legs that leads to other products or if people think it's going to be just a historical curiosity.
Nearly four years on from the OP. I came across Rel recently, and it does have potential for what I am doing. It is more clearly established as a teaching language, but the implementation is now quite solid, though still a little fragile in syntax. It does have potential and I hope that this potential will be realised. Unfortunately this is a similar statement to that made four years ago, so if it is to be realised, it is evidently a very slow burner. Still most research efforts take about 10 years to become embedded in product, so there is still hope.

Asking to see employer's code/database in an interview

I've been asked to write code/design things in an interview. Sometimes even to provide code samples. Very reasonable and very wise (always surprised when this DOESN'T happen)
I had a job a year or so back where the code was so awful that I would not have taken the job, if I'd seen the mess I had to deal with ahead of time. And I can't tell you how many horrendous databases I've had to work with.
Is it out of the question for me to ask them to provide a code sample and to view their database design? Assuming I'd be happy to sign an NDA, part of me feels it would insane to take a job without examining the codebase or database I'd be working with.
Anyone done this?
Update
This would be something I would ask later in the interview process, if things were proceeding well and I felt an offer was forthcoming.
It's also in the context of working in a small shop or small project as my preference is to avoid places that use phrases like "get a developer off the floor"
You can definitely ask. The answer may be "No," but nobody should consider that to be a bad or inappropriate question.
If they won't show you the code, you should definitely take that into account when you decide whether you want to accept an offer. I would take it as a sign that at least one of the following things is true:
The code is so horrible that they know you'll run away screaming.
The company has an ultra-secretive trust-nobody culture (which I would hate).
The company thinks they have such amazing code that just glancing at it would turn you into a superstar competitor. (In other words, they're self-deluded morons.)
They have glaring security holes that they hope to keep secret.
The people who are interviewing you don't know how to get the code themselves. (In which case you are not talking to the right people.)
I'd be more interested in seeing the company's systems - i.e. test framework, release process, autobuilds.... The presence or absence of those would tell me a lot more than a couple hundred lines of code.
I did ask: "Can I see some code and talk to programmers working here?"
The employer replied: "Sure! Come you can directly talk to our lead programmer of our information system!"
What an honor!
they showed me concept papers
I could talk to the lead programmer
they showed me a small part of a very new project telling: "this is just a prototype, direct3d is so sketchy, that's why this code is so messy"
It turned out that:
the lead programmer left the day I arrived
the software he had the lead, was a big mess
somehow I ended up spending 50% of my time, fighting against the mess
None of the candidates we have interviewed have ever asked that; however, many of them have been co-ops/interns in the company so they are familiar with our code...
Having said that, it is highly unlikely we will show our code to ANY candidate, regardless of an NDA. I would be happy to answer questions about what technologies we use, what system we use for revisions, practices around, etc. Actual code though? No.
Also in a large enough system (as ours is) someone can just show you the "best" code there is...and you would be where you started :) As for a database design...both companies I have worked at have had enormously large databases (university, corporate company)...so that wouldn't work either.
I've asked this in interviews with Xerox PARC, a startup, and Yahoo.
At PARC they sat me at a workstation with the code I'd take over if hired, went over the structure of the codebase super-briefly, and left me alone for around 20 minutes. This was enough to get an idea whether I could stand working with it, though I'd have liked some more time, like an hour total. Afterward I asked about a design decision that seemed dubious, and we chatted about the design and the style in general. This didn't just tell me more about the job, it told them more about me: did I explore their code top-down or bottom-up, what did I pick up on or ask about, etc. Valuable all around.
At the startup, they set up a separate meeting on another day, bringing in the author of the code (who wasn't an employee); we sat down at a laptop and went over things together. It was an unusual request to them and I think I had to sign a new NDA. This was once again worthwhile: my earlier interviews hadn't really cleared up what this fancy AI language was all about or what they'd want me to do with it, and sitting down with some concrete code blew away a lot of fog.
At Yahoo, I didn't see much of anything; I don't recall just what their response was. If I'd seen the code I ended up dealing with I might have had second thoughts (though it worked out all right in the end). (Both of the above codebases that I did get to see seemed generally nicer; the PARC one was open-sourced later on.)
In all these cases I shared some code of my own with them.
If you are going to do this then I think you need to give them a little warning so they can prepare an NDA and get an apppriate environment set up in which you can see it. Also be prepared to dedicate a little time to understanding why the code is in the shape it is.
If you turn up at your first interview and say, right, can I see the code, all but a very few people will say no. And not necessarily because they are evil and don't want to show you, but because it just isn't as simple as saying yes.
In my experience as a recruiter for a large software company it would have taken a considerable amount of time for us to disclose enough detail of the code and internally developed frameworks for any candidate - however bright - to be able to make a meaningful judgement of its pros and cons. We would only contemplate doing that if we were serious about hiring them.
If I were asked that question I woul say yes, come back another time and we'll arrange something. I would get a trustworthy developer off the floor and have them bring a laptop to the next interview and show a little of the code.
The reality is pretty much any software project which is of a reasonable size and has been in existence for more than one release will have some horrible scary rubbish in it.
Similarly to some of the other responses, I've never had a candidate ask to see our code. Even if they did I've be very careful to do so and most likely would not. As Swati mentions, pretty much any non-trivial system will have sections that look good so even seeing the code won't help that much.
Better than looking at actual code is the Joel Test. Basically it is 12 yes or no questions that you can ask an employer. The more yes answers, the better the work environment is expected to be. It's obviously not a hard and fast "rule", but it would seem to indicate those companies that take code (and coders) seriously.
I can't think a reason for not showing some classes or talking about the architecture they're using. From my point of view it's like asking them to show you where are you going to work (room, table, chairs, teammates...).
Anyhow, asking for it will show them you're interested in best practices and also that you're not desperate about finding a job at any price, and don't know how this can hurt.
Go to open source projects. There you don't have to ask for permission to see the code.
It can't hurt to ask and this is a very good idea which I am going to add to my checklist of questions to ask employers.
An interesting idea, but I don't know how many companies would go for it. I know we can't do it where I work now.
I think the biggest problem you're going to have with this is that I have found that a lot of people take offense to people not liking their code. It's like criticising someone's therapist, it's just not a good idea to be an outsider and do it. Seeing the code and then not taking the job could give you the reputation that you're arrogant or not good enough to work on the code and that's why you didn't take the job. It might save you from getting job you don't want, but it could give you a negative reputation down the line. I live in a sizable city, but the IT people still know one another and word spreads. People in our field have egos, and it's easier to trash somoene else's reputation than it is to admit that code you wrote isn't up to par.
Even if they showed you some code, would that be sufficient for you to come to a rough conclusion about the quality of code that you would be spending time with? For example, at my previous place, one of their products was a large e-banking middleware application. The core of the application was in C++ and designed and written in a great way. However, the extensions (which by far covered a large part of the application and its various different versions), which were in C++ too, that were mostly coded by the less-experienced and less-knowledgeable developers were a pile of crappy code (which I had to fix and work with or write from scratch at times) slapped together to just somehow work. If I had asked them to show me a snippet of the code during the interview, and they had shown me some of the core stuff (the extension code actually mostly contained the client-specific business logic so it wouldn't make much sense without the business-domain knowledge, etc), I would've thought that the overall quality of the code is good (which was not completely the case).
More important than to ask for code snippets, I believe, is to ask them for which source code control product they use (run away from companies that answer "Visual SourceSafe") and which methodology they use: "Agile" or "Scrum" sends positive signals, CMMI usually means company loves bureaucratic processes, if they give you a "huh?" then you're warned ;)
I think this is a great idea; however, as an employer, I would be hesitant -- even with an NDA -- to provide an interview candidate samples of real, working code unless I was pretty sure I wanted to hire the person.
The problem is they will show you a little bit of code, but each of their programmers will write code in a different way. You are unluckily to have to work on the part of the code base that is well written.
Asking to see their coding standard and how they enforce it is more likely to be of use.

Resources