Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

unplugme71

macrumors 68030
Original poster
May 20, 2011
2,827
754
Earth
So for the past few years, I've always been programming in languages like HTML, CSS, and PHP. I've developed some nice web applications in conjunction with MySQL DB. I also learned a little bit of C++ back in high school and made some cool DOS-like applications.

Last year, I glimpsed through C and Objective-C and couldn't seem to understand it much. I was able to create a CLI of a calculator but that was it. Enter a number, followed by a symbol and another number and it output the result. Most likely I programmed it the way I remembered 10 years ago and probably didn't take advantage of the newer functions/classes.

With Swift, Apple says its supposed to be a lot easier to learn for beginners, so I began reading the first 50 pages. It doesn't look too bad, but my question was, how do you go from the programming language to the visual piece of the app? Most of my programming in C++ produced a shell application with no GUI. PHP is similar. The only visually piece I was ever able to do is with HTML/CSS but it seems to much easier.

For those who started programming, how did you transition from coding shell stuff to GUI? I'd like to make something simple like a calculator. How do you create the buttons, how do you assign it a value, and finally, how do you take those mouse inputs, calculate it, and output a result? I don't necessarily want the answer literally, but how you went on to learn how to do it so I can teach myself.
 
So for the past few years, I've always been programming in languages like HTML, CSS, and PHP. I've developed some nice web applications in conjunction with MySQL DB. I also learned a little bit of C++ back in high school and made some cool DOS-like applications.

Last year, I glimpsed through C and Objective-C and couldn't seem to understand it much. I was able to create a CLI of a calculator but that was it. Enter a number, followed by a symbol and another number and it output the result. Most likely I programmed it the way I remembered 10 years ago and probably didn't take advantage of the newer functions/classes.

With Swift, Apple says its supposed to be a lot easier to learn for beginners, so I began reading the first 50 pages. It doesn't look too bad, but my question was, how do you go from the programming language to the visual piece of the app? Most of my programming in C++ produced a shell application with no GUI. PHP is similar. The only visually piece I was ever able to do is with HTML/CSS but it seems to much easier.

For those who started programming, how did you transition from coding shell stuff to GUI? I'd like to make something simple like a calculator. How do you create the buttons, how do you assign it a value, and finally, how do you take those mouse inputs, calculate it, and output a result? I don't necessarily want the answer literally, but how you went on to learn how to do it so I can teach myself.

Download "Xcode Without the Code" free from the iBooks store. You will see visuals on creating and linking buttons, sliders, etc.
 
There are some great video courses on the itunes university free of charge if I remember right. This may be a different way to get a handle on the concepts.

Basically, GUI programming is about turning things outside in compared to normal programming. Instead of your main programming controlling the world and getting things from the user it goes the other way round. The GUI application framework sets up the rules you need to follow.

Your program becomes a lot of small snippets each doing tiny bits of the function. As example in doing a calculater, you write a small function "behind" the "7" key, and another small function between the "+" key. (Now, this is is a simplification). It takes a bit of turning around in the head and it does help if you can get input from different sources in finding the path.

/ Gunnar
 
For those who started programming, how did you transition from coding shell stuff to GUI? .

I think you are doing the right thing and from what you say it sounds like you TRULY want to learn to program like I did. I spent almost a year learning before I made my first GUI and shortly after that an app in the app store.

Also like aaronvan said, get xcode and start to learn that program if you haven't already. That 1 program allows you to build your buttons and such and write the code.

Good Luck!
 
Basics

While swift looks and functions in a way that is 'easier' for new developers, Cocoa and iOS/OSX libraries used to create the visual aspect of the applications have been written in Objective-C.

I have a firm belief that if you want to know how iOS or OSX applications work you need to understand how Objective-C and the Cocoa Libraries work before you can inject Swift code.
 
There are some great video courses on the itunes university free of charge if I remember right. This may be a different way to get a handle on the concepts.

Basically, GUI programming is about turning things outside in compared to normal programming. Instead of your main programming controlling the world and getting things from the user it goes the other way round. The GUI application framework sets up the rules you need to follow.

Your program becomes a lot of small snippets each doing tiny bits of the function. As example in doing a calculater, you write a small function "behind" the "7" key, and another small function between the "+" key. (Now, this is is a simplification). It takes a bit of turning around in the head and it does help if you can get input from different sources in finding the path.

/ Gunnar

I followed the first two videos on how to build an iOS app from the Stanford U courses. The whole MVC concept cleared up a lot of questions I had. Even though its a bit outdated with Swift out now, at least I can learn the concept.

----------

I think you are doing the right thing and from what you say it sounds like you TRULY want to learn to program like I did. I spent almost a year learning before I made my first GUI and shortly after that an app in the app store.

Also like aaronvan said, get xcode and start to learn that program if you haven't already. That 1 program allows you to build your buttons and such and write the code.

Good Luck!

I guess it's also easier if you know what to program. I learned HTML, PHP, and MySQL by creating a personal website for me and logging hits in a database rather than a flat text file. Eventually I expanded into learning CSS and creating more complex functions within my personal site. However, I never picked up OOP with PHP and I somewhat regret not learning it earlier.

The other thing is, books never really teach you why certain things are done or real-world concepts. I created a login/logout form using PHP Sessions and when I had someone look at it they pointed out so many flaws in the code. However, it did work but it wasn't secure, certain things were missing, certain things weren't needed. That's the other part of programming that I find complex. How do you "learn" these things other than from trial and error or having it reviewed by someone else?
 
That's the other part of programming that I find complex. How do you "learn" these things other than from trial and error or having it reviewed by someone else?

There is no real secret to it. It just comes from reading a lot and asking questions on forums like this or on websites like Stack Overflow.

Like most things in life it takes a lot of practice to get good at anything. Unfortunately there is no silver bullet other than taking the time to learn.

On the plus side it is incredibly interesting when you get into it so that's good :).
 
How do you "learn" these things other than from trial and error or having it reviewed by someone else?

That's how you learn these things. Kids don't learn how to ride a bicycle by reading a physics book. They learn by trying to ride one (and getting up and trying again when they fall and skin their knee). There might be a few kids who can skip doing all their arithmetic and math homework, but most people have to do the problem sets in order to gain enough skill to move on to subsequent stuff.

So you learn to code by trying to code. Maybe failing. Maybe succeeding. Maybe having mistakes pointer out by a teacher or collaborator. But programming a better solution the 2nd, 3rd or Nth time.
 
That's how you learn these things. Kids don't learn how to ride a bicycle by reading a physics book. They learn by trying to ride one (and getting up and trying again when they fall and skin their knee). There might be a few kids who can skip doing all their arithmetic and math homework, but most people have to do the problem sets in order to gain enough skill to move on to subsequent stuff.

So you learn to code by trying to code. Maybe failing. Maybe succeeding. Maybe having mistakes pointer out by a teacher or collaborator. But programming a better solution the 2nd, 3rd or Nth time.

Yes but riding a bike is different. You either learn to balance yourself or not and fall..

Whereas programming, you can write code that works, but can have security holes or maybe not the 'right' way to have written a function or something. It seems this area of programming is hard to find reference too unless you find an example online to copy from.
 
Yes but riding a bike is different. You either learn to balance yourself or not and fall..

Whereas programming, you can write code that works, but can have security holes or maybe not the 'right' way to have written a function or something. It seems this area of programming is hard to find reference too unless you find an example online to copy from.

Very true. There are hundreds of different ways to solve any given software engineering problems with different pros and cons. Some like clever solutions while others value stability and maintainability, for example.

Writing a clean well-written code is certainly a skill of its own and usually doesn't matter which programming language you have started with, though.
 
Very true. There are hundreds of different ways to solve any given software engineering problems with different pros and cons. Some like clever solutions while others value stability and maintainability, for example.

Writing a clean well-written code is certainly a skill of its own and usually doesn't matter which programming language you have started with, though.

Yeah, I've gotten in the habit of spacing my lines of code out so its easy to read and also comment a lot.

However in regards to the multiple ways, I guess that comes from trial and error. I'd have to hire someone to try and break the app (find ways to crash it or make it act in a way that was unintended) to verify its stability.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.