C++ or Python as a starting point into GUI programming? - c++

I have neglected my programming skills since i left school and now i want to start a few things that are running around in my head. Qt would be the toolkit for me to use but i am undecided if i should use Python (looks to me like the easier to learn with a few general ideas about programming) or C++ (the thing to use with Qt).
In my school we learned the basics with Turbo Pascal, VB and a voluntary C course, though right now i only know a hint of all the things i learned back then.
Can you recommend me a way and a site or book (or two) that would bring me on that path (a perfect one would be one that teaches the language with help of the toolkit)?
Thank you in advance.

Being an expert in both C++ and Python, my mantra has long been "Python where I can, C++ where I must": Python is faster (in term of programmer productivity and development cycle) and easier, C++ can give that extra bit of power when I have to get close to the hardware or be extremely careful about every byte or machine cycle I spend. In your situation, I would recommend Python (and the many excellent books and URLs already recommended in other answers).

http://wiki.python.org/moin/PyQt
You can use PyQT for Qt in Python. They have recommendations for tutorials and references on there.
Google "How to learn Qt" and "Learning C++".
There are some decent sources on there.

I have read Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt Programming by Mark Summerfield , it's cool.
for C++ : C++ GUI Programming with Qt 4 (2nd Edition)
just my two cents.

How about Ruby? You can write Qt apps in Ruby allegedly (http://rubyforge.org/projects/korundum), and it gives you a good excuse to look at the very excellent "Why's Poignant Guide..." (http://poignantguide.net) which is how Monty Python would have introduced programming....
(Actually thinking about learning python myself, so feel free to ignore my advice (but visit Why's site anyway))

Related

Any suggestions on where to learn C online in preparation of learning Objective-C

I've been programming PHP & mySQL for about 8 years now. I understand and make use of modern software architectures and OOP in my projects on a daily basis. I decided I want to learn something new.
I finally decided yesterday that I want to learn C and eventually Objective-C so I can begin creating Mac / iOS applications. (Would you recommend C, C# or C++? I just assumed C would be best.)
That said, I miss the days of programming BASIC tic-tac-toe games on my graphing calculator haha. I'd like to get a very good foundation in C, maybe create some command line games, and then eventually move up to GUI programming with Objective-C
Where would you recommend that I start looking online. I don't just want to understand how to make code work in C, but I also want to understand how and why code work.
Thanks & wish me luck :-)
It's not online, but to learn C, I recommend you read Kernighan and Ritchie's The C Programming Language, 2nd ed. (also known as "K&R"). It is a slim volume that communicates the fundamentals of C89. You can probably find it for free at your local library; that's what I did, anyway. C99 changed a few things, but the core of the language remained the same.
I don't recall whether it gets into the details of how an executable is loaded and linked and how the stack and heap are generally used. For that, check out the latest edition of Patterson and Hennessy's Computer Organization and Design: The Hardware/Software Interface.
If you already understand OOP, and you are conversant with C, then picking up Objective-C is as easy as reading through Apple's The Objective-C Programming Language and looking at a few examples.
Objective-C is simple, but the Mac/iOS frameworks are mammoth. Most of your time learning to program for Mac/iOS using Objective-C will be spent learning the frameworks and how to cooperate with the execution environment (NSApplication/UIApplication, NSRunLoop, the responder chain and event handling, etc.). You can get by with Apple's documentation, but Hillegass's Cocoa Programming for Mac OS X (currently in its third edition) is the standard non-Apple introduction to Mac OS X desktop programming. A clear standard introduction for iOS programming has yet to emerge, but I recommend Conway and Hillegass's iPhone Programming. After reading Hillegass's other book, you'll be comfortable and familiar with the didactic style employed in iPhone Programming.
If you want to do Mac/iOS apps, just learn objective-C. I don't think you will "move up" from C to obj-c, rather you will just learn two different programming languages. Working in C is very different from working in C++ or obj-c. Mastering C will help you become... a master in C, not in obj-C.
I feel it's like saying that you should first learn how to ride a motorcycle in order to learn how to drive a car. Just because they both have wheels, doesn't mean it works like that.
On the other hand, if you feel C would be useful to you for some other reason (which it might very well be), there are many great books on C out there. I recommend the C Programming Language by Kernighan & Ritchie (often referenced just by K&R).
Don't learn C to seed your learning for Objective-C, that step is unnecessary.
I come from a C# background, and when I first started learning Objective-C I had little C experience, which didn't inhibit me when working in Objective-C. The big thing you've got going for your is the OOP and software architecture. That will get you further than learning C.
I found that the best resources for learning Objective-C and specifically iOS programming can be found within Apple's documentation:
Start reading through the iOS Reference Library specifically:
Human Interface Guidelines
Memory Management (this is as close to C as you need to get)
Apple's source code examples are great. specifically:
iPhoneCoreDataRecipes
Another great resource is Cocoa with Love which is written really well and has some great content, specifically:
Assign, retain, copy: pitfalls in Obj-C property accessors
Method names in Objective-C
Debugging tips for Objective-C programming
As well, I've found a lot of people like the AppsAmuck demos. Personally I found that they're coded quite poorly, but there are some good area specific examples for working with animations, urls, etc.
I would recommend learning Objective-C because it's so different C. You should know most of the C-syntax developing PHP.
I don't really think you need to get too deep inside C, just because you usually don't need to use C code while developing in Objective-C (or at least not the features that you would learn). Start directly with Objective-C and try to fill up holes just when needed.
Although Objective-C is considered an extension of C language (in term of its grammar), it replaces almost everything you needed to do in C with Objective-C and its types, so there's no really need to use it so ofter. Usually you need it when interfacing with something low level but not so frequently (since Obj-c wrappers are present for almost everything).
Scott Stevenson's Cocoa Dev Central hosts a lot of useful Cocoa tutorials, including a C tutorial for Cocoa programmers and links to several other useful resources on the topic.
Another good one is Masters of the Void by Uli Kusterer, a longtime Mac programmer.
If you really want to learn C before Objective-C, go for it. For many people it's an unnecessary step, but you will use it eventually. If you decide that you want to skip learning C and dive into Objective-C, Kochan's book is a gentle "from the ground up" introduction.
For C, it's going to be better to get a book than try to find online tutorials. The classic text (like everyone here is saying) is the K&R C book. It's well known as the standard. The problem is that it's very dry and not that great for self-learning. It's more of a classroom book.
The best C book for self-learning is K.N. King's C Programming: A Modern Approach. It's pricey, but is very well paced, in-depth, has comprehension questions at the end of each chapter. I found out about this book from the guy who wrote the classic Objective-C book, Aaron Hillegass. He understands teaching and recommended it because it's a great book to learn from. It will help you to think about C and programming, where K&R will just inform you.
Personally, I gave up on my goal of learning C for iPhone programming and just learned Objective-C from Hillegass's book (and Jeff LaMarche's book). I get confused on the odd occasions that I have to write or understand C code, but it hasn't been a huge hurdle.

what's the best way to learn C++ and Qt at the same time?

Hi I did A Google search and couldn't find anything,
so I wanna learn Qt/C++ my University (I'm a first year CompSci Student) won't be teaching C++ next year which is a big disappointment
I already know Python
and dabbled in LaTeX, Javascript, C++
I'm currently helping out a free software project Clementine but it's programmed in Qt/C++ and I don't know enough of both to help out enough.
Is there any tips, Tutorial, howtos out there?
Don't learn both at the same time. Learn C++, then learn Qt. Grab a book about C++, then a book about Qt; there is no substitute for a good book.
Trying to learn C++ and Qt at the same time is like trying to learn the alphabet while reading Shakespeare.
I don't think it's an impossible thought learning both at the same time. Since you already know Python, try learning some basic Qt concepts by implementing something simple in PyQt or PySide. Learn C++ by writing simple console programs. Once you've mastered C++, try doing the same stuff with Qt using C++. It's a fact that you'll get a lot more help and code examples from people using C++, so you shouldn't just be satisfied with using Python to implement Qt programs.
From Qt's website: How to learn Qt and Qt tutorials.
Since you're familiar with programming already, the Best Practices might be of interest too.

Tired of building web applications? Trying maybe C++?

I'm getting a little tired of building web applications. Feels like same thing over and over again. Are there any other cool things you can do. I'm maybe getting to start coding in C++.
Any suggestions for tips in that area? Should I delve into Qt or MFC? Any suggestions?
My latest interest is in Robotics. You can get a microcontroller for about $30 (arduino.cc) - and miscellaneous motors off of E-bay. I also have some cheap rangefinders and a GPS receiver - each of them under $30...
I build web apps as well. I'm not really tired of it, but I spend all my spare time programming in C.
If you're just starting out in C++, I recommend starting with some simple console-based applications first. Get used to the syntax and some fundamentals like strong typing, pointers, and understanding the difference between pointers and references. (Depending on your experience as a developer, you may already know all or most of the theory behind these concepts.)
If you're comfortable with these things, building GUI applications is easier (although still far from trivial.) I'd recommend going with a toolkit like Qt rather than MFC, which is largely deprecated in favor of dot NET, if I'm not mistaken.
Edit: also, consider trying out a language like C# instead. C# is newer, a little more cohesive, and lets you use dot NET for building Windows GUI applications.
Write a game. An action game. Like, a shoot-them up for example.
You'll discover the other face of programming. Use whatever you want to make it. C++ is a good choice, but any language will be good. C++ will be harder to "master" than other languages but learning it will make you understand a lot about other languages. But that's your choice : the project domain is more important than the language (that is just the tool).
Just try to make a game, I think it will really be different and you'll discover a lot of interesting things. I recommand a shoot them up because it's visual, make you learn basic graphic rendering, basic collision management and is a good base for a potentially interesting game (if you add a feature that makes it stand appart) that will keep your motivations for learning.
Look into mobile application development like on Android or iphone. C/C++ will come in handy.
C++ is great and all, but writing GUIs in MFC is just stupidly painfully compared to any other reasonable framework out there, like .NET (VB, C#, C++/CLI, pick your language) or Cocoa/Obj-C on the Mac OS X / iPhone OS. Qt is probably better than MFC.
Buy "The C Programming Language" by Kernighan and Ritchie and work through it.
Ideally, you also have access to an OSX/Linux system and can work on that. (C and Unix go hand in hand).
If you're used to working in relatively high-level languages such as C# or PHP, going back to something like C++ where you need to do your own memory allocation and other low-level stuff will probably seem cumbersome. Personally, I was happier making the switch in the other direction, and having much more done for me.
But if you do want a challenge, C++ could be a good option. Or, go straight to embedded. Robotics is a very fun topic, try to fit interesting things (that really move!) inside the 2-KB RAM environment of a PIC microcontroller :-)
I would recommend trying to implement something useful in C/C++. Is these a utility in your operating system you don't like? That you think you could improve? Have you always wanted to do X easily and have a good idea? No matter how big it might seem, research it. Learning an OSes API will teach you a lot about C/C++. Add a user interface in the library of your choice to learn even more. Basically, push the envelope a bit - building a calculator is great or a little console app for learning a few things, but building a fully fledged app with a purpose will really teach you things.
Add intelligence to a simple game using a neural network. I've always wanted to add a neural net to Oware to see if it improves its wins.
If your into pain, you could correct flaws on Windows Vista and 7. :-(
I'd recommend moving to Python rather than C++ if you're coming from a web design background. Get good at object-oriented programming, encapsulation, and related things before you go to C++ and have to deal with pointers and cleaning up after yourself.

Getting started with C++ ( the paradigm shift from Python )

I want to learn C++ so that i can develop C++ Python modules for server-related stuff.
I'm a purely dynamic languages developer (Python, PHP, Ruby, etc). I want to learn a fast language, and if I'm going to do this, I'd rather learn a really fast language like C++. Before I even get started though, I understand that suddenly working with static types, a different syntax, and compiling code will be quite the paradigm shift. Is there any advice that a C++ dev who also has dynamic languages experience can give me to me to help me make that shift faster?
I doubt there is any specific advice that can be given, other than that you must read a good book on C++ written by an authoritative author or authors - do not pick the first or cheapest one that comes your way. For a list of books see The Definitive C++ Book Guide and List - I personally would strongly recommend Accelerated C++ - it is written for people with programming experience, though not specifically for those coming from a dynamic language background.
Get the the books, and the tools (g++ or VC++)
In the transition from python to C++ I would recommend
learn the differences between duck typing and static types
learn the differences between the memory management of Python related to the memory management of c++.
When you know this good, you'll be able to write something without shooting yourself in the foot.
There are plenty of other different topics also, because of the multi paradigm nature of c++, but start with the basics and add to your repertoire as you need it.

Learning C++ right?

Since I have been mostly using script languages in the past time but now want to go to the "high-performance" level I decided to learn C++ some time ago.
I looked at some "beginner" tutorials and bought an O'reilly C++ pocket reference book (it's really helpful). My problem is that I now know all the basics but I'm not good enought to program a more complicated game, for example, yet.
Do I have to get one of those thick C++ books for further learning?
I'm going to use C++ on Windows mainly. What APIs beside Win32 are important for me?
My goal would be to write a small interpreter for a programming language I've though of - I managed that in several scripting languages already, what API/Library knowledge do I need in C++ to write one?
You don't need a thick book - you need a good one. Get Accelerated C++, written by Koenig & Moo, two of the original C++ development team.
Depends what you want to do.
You don't need anything - you can write a perfectly good interpreter or compiler using just the C++ Standard library. See this SO question for lots of info in this area.
Learn with books. C++ is a complex language. My suggestion is to first go with a rather quick introduction and general overview of the major programming paradigms that C++ supports: OOP and generic programming: Accelerated C++.
When you finish this book, you can go with the two volumes of Bruce Eckel's Thinking in C++ which are very detailed.
For UI programming, the best C++ toolkit is Qt, and it is multiplaform-ready. You can read "C++ GUI Programming With Qt4" (the first edition is free to download, just google it). If you want to stick with C++/Windows API, learn the Windows Template Library, altough it may be a bit hard due to lack of official documentation (altough there are good tutorials on the net). WTL is the way to go to create very small, lightweight applications (Qt DLLs on the other side, need a few MBs each).
I have always found that learning a language from a book is pretty difficult and that after you know the basics you should begin to program. So instead of picking up a thick manual I would check out something like http://www.cprogramming.com/tutorial.html#advanced or just google for c++ tutorial and something that you would like to try to make.
A good (and) thin book to get started in C++ is Accelerated C++ by Koenig and Moo.
I mainly do programming under Linux, but I hear a lot of bad things about MFC, so I'd try to find a different GUI library.
Once you get up to speed with some of the more complicated parts of C++ syntax, have a look at the Boost.Spirit libraries for parser generation. The various Boost libraries provide some very useful extensions to the Standard Library.
Honestly, In learning C++ i never picked up a book (no flaming please). The best advice i can give is to go to this page and go through the tutorial. It covers the majority of the C++ language (read: most commonly used features) and keeps it as simple as possible. As far as APIs that are important... well that is a matter of preference. No one toolkit/api has really "won", but Qt, GTK-- (gtkmm), and wxWidgets are all big players. And besides GUIs, you'll probably want to learn either the raw winsock2 and threading APIs OR the boost library's threading and network interfaces. I do agree that MFC is dying, and for windows-only development C# is taking an increasingly large role (even on linux/mono C# is starting to catch on... slowly).
Also, the best way to learn a language is to code. So don't just read a whole ton- without practical experience you're never going to learn the language. Ask questions, answer those you can, and write tutorials- for yourself if nobody else. Writing down what you've learned is a great reference, and the process of straightening everything out in your head to write it down in a fashion that another person can understand it alone is a great way to reinforce concepts. In a strange, but seemingly backwards, way I found the best way I learn programming is by helping other people with their questions.
#Neil- i disagree that online tutorials are "flat out wrong". If anything, the style they teach you might be geared towards readability rather than optimization- which in-my-not-so-humble-opinion is an advantage. In my limited experience I've found cplusplus.com a go-to reference for pretty much everything.
Specifically, to answer your questions:
1. No thick book needed. I've heard that the thinner ones can be useful as a quick reference, though.
It's completely subjective and depends on your goal. Boost's network and multithreading libraries are probably a good start.
between std::string, std::stringstream, and getline(std::istream&, std::string&) you should be pretty good. C++ comes with a whole ton of built-in functionality yet isn't too bloated/huge/impossible to learn. Take advantage of it. All of the parsing is built in already.
Please, for Pete's sake, don't use directly use the Win32 API. You'll be painting yourself in the Microsoft corner. There are plenty of cross-platform libraries out there you can use instead:
Standard C++ library: strings, file i/o, containers, algorithms
Boost for the everyday stuff they left out of the standard library: parsing, networking, threading, smart pointers, memory pools, date/time, matrices, etc... Boost libraries are peer-reviewed before being accepted and are high-quality. Boost is the breeding ground for libraries that eventually become part of the next C++ standard.
GUI Toolkits: Qt and wxWidgets are very mature and widely used. There are many more.
For C++ on windows, definitely learn Microsoft Foundation Classes (MFC). Without MFC, you have to implmenet all of the windows API stuff yourself, which is more C than C++ and can be quite a pain.
You also may want to get, learn, and use the boost C++ libraries. They aren't windows specific, but they are a great resource for anyone.
I highly recommend Stroustrup's Intro C++ book. It covers C++ and STL in a very approachable way.
After that you might consider looking into books on Qt, a multi-platform GUI toolkit, or WTL or MFC for Windows. You could do .NET + C++, but that would be a lot to learn. In my experience with Qt and MFC, books have not helped much. Tampering with sample apps, building small apps just to test out one kind of feature, and poking around the docs was the only way I could get my head around either library. The books I had tended to simply gloss over too much--they were not worth the money.