ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
GTK programming in C is very complex for a beginning programmer. I would highly recommend you learn C for longer than you think you should before moving into GUI programming. I have the book "The Official Gnome 2 Developers Guide", let me take a quote from the Introduction chapter:
Quote:
... you should have:
Firm programming experience in C, including pointers, dynamically allocated memory data structures, and pointers to functions. You should also be familiar with enumeration types and bit fields [Kernighan].
A solid grasp of pointers to pointers (** types), where to use them, and how to extract and use the address of a pointer.
Understanding of C macros and the C preprocessor
Fundamental understanding of Unix: processes, libraries, search paths and so on.
Don't get me wrong, none of that is too difficult, but it definately takes some practice in C programming, the amount of time would be different for everyone, but I would say if you spend alot of time in C and asking questions on various programming forums you could probably get up to speed in 6 months to a year. You could also start programming from a GTK book immediately if you wanted, sure you could get things to work but you wouldn't have nearly the understanding of it that you should.
As for which C book to buy, I started with C++ and moved back to C, so I'm the wrong person to ask on where to start learning C. I started learning C++ from the book 'C++ Primer Plus: 4th Edition' by Stephen Prata, and I know he has written the same book for C as well. I really liked the book and still reference it every once in a while. As your skills progress, you'll want to pick up 'The C Programming Language' by Kernighan and Ritchie.
The ultimate C book: "The C Programming Language, Second Edition" Kernighan and Ritchie prentice Hall
this looks much like the gnu c programming tutorial. good tutorial some bad linux only code used tho. YOU HAVE BEEN WARNED
i started learning a year ago then started just recently relearning things and having a better understanding now then i did back then. I have tried gtk programming and after creating a program with 2 buttons decided i better learn more about C before trying anything further. gtk is eazier then i would say xlib is but can still be very confusing to a new programmer like myslef.
Thanks for your replies. I have actually considered to buy "The ultimate C book: "The C Programming Language, Second Edition" Kernighan and Ritchie", and I think I will buy it now.
So, the right thing to do for me if I want to learn to program simple GTK apps is to first learn C, and then learn GTK? And yes, I'm prepared to spend some time learning C first.
How much programming experience do you have? I dont think 'The C Programming Language' is suitable for non-programmers. I think you would just end up getting frustrated at TCPL, you should look for more of a beginners book instead, just my two cents.
To master GTK it requires quite good C knowledge (especially things like pointers). There are tutorials, however, that start with very simple examples, so you can check them just after 2-3 days with C. The time may vary depending on the fact if you know any programming language (learning 2nd, 3rd... is much easier than first) or not.
I have been programming for just over a year and am still very much on the learning curve.
However I feel that I have enough experience to lend you a valid opinion.
My first introduction to C was through K&R mentioned above.
B4 that; my only other programming experience was some basic college assembly language
anyway..
I have a couple of other books on C but the beauty of The C Programming Language, Second Edition" Kernighan and Ritchie prentice Hall is that it gives a feel for the fundermentals of the language and how to approach a C program very early on.
Unlike other books that give you pages and pages of syntax on basic functions .Details which IMHo you are better off picking up as you go on ?!?!
I also don't feel that C is too hard as a first language.All though I do concede that it takes some mastering(I'll lket you know wen I have),but you can have fun writing useful unix/linux programs on the way.
i think you may wish to humble your ambitions slighty at first ,but you WILL get there if it is what u want to do.
Well, also, depending on your priorities, you can program for GTK using languages which are supposed to be simpler, like Python. I wouldn't be surprised if there are PHP binding for GTK! In that way you will be learning a lot about GTK. On the other hand, if your priority is C, then a good book (like those that have been posted) and the many tutorials on the internet will suffice.
Originally posted by craigs1987 I found Ivor Hortons book, Beginning C (Third Edition) very helpful. Though I moved on to his ANSI C++ rather than move to GTK+.
Just to say, I recommend Horton as well. I have his books on C++ and Java and I find them both easy to follow, so I assume "Beginning C" would be the same .
Well, also, depending on your priorities, you can program for GTK using languages which are supposed to be simpler, like Python. I wouldn't be surprised if there are PHP binding for GTK! In that way you will be learning a lot about GTK. On the other hand, if your priority is C, then a good book (like those that have been posted) and the many tutorials on the internet will suffice.
HTH!
I think maybe I'll start learning Python and then start learning PyGTK. It seems not so difficult.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.