Live data from Hacker News

Try Objective-C

tryobjectivec.codeschool.com

41–50 of 68 posts

Re: Try Objective-C

#41
post #38

Earlier quoted context omitted.

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. ;-) Or even better, use ZFS snapshots as your sandbox. Copy on write kicks butt. See: http://vocalbit.com/article/402/freebsd-jails-using-zfs-and-...

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.

Re: Try Objective-C

#42
post #34

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.

A good solution to this is to use always use a debug-mode dependent macro for logging[1]:

#ifdef DEBUG

#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt),__PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)

#else

# define DLog(...)

#endif

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.

1: http://stackoverflow.com/questions/969130/how-to-print-out-t...

Re: Try Objective-C

#44
post #7

Very nice presentation, but it seems like this could benefit from an Emscriptened browser-based Objective-C compiler. Fabrice Bellard's browser-based Linux boots in less time than this prints out "Hello, world!"

Wow, this is totally awesome. This is my first time hearing about emscripten and I've been a Cocoa and JS programmer for about 9 years.

What are some of the coolest applications of emscripten?

Re: Try Objective-C

#45
post #7

Very nice presentation, but it seems like this could benefit from an Emscriptened browser-based Objective-C compiler. Fabrice Bellard's browser-based Linux boots in less time than this prints out "Hello, world!"

Wow, this is totally awesome. This is my first time hearing about emscripten and I've been a Cocoa and JS programmer for about 9 years. What are some of the coolest applications of emscripten?

PDF.js is used by Firefox to render PDFs in the browser.

Re: Try Objective-C

#46
post #36
post #34

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.

Huh? How so?

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.

Re: Try Objective-C

#47
post #34

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.

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.

Re: Try Objective-C

#48
post #41
post #38

Earlier quoted context omitted.

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. ;-) Or even better, use ZFS snapshots as your sandbox. Copy on write kicks butt. See: http://vocalbit.com/article/402/freebsd-jails-using-zfs-and-...

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.

Very true. We really leaned heavily on the new literals and ARC in this course.

Re: Try Objective-C

#49

Earlier quoted context omitted.

Wow, this is totally awesome. This is my first time hearing about emscripten and I've been a Cocoa and JS programmer for about 9 years. What are some of the coolest applications of emscripten?

PDF.js is used by Firefox to render PDFs in the browser.

PDF.js doesn't use emscripten, as far as I can tell.

For a recent example of emscripten, try this one from yesterday: https://news.ycombinator.com/item?id=5673356

Re: Try Objective-C

#50
post #46
post #36

Earlier quoted context omitted.

Huh? How so?

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.

Is there any reason NSLog doesn't filter input to escape these format args?
Post reply on HN