Ask HN: Learning C and Using Libraries
So, I'm a web developer who has lately decided to get into "desktop" programming, and to suck it up and finally learn C.
I'm coming from the web world, Ruby, PHP, Python. Each of these languages has an excellent repository for libraries -- these repos let me search for what I'm looking for, check out the matches, and decide what I should use; either through a web interface or the command-line tool of choice.
C is fun to learn, but I'm basically just searching for "<functionality> C library" in Google, and hoping for the best. Surely there is a better way?
I'm developing on Linux and Mac (I use homebrew). I know that a lot of libraries can be pulled in through apt or similar, but they don't seem to have the same breadth or focus that the other languages have.
What am I missing? Or is it merely a case of myself having the wrong mindset perhaps?
6 comments
[ 2.8 ms ] story [ 26.2 ms ] thread"I'm developing on Linux and Mac (I use homebrew)." I don't know about Mac, but at least you're on Linux, I found C on Windows to be more annoying.
IMO, the ideology behind C expects you to do more of the code by yourself, especially regarding the infrastructure. As an example, a few months ago I typed up a program to compute the square root of two without using <math.h>.
I'm at the point where I rely less on books or stinkoverflow and read other people's code. It might be an idea to look at what libraries other coders use. Right now I'm snooping around github.
I just spent an hour doing the same! I did see ccan on the front page here, that has some great snippets in it.
> IMO, the ideology behind C expects you to do more of the code by yourself, especially regarding the infrastructure.
See, I agree with you here, that's why I asked whether my mindset was wrong perhaps. The thing is though, I come from other languages where reinventing the wheel is seen as a really dumb idea, but perhaps in C it is the right way to go? I'm honestly not sure!
Cheers for the reply, it made me feel less lost ;)
"The thing is though, I come from other languages where reinventing the wheel is seen as a really dumb idea, but perhaps in C it is the right way to go? I'm honestly not sure!" They often say that about assembly, and I think I may have to pull my foot out one day and learn it.
The C programming mindset requires one to think like a machine. Very few people are born with that skill, it has to be beaten into programmers with a keyboard.
BTW I only started learning coding last year, but I started with C++. Did you do the same or jump straight to C? I tend to agree more with Stallman and Torvalds these days: "A horrible language".
As someone mentioned, CCAN was on the front page, but generally there hasn't been the same sort of organized directory to find the C library best for a particular problem.
For myself, I go off of what I've used before, what others maybe have recommended, or sometimes just search for something that does most of what I want. If I need to write it, so be it.
What are you trying to do?