<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">

<channel>
	<title>FreshBooks API Blog</title>
	
	<link>http://developers.freshbooks.com/blog</link>
	<description>Unleash your data. Build on the platform.</description>
	<pubDate>Mon, 17 Nov 2008 17:44:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/APIBlog" type="application/rss+xml" /><item>
		<title>Dan is on the scene</title>
		<link>http://developers.freshbooks.com/blog/2008/10/20/dan-is-on-the-scene/</link>
		<comments>http://developers.freshbooks.com/blog/2008/10/20/dan-is-on-the-scene/#comments</comments>
		<pubDate>Mon, 20 Oct 2008 14:55:57 +0000</pubDate>
		<dc:creator>danw</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/?p=77</guid>
		<description><![CDATA[
Hello there Developers.  My names Dan.  I&#8217;m new developer on the API team! I&#8217;ve been lurking in the shadows, answering your support questions, getting up to speed on the back-end here at FreshBooks.
Now that the training wheels are off I&#8217;m going to be roaming around the API with Mike.  Keep your eyes peeled for fresh [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Dan Williams" src="http://www.freshbooks.com/images/team/danw.jpg" alt="" width="145" height="165" align="right" /></p>
<p>Hello there Developers.  My names <a title="View Dan's profile on the FreshBooks website" href="http://www.freshbooks.com/our-team.php#danw">Dan</a>.  I&#8217;m new developer on the API team! I&#8217;ve been lurking in the shadows, answering your <a title="Offering Support for Free" href="http://www.freshbooks.com/blog/2008/09/17/on-offering-support-for-free/">support</a> questions, getting up to speed on the back-end here at FreshBooks.</p>
<p>Now that the training wheels are off I&#8217;m going to be roaming around the API with Mike.  Keep your eyes peeled for fresh new integrations and additions to the API. We&#8217;ll be tackling things that are brought to our attention here on the blog as well as over at the <a title="FreshBooks - Developer Community" href="http://forum.freshbooks.com/viewforum.php?id=19">developer community</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/10/20/dan-is-on-the-scene/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Object URI and You</title>
		<link>http://developers.freshbooks.com/blog/2008/09/26/object-uri-and-you/</link>
		<comments>http://developers.freshbooks.com/blog/2008/09/26/object-uri-and-you/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 15:25:18 +0000</pubDate>
		<dc:creator>gauthier</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/?p=69</guid>
		<description><![CDATA[Good day, eh.  There&#8217;s been a small update to the API that some of you might already have noticed.  We added an &#60;auth_url /&#62; element, in the style our existing &#60;url /&#62; tag, for invoices, estimates and clients.
The new &#60;auth_url /&#62; requires an authorized session to work, and is intended to provide an administrative link [...]]]></description>
			<content:encoded><![CDATA[<p>Good day, eh.  There&#8217;s been a small update to the API that some of you might already have noticed.  We added an &lt;auth_url /&gt; element, in the style our existing &lt;url /&gt; tag, for invoices, estimates and clients.</p>
<p>The new &lt;auth_url /&gt; requires an authorized session to work, and is intended to provide an administrative link to your target object.  Since we didn&#8217;t have a client &lt;url /&gt; element in the client.get response, we&#8217;ve included that for consistency.</p>
<p>&lt;auth_url /&gt; will honour an existing administrative session, if you have already logged into the application in some way. It will NOT auto-magically direct you to a secure administrative page without prompting you for user and password if you haven&#8217;t already logged in.  So don&#8217;t get&#8217;em mixed.  &lt;url /&gt; is for client links, &lt;auth_url /&gt; is for you.</p>
<p>Summary:</p>
<ul>
<li>client.get:
<ul>
<li>&lt;url /&gt; added to response</li>
<li>&lt;auth_url /&gt; added to response</li>
</ul>
</li>
<li>estimate.get:
<ul>
<li>&lt;auth_url /&gt; added to response</li>
</ul>
</li>
<li>invoice.get:
<ul>
<li>&lt;auth_url /&gt; added to response</li>
</ul>
</li>
</ul>
<p>Our API documentation has been updated to include this element where necessary.</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/09/26/object-uri-and-you/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introducing Mike</title>
		<link>http://developers.freshbooks.com/blog/2008/09/25/introducing-mike/</link>
		<comments>http://developers.freshbooks.com/blog/2008/09/25/introducing-mike/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 15:58:11 +0000</pubDate>
		<dc:creator>gauthier</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/?p=58</guid>
		<description><![CDATA[ Allo Freshies!  My name is Mike (no, not McDerment), and I&#8217;ll be one of your API developers.  I say &#8220;one of your API developers&#8221; as we have a whole team now (there are two of us).  So be prepared for updates big and small.
Since I&#8217;m the second Mike in the office, I&#8217;ve been barraged [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.freshbooks.com/images/mikeg.jpg" alt="Mike Gauthier" align="right"> Allo Freshies!  My name is <a href="http://www.freshbooks.com/team/mikeg">Mike</a> (no, not <a href="http://www.freshbooks.com/team/mike">McDerment</a>), and I&#8217;ll be one of your API developers.  I say &#8220;one of your API developers&#8221; as we have a whole team now (there are two of us).  So be prepared for updates big and small.</p>
<p>Since I&#8217;m the second Mike in the office, I&#8217;ve been barraged with nicknames since I joined up.  Because my last name is Gauthier, there are a few variations I will respond to.  Mikey G or MG would work.  G-man?  Michael?  Embarrassing.  But since Mike McDerment doesn&#8217;t really post on the Developers blog, I can hope and dream of being just &#8216;Mike&#8217; again.  We can keep that between us.</p>
<p>From here on in, we intend to post more frequently than we have.  Our last blog post was in June, and that&#8217;s just not cool.  Also, please feel free to get in touch with us via the <a href="http://forum.freshbooks.com/viewforum.php?id=19">developer forum</a>.  My teammate <a href="http://www.freshbooks.com/team/danw">Dan</a> (introduction forthcoming) and I will be actively monitoring our community and addressing developments and concerns both here and there.</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/09/25/introducing-mike/feed/</wfw:commentRss>
		</item>
		<item>
		<title>More apps using the API!</title>
		<link>http://developers.freshbooks.com/blog/2008/06/23/more-apps-using-the-api/</link>
		<comments>http://developers.freshbooks.com/blog/2008/06/23/more-apps-using-the-api/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 21:02:45 +0000</pubDate>
		<dc:creator>Taavi Burns</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/?p=45</guid>
		<description><![CDATA[We now have several new apps that interact with FreshBooks.  It&#8217;s great to see this kind of work starting to happen!

Andrew finally had enough of seeing people enjoy the OSX widget and wrote a time-tracking gadget for the Vista Sidebar based off of the OSX widget!  Not only does our widget provide a [...]]]></description>
			<content:encoded><![CDATA[<p>We now have several new apps that interact with FreshBooks.  It&#8217;s great to see this kind of work starting to happen!</p>
<ul>
<li style="clear:both">Andrew finally had enough of seeing people enjoy the <a href="http://www.freshbooks.com/widgets/mac-osx-timer-tracker-widget/">OSX widget</a> and wrote a <a href="http://www.andrewflusche.com/freshbooks-vista-sidebar-gadget/">time-tracking gadget for the Vista Sidebar</a> based off of the OSX widget!  Not only does our widget provide a place for others to start, but we&#8217;re also going to help Andrew make it look pretty. <img src='http://developers.freshbooks.com/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> </li>
<li><img src="http://developers.freshbooks.com/wp-content/uploads/2008/06/getfreshlogo-150x150.png" alt="GetFresh Logo"width="150" height="150" style="float:right" />Joel has written <a href="http://www.getappy.com/">GetFresh</a>, a new way for your clients to log into their FreshBooks accounts in order to pay you faster.  For a small fee, you can download and configure the app, then send it to your customers.  They can fill in their username and password, and with 2 clicks can be logged right into FreshBooks.  Joel&#8217;s also included a <a href="http://www.getappy.com/getappysupport.html">screencast</a> showing how to configure things.</li>
</ul>
<p>Remember that the above apps are from 3rd parties, and FreshBooks is not responsible for their content or functionality.  We&#8217;re just happy that people are building useful things for everyone, and want to share the news with everyone.</p>
<p>If you&#8217;ve got an idea for a widget, gadget, app, or script that would make your life easier, all I can say is that there is no time like the present.  The API is here, it&#8217;s alive, and I&#8217;ll be kicking it into shape for you.</p>
<p>Once you&#8217;ve got your app running, you can count on us to take notice, and let everyone know about the excellent job you&#8217;ve done.  We&#8217;re rooting for you!</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/06/23/more-apps-using-the-api/feed/</wfw:commentRss>
		</item>
		<item>
		<title>FreshBooks API for staff time tracking is here, and more!</title>
		<link>http://developers.freshbooks.com/blog/2008/05/15/freshbooks-api-for-staff-time-tracking-is-here-and-more/</link>
		<comments>http://developers.freshbooks.com/blog/2008/05/15/freshbooks-api-for-staff-time-tracking-is-here-and-more/#comments</comments>
		<pubDate>Thu, 15 May 2008 14:29:06 +0000</pubDate>
		<dc:creator>Taavi Burns</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/?p=44</guid>
		<description><![CDATA[We&#8217;re happy to announce that we&#8217;ve extended the FreshBooks API to allow staff access to time tracking functions!  Yes, that includes our OSX Widget, and other time tracker add-ons.   
Notable features

Each staff member receives a unique API token, just like the admin user.  This identifies the staff member for any actions [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re happy to announce that we&#8217;ve extended the FreshBooks API to allow staff access to time tracking functions!  Yes, that includes our <a href="http://www.freshbooks.com/widgets/time-tracker/">OSX Widget</a>, and <a href="http://www.freshbooks.com/add-ons/">other time tracker add-ons</a>.  <img src='http://developers.freshbooks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h4>Notable features</h4>
<ul>
<li>Each staff member receives a unique API token, just like the admin user.  This identifies the staff member for any actions he or she takes via the API.</li>
<li>We speak the same great API for both staff and the admin account!  This means that time trackers that work with the admin account should continue to work seamlessly for your staff members.</li>
<li>We respect the access restrictions you&#8217;ve set.  Your staff members will be able to view and edit the same information (no more, and no less) through the API as they would be able through the application itself.</li>
<li>This change shouldn&#8217;t affect any API applications you already had running.  If it does, let us know!</li>
</ul>
<h4>How to find your staff token</h4>
<p>First of all, the admin user has to <a href="http://developers.freshbooks.com/overview/">enable the FreshBooks API</a>.  Then any staff member can browse over to his or her Profile page (link at the top, beside Help and Logout).  The token and access URL will be displayed at the bottom of the page.  The admin user can also find any staff member&#8217;s token, by Editing the staff member in question.</p>
<h4>Caveats</h4>
<p>Of course, there are always caveats.  In order to release this feature as soon as possible for your use&#8211;while maintaining the same security you expect from FreshBooks&#8211;we&#8217;ve only implemented the <code><a href="http://developers.freshbooks.com/clients">client</a></code>, <code><a href="http://developers.freshbooks.com/project">project</a></code>, <code><a href="http://developers.freshbooks.com/task">task</a></code>, and <code><a href="http://developers.freshbooks.com/timesheet">time_entry</a></code> API methods.  Staff members trying to access unimplemented features will receive an API error response.</p>
<h4>And more!</h4>
<p>We&#8217;ve made a few other updates to the API:</p>
<ul>
<li><code>client.get</code> now returns the client&#8217;s current credit balance</li>
<li><code>project.list</code> and <code>task.list</code> now only return active, non-archived items, just like you expect when tracking time in your browser.</li>
</ul>
<p>We&#8217;ll be updating the API docs today to reflect these changes.  So go forth and track time, and let us know what you think.  Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/05/15/freshbooks-api-for-staff-time-tracking-is-here-and-more/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Making Widgets with jQuery</title>
		<link>http://developers.freshbooks.com/blog/2008/05/01/making-widgets-with-jquery/</link>
		<comments>http://developers.freshbooks.com/blog/2008/05/01/making-widgets-with-jquery/#comments</comments>
		<pubDate>Thu, 01 May 2008 18:16:17 +0000</pubDate>
		<dc:creator>Taavi Burns</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/?p=42</guid>
		<description><![CDATA[You may have noticed that we recently released the FreshBooks Time Tracker widget.  What you may not have noticed beneath its shiny exterior, is this fantastic helper library called jQuery.  Here are some excellent reasons for using it&#8230;
Portability
While the FreshBooks widget is currently only for OSX&#8217;s Dashboard, a lot of the HTML element [...]]]></description>
			<content:encoded><![CDATA[<p>You may have noticed that we recently released the <a href="http://www.freshbooks.com/widgets/">FreshBooks Time Tracker</a> widget.  What you may not have noticed beneath its shiny exterior, is this fantastic helper library called <a href="http://jquery.com">jQuery</a>.  Here are some excellent reasons for using it&#8230;</p>
<h4>Portability</h4>
<p>While the FreshBooks widget is currently only for OSX&#8217;s Dashboard, a lot of the HTML element access and glitzy fades are pure jQuery, and should be portable to other widget facilities, and the FreshBooks website itself.  It&#8217;s also nice to be able to use the same skills in widget creation as webpage creation.</p>
<h4>Power</h4>
<p>The <code>$()</code> construct is much, much more powerful than it at first appears.  Take a closer look at the full power of <a href="http://docs.jquery.com/Selectors">selectors</a> to see what I mean.  And the skills you learn are re-usable, since jQuery implements CSS3-style selectors.  When browsers get around to fully supporting them, you&#8217;ll already be at home.  In addition, jQuery also makes dealing with XML (as returned by the FreshBooks API) and Ajax in general a whole lot easier!</p>
<h4>Conciseness</h4>
<p>jQuery also leads to shorter, more concise JavaScript.  <code>$("#submit")</code> is so much easier to type than <code>document.getElementById("submit")</code>, and infinitely more flexible when you want to, say, operate on all of the images in a page with <code>$("img")</code>.  You &#8220;chain&#8221; together various jQuery commands, such as <a href="http://docs.jquery.com/CSS" title="jQuery CSS commands"><code>css()</code></a> and <a href="http://docs.jquery.com/Effects" title="jQuery effects"><code>show()</code></a> simply by applying them to the returned &#8220;wrapped set&#8221;, like <code>$("img").css('opacity',0.5)</code>.</p>
<h4>Peer Pressure</h4>
<p>Apparently I&#8217;m not the only one who thought this would be a good idea.  I just recently noticed an awesome <a href="http://www.apple.com/downloads/dashboard/developer/svnnotifier.html">SVN notifier</a> widget which also includes jQuery.  Perhaps the idea is catching on&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/05/01/making-widgets-with-jquery/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Minor API Changes for April</title>
		<link>http://developers.freshbooks.com/blog/2008/04/07/minor-api-changes-for-march/</link>
		<comments>http://developers.freshbooks.com/blog/2008/04/07/minor-api-changes-for-march/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 18:14:58 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/2008/04/07/minor-api-changes-for-march/</guid>
		<description><![CDATA[Howdy folks - a couple of small API changes to announce:

invoice.get and invoice.list now return &#60;recurring_id/&#62;
project.list can now be filtered by &#60;task_id/&#62;
time_entry.create rounds hour values to hundredths of an hour (just like the web interface)
Raised maximum request limit to 5000 requests/day
A handful of other bug fixes and tweaks

As always, if you have questions or comments, [...]]]></description>
			<content:encoded><![CDATA[<p>Howdy folks - a couple of small API changes to announce:</p>
<ul>
<li><a href="http://developers.freshbooks.com/invoices/#get">invoice.get</a> and <a href="http://developers.freshbooks.com/invoices/#list">invoice.list</a> now return &lt;recurring_id/&gt;</li>
<li><a href="http://developers.freshbooks.com/projects/#list">project.list</a> can now be filtered by &lt;task_id/&gt;</li>
<li><a href="http://developers.freshbooks.com/timesheet/#create">time_entry.create</a> rounds hour values to hundredths of an hour (just like the web interface)</li>
<li>Raised maximum request limit to 5000 requests/day</li>
<li>A handful of other bug fixes and tweaks</li>
</ul>
<p>As always, if you have questions or comments, please let us know on the <a href="http://forum.freshbooks.com/viewforum.php?id=19">developer forums</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/04/07/minor-api-changes-for-march/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The Importance of Strict HTML</title>
		<link>http://developers.freshbooks.com/blog/2008/03/03/the-importance-of-strict-html/</link>
		<comments>http://developers.freshbooks.com/blog/2008/03/03/the-importance-of-strict-html/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 20:38:14 +0000</pubDate>
		<dc:creator>Taavi Burns</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/2008/03/03/the-importance-of-strict-html/</guid>
		<description><![CDATA[The other day I was investigating an odd error using our development version of FreshBooks in Safari.  Lines in an invoice were being reset in an odd way, and I couldn&#8217;t add more lines to an invoice as I was creating it.  This worked perfectly in FireFox, but not in Safari.
Of course, the [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I was investigating an odd error using our development version of FreshBooks in Safari.  Lines in an invoice were being reset in an odd way, and I couldn&#8217;t add more lines to an invoice as I was creating it.  This worked perfectly in FireFox, but not in Safari.</p>
<p>Of course, the first step was to look at the page source.  However, the page source looked entirely correct.  All of the form elements were defined in the correct places, with the expected order.  This is where fantastic tools like Web Inspector (found in the <a href="http://developer.apple.com/internet/safari/faq.html#anchor14">Safari Debug menu</a>) and <a href="http://www.getfirebug.com/">Firebug</a> come in handy.  On reproducing the bug, I managed to SEE the offending tag in its new location in the Web Inspector view.  A whole set of <code>input</code> tags sitting at the start of a <code>table</code>!</p>
<p>It turns out that if you replace a table inside a <code>div</code> tag, Safari does some reparsing of your provided HTML.  Say, you put a hidden <code>input</code> tag within a <code>tr</code>, but outside of a <code>td</code>.  Normally this works fine, and <code>document.forms[0].elements[]</code> shows up in the way you&#8217;d expect.  But when replacing the table via something like <code>innerHTML</code>, it barfs because the ONLY things allowed in a <code>tr</code> tag are <code>th</code> or <code>td</code>.  Thus speaks the <a href="http://www.w3.org/TR/xhtml1/dtds.html#dtdentry_xhtml1-transitional.dtd_table">XHTML 1.0 transitional DTD</a>:</p>
<blockquote><p><code>&lt;!ELEMENT tr       (th|td)+&gt;</code></p></blockquote>
<p>What appears to happen, is that any <code>input</code> elements outside of a <code>td</code> get bubbled up the DOM until they find a place where they are allowed&#8230;in this case, immediately before the enclosing table.</p>
<p>Hence, you get strange results with:</p>
<blockquote><p><code>myDiv.innerHTML = &quot;&lt;table border=&#x27;1&#x27;&gt;&lt;tbody&gt;&quot; +<br />
   &quot;&lt;tr&gt;&lt;td&gt;&lt;input type=&#x27;text&#x27; value=&#x27;First&#x27;&gt;&lt;/td&gt;&quot; +<br />
   &quot;   &lt;input type=&#x27;text&#x27; value=&#x27;Second&#x27;&gt;&lt;/tr&gt;&quot; +<br />
   &quot;&lt;/tbody&gt;&lt;/table&gt;&quot;;</code></p></blockquote>
<p><img src='http://developers.freshbooks.com/wp-content/uploads/2008/02/sad-form.png' alt='"Second" comes before "First", and is outside the table.' /><br />
But not with:</p>
<blockquote><p><code>myDiv.innerHTML = &quot;&lt;table border=&#x27;1&#x27;&gt;&lt;tbody&gt;&quot; +<br />
   &quot;&lt;tr&gt;&lt;td&gt;&lt;input type=&#x27;text&#x27; value=&#x27;First&#x27;&gt;&quot; +<br />
   &quot;   &lt;input type=&#x27;text&#x27; value=&#x27;Second&#x27;&gt;&lt;/td&gt;&lt;/tr&gt;&quot; +<br />
   &quot;&lt;/tbody&gt;&lt;/table&gt;&quot;;</code></p></blockquote>
<p><img src='http://developers.freshbooks.com/wp-content/uploads/2008/02/happy-form.png' alt='"First" comes before "Second, and is inside the table."' /><br />
Hence, when adding form elements improperly, programmatically, and referencing them with <code>document.forms[].elements[]</code>, you get Very Strange results.</p>
<p>So please, for your own sanity&#8217;s sake, nest your elements properly!</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/03/03/the-importance-of-strict-html/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Comparative Infinite Recursion</title>
		<link>http://developers.freshbooks.com/blog/2008/02/13/comparative-infinite-recursion/</link>
		<comments>http://developers.freshbooks.com/blog/2008/02/13/comparative-infinite-recursion/#comments</comments>
		<pubDate>Wed, 13 Feb 2008 17:01:01 +0000</pubDate>
		<dc:creator>Taavi Burns</dc:creator>
		
		<category><![CDATA[General Programming]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/2008/02/13/comparative-infinite-recursion/</guid>
		<description><![CDATA[As you may know, I started at FreshBooks at the start of this year.  You&#8217;ll see me posting random programming-related things as I hit them in my move from systems C programming into the world of PHP and web programming.
Yesterday I was merrily coding away, creating Cool New Features for you, our FreshBooks users. [...]]]></description>
			<content:encoded><![CDATA[<p><em>As you may know, I started at FreshBooks at the start of this year.  You&#8217;ll see me posting random programming-related things as I hit them in my move from systems C programming into the world of PHP and web programming.</em></p>
<p>Yesterday I was merrily coding away, creating Cool New Features for you, our FreshBooks users.  After adding 4 innocent lines of code, I started to see raw JavaScript instead of the beautifully formatted FreshBooks interface we all love.  This led me through the following hoops:</p>
<ol>
<li>There&#8217;s no trailing &lt;script&gt; tag in the page source.  So that&#8217;s why I saw raw JavaScript.</li>
<li>Apache&#8217;s <tt>error.log</tt> showed dying processes!</li>
<li>Reconfiguring Apache to use only one child thread, I attached <tt>gdb</tt> and recreated it&#8230;and caught PHP dying of a <a href="http://en.wikipedia.org/wiki/Segmentation_fault" title="Segmentation fault - Wikipedia, the free encyclopedia">segmentation fault</a>!</li>
<li>At this point I think I&#8217;ve found a bug in PHP (since progams should <em>never ever</em> segfault).</li>
<li>Then I discovered I made the classic error of pasting-without-looking, and inadvertently created an infinite recursion!, and found a <a href="http://bugs.php.net/bug.php?id=37612" title="PHP Bugs: #37612: Segfault - infinite recursion">bug report</a> that indicates that this is &#8220;working as designed&#8221; in PHP. <strong>*cough*</strong></li>
</ol>
<p>To wit, I proceeded to see how other scripting languages handle infinite recursion.  Here are the results&#8230;</p>
<h4>PHP</h4>
<pre>
<strong>$</strong> <em>php -r "function f(){f();}f();"</em>
Segmentation fault</pre>
<p>Dies an untimely death, because <a href="http://bugs.php.net/bugs-generating-backtrace.php">each function invocation recursively calls execute()</a>:</p>
<p>In my opinion, a well-behaved program should NEVER segfault, because a segmentation is only rarely the first bad thing that&#8217;s happened (it&#8217;s just the most fatal one to the process in question).  But let&#8217;s see if anyone else does better&#8230;</p>
<h4>Perl</h4>
<pre>
<strong>$</strong> <em>perl -e "sub f{&amp;f;}&amp;f;"</em>
Killed</pre>
<p>Runs the system out of memory (all 256MB RAM + 400MB swap in my Linux VMWare image).  <tt> <img src='http://developers.freshbooks.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </tt>  While this is horrible from a denial-of-service perspective, it&#8217;s easy to prevent by setting ulimit on the server processes.  And it shows that Perl isn&#8217;t artificially limiting recursion depth; if you&#8217;ve got the RAM, you can go to infinity (almost).</p>
<h4>Python</h4>
<pre>
<strong>$</strong> <em>python -c "def f(): f()
f()"</em>
Traceback (most recent call last):
  File "&lt;string&gt;", line 2, in &lt;module&gt;
  File "&lt;string&gt;", line 1, in f
...
RuntimeError: maximum recursion depth exceeded</pre>
<p>YAY!  A useful result.  Of course it indicates that you may have <a href="http://www.google.com/search?q=python+recursion+depth">problems recursing deeply</a>.  See below for alternatives&#8230;</p>
<h4>Ruby</h4>
<pre>
<strong>$</strong> <em>ruby -e "def f
  f()
end
f()"</em>
-e:2:in `f': stack level too deep (SystemStackError)
	from -e:2:in `f'
	from -e:4</pre>
<p>Also an excellent, useful error message!</p>
<h4>Tail Recursion</h4>
<p>Of course, if you wanted to loop infinitely, you&#8217;d be much better off using a language that supports tail call optimization.  Something like <a href="http://swiss.csail.mit.edu/projects/scheme/">Scheme</a>, <a href="http://www.lua.org/">Lua</a>, <a href="http://www.erlang.org/">Erlang</a>, etc. Even better, you can write your own language that supports tail call optimization (take a look at the last chapter of <a href="http://mitpress.mit.edu/sicp/" title="Welcome to the SICP Web Site">Structure and Interpretation of Computer Programs</a>, and section <a href="http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-31.html#%_sec_5.1.4">5.1.4</a> in particular). However, since choosing (or writing) a different language is not always feasible, people are always coming up with <a href="http://lambda-the-ultimate.org/node/1331">creative</a> <a href="http://www.cs.indiana.edu/hyplan/dfried/mex.pdf">solutions</a> in languages that don&#8217;t support TCO!</p>
<h4>For those with a practical bent</h4>
<p>Not willing to give this up just yet, here&#8217;s a set of less artificial examples:</p>
<pre>&lt;?
//php
function f($x) {
	if ($x == 1) return 1;
	return ($x + f($x-1));
}
echo f(1) . "\n";
echo f(10) . "\n";
echo f(100) . "\n";
echo f(1000) . "\n";
echo f(10000) . "\n";
echo f(100000) . "\n"; // Segmentation fault
?&gt;

#perl
sub f {
	my $x = shift;
	if ($x == 1) {return 1;}
	return ($x + f($x-1));
}
print(f(1) . "\n");
print(f(10) . "\n");
print(f(100) . "\n");
print(f(1000) . "\n");
print(f(10000) . "\n");
print(f(100000) . "\n");
print(f(1000000) . "\n");
print(f(10000000) . "\n"); # malloc: *** mmap(size=351752192) failed

#python
def f(x):
	if x == 1: return 1
	return x + f(x-1)

f(1)
f(10)
f(100)
f(1000) # maximum recursion depth exceeded

#ruby
def f(x)
	x == 1 ? x : x + f(x-1)
end
puts f(1)
puts f(10)
puts f(100)
puts f(1000)
puts f(10000) # stack level too deep</pre>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/02/13/comparative-infinite-recursion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>New: API Version Numbers, Better Paging</title>
		<link>http://developers.freshbooks.com/blog/2008/01/10/new-api-version-numbers-better-paging/</link>
		<comments>http://developers.freshbooks.com/blog/2008/01/10/new-api-version-numbers-better-paging/#comments</comments>
		<pubDate>Thu, 10 Jan 2008 19:03:36 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
		
		<category><![CDATA[News and Updates]]></category>

		<guid isPermaLink="false">http://developers.freshbooks.com/blog/2008/01/10/new-api-version-numbers-better-paging/</guid>
		<description><![CDATA[Afternoon gang! We’ve got a couple new API feature announcements to kick off 2008 - just 3 weeks after our last release.
Paging Metadata
Now when you submit an API request that returns more than one object (i.e. all *.list methods), you’ll also be returned paging metadata that describes the result set. This should help you better [...]]]></description>
			<content:encoded><![CDATA[<p>Afternoon gang! We’ve got a couple new API feature announcements to kick off 2008 - just 3 weeks after <a href="http://www.freshbooks.com/blog/2007/12/21/freshbooks-42-now-with-less-pain/">our last release.</a></p>
<h4>Paging Metadata</h4>
<p>Now when you submit an API request that returns more than one object (i.e. all *.list methods), you’ll also be returned paging metadata that describes the result set. This should help you better navigate large data sets returned by the API.</p>
<p>Here’s a sample new response from <a href="http://developers.freshbooks.com/invoices/#list">invoice.list</a>:</p>
<pre><code>&lt;?xml version="1.0" encoding="</code><code>utf-8</code><span class="attribute-value"></span><code>"?&gt;
&lt;response status="ok"&gt;
  &lt;invoices page="2" per_page="5" pages="8" total="37"&gt;
    &lt;invoice&gt;...</code><code>&lt;/invoice&gt;</code><code>
</code><code>    &lt;invoice&gt;...</code><code>&lt;/invoice&gt;
</code><code>    &lt;invoice&gt;...</code><code>&lt;/invoice&gt;
</code><code>    &lt;invoice&gt;...</code><code>&lt;/invoice&gt;
</code><code>    &lt;invoice&gt;...</code><code>&lt;/invoice&gt;</code>
  &lt;/invoices&gt;
&lt;/response&gt;</pre>
<p>Now, we think this is a swell improvement, and our users have been pining for it. But it comes at a small cost – the introduction of these new top-level paging nodes could break existing integration code. This issue leads into our next announcement:</p>
<h4>API Version Numbers</h4>
<p>Now when you submit your API requests, you can optionally specify a version number as part of the request URL.</p>
<p><span class="hl">Old URL:</span></p>
<pre><code>http://mycompany.freshbooks.com/api/xml-in</code></pre>
<p><span class="hl">New URL:</span></p>
<pre><code>http://mycompany.freshbooks.com/api/2.1/xml-in</code></pre>
<p>To take advantage of these new response formats, you must specify version 2.1 as part of the request URL. If you do not specify a version number, the API will return the old, less-descriptive response format (version 2.0).</p>
<h4>Deprecation Warning!</h4>
<p>We will support both versions (2.1 and 2.0) <span class="hl">until March 1st, 2008.</span> This will give you nearly 8 weeks to migrate your applications to the new schema.</p>
<p>If you have questions, comments or concerns, please <a href="http://www.freshbooks.com/contact.php">contact us</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://developers.freshbooks.com/blog/2008/01/10/new-api-version-numbers-better-paging/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
