We're reusing the stuff we built for the Try iOS course we came out with late last year. I've looked into Emscripten for this and from what I saw it really wouldn't work with this course, although maybe I missed something?
You could always boot the VM with an image that contains the compiler and run there. If it truly does boot faster than the results take otherwise then you could move it all into javascript that way, and not have to worry as much about the infrastructure around it.
Very cute. I did the first 9 challenges. I am rather worried though that you're teaching people that `NSLog(var)` is acceptable, because it's a horribly dangerous thing to do if var contains untrusted input.
Put that in your [Project]-Prefix.pch file to make it available globally. Aside from letting you log without fear, it gives you better performance in production, and you can get extra context for your output.
Yup, I agree with you, but I wanted to introduce referencing a variable before introducing formatted strings and placeholders. We actually went back and forth on this a couple times.
If the variable's value contains any format args, e.g. %s, then NSLog (or printf, or whatever string formatting function you're using) will look for another argument, which you didn't actually pass, so it starts looking at garbage stack values.
Besides causing incorrect output, this may crash your program, or potentially be a vector for an exploit.
"In particular, the varargs mechanism allows functions to accept any number of arguments (e.g. printf) by "popping" as many arguments off the call stack as they wish, trusting the early arguments to indicate how many additional arguments are to be popped, and of what types."
NSLog is similar; it has to trust its first argument to be consistent with the number and types of arguments actually passed to it.
If you call NSLog(x), but do not have complete control over the value of x, you cannot guarantee that.
Sorry for the slow response times on the challenge submissions everyone. We only have so many Mac Minis running these things . We are looking into ways to speed it up
You could also roll your own in a very few lines of code. Maybe even have the output of the program, not the compiled code, be the content of the hashed file, assuming you aren't reading STDIN or anything like that from the user.
That's a really cool project! Definitely going to look into it for some of our more complicated courses, but for this course compilation is usually under a half-second so it's not the compilation that's slow (it's the way we are tearing down an entire VM after every submission, we are working on changing that now)
Ah. Maybe consider a FreeBSD jail with a union mounted filesystem if you can get away with using a non-Apple (GNUstep/GCC?) toolchain. The teardown on a jail is as fast as the chroot syscall. ;-)
Just one nitpick for an excellent comment. GNUstep/Clang would be the only way to get support for array, dictionary and number literals, as well as ARC.
GNUstep/GCC is possible, but you lose support for all of the above, blocks, and several other recent additions to the Objective-C language.
Looks like those Mac Minis are getting smoked right now, poor little guys. I can't load the page unfortunately to see myself, but could you use GNUStep to compile the examples on any flavour of box?
I know I feel so bad for them. We are working on some temporary fixes (including caching which as we all know is really easy to do) and changing the way we isolate the code submissions so we can get more throughput. GNUStep might be an interesting long term fix.
In challenge # 22 in level 4, I am getting an error :‘extern’ variable has an initializer;
I have tried the running the show answer solution but to no avail.
I have to work on porting an iPad app to Java from a guy that didn't bother to use comments or any documentation and his idea of versioning system are a bunch of folders 1,2,3 for different components whose numbers dont always match up.
I'm afraid I've been scared off Obj-C for life now.
> What does this have to do with the Objective-C language itself?
Nothing except they had a bad experience using the language. It's like that time you ate a bunch of meatloaf right before coming down with the flu. It wasn't the meatloaf, but you still might never eat it again...
nothing at all. but it scared me off. like in highschool i had this german teacher who scared me off german because she was a massive bitch. not the language's fault, but i hate german now.
I really like this, but I'll have to give it another try in a few hours after work when the HN rush subsides and gives the server some time to breathe/compile the challenges.
Only one complaint from me: error messages. I realize this is probably a complicated problem, but on the other hand, can alienate beginners.
For example, on the first exercise, you're asked to write NSLog(@"Name"); When I did it, I first missed the semicolon, and got an error "expected ‘;’ after expression". Okay, fine and good, that makes sense. I added the semicolon and got "‘extern’ variable has an initializer" because I called NSLOG instead of NSLog. Even for a programmer, that's not a helpful error message...
Thanks for the examples, and I agree that error messages are super-important for beginners. We have written a bunch of code trying to "massage" error messages to be more helpful. I'll be adding these to the list, thanks!
Very interesting. I started with Try iOS but getting an actual app together in Xcode proved more difficult than I thought, partly because Obj-C still felt so weird after only learning Java/C# during university.
I ended up buying the Big Nerd Ranch book (it's great!) on iOS programming, which also covered Objective C in more detail.
We see green across the board for all 3 git courses, if you're personally having problems with one of them you should head on over to http://codeschool.com/support and drop them a ticket. :)
I'm actually working on extracting all the content for just a plain HTML version so people who don't want to do all the challenges will have something to read (it's almost a books length of content)
I still fail to see the appeal of learning a language with such extremely limited value (only works, has tools and adaptation on a certain lawsuit-happy gadget-vendor's OS).
Anyone? And what about principles? What about giving back to the community? Shouldn't hackers hacking away on the next big thing be using open technologies as open technologies was what enabled them to get hacking in the first place?
Politically I agree, but Objective-C is a better language than C++ or Java, and Cocoa is a better framework than the STL or the Java core libraries. That's before we get to the GUI experience. Learning it will make you a better programmer.
Since I became a convert to the "put your own VM in the frameworks and add a cute language for your core logic" kind of school of thought, I seriously cannot see the value in Obj-C and the Android/Java thing. I've been writing code in these environments for decades: I'm now seriously addicted to Lua.
2 years of Lua work, and I absolutely cringe with the idea of having to go back to Java/Obj-C/C++, in any context other than to push a bridge across the VM gap to some framework.
Its a smaller language, its lighter. It performs quite well, and can be put almost anywhere there is a lib.so file (so: everywhere). Choose what you want to link with, extend the external API's with Lua, and leave the whole problem of obscure languages for the young 'uns..
So, its not so much about my desire to pimp Lua, but my point is this: You can choose whatever language you want, actually, to develop a core host environment with, but use a very simple, sweet language for the majority of the work.
Fabrice Bellard's browser-based Linux boots in less time than this prints out "Hello, world!"