Programming Throwdown - Objective-C
Episode Date: June 18, 2011This show covers Objective-C, the premier language for iphone, ipad, and os/x app development. The episode talks about the upcoming Wii U console and Duke Nukem Forever, (possibly) the most o...ffensive game ever made. After the news, the show discusses why and how Patrick and Jason got into programming. The tools of the biweek are JavE, an ascii art drawing and conversion tool, and Ascii Flow Diagram, an ascii art flowchart creator. ★ Support this podcast on Patreon ★
Transcript
Discussion (0)
Hosting provided by Host Tornado.
They offer website hosting packages, dedicated servers, and VPS solutions.
HostT.net.
Programming Throwdown, episode number 7, Objective-C.
Take it away, Jason.
Hey, so I'm biking to work now, which is just pretty awesome. I actually,
I didn't know if I was going to, you know, like it because, you know, I like the exercise,
but then there's this whole, you know, you get to work a little bit later. I mean, it might take you
like an hour to bike five miles or something, right? So you spend a lot of time on the bike
and you kind of have to
you know shower afterwards and stuff like that you are such an overachiever i'm just saying it
showering is an overachiever what does that say no riding your bike no it's but it's super fun
you know you get to feel there's something weird like there's something invigorating about like
almost literally just taking yourself to
work oh yeah well that too but uh people over here in california are actually pretty uh nice
to uh bikers like in florida i feel like if i had pulled some of the stunts i pulled
here i would definitely have been killed like actually if you're if you're biking and they
actually they have a bike lane here which is pretty cool but if you're biking in the bike
lane which is on the right side and you need to make a left turn,
you can just swing over to the left lane and take up a whole car lane, you know, until the turn signal goes.
And then, you know, make the left turn and then swing back out to the bike lane.
And this only works because everyone's in on it.
Like the cars know you're going to do it.
You know you're going to do it.
You stick your arm out.
Make sure to do your hand signal, yeah. We used to have to do that when i was at school and you know
going to university that was how it was you had to ride and it's actually the right way to do you
have to ride in the turn lane and block traffic and people would honk at me and get mad and that
was really scary but you that's the rule like that's what you have to do to make the turn
yeah your only other thing you can do and i've i've done this like i'm still doing
this today on a couple of the intersections where i have to make lefts because i'm just not
comfortable yet you know you can walk your bike like along any of the pedestrian paths right but
technically it's against the law to you know ride your bike like on a sidewalk or a crosswalk or
something yeah yeah right or even where there isn't i believe the rule is if there's no bike lane you're supposed to take up a regular lane of traffic or just kind of get over to the
right so consult your lawyer please yeah that's right but uh it's actually it's a lot of fun
and uh you get some exercise and that's awesome i could use a lot more exercise too but uh i'm
glad you're getting hopefully you'll just get enough for the both of us okay the one thing about it though at least you know up until now
maybe I'll actually build muscle but as long as I'm still kind of like indistinguishable from a
skeleton I uh I'm I'm like perpetually sore like every day I'm sore because you know you have this
like you know eight mile bike ride or whatever so even if you don't work out, you're going to be sore.
What I want you to do is mount the camera to the front of your bike,
ride the bike, so then you can upload that video to me,
and then I'll ride my stationary bike.
Okay.
I'll sit on my couch and watch you bike to work.
Oh, man.
I'm totally going to call.
Let's just say somebody I know who may or may not be in my family, and I have no brothers and sisters, would watch Sweating to the Oldies and just like sit on the couch eating like Cheetos.
And the guy was named Richard Simmons, right?
Yeah, yeah, yeah.
Richard Simmons is like, you're doing great, honey. You're doing great.
She's just like eating Cheetos.
Yeah. Keep going. Don't stop now. great honey you're doing great she's just like more ice cream cheetos yeah keep going
don't stop now yeah that's right she's like he's like one two three reach for it
yeah that's for when you're at the back at the bottom of the ice cream container
or when it falls under the ground. Oh, man.
Okay.
So we have kind of a mini news segment today because we want to talk about how we got into programming.
Yeah, thanks to a viewer or listener email.
Yeah, a listener suggested that we cover Objective-C,
which we're going to do, as you know,
and also suggested we kind of talk about how we got into programming.
I think that's really good, two excellent suggestions.
And in general, if you guys have any, you know, feedback that you want to give that involves, you know, future episodes, definitely, you know, bring that to our attention.
Yeah, it's nice to know that we actually do have people listening to this.
Besides our moms.
Hi, Mom.
Hey, Mom, how's it going?
I think we're the number eighth or ninth podcast on iTunes if you search for programming, which is really awesome.
Yeah, I mean, and some of the ones up there are like Stack Overflow, which is going to be, it's going to be a challenge, but I think we can take them down.
Yeah, Joel Spolsky better watch out.
That's right.
And you said we broke 25,000 downloads, is that right? That's right, 25,000 downloads. That's right. And you said we broke 25,000 downloads. Is that right?
That's right.
25,000 downloads.
That's amazing.
Yeah, something like close to 2,000 unique IP addresses grabbing episodes.
Some people are downloading it more than once.
That's pretty cool.
Not sure why, but that's awesome.
Yeah, yeah.
Some people, I think a lot of people, at least the ones that have talked to us, are getting it on their mobile and getting it again on their on their computer and things like that which is pretty
awesome all right pretty good all right so yeah first item of news we had was uh the new we we
talked about that uh it's that last episode of the episode before um yep that you know was it
going to come out and sure enough at e3 announced it, I guess that was last week. And they, it's actually kind of interesting. The first pictures I saw was of this
weird, like tablet device. I don't know, have you seen these pictures? The thing looks crazy.
Yeah, it looks awesome. I mean, we talked about this on the last episode, how they tried to do
this kind of experience with the GameCube and a bunch of GBAs.
But this sort of forces the experience onto you.
And I thought that environment was incredible.
So yeah, I kind of didn't believe it.
And then I saw the pictures and I was like, that looks stupid.
But reading people who actually tried it said it's like,
it's really fun and really amazing.
And like you said, with the Game Boy Advances, you know,
that's what they tried to do before.
But supposedly, I guess they executed it this time really well and people said that you
know you can basically have the normal wii remotes for everybody else and one person has this tablet
screen and they can kind of be like a different player than everybody else with more information
or a different world view um than everybody using the tv screen and so you can
kind of get this like different players have different roles dynamic at an even fundamental
level yeah i mean you know this mechanic has been around forever i mean you had the idea of
even dungeons and dragons if you ever played that in like middle school or high school or even i
know people who play it today uh you have this idea of the dungeon master who sort of, he has information
that no one else has, and he has
sort of a certain amount of control, and is
sort of more like the moderator.
You know, as the Wii has sort of taken
over the family demographic,
you could see playing this with your
kids, and sort of being
sort of the dungeon master and help guiding them
to having even more fun than they could have
just playing by themselves on the computer. Yeah, or yeah or you know having it for your football game so
nobody can figure out what play you're choosing or yep yeah it's kind of cool and it's supposedly
going to be a big upgrade they're going to be said i think 50 faster or more hardware or power than
the ps3 oh wow so well yeah i said the same thing like well that's pretty good and then i saw
some commentary which was a good point which is yeah but the xbox 360 and playstation 3 are many
years old now like they better be able to surpass it and um like right now computers are like an
order of magnitude more powerful than a ps3 or an xbox 360 so they're actually really far behind as far as you know
raw power goes yeah i would take that with a grain of salt though because these are like specialized
processors and they can optimize them because everybody has exactly the same hardware so they
know what it's going to be yeah exactly i mean remember the nintendo is like what 10 megahertz
or something but uh we couldn't emulate it until you had, like, at least 20 times
that, so you could do a lot with, you know, not that much power if it's specialized. Yeah, yeah,
but it's still an interesting point that, although they're going to leapfrog everybody else, that
they'll probably be absolutely crushed when the next, you know, the PlayStation 4 and the Xbox
720 come out. Yep, I mean, you know, I think what'll the xbox 720 come out yep i mean you know i think what
will happen is putting my visionary glasses on is uh you know the next xbox and ps that come out
will um will probably support 3d if they don't already and we'll all be saying oh how come the
wii you know is the only one without 3d kind of like we're saying now how come the wii is the
only one without 1080p but i guess they're not going after the the visuals it's more about the gameplay experience
and these controllers and they really led the way i mean now with playstation you got the playstation
move and the xbox 360 connect which have been successful in their own rights but i mean they
all came years after the wii introduced this motion controller yeah Yeah, that's right. That's exactly right.
Cool, man.
All right, you have any news?
Yeah, so I'm going to talk about something
not as sophisticated or eclectic as the Wii.
I'm going to talk about Duke Nukem Forever.
This article is titled
Duke Nukem Forever Barely Playable,
Not Funny, Rampantly Offensive.
Okay, that sounds like a glowing review
yeah that's right you can imagine where this is going but um you know i saw the don't give me
spoilers i don't know if there's i've not played these games but uh i don't know i haven't played
it either actually i didn't know until today that the game was out so um which is kind of
a testament to how bad it's doing but um yeah yeah, I mean, I think that, you know, I saw the preview for it.
And they're sort of really going after this niche market of people who, like, want to have sort of, like, nudity in their games.
Like, even, I don't know if, have you seen the preview for this?
No.
For this game?
So, even the boss is basically the top half it's sort of like this
keep our clean rating yeah yeah so so keeping on the clean rating it's it's basically it looks like
uh top half of a naked woman but like if you had textured that in such a way and changed the face
to make it look like a monster like a a half-naked woman torso with a monster head.
So it's like, there's just,
and even the preview is just littered with nudity.
And so it's sort of,
I feel like that's sort of what they're going for.
And this article really sort of pokes at the huge weaknesses of this game.
And I thought it was a funny read.
So I definitely give it a glance.
Okay.
Well, we had two news stories.
Both were gaming-related, so next week we'll have to mix it up
and give something actually programming-related.
Yeah, for sure.
And there are some programming news articles that I was reading,
so we can definitely deliver on that.
We're trying to be more exciting.
Yeah, yeah.
I mean, the hip thing.
Video games are hip.
We want to be with the young kids.
I was playing, just an aside, I was playing Demon's Souls,
which is this really hardcore game for the PlayStation 3.
And I don't know if I'm going to make it through.
The graphics are beautiful and the experiences,
it's like I'm getting a lot of enjoyment out of the game.
But basically, every time you die, you have to start all over again, and the experiences it's like i'm getting a lot of enjoyment out of the game but basically
basically every time you die you have to start all over again kind of like those old nintendo games
and i'm just so sick of playing like the beginning over and over again that i just don't think i can
tough it out that sounds pretty brutal yeah yeah definitely okay all right so uh go ahead no all
right so um we were going to talk a little bit about
on kind of the reasons we got into programming and some of our early days and try to remember
clean out those cobwebs and try to try to think about what it was like and any sort of advice i
guess so i guess i guess you go ahead and start it off so how did you get into programming
yeah so i started programming really young actually my i come from
like a lot of computer science majors in my family my extended family especially and so my cousins
were kind of teaching me how to program and they were teaching me basic and you know how you do
like print your name go to 10 and it would just spam your name on the screen i remember that one
like oh i crashed it with my name. It's awesome.
I know.
It's like, and so it's sort of like, it's like there was nothing and then I created
my name like an infinite number of times or just a really large number of times.
And so that idea of being able to create something from nothing has sort of like pervaded all
of my interests in programming thus far.
Like I've worked on this underworld hockey club, this video game that I made from scratch has sort of pervaded all of my interests in programming thus far.
I've worked on this Underworld Hockey Club,
this video game that I made from scratch,
and I really wanted to see a hockey game with physics,
where when you body check the person, there's some physics engine running.
And it was kind of funny, and just another aside,
I was looking at video games at Target the other day, and NHL 2011 has come out.
And on the back of the box, it says, new physics simulation.
Like, every hit is unique.
And I was just thinking to myself, it's so funny because I did that in, like, 2008.
And so that idea where...
You should sue them.
Yeah, that's right.
I'm going to sue Sony, too, because I'm thinking of the PlayStation 4 right now.
Oh, no.
You're in trouble.
But, yeah, the idea that one person just, you know, in their basement can create something that usually takes, you know, a whole team of people or can change the entire world, can create a project that's downloaded or used by hundreds or even thousands of people.
That is something that's sort of unique to programming.
I mean, there's many different arts.
There's painting, there's sculpture, there's writing.
But few of those arts allow you to influence and allow you to get inside the homes and
the minds and the lives of so many people
as as computer programming i mean you could write an iphone app for i was talking to somebody today
who wrote iphone out for deer hunting it's like the number two or number three app like every
deer hunter wants needs his app and even people who don't like deer hunting for some reason they're
fascinated it's like a deer caller or something no what it is i guess it keeps track
of like deer like migration or something and also it you can it's sort of like a user-driven content
like you can specify like if you know good places to hunt and places to hide where the deer are and
stuff like that um and but the idea that there's someone in the spare time square for the forest yeah that's pretty much that's exactly it i checked in at the deer stand
someone in their spare time just made this app and it completely took off and i think that you
know you can be like an amazing painter but often you need different sponsors you go to galleries you need
to you know get your foot in the door and you know now with the internet of course all of that is
changing but definitely when we were young that was the case both computer programming even back
then before you know the internet had really taken over and things like that when we were very young
there was this notion that like one guy like like you'd play Pitfall for the Atari and
it was like made by this guy, like that guy made that whole experience. And you'd go to the movie
theater and there'd be a cast of hundreds of people to create a movie. So this idea that you
have just this incredible power is sort of what got me into programming. And I think that happens
even to today. I mean, what is the the story i mean i'm not
completely familiar with the guy who wrote minecraft right he was pretty much by himself
until i mean now he has a team i think but he spent a lot of time doing it but he pretty much
did it by himself right yeah i mean he worked on um he worked on worm online which is sort of an
mmo that was kind of trying to be like minecraft so it was an evolutionary
process but still i mean he created minecraft himself from scratch i think his his online
pseudonym is notch okay i forgot his real name but um mark is real person that's what it is yep
but yeah so even today one person can make a gigantic impact on the world with programming i mean he made like
hundreds of thousands of dollars selling his beta version of his game yeah he made millions i believe
millions okay i think so yeah so what about you patrick what made you get into programming
yeah so i guess a little similar um my family even my immediate family my father does programming so that always is kind of there
people always you know ask me and I share this story a lot and I'll share it in a minute about
kind of how my dad was at programming because a lot of people know my dad and know that he
programs and writes code and stuff and are kind of familiar with that so they ask me how how that
was growing up with that and I mean mean, it's hard to say.
It's like one of those things you don't know growing up another way how you would have been or if you would have been different.
But, you know, I feel like through his doing or through my mom or through some combination of just family that you always had this thing about solving problems.
It wasn't just, you know, the answer to something was never just told to you it was always
you know kind of asked as a form of a question you kind of had to try to figure out yourself
and um so that kind of solving puzzle aspect always you know led me to how do i get things
done how do i find answers and uh you know that eventually played well with the first few forays
into computer programming.
Similar, writing some little basic thing that just followed the tutorial.
Oh, look, it's printing out my name or it's converting a temperature or whatever.
And it was just kind of cool to see it solving a problem,
to figure out how do I express this thing in my head for the computer to do.
And even today when I explain to other people about programming,
a lot of people just look at me with the glossy eyed stare.
Like,
I have no idea what you're talking about,
but you know,
this,
how,
how do you tell a computer to do something,
you know,
even something basic that humans can do really simply like,
you know,
one of the first things you learn in,
you know,
classic academia about programming is sorting.
And a human has like all these different ways they might sort something but then if you say well how would you codify that
how would you write down a set of rules or steps algorithm to use a word you know that says how you
do that sorting of you know those those playing cards and they kind of have to think about it and
you know a lot of them you know have trouble even figuring that out it's like yeah try doing that for like all sorts of problems all day long
you know and to me that's exciting it's like oh this is fun and uh you work really hard trying
to solve some little bit of code and then you know just get that excellent feeling of accomplishment
even if nobody else appreciates what you just did um and so once I got to that point, I was hooked. And getting there
was an interesting task. And I guess it was just influenced by the fact that even my grandfather
did write code at one point and worked on some software stuff that was, you know, pretty early
on. And so I guess kind of unique being as fairly young as I am and being a third generation programmer.
I guess that's a pretty good story.
Not a lot of people have grandfathers who program computers.
Yeah, it's ironic because my grandfather also worked on some of the first computers like with the vacuum tubes and everything like that.
Oh, really? Oh, so yeah.
Maybe there's a genetic component to it.
Maybe, I don't know.
But yeah, so not a lot of people can say that.
So that's kind of a kind of badge of honor, I guess, in some ways.
It's kind of cool that you can always say nerdy things
and know somebody in your family gathering won't roll their eyes.
Yeah, I feel like a lot of people, you know,
a big part of problem solving is being able to,
I guess to use your word, to codify intuition.
You know, I was playing Professor Layton with my wife the other day.
Oh, yeah.
Yeah, and it was one of those problems where it's like, you know, your brother is twice your age and your cousin is six years older than you and half your brother's age or something like that you know and somehow like those you
there's like a set of constraints that like and then it's like what's your age and the constraints
are such that like your age has to be some exact number right and so i'm sitting here like writing
formula and trying to you know figure it out and solving a system of equations and my wife is just
trying different numbers like five oh five didn't really work out. If I have five, then my brother's age is negative three, so let's try seven.
And by the time I was done, she had already solved it and moved on to the next question.
Well, that's a sad story, Jason.
I know.
But when I was done, I had solutions for – I mean, I had the solution, but in a way that, you know, like a computer could have solved.
So in other words, I could have written another program. You could have solved it in no marginal
time. Yeah, exactly. And so that's really the thing. A lot of people can solve problems, but
being able to do this almost like meta task of writing a program to sort of solve an entire
class of problems is really super challenging. And i think that's one of the funnest
parts of being a programmer yeah it definitely is fun and you know like you said the sense of
creating something even if it's not something physical ish like a game or art or music or
whatever but you know even just creating programs that run on the computer is is kind of fun and
exciting and building them up
it's kind of like legos in a way you know you have all these small pieces and you build them
into bigger structures and there's a beauty that's hard for outsiders to understand but it's kind of
cool uh if you if you know what's going on yeah for sure for sure and then also being able to
think when you see stuff in movies that are you you know, 3D graphics or video games or, you know,
jumbotrons, and you kind of know what goes into making those work, because so much of today's
society is culture. I know you say, but the so much of what we interact with every day has
computers in it or has some sort of code running to help either generate it or run it or control it and so kind of knowing how that
works is very powerful yeah and i mean my opinion might be biased but i've always been under the
presumption that everyone should know how to program like even i mean not a specific language
it doesn't really matter but just you know a program is basically a set of instructions with certain basic structures like control loops and, you know, if decision statements and just the idea of, you know, being able to describe what you want to do, regardless of you could be whatever, like a janitor or it doesn't matter.
But being able to describe what you do and how to do it in a in a way that's programmatic
i think is important to any discipline yeah yeah yeah so um let's talk a little bit about
our first kind of you know early experience we talked all about basic but i know like when i
i first started you know i i did a little bit of basic stuff, but I never really got past, you know, just kind of messing around.
But then I picked up a book on C programming and started there and started to write some code, you know, just kind of entering the examples there.
And I remember kind of trying to work through the book and, you know, not at that point, I realized that the, it was kind of looking back. The first time I really started to click is taking the examples, putting them in, but then not just moving on or
just reading the examples, but actually typing in the examples and then like changing it. So I had,
you know, for instance, like a program that converted Celsius to Fahrenheit. So I said,
okay, well let me make one that goes the other way, you know, Fahrenheit to Celsius. Cause it
should be almost the same, right? You know? so yeah so making little tweaks like that and making it my own and that really led to
understanding and so that's actually kind of where that funny story i was talking about earlier came
from so i was writing you know this program to do temperature conversion so i was pretty excited
that i had you know modified this example you know it's pretty dinky i was pretty young so i i you
know got my dad to come in and i'm like oh oh, hey, look what I wrote. I wrote this thing.
It converts Fahrenheit to Celsius.
So I think he was like, oh, that's interesting.
Let me see.
And so he types in some temperature and it converts.
And he's like, oh, okay.
Then the very next thing he does is he goes negative, 9999999999999.
He just keeps typing nines for a while.
And then it crashed. And he goes, oh, oh your program's broken you need to fix it oh that's so harsh
so another thing that i learned quickly with programming was uh and and i think sticks with
me today is you know writing kind of error proof code or at least error resistant code or really thinking about how are you going to test this
and make sure it doesn't crash
along with how are you going to make it work.
Yeah, that's funny, man.
That's intense.
So needless to say,
today I'm really good at breaking other people's code.
People always bring code to me and say,
this is ready, hey, can you test it out for me?
And I say, yes, I would love to.
And pretty much within a matter of minutes or seconds i have it crashed oh nice yeah for me historically i i started off actually
writing i did a lot of writing when i was when i was really young and uh like writing books
comics yeah i know i wrote a lot of kind of like short stories. Okay. And I read a lot, and I wanted to make a choose-your-own-adventure.
I actually made a few choose-your-own-adventures on a typewriter.
That's pretty hardcore, dude.
It was really hard, you know.
I mean, the worst is the typewriter is you make a mistake.
You have to just kind of keep going.
And I decided, you know, I want to make a choose-your-own-adventure on the computer.
So I started off in this program is the print shop.
I don't know if you ever use that.
I mean, like reading cards and stuff.
Yeah.
So I somehow, oh, I made like a set of, I used the print shop and made like a set of greeting cards.
And it was like, go to page three or whatever.
It was pretty epic.
I still have it.
Actually, I was going through my stuff and I found it.
It's called, it was called the race that that never ends and it was like eight pages um i think i've seen this before if you want that
if you want the intelligence test turn this paper over if you want to see the intelligence test turn
this paper over it just says okay sorry it was so funny because it was like do you want to go left
or right you know and it was like do you want to go left down the dirt road or right on the ocean and if you go left you die but like there's no
context it's like you just died so you shouldn't have picked the dirt road dummy so did you get
inspired to do that from playing like zork or another tech space adventure so kind of a weird
story my parents did a lot of like shopping like garage sale flea market that kind of a weird story. My parents did a lot of like shopping and like garage sale, flea market, that kind of thing.
Like that was a common like family outing.
And this one flea market, this guy had the fighting fantasy.
Have you ever heard of these books?
No.
I heard them from you.
Oh, okay.
There you go.
They're basically, and there's an iPhone app for them, by the way, now.
Someone's converted them to like an iPhone app, which is pretty epic.
But it's basically like
400 sections and each section can be from a page to you know even a few lines so um a 400 section
choose your own adventure book like this massive choose your own adventure book and so that's
really what got me started into trying to write my own stories and my own choose your own adventure
books after reading tons of those i bought the whole set of like 36 or something books for like ten dollars
um and so uh that really was started the whole thing and then i moved on to basic
um you're writing different stories and that and then uh from there it just kind of went on to
writing games and uh from games to programming uh you know websites and then
it just kind of one thing led to another yeah i mean i guess that's a point too i did a little bit
you know i guess it was around the same time or a little bit after you know when web browsers were
first picking up and you know not that they were just being invented but um you know i guess just
becoming mainstream as it were but that started
doing you know writing html which i guess we should point out it's a little different than
programming is it's more designing and laying out a page um if you do javascript you get into
programming but doing actual html is slightly different yeah i mean i just there's just so many
some of my best memories are just geeking out to produce
something like really crazy one time i wrote like a little 3d engine in flash just using sprites
and then i made this website where when you went to it based on the time of the day it would show
you like this scene so it was like this there's like trees and like a lake and some rocks and the sun would kind of go
over the scene wow and so if you came in the evening the sun like the wavelength like i just
made the wavelength the function of time or whatever on the light that was being emitted
from the sun so it looked like it was the evening and at night it'd be just pitch black
and it's just just some of the times like you create you can create something just like totally crazy and this was like flash was fairly new action script like i think one or two or
something like that so it's like that's something that like nobody else had ever seen before you
know that's pretty nerdy i'm not gonna lie yeah so a big part of it is just yeah being able to
make something completely crazy and the technology is evolving so rapidly that any of you guys out there can be on the cutting edge and could be, you know, maybe as we talk about Objective-C, can be using Objective-C to make something on the iPhone that nobody's ever seen before.
So let me ask you a question.
Sure. sure uh do you think that it's more important to pick a language that people say are good to know
or good foundation languages uh you know like people would say maybe java or c++ or if you have
some task you want to do um learn the language that does that task which one would you recommend for a beginner um i think honestly it depends on what the task is
so i mean clearly if the task is an iphone app it's going to be objective c but you know if the
task is a website well then maybe you should do that in python or php or if the task is
you know a desktop application then maybe you should try doing that in Java.
So it really sort of depends on what you want to do.
I think that the biggest thing for someone who's just starting out, I would say, is to pick a project.
Once you know what you want to do, then you can use these podcasts
or you can use any of the resources out on the internet to try and find the language that suits your needs.
Because in the end, not to be too blunt, but in the end, your first programs are going to suck.
And they're almost certainly going to misuse the language.
So you might be writing in Python, but in a way that doesn't accurately reflect the strengths of Python.
And this happened to all of us.
I wrote this beat-em-up, kind of like this Double Dragon beat-em-up game MMO that you could play in a Java applet.
And it was terrible.
I used all these different multi-processing libraries that I didn't have to do any of that for and just the whole thing
Was it's at the architecture is a nightmare
But I learned a lot and I think that those lessons can be gained in really any language
So if your project is web-based, you know, if it's a applet use Java or flash
You know if it's a website you can use Python or PHP. If it's the iPhone,
use Objective C, just pick the language that best reflects what you want to do.
Yeah, I'd agree. And, you know, I definitely I think you hit on upon a good point, I wanted to
call it specifically there, which is that you'll mess stuff up. And that'll drive you learning new
parts of the language. So you'll go through some tutorial, and it'll be really boring. Like boring like i don't you know i just want to get started doing my thing and you'll start
doing it and you'll you know for instance you only know how to do while loops and you don't
know how to do four loops yet or something and so you'll it'll be terrible and you'll eventually get
frustrated go there's got to be an easier way and you'll go look i'll be like oh that's it i just do
that and that'll lead you how to learn you know and that's a valid way to do it is, you know, pick something you're trying to do and then learn kind of ad hoc as
you need the skill to do something that you're not able to do with the ones you currently have.
Yeah. And definitely, you know, unless, unless you're doing this with, you know,
a core group of people and you're looking to make a profit or it's your job or something like that.
But if you're doing it as a hobby, definitely reach out to the open source community.
Post your project on Google Code or SourceForge.
Get some people interested, or at least if you don't want to get people interested,
make your project public so people who are interested can contribute.
And that's one way to learn a tremendous amount my first project actually that went that i
that i open sourced was a j iso man this javascript isometric engine and it's completely obsolete now
but at the time it was pretty cool because there wasn't any open gl rendering in java or anything
like that so um i got a lot of help from different people who really taught me how what I was doing was
terrible. And taking their advice made me a much, much better programmer. So definitely reach out
to the community. There's tons of people just like you love to program. And, you know, anytime
you make something public, you're almost guaranteed that somebody's going to look at it.
And definitely stick with it because it is hard. It's and you know i i've seen so many people on the internet do it
and i was here myself but you know they decide i want to make uh i don't know what's the big
uh first person shooter now i don't even know call of duty modern warfare
some dude you come forever okay so you play that game and you're like oh I want to make that
okay well you got to understand you know that takes a team of people in the case of Duke Nukem
forever like decades but uh in the case of another video game like years you know and millions of
dollars to make that and that's not to say you can't make something fun but it's to say that
you got to break that down and start learning what you don't know i mean that's half the battle is you know figuring out what it is that you don't know so that you can go
learn it and it people say i want to jump into making you know an iphone game well that's great
you know and that's a good inspiration and that'll keep you motivated to learn what you need but you
got to start don't think the first thing you're going to make is you know some crazy 3d you know phone game you know
first start with make tic-tac-toe and it sounds stupid but figure out how to do it because it'll
teach you a lot it'll teach you how to interact with the screen it'll teach you how to detect an
end game like the game has ended how to start it over how to have a game loop i mean you'll learn
tons of stuff just writing tic-tac-toe say okay i'm done with that all right right hangman right snake the you know little snake that moves around the screen and eats
apples or whatever and uh doing that will begin to teach you things and each one being more advanced
will will make you learn stuff but kind of go through that because that if you try to skip to
the end you're just going to get frustrated and give up. Yeah, that's definitely true. And I think that, you know, if you go for something huge like that and fail,
you won't really have anything to show for it.
If you want to go for something big, like some big 3D platform
or like Duke Nukem Forever on the iPhone,
you can break it down into modules and make sure that,
this is true whether you're a
novice or an experienced programmer make sure that each piece is measurable you know like start off
with a little ascii art top down thing where you're just running around picking up ammo or something
like you're like a little at sign running around some world of periods like click you know collecting
equal signs you know like start off there and work your way up
to the game and make sure that you're constantly rewarding yourself i feel like the biggest you
know the projects that i that i completely failed on were ones where i didn't have these intermediate
goals were ones where i had this end picture in mind but i didn't have the steps to get there and
i didn't have products to show at each level.
If you can show the at sign,
running around, collecting equals glyphs or whatever,
that's something that somebody else on the internet can say,
you know, this guy, at least he's doing something
and he's on a path forward
and I want to join this project.
And even just to yourself,
you could show your friends and be like,
look, I'm going to step towards making something awesome.
Yeah, and then they may even say, well, that's kind of silly.
This game is boring.
Well, what have you made?
Yeah, that's right.
Or they might give you really important feedback.
They might say, oh, these equal signs are too far away.
Or they look like the two minus signs on top of each other confuse me with the equal sign.
Yeah, that's right and uh you
know you might actually learn some of the gameplay mechanics just from your alaskan art drawing yeah
and i think you can get involved in big projects but i i think you got to get in with other people
because they'll help teach you motivate you show you what needs to be done um and so i know there
are some people who who definitely learn programming by getting involved in open source projects and starting off by, you know, going
through and reading the bugs and, you know, trying to fathom how to commit some of the bug fixes or
even just writing documentation, which forced them to go read the code and think about things
and get involved. And then slowly but surely, they began to understand more and more about
what was going on to the point where they could write their own stuff and that's another way to approach
it uh i think that's probably a little more unusual i i know a few people who have done that
but i think more typical is people kind of starting with small things and building up
yeah because usually you know it has to come from you so So, I mean, if you typically people want to produce something,
that's why they get into, you know, programming and open source stuff. It's sort of like what,
how can open source make me do something awesome? Like, I don't know how 3D programming works,
but here's this open source 3D engine that does a lot of that heavy lifting.
But yeah, I mean, I have seen cases where people have started off just you know i want to
contribute to something and uh start reading documentation getting familiar on how the
technology works so yeah there have been both cases and let's not forget another important
reason to learn to program is like having the ultimate geek credential yeah that's right few
classes of geeks are more geeky than programmers yeah i mean like if you
thought band was cool programming is super cool okay so what is your uh what is your tool of the
bi-week now that we've got everyone kind of jazzed up about programming and uh things like that yeah
um so hopefully we haven't lost some of our more interested viewers
or they've skipped ahead to this point.
But that's okay.
I think we've got to understand there's people of all levels out there
and maybe some people could relate to ours
or at least laugh at us at how silly we sound.
But my tool of the bye week is something I actually just found
called flow diagram or ASCII flow diagram, sorry.
And on the tune of making your own um
first person overhead shooter or i guess that's third person overhead shooter ascii art game that
jason's brainstorming here on the show which i fully expect to see uh by next show because it
sounds pretty awesome uh this uh tool is a web tool that allows you to make flow diagrams in ASCII art.
So you can kind of draw boxes and arrows and lines and, you know,
show the flow of a program or of, I guess,
anything that wants to show data flow or any other kind of flow.
And then, you know, you can copy.
It does it all text-based, ASCII-based, you know, rows and columns.
Then you can copy and paste that into pretty much anything at that point into your code into comments, into like a mailing list post or, you know, just
anywhere it's as opposed to trying to make a picture and draw something fancy and complicated.
And the nice thing about doing ASCII art is it's really easy to edit, right? You just go add
a few more dashes or pipes here or there and change it to how you need.
So I thought that was pretty cool.
There's so many times when the best documentation for something is the source code.
And so, you know, let's say you used a bunch of training data and came up with, like, let's say you're making a breathalyzer, right?
And you came up with a bunch of training data.
You got a bunch of your friends intoxicated and then had them blow. meant people with bad breath so you got people to not brush their teeth oh yeah
so you get people you get people not brush their teeth and then breathe into this breath sensing
device and it spits out a bunch of numbers and you know using the different numbers that spit
out in your friends testing uh you know mouths you develop testing data data and come up with some equations.
You did all this stuff behind the scenes
on your TI calculator or whatever.
Then you came up with the answer.
It's 42.
If you take the output of the breathalyzer
and you multiply it by 42,
you get a 1 or a 0.
Yeah, that's right.
A stinkiness between 1 and 10.
But you did all this work behind the
scenes that nobody knows about they just see times 42 and they don't really know what's that code
doing there it doesn't make any sense so you would love to sort of give them a graph or draw them a
picture or give them a little flow chart of uh you know what you did behind the scenes and just
embed it into the code and uh this that app lets you do that yeah
as i just found it but i think i'll be using that because i've done some stuff like this and i had
to do it on my own that was kind of annoying so this person i'm sure was in the same boat and they
got tired of doing it so i'm just gonna go make a little web app to do that good for them i'm glad
yeah it's awesome so what about you what's your tool of the buy week? My tool of the buy week is actually Javi, which is very similar.
Is that French Java?
That'd be pretty awesome.
Oh,.de, is that German then?
Yeah, so this would be German. It's a German website.
And Javi stands for Java ASCII Versatile Editor.
And as you can see from the website it um it's basically an ms paint
but for ascii art so um you can sort of like use your mouse and draw like cool lines and shapes and
draw bubbles and it lets you um sort of draw different types of uh uh you know borders and
embed your text into those it can also do um image to ascii art so it can you
know yeah you can give it like a jpeg or something and it'll turn into ascii art
and so this is the same kind of thing where like you can wrap a comment block you can
let's say for example you have a bunch of graphs you can export the graphs to like a png from excel or from open office you can import that png
into ascii art using javi and then you can copy paste that ascii art chart into your code i am
totally going to do this to all of my programs at work now yeah i'm just going to get like random
pictures of like logos and of just graphs of of data and paste them into my code.
And people will just be like, this is amazing.
I know.
I've been getting just kind of beat down on my new job on some peer reviews.
Because I don't really have the style completely down.
And maybe what I'll do is I'll take some horrible picture off the internet.
I'll take **** and render it as ASCII art.
And there goes the clean rating.
The clean rating just went pew.
No, but you can have a lot of fun with this,
and you can also be pretty productive with it.
It's actually quite useful for capturing that metadata.
Both of these tools, I think, are fantastic additions to your programming toolbox and they're themed this week
that's right the past couple of weeks we've had we've had a theme i believe good yeah yeah that
one time i still have to buy that thing-o-matic i think that's what it was oh i'm trying to save
up enough paychecks there's a lot of paychecks to save up it's like a grand
right oh no is it i thought it was like 300 or something uh i don't think so yeah i um i have
direct deposit and direct withdrawal so it's like just like all that's left are these tiny increments
oh man the thingamatic is expensive. So we studied this in school.
Money in, less money out means more in your bank account.
Well, that kind of rhymed.
That was awesome.
You got to reduce your expenses and then you can – okay, sorry.
Yeah, it's true. I need to stop buying bikes.
Okay.
So objective C.
That's right objective c now let's just go ahead and address the
3 000 pound elephant gorilla hybrid in the room okay which is the fact that uh objective c is
is all the new rage uh because of basically one slash two devices which are the iphone and now
the ipad so apple apple has kind of a history
which i guess we'll talk about in a few minutes about uh of using objective c and because of the
the increasing popularity of ios devices i guess as they're known and objective c being pretty much
the de facto standard of what you have to program in.
And because of that, they've had this kind of resurgence of popularity that they probably didn't even ever have before.
And so everybody's wanting to learn Objective-C
because it is the enabling technology to be able to use to write the next great Angry Birds.
That's right.
Yeah, so do you know anything about the history of Objective-C?
So the way I understand it is that I guess it was originally written as a pre-processor
for C, similar to which we haven't talked yet about C++. But C++ has a similar background
where originally people were using C and some other languages like Smalltalk started to come out and introduce these object oriented concepts.
And Objective-C was one effort to try to give C object oriented support. instead of writing a whole new language compiler, as it were, they wrote kind of an extension of the language,
which did become a whole new language,
that compiled not to machine code or assembly like we talked about last time,
but C code.
And then you could use your normal existing, in theory,
really good C compilers to generate machine code.
And that was adopted by Steveve jobs small company that he
founded uh when he first left apple which was uh next right yeah and uh so there's a lot of
stuff you'll see um in even the notation for objective c which is like NSObject, NSString, which is for Next Step String, Next Step Object, I believe.
Oh, I didn't know that.
I always wondered why there was all that NS.
I think that's, I'm pretty sure that's what it is.
I just made that up and it sounds really convincing.
So I'll just fact check that.
No, I think it's true.
It makes total sense.
So that's kind of the history.
So what is it kind of, we talked about what it's, you know, popularity today is for, but what was it good for?
What is what is the reason it exists?
Yeah.
So this is sort of a point of contention, right?
Because a lot of people would say the reason why it exists is because it's what you have to write in to program for the iPhone.
But it does have some some some strengths that, some strengths that sort of separate Objective-C
from a lot of other languages. Many of them are sort of more geared on sort of enterprise,
writing safer code, and increasing productivity. So one is that Objective-C is both dynamically
and statically typed. So basically, you know, just to cover that again,
if you do in C, if you do int i equals 3, you can't just say j equals 4, you have to say int j.
That means it's statically typed. So at compile time, you're going in and typing in what the type
is of every variable in the system. This is slow, but it prevents you from
having these unforeseen side effects. I mean, imagine if you had a round function that rounded
a number and someone passed in the word tree. Your round function, it either has to be smart enough
to handle what, you know, to do something when you give it tree, or it's just your whole program is going to crash.
So statically typed language like C is safer in the sense that you know what's coming in
and going out of all of your functions, and so you don't have to handle all these weird
corner cases, and that prevents errors at runtime.
On the contrast, dynamically typed languages like Python, they don't have a type. So
you just say j equals 4, and then your very next line could be j equals apple, and it handles it
just fine. Just behind the scenes, it's going and figuring out what j is at runtime and changing
that. So Objective-C kind of has the best of both worlds because you can do int i equals 3,
and the compiler will know that that's an integer and it should stay an integer.
But you can also use this special term id.
So you could say id i equals 3.
And what that tells the compiler is i can be anything.
Like right now it's 3, but later on it could be Apple. It could be a database, a pointer to a database.
It could be anything.
And so it gives you the strength.
When you need to be flexible, like you're writing a user interface
and someone might be typing in strings or numbers or whatever,
you could be flexible.
And when you are doing some kind of numerical simulation
where everything has to be afloat and you know you have certain expectations
or you're doing something that's mission critical you know you can you can have that have that
security as well that seems kind of powerful and I think that is something that is kind of appealing
it's kind of a nice feature although it seems like it might be confusing and indeed I've had experience where that can get kind
of confusing to have both dynamic and static typing something else that I found interesting
is it so it supports object oriented and it kind of does it in a way that's different than C++
which is why you know both C++ and Objective-C kind of existed and coexist, is the fact that it has a different model for doing, like, the calling of functions with classes and stuff.
And maybe you can explain this a little bit better,
but I guess it's based on messaging as opposed to function calling.
So if you have a class in C++ and you want to say you know this class dot you know foo and pass it
in the number three then you're calling a function of that class you're actually going and invoking
some code that's you know done by a function pointer what it boils down to versus objective
C it's a message passing thing so if you did what's the equivalent syntax and objective c for that
you're not calling a function you're sending a message to that instance of the object that has
hey i want to have a message of kind of type foo with the contents of three and it's up to that
class to figure out how to handle that message right so you know that all happens sort of under
the scenes. On the surface level it is very similar to C++ where you're
calling functions, but yeah under the scenes there is a message passing
interface and so basically what that means is the parameters and
actually the function itself that you want to call get packaged up into this blob
and then sent over to that class.
And so under the hood, what that means is it's sort of what enables the dynamic typing,
is this idea of being able to do message passing.
But anything that we've talked about with respect to object-oriented in the past still holds here.
So, for example
you can have inheritance, you can have polymorphism, you know you could have
going back to my canonical example you know your area interface or I guess a
shape interface with a get area function that's virtual or returns nothing and
then as you implement that shape you can have a square where the area function returns side times shape, you can have a square where the area
function returns side times side, and you can have a triangle where the area function returns,
you know, one half base times height. And at runtime, when you call get area, you might not
even know if it's a triangle or a square because it was created minutes ago, and it's been typecasted
down to a shape. You might have no idea as the programmer
What that is but the compiler and the virtual machine know that it's a that that's a square
Triangle and it does the appropriate thing
Yeah, so but I guess like you pointed out I mean that's not tip that's not really all that applicable to you know
Somebody who's trying to just write in the code.
It's kind of handled under the hood, but it does serve to kind of explain to some of the more advanced listeners,
what is the difference?
Why is Objective-C still around?
And it isn't just used for iOS.
I mean, it's also used on OSX in the Cocoa framework.
Am I saying that right?
Yep, that's right. on OSX and the Coco framework. Am I saying that right? And so they use it there for doing a lot of the programming of apps on OSX.
So I guess applications are just programs as opposed to apps.
I think it's still apps.
Oh,
I think,
I think on my Mac it says the Mac app store,
I think.
Oh,
but anyway,
okay.
Yeah.
I used to always call them apps.
Now apps kind of mean something more specific yeah I used to always call them apps now apps kind of mean
something more specific than I used it for yeah now it seems to be specific to mobile mobile apps
yeah and you know another benefit of Objective-C is it has a really smooth interface so basically
let's say you want to use some C++ like the bullet physics engine in some Objective-C app you're writing.
Now this for one thing I should preface this by saying that this applies loosely in the iPhone
and iOS world but this is mainly for people coding on Mac OS X. You can still do some of this on the
iPhone but some of it is very limited.
And that's mainly an artifact of just the iPhone trying to restrict you from coming up with exploits and things like that.
It's nothing inherent to the design or something.
It's a political decision. But with that said, you can integrate Objective-C and C or C++ very easily.
Now, basically, you create a C or C++ interface in your Objective-C and C or C++ very easily. Now, basically, you create a C or C++ interface in your Objective-C code,
and it just sort of mentions what classes there are,
what functions there are that you can call, and things like that.
And the API is really straightforward.
So if you have, let's say you have this monolithic C or C++ application,
and you want to write an OS X you know GUI for it
that would be very easy in Objective-C because it ties in so well to both of those languages
yeah I did some stuff where I wrote some iPhone apps and it's you know it's kind of hard because
like we were talking about before sometimes the best way to learn programming is with really simple things.
And you kind of have to do a lot before you even get the first program up and running on an iPhone.
I'm sure it's pretty similar on OSX.
Or even just the most basic C program is still probably like 10 or 11 lines of stuff you have to type
versus just a simple one line you know print in python um yeah so that's kind of a a little bit
of a oh man this is scary and you have to write a bunch of lines you kind of don't even know what
they mean initially and the same thing is true in the iphone that there's kind of stuff you have to
do and set up and work with to even you know get something that you can just
draw to or write text to on the iphone um but i kind of having roots in c and you know you know i
maybe i think this would be my advice to people trying to learn objective c programming to do
stuff on on the iphone would be kind of learn c first because it's simpler in a way.
I mean, there's advanced parts to it
that are really complicated,
but you don't have to worry about the iPhone specific parts.
Not only will you be have a lot more resources
to draw on as far as learning C,
you'll have something that's very applicable
to a lot more than just the iPhone.
And then my experience of programming iPhone
was that I was in there,
I would do these kind of things I had to do, this little song and dance to get everything set up the way it needed to be to get the iPhone happy.
And then I would pretty much just write C code.
So, you know, they have all these NS objects you pass around.
And I would just figure out how do I get a pointer to the data, the array.
And then I would just, you know, do regular pointer stuff and C.
And, you know, just do all stuff and see, and, you know,
just do all my old stuff that I knew, have done for years, and I'm very comfortable with. And I
had no problem doing that. And a lot of ways, that could actually ended up being a little bit faster
than doing it the way that kind of they recommend to do it, because it involved less overhead. And
so it worked out well for my application,
at least. Now, I can't say that, you know, universally that'll be the case, but I definitely
didn't feel hampered only having a strong C background and not really knowing what I was
doing in Objective-C. I was still very much able to write a fully functioning iPhone app that did
everything I needed to do and, you know, was well received. Yeah, I actually went through something similar
where I, I made a little board game. I guess a board computer game. I don't know. I made a board
game, but you know, not having the facilities to print large amounts of stock paper, I created an
emulated version on the computer. I wanted it to run on the iPhone. And so I was taking this
program that is actually written in Python, and converting it over to on the iPhone. And so I was taking this program that was actually written in Python and converting it over to Objective-C.
And it converted over pretty well.
So I think that, yeah, definitely, I think that I wouldn't pick Objective-C as my first language to learn either.
I would pick a simpler language like C or like Python.
Something very much like text-based i think is kind of key
there as silly as that sounds yeah i mean i think that when i read objective c and i don't know if
it's because i started in c but everything seems a little backwards you know like it seems like i
think things are out of order um in certain areas of it maybe the way that there's the things are
nested but i always feel like i'm reading things backwards i think what it. Maybe the way that the things are nested.
But I always feel like I'm reading things backwards.
I think what it is, is how you put the brackets,
and then you put the object and the function name inside the brackets, as opposed to object parentheses or function name parentheses.
Yeah, so that is a little bit getting used to.
But one thing that should be mentioned is that the Xcode,
which is the editor IDE
you'll almost certainly be using
if you're doing iPhone development,
has a really nice slick UI
for creating the UI for your app.
So kind of like how Microsoft MFC used to be,
although MFC is the devil, but that's another story.
They have this nice, Mac, actually, Apple did a great job.
They have this resource builder where you can go in, drag buttons, kind of get an idea, mock up how your app is going to look.
And then you can double click on the buttons to create little stub functions and
things like that so you know like patrick said if you get a foundation in c or python or any other
procedural language java you could take that to objective c and be able to do whatever you need
to do on the iphone there yeah i i'd agree with that and i mean if if you really want to make an
iphone app and that's really what motivates you,
by all means, please go ahead and learn Objective-C.
And there's becoming more and more resources out there to do it.
And the stuff you learn there will,
just like we're saying other stuff will apply to that,
what you learn in Objective-C will apply to other things.
For sure.
So that's what motivates you.
I think it's just a word of caution to be careful to not get overwhelmed by you know the kind of graphical nature of this ios device versus you
know kind of just starting with simple text-based stuff yeah that's true definitely because graphics
does add it's fun because it's really enjoyable to be able to see you know kind of animations and
visually what's going on that's a really fun thing to do
but it does add a whole layer of complexity that is it's hard especially for a beginner to figure
out exactly what's going on and all you have to do yeah maybe we'll take a little bit of time here
and talk about asynchronous because a lot of anything you're going to do with the user interface
and if you're doing stuff on the iphone or the um you know osx or the ip anything you're going to do with the user interface, and if you're doing stuff on the iPhone or the OSX or the iPad, you're almost certainly going to have to deal with the user interface.
As Patrick said, you're not really going to be writing console apps for the iPhone.
Before we do that, let me interject quickly that we've been talking about OSX and about the iPhone, but GCC actually does support Objective-C as well.
And so you can write text-based command line programs that way.
I don't really know of a lot of people doing that.
The only people I know writing Objective-C
are doing it for OSX or Cocoa or iOS.
But there are a couple,
also the LLVM CLang compiler will do objective c so you do have
options on other platforms for doing that but it's mostly supported by apple and their products so
that's where you're going to find i would dare to even say probably 99 of objective c development
yeah for sure okay sorry so asynchronous so asynchronicity is something you have to worry about whenever you have a user interface.
And basically, you might have wondered this.
You know, I write this program, and somewhere along the line, it has a set of instructions.
And then when that instruction finishes, my program ends.
So, how can I write something like a user interface where it's kind of waiting on the user?
So, you might think of, well, I'll just do kind of like
a while true around my entire program.
And this while true will just continue to loop
and sort of wait for the user to do something.
And when the user does something,
then there'll be some kind of action.
And this is basically the heart of asynchronous programming.
So what's going on here is basically you have sort of a while true, so you have some
loop that's constantly running, but then within that loop it sort of asks a series of questions.
And so these questions are getting asked, you know, hundreds, maybe thousands of times a second,
maybe even more than that. So the questions might be, you know, has the user clicked on a button?
Has the user moved the mouse? Has the user done anything? Maybe there's an idle function, you know, has the user clicked on a button? Has the user moved the mouse? Has the user
done anything? Maybe there's an idle function, you know, has a second of time gone by?
There's just a series of questions. Now all this is going on behind the scenes. You don't see any
of this code. But if the user has, let's say, moved the mouse, then look for any, you know,
mouse moved functions in the code. And by look for it, what I mean is actually you tell the
operating system, or in this case, you tell the application layer.
Called registering. Yep. So you might have some function where
every time the user moves the mouse, it draws like a cute mouse trail
or something like that. In that case, you're
going to register this mouse moved function that case you're going to register this mouse
moved function and you're going to bind a mouse moved callback to one of your
functions. So when the mouse is moved then I'm going to you know
add these little mouse trail pointer these little graphics. So writing
asynchronous code if you look at the code
what you'll see is some main function that just creates all these callbacks it just instantiates
all these callbacks like you might have like main and then you know bind mouse move to
my trail function bind user clicked on this button to my submit function all these binds and then just a go
and what's going on behind the scenes when you call that go is there's just a loop and it's just
going through and waiting for the user to do something and then reacting to it so this is
something that as as programmers you know if you're used to writing sort of recipe kind of programs like C or C++, asynchronous programming can seem very scary.
But it's something that you just kind of got to get familiar with.
And once you start doing it, you'll quickly get the hang of it.
The other thing that's confusing there that is worth pointing out is that if you kind of think about asynchronous you know just means not everything being synchronized
and in lock step so if you read a normal c program it's everything is operates one after the other
and you can follow a line of execution straight through your program or if you've got a loop you
know you can follow it through each cycle of the loop and then to the end of the program
or whatever it means but it's kind of everything one right after the other when asynchronous comes in you don't know which parts of your code are going to operate in which
order which is because you bind these functions to certain events and you don't know which one
might get called before another and they can be called while you're off doing something else and
so that introduces a kind of confusing thing to your code where you can't just read it like a book
and the other thing is that you have to be careful because what happens is is there's a thread of
execution that is you know responsible for drawing all the stuff on your screen and so somebody
clicks a button and in that button event handler you try to do some complex math like you try to
solve the meaning of the universe.
What's going to happen is during that time,
the user is going to not be able to get a response out of your GUI.
The buttons won't highlight when you move over them.
They won't be able to resize a window.
And if you've ever seen this happen in a program,
that's typically what the problem is.
Something's gotten stuck somewhere doing a bunch of processing.
It wasn't supposed to do in that thread,
and now you're not getting a response out of the GUI.
So the right way to handle that is in the message, well, handle it in the handler,
is to push that work to another thread or to some other something that's going to do that processing that's going to take longer
so that that function can return and the GUI can continue
to be updated so that the user maintains responsiveness right so one thing I probably
should mention you know in addition to in that while loop that I talked about before where it's
checking to see did the user click a button did the user move the mouse etc there's also uh what
Patrick alluded to I draw the screen and and as he's saying, if you interrupt that while loop,
if you halt that while loop by solving the meaning of the universe,
it can't get to that draw the screen, draw the screen.
The user moved the mouse, draw the screen, draw the new mouse.
It can't do any of that.
And so a lot of asynchronous programs will,
if you have a threading library, they'll say,
okay, you clicked on this button to
submit your information to the website while I'm contacting the website and
submitting the information etc let's push that off onto a separate thread so
that this main thread can continue running or let's break this up into
pieces so if you click on you know Graph, and it's going to take all this data that you've put into
your phone, it's kind of like Excel.
It's going to fit a curve to your data and display it on screen for you to do whatever
with.
It might break that up into pieces, and it might say, draw the curve, and then the next
time it goes through the loop, find some data. The next time it goes through the loop, fit the data to the curve, and then the next time it goes through the loop, find some data.
The next time it goes through the loop, fit the data to the curve.
And so every time you're going through the loop, you're checking,
did the user move the mouse, you're drawing the screen,
and then you're doing just a little bit of work.
And so the GUI is actually being halted, but by such a tiny amount that nobody can notice.
So these are often the core features you see in asynchronous programming. But GUI code is definitely more confusing to read than
normal synchronous code. Yeah. Because of these facts. Right. And internet code is
even harder because you typically have hundreds maybe thousands of users all
using the same thing at the same time.
Yeah, which will lead to maybe some stuff we'll talk about in the future,
some interesting new directions people are going in web servers
and how to handle large numbers of users from one program.
Yeah, definitely.
We should definitely get into some more Internet topics in the future.
Yeah, those are very applicable, and I think a lot of people are out there doing that and uh you know
we should be careful that you know when talking about learning to program which i guess we kind
of got off of when we were on objective c but that you know a lot of people will kind of uh
fuss at you about your choice oh i can't believe you learned basic or i can't believe
you learned php that's not a
real programming language uh sometimes i find that those people tend to be the people that don't know
what they're doing and so they're just saying that because they're ignorant and they're threatened or
you know whatever it is it's kind of like the people that make fun of you in school you know
remember those people it typically because they had some sort of
huge flaw themselves and they were trying to cover it up by making fun of everybody else
uh yeah i mean so never be embarrassed by your choice it's so interesting how you know often
like you're saying the people who are the most despondent are the people who it's typically that
they just don't they cannot see the benefit of whatever they're you know making fun of but
the fact is that all these languages that we've talked about until now and likely all the ones
we're going to talk about unless we really start running out of languages are are very popular and
they have an incredible amount of utility so um it's all about picking the right tool for the
right job that's right and if you're
writing ios programs that's objective c that's definitely the right tool for sure so we talked
about a lot of the strengths but maybe we should cover some of the weaknesses of objective c we
kind of been hinting around the first one that i have which is that outside of these uses nobody really uses objective c for anything in fact um if i if i
understand correctly apple kind of released the second version of objective c language or the c
compile objective c compiler or however you want to phrase it kind of the upgrade and that's not
even supported by anybody else like gccive-C don't support those language features because there's just not enough people interested in using this outside of the OSX iOS environment.
Yeah, that's right.
Yeah, the low user base is by far the biggest weakness.
And, you know, now I think that some people have figured out ways to write, you know,
apps for the iPhonehone without using objective
c i've seen uh this corona sdk it's a development kit for the iphone where you can write in i think
c++ and i don't know what they're doing behind the scenes yeah i thought there was something
i i i'm not that fresh on i wasn't prepared for that topic but um i know there was a while where they had
something in the license agreement that basically said you had to write an objective c with apple's
you know deemed appropriate development environments and you weren't allowed to
write anything else and i think people kind of fussed and i think they backed off of it a little
but i think in general that's still their stance is that you're supposed to always run Objective-C
or write in Objective-C.
Yeah, yeah, I think that, you know,
it's still 99% of the code on the iPhone,
I would say, is Objective-C.
But yeah, there are ways.
I think Boo is a dialect of Python,
which can be used on the iPhone in some capacity.
But yeah, I mean, in the end,
if you're writing for the iPhone,
really the best advice is to just suck it up
and learn Objective-C.
We did for writing our iPhone apps.
One of the other weaknesses I would say about Objective-C
is that it's just the syntax is,
I feel like it's very verbose and complicated.
But maybe that's because we're colored by being C++ programmers first.
Well, I feel like that, but I feel like objectively what I can say is that, you know, going back to the strengths of Objective-C,
being, you know, dynamically and statically typed,
having the, oh, one thing we didn't really talk about was the different property directives.
It's very easy to create properties in Objective-C.
But just being able to get that power
and the reference counting, things like that,
comes at the cost of the syntax, I feel.
I feel like i could be
objective and say that a language like c which doesn't have all the bells and whistles um you
know has a much simpler to read syntax but you know again a lot of that is because whoa whoa
hang on hang on hang on i don't know if we can let that fly c has a simple syntax
well have you seen some of the c code I've seen? Oh, yeah.
C code could be terrible. I guess any code
could be. But maybe this is a more
fair statement.
If you're writing for the iPhone, you will
almost certainly be doing asynchronous
programming. And so
there aren't really
any canonical hello world.
There isn't a
large code base of command line,
straightforward code
written in Objective-C
for you to get your feet wet.
So chances are,
if you're going to learn the language,
you're going to take on
an asynchronous iPhone app
with many different function calls
going all over the place.
And I think that's enough
to make any language complicated.
Okay.
Yeah, I mean, I'm giving you a hard time i agree that the language in my opinion has a lot of characters that you
don't really need yeah and you know this is really endemic to a lot of these sort of uh these sort of
uis i mean remember mfc and what a disaster that was? Like, it was like application
layer, integer pointer, like all of those words strung together just to like to name a variable
for a freaking button on a UI. And so MFC had this problem. You know, Java, even Java has this
problem, like new file reader, and then inside of that new buffered reader new io
reader so anytime you start dealing with um you know gui user experience kind of things it's going
to become very verbose and so i think it's just um the fact that objective c is only used for those
kind of applications okay that means that you're going to be yeah reading a lot of complicated code i'll agree to agree with that
this isn't much of a you know our our podcast is programming throwdown
we you know i kind of thought maybe we'd throw it down with each other a little more but
it hasn't really turned out that way yeah well i think that you know every now and then we kind
of grill each other i think that we should pick a language that has much contention.
Maybe we'll do C++ next time,
one where at least I'm very opinionated.
I don't know about you.
I can take whatever opinion that is opposite of yours.
Bring it on.
You are definitely wrong.
No.
We'll just have a crying match.
Well, to close this up, since we're drifting a little,
I want to thank all of our listeners.
Thank you for those who have written us some emails
and written us some good reviews in iTunes.
Continue to do that, please.
That helps us feel appreciated for doing this work.
And we enjoy doing it, but it helps to know that it's
worth it because people are out there listening to it and uh it helps us get even more listeners
because it rises us in the rank so other people can see us so i encourage you please not it's nice
to click click the five star review and four stars reviews please five stars and uh but it's it's even
nicer if you can write a little message and tell us what you like about it
and then if you have something you don't like so much
just write the good things in the review and then send us an email
or post it on the blog, your comments and critiques
so we can try to make things better
and feel free to post on those
we do on our website programmingthrowdown.blogspot.com
you'll find show notes, links to some of the
stuff we talked about, kind of a little bit of a recap of our discussion in case you can't
remember something later.
If you have terrible memory, like at least I do.
Yeah, same here.
Okay, and Jason too.
And, you know, also a link to the podcast if you want to download it.
It looks like most people download through iTunes, but if you want to listen to it on your computer
or download it for another device,
you can find that on the website.
Yeah, and I mean, a shout out to Weston
for coming up with both of the ideas for the show
for why we decided to start programming
and for Objective-C.
So definitely, if you have any comments or suggestions,
we do have our ears open.
And that was a particularly good one.
Yeah, can't promise that we'll implement what you say or do it.
But we'll definitely read it.
We'll definitely listen to it.
And we'll probably give you a shout out on the show.
Yeah, so I think that about wraps it up.
All right.
Well, until next time.
Have a good one, guys.
Take care.
The intro music is Axo by Binar Pilot. alright well till next time have a good one guys take care