<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>CodeProject Archives - Ryan Peden</title>
	<atom:link href="https://ryanpeden.com/category/codeproject/feed/" rel="self" type="application/rss+xml" />
	<link>https://ryanpeden.com/category/codeproject/</link>
	<description>Full Stack DevRel</description>
	<lastBuildDate>Sun, 18 Aug 2019 12:38:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.3.2</generator>
<site xmlns="com-wordpress:feed-additions:1">155423463</site>	<item>
		<title>How to remove /api from Azure Functions URLs</title>
		<link>https://ryanpeden.com/how-to-remove-api-from-azure-functions-urls/</link>
					<comments>https://ryanpeden.com/how-to-remove-api-from-azure-functions-urls/#comments</comments>
		
		<dc:creator><![CDATA[Ryan Peden]]></dc:creator>
		<pubDate>Thu, 15 Aug 2019 18:11:27 +0000</pubDate>
				<category><![CDATA[Cloud]]></category>
		<category><![CDATA[CodeProject]]></category>
		<guid isPermaLink="false">https://ryanpeden.com/?p=107</guid>

					<description><![CDATA[<p>Note: All of the following assumes you&#8217;re working with Azure Functions 2.0. Azure Functions are great. By default, all HTTP functions on Azure have their URLs prefixed with /api. For example, if you have functions named Function1 and Function2, you&#8217;d reach them by calling http://my-app.azurewebsites.net/api/Function1 and http://my-app.azurewebsites.net/api/Function2. Usually, this is</p>
<div class="belowpost"><a class="btnmore icon-arrow" href="https://ryanpeden.com/how-to-remove-api-from-azure-functions-urls/"><span>Read More</span></a></div>
<p>The post <a rel="nofollow" href="https://ryanpeden.com/how-to-remove-api-from-azure-functions-urls/">How to remove /api from Azure Functions URLs</a> appeared first on <a rel="nofollow" href="https://ryanpeden.com">Ryan Peden</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p><em>Note: All of the following assumes you&#8217;re working with Azure Functions 2.0.</em></p>



<p>Azure Functions are great. By default, all HTTP functions on Azure have their URLs prefixed with <code>/api</code>. For example, if you have functions named Function1 and Function2, you&#8217;d reach them by calling <code>http://my-app.azurewebsites.net/api/Function1</code> and  <code>http://my-app.azurewebsites.net/api/Function2</code>.</p>



<p>Usually, this is fine. But it seems like an arbitrary restriction. What if you&#8217;d rather not have it?</p>



<p>Fortunately, there&#8217;s a configuration option in your function app&#8217;s <code>host.json</code> file to change it. Unfortunately, as I&#8217;m writing this, <a href="https://docs.microsoft.com/en-us/azure/azure-functions/functions-host-json">Microsoft&#8217;s documentation</a> is incorrect. </p>



<p>It tells you your <code>host.json</code> should look something like this if you want to remove the /api prefix:</p>



<pre class="wp-block-preformatted">{
    "http": {
        "routePrefix": ""
    }
}</pre>



<p>This won&#8217;t work. If you&#8217;re running Visual Studio, it&#8217;ll tell you <em>Property name is not allowed by the schema.</em> Instead, the <code>http</code> object must be placed inside of <code>extensions</code>:</p>



<pre class="wp-block-preformatted">{
  "version": "2.0",
  "extensions": {
    "http": {
      "routePrefix": ""
    }
  }
}</pre>



<p>Setting <code>routePrefix</code> to an empty string removes <code>/api</code> from the URL. Now, to access Function1, you&#8217;d call  <code>http://my-app.azurewebsites.net/Function1</code>.</p>



<p>Also note the <code>version</code> property. If you don&#8217;t add this, the Azure Functions local simulator will flip out and fall into an infinite loop of scary-looking error messages:</p>



<figure class="wp-block-image"><img decoding="async" fetchpriority="high" width="1000" height="526" data-attachment-id="108" data-permalink="https://ryanpeden.com/how-to-remove-api-from-azure-functions-urls/image/" data-orig-file="https://i0.wp.com/ryanpeden.com/wp-content/uploads/2019/08/image.png?fit=1228%2C646&amp;ssl=1" data-orig-size="1228,646" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}" data-image-title="image" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/ryanpeden.com/wp-content/uploads/2019/08/image.png?fit=300%2C158&amp;ssl=1" data-large-file="https://i0.wp.com/ryanpeden.com/wp-content/uploads/2019/08/image.png?fit=1000%2C526&amp;ssl=1" src="https://i0.wp.com/ryanpeden.com/wp-content/uploads/2019/08/image.png?resize=1000%2C526&#038;ssl=1" alt="" class="wp-image-108" data-recalc-dims="1"/></figure>



<p>If host.json is blank, the simulator will be fine. But as soon as you add <em>anything else</em> to host.json, you also have to add a version, or the simulator will go crazy.</p>



<p>And that&#8217;s it! You now know how to remove /api from your Azure Functions URLs. You can also use a non-blank string to use a prefix other than <em>api. </em>If you&#8217;d like your functions URLs prefixed by <em>popcorn </em>or <em>cats</em>, there&#8217;s nothing stopping you!</p>
<p>The post <a rel="nofollow" href="https://ryanpeden.com/how-to-remove-api-from-azure-functions-urls/">How to remove /api from Azure Functions URLs</a> appeared first on <a rel="nofollow" href="https://ryanpeden.com">Ryan Peden</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://ryanpeden.com/how-to-remove-api-from-azure-functions-urls/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">107</post-id>	</item>
		<item>
		<title>How do JavaScript arrays work under the hood?</title>
		<link>https://ryanpeden.com/how-do-javascript-arrays-work-under-the-hood/</link>
		
		<dc:creator><![CDATA[Ryan Peden]]></dc:creator>
		<pubDate>Sat, 27 Jul 2019 14:30:00 +0000</pubDate>
				<category><![CDATA[CodeProject]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://ryanpeden.com/?p=23</guid>

					<description><![CDATA[<p>Front-end and full-stack developers use JavaScript arrays every day. Most of them, however, haven&#8217;t done a deep dive to understand how JS arrays are implemented in native code. Not doing this doesn&#8217;t mean you&#8217;re a bad developer. It&#8217;s entirely possible to use JavaScript effectively without digging in to understand how</p>
<div class="belowpost"><a class="btnmore icon-arrow" href="https://ryanpeden.com/how-do-javascript-arrays-work-under-the-hood/"><span>Read More</span></a></div>
<p>The post <a rel="nofollow" href="https://ryanpeden.com/how-do-javascript-arrays-work-under-the-hood/">How do JavaScript arrays work under the hood?</a> appeared first on <a rel="nofollow" href="https://ryanpeden.com">Ryan Peden</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Front-end and full-stack developers use JavaScript arrays every day. Most of them, however, haven&#8217;t done a deep dive to understand how JS arrays are implemented in native code. </p>



<p>Not doing this doesn&#8217;t mean you&#8217;re a bad developer. It&#8217;s entirely possible to use JavaScript effectively without digging in to understand how JS arrays are implemented. But taking a closer look can help you understand performance issues your might run into, so it&#8217;s a worthwhile exercise. </p>



<p>How exactly they are implemented depends on the specific JavaScript interpreter or VM you&#8217;re using. I&#8217;m going to use the V8 JavaScript engine (used by Chrme and Node.js) as an example. Other JavaScript engines, such as Mozilla&#8217;s SpiderMonkey and Microsoft&#8217;s Chakra will be similar but not identical.</p>



<h2 class="wp-block-heading">JavaScript Arrays in V8</h2>



<p>In V8, if your array only contains integers, it&#8217;ll be backed by a C++ array of integers. Typically, the backing array will be bigger than the number of integers it currently contains. If it contains a mixture of integers and floating point values or only floating point values, it&#8217;ll be backed by an array of doubles. </p>



<p>If the array contains only objects, or a mixture of numbers and objects, it&#8217;ll backed by an array of pointers. Even though JavaScript itself doesn&#8217;t have a concept of &#8216;integer&#8217; or &#8216;double&#8217; &#8211; it just sees them all as &#8216;number&#8217;, V8 keeps track and makes it so arrays are a bit faster and more memory efficient if you only put integers in them.</p>



<p>If you call&nbsp;<code>push()</code>&nbsp;when the backing array is full, it&#8217;ll allocate a new, bigger backing array, copy the existing elements over, and then add the new value you pushed. This is similar to the implementation of&nbsp;<code>ArrayList</code>&nbsp;in Java or&nbsp;<code>vector</code>&nbsp;in C++.</p>



<p>All of the above only is only sure to apply if your array is packed, and not sparse &#8211; i.e. you don&#8217;t have any gaps in the array. If you do something like</p>



<pre class="wp-block-code"><code>let abc = [1,2,3];
abc[100] = 50;</code></pre>



<p>you now have a sparse array. If is not too spare, it&#8217;ll still be backed by an array, with empty array indices replaced with a &#8216;hole&#8217; value. If you look at V8&#8217;s C++ array source (linked below), you&#8217;ll see calls to&nbsp;<code>element-&gt;is_the_hole(i)</code>. If an array is very sparse, it&#8217;ll no longer be backed by an array in memory. Instead, it will be backed by a dictionary/hashtable, and it&#8217;ll take longer to both access elements and iterate through the array.</p>



<p>If you&#8217;re interested, you can read through V8&#8217;s array implementation in C++&nbsp;<a href="https://github.com/v8/v8/blob/master/src/builtins/builtins-array.cc">here</a>. You&#8217;ll notice that it often checks the following constants:</p>



<ul><li><code>PACKED_SMI_ELEMENTS</code> &#8211; a packed integer array</li><li><code>PACKED_DOUBLE_ELEMENTS</code> &#8211; a packed double array</li><li><code>PACKED_ELEMENTS</code> &#8211; a packed object array</li><li><code>HOLEY_SMI_ELEMENTS</code> &#8211; a sparse integer array</li><li><code>HOLEY_DOUBLE_ELEMENTS</code> &#8211; a sparse double array</li><li><code>HOLEY_ELEMENTS</code> &#8211; a sparse object array</li><li><code>DICTIONARY_ELEMENTS</code> &#8211; a very sparse array that is backed by a dictionary</li></ul>



<p>And you&#8217;ll see that it always tries to do whatever will be fastest for the array it is operating on. Lots of builtin functions like push, pop, shift, unshift, and concat do different things depending on the array&#8217;s density and what kind of elements it contains.</p>



<p>Some other things to keep in mind: if you have an array that only contains integers, and you push a floating point number or other type into it, it will be &#8216;downgraded&#8217; for the rest of its life, even if you purge the non integers from it.</p>



<p>Also keep in mind that none of these implementation details are guaranteed. A naive implementation of JavaScript&#8217;s Array object could be backed by a linked list, and it would still work the same way it does now. It would just be slower. </p>



<p>Actually, if you grab an early copy of the Mozilla source code from 20 years ago, you&#8217;ll find that arrays were backed by ordinary JS objects without much optimization, just some extra code to handle special cases like the `length` property.</p>



<h2 class="wp-block-heading">Digging Deeper</h2>



<p>If you&#8217;re interested in diving even deeper into V8&#8217;s internals, I suggest starting by reading through the source files I linked to above. If you&#8217;re not used to C++, understanding it will be a bit of a chore at first. </p>



<p>I recommend sticking with it, though. Learning and understanding a new language is always good &#8211; and every extra insight you gain into how JavaScript VMs run your code will make you a more effective JavaScript developer. </p>



<p><strong>If you liked this, you might like these other articles I&#8217;ve written:</strong><br><a href="https://www.grapecity.com/blogs/using-web-components-with-react-2019">Using Web Components with React in 2019</a><br><a href="https://www.grapecity.com/blogs/angular-roadmap-the-past-present-and-future-of-angular">An Angular Roadmap &#8211; The Past, Present, and Future of Angular</a></p>
<p>The post <a rel="nofollow" href="https://ryanpeden.com/how-do-javascript-arrays-work-under-the-hood/">How do JavaScript arrays work under the hood?</a> appeared first on <a rel="nofollow" href="https://ryanpeden.com">Ryan Peden</a>.</p>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">23</post-id>	</item>
	</channel>
</rss>
