{"id":622,"date":"2010-06-14T01:11:04","date_gmt":"2010-06-14T06:11:04","guid":{"rendered":"http:\/\/vgable.com\/blog\/?p=622"},"modified":"2010-06-14T01:50:21","modified_gmt":"2010-06-14T06:50:21","slug":"ask-f-script","status":"publish","type":"post","link":"https:\/\/vgable.com\/blog\/2010\/06\/14\/ask-f-script\/","title":{"rendered":"Ask F-Script!"},"content":{"rendered":"<p><a href=\"http:\/\/www.fscript.org\/\">F-Script<\/a> is an amazingly useful tool for answering quick API<br \/>\nquestions, like &#8220;What happens if I pass in <code>nil<\/code>&#8220;. I use it several times a week. For verifying corner-cases, F-Script is faster than google, stackoverflow, or reading header files. Just type in a questionable expression and <em>instantly<\/em> see what happens.<\/p>\n<p>There&#8217;s a <a href=\"http:\/\/www.fscript.org\/documentation\/LearnFScriptIn20Minutes\/index.htm\">good tutorial<\/a> to get you started quickly. I&#8217;m not going to reproduce it here, so if any of these examples aren&#8217;t clear, <a href=\"http:\/\/www.fscript.org\/documentation\/LearnFScriptIn20Minutes\/index.htm\">go read it<\/a>.<\/p>\n<h3>Example: <code>NSMutableArray<\/code><\/h3>\n<p>Objective-C had historically poor support for exceptions, and the Foundation\/Cocoa libraries are pretty inconsistent about using them. For example, trying to add <code>nil<\/code> to an array throws an exception, but trying to remove <code>nil<\/code> from an array has no effect. Here&#8217;s how I used F-Script to verify that,<\/p>\n<pre>\n> a := NSMutableArray array\n\n> a <span style=\"color:white;background-color:black;\">addObject:nil<\/span>\nNSInvalidArgumentException: *** -[NSCFArray insertObject:atIndex:]: attempt to insert nil\n\n> a addObject:'foo'\n\n> a\nNSCFArray {'foo'}\n\n> a removeObject:nil\n\n> a\nNSCFArray {'foo'}\n<\/pre>\n<p>If you&#8217;re not impressed, I understand. Static text really can&#8217;t convey the power of an interactive console. Sure, the F-Script syntax is marginally more concise than writing the equivalent code in Objective-C, but not enough that it matters. What matters is the interactivity, <em>I got my answer as soon as I hit return<\/em>. No <a href=\"http:\/\/xkcd.com\/303\/\">waiting on the compiler<\/a>. No switching between the program and Xcode. Immediate feedback.<\/p>\n<p>You might prefer to <a href=\"http:\/\/www.mikeash.com\/pyblog\/friday-qa-2009-11-20-probing-cocoa-with-pyobjc.html\">use python<\/a> as a Cocoa console. That&#8217;s cool! I prefer F-Script because it&#8217;s closer to Objective-C, but any tool with a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Read-eval-print_loop\">REPL<\/a> console works. If you have a favorite, please <strong>leave a comment<\/strong>!<\/p>\n<p>REPL consoles for exploring Objective-C on a Mac:<\/p>\n<ul>\n<li><a href=\"http:\/\/www.fscript.org\/\">F-Script<\/a><\/li>\n<li><a href=\"http:\/\/www.macruby.org\/\">MacRuby<\/a><\/li>\n<li><a href=\"http:\/\/www.mikeash.com\/pyblog\/friday-qa-2009-11-20-probing-cocoa-with-pyobjc.html\"> python<\/a><\/li>\n<ul>\n","protected":false},"excerpt":{"rendered":"<p>F-Script is an amazingly useful tool for answering quick API questions, like &#8220;What happens if I pass in nil&#8220;. I use it several times a week. For verifying corner-cases, F-Script is faster than google, stackoverflow, or reading header files. Just type in a questionable expression and instantly see what happens. There&#8217;s a good tutorial to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,203,3,5,4],"tags":[86,591,588,593,486,592,487],"class_list":["post-622","post","type-post","status-publish","format-standard","hentry","category-cocoa","category-iphone","category-macosx","category-objective-c","category-programming","tag-command-line","tag-f-script","tag-ios","tag-macruby","tag-python","tag-repl","tag-ruby"],"_links":{"self":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/622","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/comments?post=622"}],"version-history":[{"count":3,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/622\/revisions"}],"predecessor-version":[{"id":625,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/posts\/622\/revisions\/625"}],"wp:attachment":[{"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/media?parent=622"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/categories?post=622"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/vgable.com\/blog\/wp-json\/wp\/v2\/tags?post=622"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}