<?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/"
	>

<channel>
	<title>LLVM &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/llvm/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Tue, 02 Mar 2021 17:16:19 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Yes Facebook, you can be Native AND Cross-Platform</title>
		<link>https://blog.xojo.com/2020/03/03/yes-facebook-you-can-be-native-and-cross-platform/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Tue, 03 Mar 2020 20:46:08 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[LLVM]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Native App Development]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Xojo Framework]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=6677</guid>

					<description><![CDATA[At Xojo we did the hard work of creating a framework with an API that manages the nuances, intricacies, and subtle yet important differences between 7 different platforms (macOS, Windows, Linux, web, Raspberry Pi, iOS and soon, Android) so you can focus on what makes your application unique. We have been doing it for over 20 years.]]></description>
										<content:encoded><![CDATA[
<p>In a recent <a href="https://engineering.fb.com/data-infrastructure/messenger/">blogpost</a>, the Facebook engineering team talked about finally arriving at the conclusion that Messenger needed to be a native app. While I&#8217;m glad they are seeing the light, they have reached the wrong conclusion about the trade-offs that come with being native. They believe you cannot develop in a cross-platform way and deliver a native app. </p>



<p>You absolutely <strong>can</strong>. Xojo creates native apps that are also cross-platform. It <strong>can</strong> be done. It&#8217;s just a matter of choosing the right framework. At Xojo, we didn&#8217;t take the easy path of drawing controls ourselves or using HTML5. We didn&#8217;t dumb things down to the least common denominator. We did the hard work of creating a framework with an API that manages the nuances, intricacies, and subtle yet important differences between 7 different platforms (macOS, Windows, Linux, web, Raspberry Pi, iOS and soon, Android) and multiple OS versions so you can focus on what makes your application unique. We have been doing it for over 20 years.</p>



<p>When discussing Facebook&#8217;s blog post, John Gruber of <a href="https://daringfireball.net/linked/2020/03/02/facebook-messenger-native">Daringfireball.net</a> said, &#8220;&#8230;native apps are smaller, faster, and more reliable.&#8221;</p>



<p>Nearly every user interface element in Xojo is native. The one exception is the desktop Listbox because way back when, none of the desktop operating systems provided one. Everyone made their own. Having said that, the Listbox is made up of native controls. The scrollbar is a native scrollbar. If the developer makes the contents editable by their end user, a native TextField control appears. The headers are native controls. The advantages of native controls can&#8217;t be overstated, Facebook was right about that. Modern operating systems provide an ever-increasing array of features via their native controls and thus using them gives you immediate and nearly free access to these features. From focus rings to spellchecking to accessibility and more much, using native controls makes the most sense.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="98" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.49.35-AM-1024x98.png" alt="" class="wp-image-6685" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.49.35-AM-1024x98.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.49.35-AM-300x29.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.49.35-AM-768x74.png 768w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.49.35-AM.png 1084w" sizes="(max-width: 1024px) 100vw, 1024px" /><figcaption>Focus rings, spellchecking (and auto-correct) on macOS</figcaption></figure>



<p>Event aesthetics come into play. Because the Xojo framework uses native controls, when Apple and Microsoft make changes to the look and feel of their controls, apps made in Xojo automatically change in appearance and behavior. Most recently, Apple added Dark Mode to both macOS and iOS and for most Xojo developers, adding this support required nothing more than indicating they wanted their apps to support it by clicking a checkbox.</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" width="1024" height="210" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.21-AM-1024x210.png" alt="" class="wp-image-6686" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.21-AM-1024x210.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.21-AM-300x62.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.21-AM-768x158.png 768w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.21-AM.png 1080w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<div class="wp-block-image"><figure class="aligncenter size-large"><img decoding="async" width="1024" height="208" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.57-AM-1024x208.png" alt="" class="wp-image-6687" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.57-AM-1024x208.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.57-AM-300x61.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.57-AM-768x156.png 768w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-11.53.57-AM.png 1092w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>While Xojo provides the developer with an easy drag-and-drop way to create their application&#8217;s user interface, it also provides a straightforward API for interacting with controls via code. The TextField control, for example, provides events that tell you when the control has appeared for the first time, when the user has changed the selection or the text itself, and even when they press down on a key or release it. There are properties to change the size, style and behavior of controls. And all of this is a level of abstraction that lets you focus not on the details of the platform but on what makes your application unique.</p>



<figure class="wp-block-gallery aligncenter columns-1 is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="1024" height="211" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-1.09.24-PM-1024x211.png" alt="" data-id="6692" data-full-url="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-1.09.24-PM.png" data-link="https://blog.xojo.com/?attachment_id=6692" class="wp-image-6692" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-1.09.24-PM-1024x211.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-1.09.24-PM-300x62.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-1.09.24-PM-768x158.png 768w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-1.09.24-PM.png 1076w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure></li></ul><figcaption class="blocks-gallery-caption">Windows</figcaption></figure>



<div class="wp-block-image"><figure class="aligncenter size-large is-resized"><img loading="lazy" decoding="async" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-12.33.57-PM-1-1024x246.png" alt="" class="wp-image-6694" width="610" height="146" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-12.33.57-PM-1-1024x246.png 1024w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-12.33.57-PM-1-300x72.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-12.33.57-PM-1-768x184.png 768w, https://blog.xojo.com/wp-content/uploads/2020/03/Screen-Shot-2020-03-03-at-12.33.57-PM-1.png 1076w" sizes="auto, (max-width: 610px) 100vw, 610px" /><figcaption>Linux</figcaption></figure></div>



<p>For example, under the hood for the desktop, Xojo&#8217;s TextField uses NSTextField on macOS, EditControl on Windows and GTKEntry on Linux. On iOS it&#8217;s the UITextField, on Android it&#8217;s EditText and on the web it&#8217;s &lt;input type=&#8221;text&#8221;&gt;. Each of these is very different but Xojo has done the hard work to provide a standard, straight-forward API so that you get the benefit of native controls without needing to learn the thousands of APIs and unique behaviors necessary to create a cross-platform app.</p>



<figure class="wp-block-gallery columns-2 is-cropped wp-block-gallery-2 is-layout-flex wp-block-gallery-is-layout-flex"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="473" height="1024" src="https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1-473x1024.png" alt="" data-id="6690" data-full-url="https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1.png" data-link="https://blog.xojo.com/?attachment_id=6690" class="wp-image-6690" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1-473x1024.png 473w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1-139x300.png 139w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1-768x1663.png 768w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1-709x1536.png 709w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1-946x2048.png 946w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0819-1.png 1125w" sizes="auto, (max-width: 473px) 100vw, 473px" /></figure></li><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="473" height="1024" src="https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1-473x1024.png" alt="" data-id="6691" data-full-url="https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1.png" data-link="https://blog.xojo.com/?attachment_id=6691" class="wp-image-6691" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1-473x1024.png 473w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1-139x300.png 139w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1-768x1663.png 768w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1-709x1536.png 709w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1-946x2048.png 946w, https://blog.xojo.com/wp-content/uploads/2020/03/IMG_0820-1.png 1125w" sizes="auto, (max-width: 473px) 100vw, 473px" /></figure></li></ul><figcaption class="blocks-gallery-caption">An iOS app made in Xojo in light and dark modes</figcaption></figure>



<p>It&#8217;s not just controls. The Xojo cross-platform framework includes dialog boxes, menus, access to the file system, printing, sockets, database access and much more.</p>



<p>Native is more than the user interface. It&#8217;s also about performance. Xojo compiles to native code for each platform as well. Behind the scenes it uses <a href="https://www.llvm.org">LLVM</a>, the same optimizing compiler that Apple, Google, Intel, AMD, Nvidia and many others use. Native code means native speed.</p>



<p>Thousands upon thousands of Xojo users have built cross-platform apps. The Xojo IDE itself and much of the Xojo framework are written in Xojo. So yes, we eat our own dog food. <a href="https://www.oranged.net">Studiometry</a> and <a href="https://www.propertyme.com.au">Property Me</a> are just two of the many examples of commercial cross-platform apps written in Xojo. There are countless others.</p>



<p>We have also done this in a way that makes it easy for students and hobbyists to learn programming so they can take it into their workplaces and build business applications. In some cases, those citizen developers create something revolutionary and become full-time professional developers. That&#8217;s why the Xojo user community is so diverse.</p>



<p><strong>So yes, you can create native applications that are also cross-platform.</strong> You just have to choose the right tool.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Code Tip: Be Careful With Loops</title>
		<link>https://blog.xojo.com/2018/03/14/code-tip-be-careful-with-loops/</link>
		
		<dc:creator><![CDATA[Norman Palardy]]></dc:creator>
		<pubDate>Wed, 14 Mar 2018 07:16:10 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[IR]]></category>
		<category><![CDATA[LLVM]]></category>
		<category><![CDATA[Loops]]></category>
		<category><![CDATA[Uint8]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3979</guid>

					<description><![CDATA[Every once in a while we get a question or post like this one that wonders why a loop might turn into an infinite loop or why it doesn't behave as expected and stop when the loop reaches the limit. And this behaviour is not specifically a Xojo thing, most programming languages do this. In fact, there are some very well know encryption algorithms, like BlowFish, that rely on this behaviour.]]></description>
										<content:encoded><![CDATA[<p>Every once in a while we get a question or post like <a href="https://forum.xojo.com/conversation/post/377126">this one</a> that wonders why a loop might turn into an infinite loop or why it doesn&#8217;t behave as expected and stop when the loop reaches the limit.</p>
<p><span id="more-3979"></span></p>
<p>In this case the specific FOR NEXT loop in question is :</p>
<pre>For X As UInt8 = 0 To 255 
  Dim strAnything As String = "Hello World" 
Next
</pre>
<p>If you run this code you&#8217;ll find that it runs forever. You&#8217;ve accidentally created an infinite loop.</p>
<p>How did this come to be this way? There are two things involved. One is what range of values a Uint8 can actually store. And the second is the actual code generated for the for loop itself. When these two combine the stopping conditions will never occur.</p>
<p><a href="http://developer.xojo.com/integer-size-specific">Uint8 values</a> can hold a range of values like any integer. They are all positive. And the range is from 0 &#8211; 255.</p>
<p>So a Uint8 will NEVER hold a value &gt; 255 or &lt; 0.</p>
<p>Combine this with the fact that a FOR loop is generated using roughly this underlying code</p>
<pre>Dim loopCounter As UInt8
Dim loopLimit As Integer = 255
Dim loopBase As Integer = 254
Dim loopStep As Integer = 1

loopCounter = loopBase

loopTop:
  If loopCounter &gt; loopLimit Then
    GoTo loopEnd
  End If
  
  // loop body code would be here
  // its been elided to focus on the actual loop mechanics
  //    dim strAnything as string = "Hello World" 
  // 
  loopCounter = loopCounter + loopStep // NOTE THIS CAN CAUSE OVERFLOW !

  GoTo LoopTop

loopEnd:
</pre>
<p>This is NOT the actual code used. It is just a Xojo version of the actual underlying <a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">LLVM IR</a> code that gets generated.</p>
<p>Hopefully this explains the confusion. Since a Uint8 cannot hold a value greater than 255, you will find that when loopCounter IS already 255 and the increment, or loopStep in this example, is added to the existing value the loopCounter goes NOT from 255 to 256 but back to 0. It wraps around. This isn&#8217;t a bug.</p>
<p>The addition of the loopStep value causes the Uint8 to overflow since the value 256, in binary, requires 9 bits, not 8 but the Uint8 can only hold 8 bits. And so when you add it the 8 bits the value <em>can</em> hold are all 0 and the loop counter resets to 0.</p>
<p>And this behavior is not specifically a Xojo thing, most programming languages do this. In fact, there are some very well know encryption algorithms, like <a href="https://en.wikipedia.org/wiki/Blowfish_(cipher)">BlowFish</a>, that rely on this  .</p>
<p>In the specific sample code that prompted this post, a loop counter that is an Integer or Uint16 is needed because they can hold values that exceed the loops upper bound.</p>
<p>Loops that count down have a similar problem. but counting down and underflowing instead of overflowing.</p>
<p>The moral of the story is to stick to using the general <a href="http://developer.xojo.com/integer">Integer data type</a> unless you have a specific need for a <a href="http://developer.xojo.com/integer-size-specific">size-specific Integer type</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 106 &#8211; Optimizer</title>
		<link>https://blog.xojo.com/2018/01/31/compilers-106-optimizer/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 31 Jan 2018 07:10:16 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3653</guid>

					<description><![CDATA[An optimizer “improves” the IR, but that can mean a lot of different things. Improve could mean “run faster” or “use less memory”. Or perhaps&#8230;]]></description>
										<content:encoded><![CDATA[<p>An optimizer “improves” the IR, but that can mean a lot of different things. Improve could mean “run faster” or “use less memory”. Or perhaps you want to optimize for memory access time because CPUs are so fast it is sometimes more efficient to repeatedly calculate something rather than calculate it once, store it and access it later.</p>
<p>This is the sixth post in our Compiler series. Previous posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">Compilers 104 &#8211; IR Generation</a></li>
<li><a href="https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/">Compilers 105 &#8211; Back End Overview</a></li>
</ul>
<p><span id="more-3653"></span></p>
<p>The Optimizer does a series of transformations to the IR code, typically in multiple passes. LLVM provides full control over these passes.</p>
<p>Not all LLVM optimizations provide benefits to Xojo code. We have distilled the many complicated optimization settings that are available with LLVM into three options that are useful for Xojo code, which you can set from the Shared Build settings: Default, Moderate and Aggressive.</p>
<p>The Default optimization does minimal optimization in order to have the quickest compile times.</p>
<p>The Moderate setting does more optimizations, primarily to reduce the time needed for mathematical calculations which results in slightly slower compile times.</p>
<p>The Aggressive setting does many more mathematical optimizations to further reduce calculation time, but also dramatically increases compile time.</p>
<p>Optimization intends to create something that is equivalent to the original code. The end result is the same, even if the means to do so might be very different. For example, the optimizer may determine that it should do a bit shift to do integer math as a single operation rather than a series of add operations. This could result in smaller, faster code but may take longer for the optimizer to process the code in order to make this determination.</p>
<p>Deciding the “best” optimization for any code is not technically a solvable problem (<a href="https://en.wikipedia.org/wiki/NP-hardness">np-hard</a>), so optimizers use a combination of “heuristics and hand-waving”. “Hand-waving” means the compiler thinks this is correct, but has no real way to prove it. And heuristics simply means that optimizations that have been known to work in prior code are used when similar code is found.</p>
<h2>Constant Folding</h2>
<p>Constant Folding is a simple example of an optimization that can be done.</p>
<p>This essentially mans the optimizer evaluates constant expressions up front to reduce execution time, and save stack and register space.</p>
<p>For example:</p>
<pre>a = 1 + 2</pre>
<p>can be replaced with:</p>
<pre>a = 3</pre>
<p>Not everything will be quite so obvious in your code, of course.</p>
<h2>Optimization Issues</h2>
<p>There are certain types of code that can make the optimizer’s job more difficult. These special Xojo features can challenge an optimizer:</p>
<ul>
<li>Exception Handling: Makes things difficult because you cannot tell where a function call may return.</li>
<li>Memory Management: Xojo has deterministic object destruction when variable goes out of scope, which forces the optimizer to have to track things more closely.</li>
<li>Introspection: The use of Introspection requires lots of metadata to remain available so it can be referenced at run-time.</li>
<li>Threading: Cooperative thread yielding affects loops and other things.</li>
<li>Xojo is a “safe” language and many of the things it does to ensure your app does not crash (and instead raise exceptions) such as Nil object checks, stack overflow checks, bounds checks, etc. all restrict what the optimizer can do.</li>
<li>Plugins: Since these are pre-compiled, they are ignored by the optimizer.</li>
</ul>
<p>Continue to learn about a specific optimization: <a href="https://blog.xojo.com/2018/03/19/compilers-107-optimizer-loop-unrolling/">Loop Unrolling</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Avoiding False-Positive Virus Detection in Windows Apps</title>
		<link>https://blog.xojo.com/2018/01/29/avoiding-false-positive-virus-detection-in-your-windows-apps/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Mon, 29 Jan 2018 18:10:37 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[Anti-Virus]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[LLVM]]></category>
		<category><![CDATA[Security]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3853</guid>

					<description><![CDATA[Anti-virus software can be a bit over-zealous about detecting what it believes to be apps that have viruses embedded within them. We have had reports over the years that apps made with Xojo are sometimes falsely identified as being infected with a virus. If you're having problems with such false positives, recompiling your apps for 64-bit may solve the problem. Doing this is not a 100% guarantee but it can reduce the chances of a false-positive occurring.]]></description>
										<content:encoded><![CDATA[<p>Viruses continue to be a big problem on Windows. As a result, anti-virus software can be a bit over-zealous about detecting what it believes to be apps that have viruses embedded within them. We have had reports over the years that apps made with Xojo are sometimes falsely identified as being infected with a virus. This sometimes occurs because the 32-bit Xojo compiler puts executable code in a location where the anti-virus software doesn&#8217;t expect to find it. We&#8217;ve seen this occur even when users are debugging apps from the IDE. Fortunately in that case, there&#8217;s a <a href="https://blog.xojo.com/2015/06/11/norton-internet-security-and-xojo/">fairly easy solution</a>.</p>
<p><span id="more-3853"></span></p>
<p>With the <a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">move to LLVM</a> as the backend of our compiler, the format of our Windows executables changed somewhat. LLVM puts the executable code in a different location that doesn&#8217;t set off those same flags for anti-virus software. If you&#8217;re having problems with such false positives, recompiling your apps for 64-bit may solve the problem. Doing this is not a 100% guarantee but it can reduce the chances of a false-positive occurring.</p>
<p>This is even more true if you are using console-based helper apps especially if you&#8217;re launching multiple instances of them. Despite this being a known and often-used technique for taking advantage of multiple cores (and one we <a href="https://blog.xojo.com/2018/01/25/supporting-multiple-cores/">wrote about</a> recently), it can make anti-virus software more suspicious. If your helper app has code that the anti-virus software thinks is in the wrong place, recompiling it for 64-bit may help.</p>
<p>Having said all of this, false is still false. If your apps (compiled for 32-bit or 64-bit) are falsely identified as having a virus, contact the anti-virus software company so they can update their software. Many have established protocols for reporting false positives.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 105 &#8211; Back End Overview</title>
		<link>https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 29 Jan 2018 07:10:02 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3650</guid>

					<description><![CDATA[The fifth post in our ongoing Compiler series. Once the front end has done its work its time for the back end components to take over.]]></description>
										<content:encoded><![CDATA[<p>Once the front end has done its work its time for the back end components to take over.</p>
<p>This is the fifth in our compiler series and the first on the back end. We covered the parts of the compiler that are called the front end in these posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">Compilers 104 &#8211; IR Generation</a></li>
</ul>
<p><span id="more-3650"></span></p>
<h2>Back End</h2>
<p>The components of the back end take the IR that was generated by the last step of the front end and emit executable code, which is machine language in the case of Xojo.</p>
<p>To recap a bit from the LLVM post, for 32-bit x86 apps, Xojo uses its own in-house, proprietary compiler first created in 2004/2005. This powerful and fast compiler handles the front end and back end, but it does have a couple limitations: it can only target 32-bit x86 and it does not do any optimizations.</p>
<p>Today when you build an iOS app, a 64-bit app for Windows, MacOS or Linux, or an ARM app for Raspberry Pi you are using LLVM as the back end to generate your native, binary code.</p>
<p>The rest of these posts will cover the back end as it pertains to LLVM. Specifically, the components are:</p>
<ul>
<li><a href="https://blog.xojo.com/2018/01/31/compilers-106-optimizer/">Optimizer</a>, <a href="https://blog.xojo.com/2018/03/19/compilers-107-optimizer-loop-unrolling/">Loop Unrolling</a></li>
<li><a href="https://blog.xojo.com/2018/03/26/compilers-108-code-generation/">Code Generation</a></li>
<li><a href="https://blog.xojo.com/2018/04/02/compilers-109-linking-and-wrap-up/">Linker</a></li>
</ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 104 &#8211; IR Generation</title>
		<link>https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 24 Jan 2018 07:10:44 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[IR]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2833</guid>

					<description><![CDATA[This is the fourth post in our Compiler series. Now that the Semantic Analyzer has verified that the code is actually correct and created syntax trees, it's time to talk about IR generation.]]></description>
										<content:encoded><![CDATA[<p>Now that the Semantic Analyzer has verified that the code is actually correct and created syntax trees, it&#8217;s time to talk about IR generation.</p>
<p>This is the fourth post in our Compiler series. Other posts:</p>
<ul>
<li><a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a></li>
<li><a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Compilers 103 &#8211; Semantic Analyzer</a></li>
</ul>
<p><span id="more-2833"></span></p>
<h2>What is IR?</h2>
<p>After the Semantic Analyzer, the next step is to turn the trees that it validated and added type information to into a representation that is much closer to what the machine is actually going to generate. This representation is called an intermediate representation (IR). The Xojo compiler, when building for 64-bit or ARM, uses <a href="https://llvm.org/docs/LangRef.html">LLVM IR</a>.</p>
<p>The resulting LLVM IR describes the actual control flow of the program and every single thing that will be in the final program. In addition to the user-visible code that gets executed and the implicit conversions that are now in the trees, it also needs to contain all of the hidden, behind the scenes calls like reference counting and introspection metadata.</p>
<p>LLVM IR is actually higher level and more abstract than the actual assembly that it’ll end up generating. For example, unlike assembly language, it’s entirely strongly typed and the Xojo compiler has to be very precise in what it generates (which is a good thing!).</p>
<h2>IR Code Generation</h2>
<p>To get started, here is the abstract syntax tree that was previously created by the Semantic Analyzer:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2831" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-19_09-02-03.png" alt="" width="600" height="292" /></p>
<p>To generate IR, the compiler walks through the above tree, <a href="https://en.wikipedia.org/wiki/Depth-first_search">depth first</a>, to get to the leaf nodes. Doing this gets us to the BinaryOperator* for the multiple on the lower right side of the tree.</p>
<p>The LLVM IR to multiply those two values (<a href="https://llvm.org/docs/LangRef.html#mul-instruction">mul</a>) looks like this:</p>
<pre>%1 = <a href="https://llvm.org/docs/LangRef.html#mul-instruction">mul</a> i32 2, 4</pre>
<p>Now it works backwards through the tree. So the next item is the implicit cast, which has to cast the value that was calculated in the previous command:</p>
<pre>%2 = <a href="https://llvm.org/docs/LangRef.html#sitofp-to-instruction">sitofp</a> i32 %1 to double</pre>
<p>The <a href="https://llvm.org/docs/LangRef.html#sitofp-to-instruction">sitofp</a> IR command means &#8220;Signed Integer to Floating Point&#8221;.</p>
<p>Continuing up the tree, the binary operator is next, so it can now grab the left hand-side value to apply to the right-hand side value. This is the IR to add the values:</p>
<pre>%3 = <a href="https://llvm.org/docs/LangRef.html#fadd-instruction">fadd</a> double 3.14, %2</pre>
<p>The <a href="https://llvm.org/docs/LangRef.html#fadd-instruction">fadd</a> IR command means &#8220;floating point add&#8221;.</p>
<p>And continuing up the tree, the implicit cast is next:</p>
<pre>%4 = <a href="https://llvm.org/docs/LangRef.html#fptosi-to-instruction">fptosi</a> double %3 to i32</pre>
<p>The <a href="https://llvm.org/docs/LangRef.html#fptosi-to-instruction">fptosi</a> IR command means &#8220;floating point to signed integer&#8221;.</p>
<p>Lastly, we reach the actual assignment (<a href="https://llvm.org/docs/LangRef.html#store-instruction">store</a>) with IR that looks like this:</p>
<pre><a href="https://llvm.org/docs/LangRef.html#store-instruction">store</a> i32 %4, i32* @sum</pre>
<p>Here is the complete IR that gets generated:</p>
<pre>%1 = mul i32 2, 4
%2 = sitofp i32 %1 to double
%3 = fadd double 3.14, %2
%4 = fptosi double %3 to i32
store i32 %4, i32* @sum</pre>
<p>Reading through this you should now understand why no one wants to manually write code at such a low-level.</p>
<p>This is the last part of the compiler that is considered to be part of the front end. The rest of the compiler components belong to the <a href="https://blog.xojo.com/2018/01/29/compilers-105-back-end-overview/">back end</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Xojo and Community Growth in 2017</title>
		<link>https://blog.xojo.com/2017/12/11/xojo-and-community-growth-in-2017/</link>
		
		<dc:creator><![CDATA[Alyssa Foley]]></dc:creator>
		<pubDate>Mon, 11 Dec 2017 08:00:07 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[XDC]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3611</guid>

					<description><![CDATA[2017 has been a good year for Xojo! We hit some bumps but we&#8217;re ending the year with the much-awaited Xojo 64-bit IDE released in Xojo&#8230;]]></description>
										<content:encoded><![CDATA[<div>2017 has been a good year for Xojo! We hit some bumps but we&#8217;re ending the year with the much-awaited Xojo 64-bit IDE released in <a href="https://www.xojo.com/download/">Xojo 2017r3</a>.</div>
<div></div>
<div>Though we didn&#8217;t have a XDC in 2017, we&#8217;re gearing up for <a href="https://www.xojo.com/xdc/">XDC 2018 in Denver</a> in April. This is the longest between conferences in many years and we&#8217;re seeing an increase in early registrations. If you are planning on attending, please register soon. We have sold out before!</div>
<p><span id="more-3611"></span></p>
<div>Some highlights from the Xojo Blog in 2017:</div>
<ul>
<li>Growing? Read how one Xojo user took his app from <a href="https://blog.xojo.com/2017/04/25/taking-your-app-from-in-house-to-commercial/">in-house to commercial</a>,</li>
<li>Transitioning Windows Graphics: <a href="https://blog.xojo.com/2017/04/12/windows-graphics-direct2ddirectwrite-direction/">Direct2D/DirectWrite</a>,</li>
<li><a href="http://blog.xojo.com/2017/03/28/raspberry-pi-remote-debugging/">Remote Debugger for Raspberry Pi</a> and the <a href="https://blog.xojo.com/2017/04/12/windows-graphics-direct2ddirectwrite-direction/">Programming with Raspberry Pi Book</a>,</li>
<li>Check out our highly popular <a href="https://jsonfeed.org">JSON Feed</a> blog post series for <a href="https://blog.xojo.com/2017/05/31/json-feed-ios-app/">iOS</a>, <a href="https://blog.xojo.com/2017/05/30/json-feed-web-app/">web</a> and <a href="https://blog.xojo.com/2017/06/01/json-feed-desktop-app/">Desktop</a>,</li>
<li>We updated Xojo&#8217;s Linux Desktop framework to <a href="https://blog.xojo.com/2017/08/15/goodbye-gtk-2-hello-gtk-3/">GTK3</a> and HiDPI,</li>
<li>Whatever happens, Xojo has your back if <a href="https://blog.xojo.com/2017/09/29/what-it-means-for-your-xojo-projects-if-mac-goes-arm/">Mac goes ARM</a>, and</li>
<li>Jump into our ongoing Compiler blog post series: <a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">LLVM Everywhere</a>, <a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compiler 101 &#8211; Overview and Lexer</a>, and <a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Compilers 102 &#8211; Parser</a>.</li>
</ul>
<p>A special mention on the topic of Net Neutrality in the US. Geoff has <a href="https://blog.xojo.com/2017/12/01/the-last-mile-why-net-neutrality-is-a-must/">shared his point of view</a> and we hope you make your voice heard to the <a href="https://www.fcc.gov/ecfs/filings/express">FCC</a> before December 14th. This is an issue that effects us all.</p>
<p>The Xojo community continues to grow with developers switching from VB, emerging citizen developers and small businesses all discovering what they can with Xojo. In the last 12 months the <a href="https://forum.xojo.com">Xojo Forum</a> has welcomed 1,688 new forum members and 60,772 forum posts.</p>
<p>Our blog post from back in June, <a href="https://blog.xojo.com/2017/06/21/daring-to-defy-software-extinction-a-limited-history/">Daring to Defy Software Extinction</a> sums up Xojo and Dev Tool history with some perspective. We&#8217;re proud of what we, along with the Xojo Community, have built over the past 21 years and we look forward to 2018 &#8211; Android support, I&#8217;m looking at you!</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-3010" src="https://blog.xojo.com/wp-content/uploads/2017/06/Ltd-History-of-Dev-Tools-Info-Graphic.png" alt="" width="800" height="2000" /></p>
<p>From everyone at Xojo, thank you for your continued support. This community is truly one-of-a-kind and we look forward to all that 2018 has in store!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 102 &#8211; Parser</title>
		<link>https://blog.xojo.com/2017/12/08/compilers-102-parser/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Fri, 08 Dec 2017 10:17:39 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2800</guid>

					<description><![CDATA[At XDC 2016 there was a lot of interest in our Compiler session and LLVM. I’ve summarized a bit about LLVM in an earlier post, but to&#8230;]]></description>
										<content:encoded><![CDATA[<p>At <a href="https://xojo.com/xdc/">XDC</a> 2016 there was a lot of interest in our <a href="https://www.xojo.com/store/#conference">Compiler session</a> and <a href="https://llvm.org">LLVM</a>. I’ve summarized a bit about LLVM in an <a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">earlier post</a>, but to take things further, we put together this series of blog posts on compilers.</p>
<p>These will all be at a high-level. None of these posts are going to teach you how to write a compiler. The goal of these posts is for you to have a basic understanding of the components of a compiler and how they all work together to create a native app.</p>
<p>This is the second post in our ongoing series on compilers. I recommend that you first read <a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a> before continuing.</p>
<p><span id="more-2800"></span></p>
<p>After the Lexer has converted your source code to tokens, it sends them to the Parser. The job of the Parser is to turn these tokens into abstract syntax trees, which are representations of the source code and its meaning.</p>
<p>For reference, this is the simple source code we are “compiling”as we go through the parts of the compiler:</p>
<pre>sum = 3.14 + 2 * 4</pre>
<p>The lexer has converted this to a stream of tokens which are now sent to the Parser to process. The tokens are:</p>
<ol>
<li>Type: identifier
<ol>
<li>value: sum</li>
<li>start: 0</li>
<li>length: 3</li>
</ol>
</li>
<li>Type: equals or assigns
<ol>
<li>value: n/a</li>
<li>start: 4</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: double
<ol>
<li> value: 3.14</li>
<li> start: 6</li>
<li>length: 4</li>
</ol>
</li>
<li>Type: plus
<ol>
<li>value: n/a</li>
<li>start: 11</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: integer
<ol>
<li>value: 2</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: multiply
<ol>
<li>value: n/a</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Type: integer
<ol>
<li>value: 4</li>
<li>start: 17</li>
<li>length: 1</li>
</ol>
</li>
</ol>
<h2>Parser</h2>
<p>To see how this works, we’ll go through the tokens and create the syntax tree.</p>
<p>The first token is the identifier, which the parser knows is actually a variable. So it becomes the first node of the tree:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2803" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-30-1.png" alt="" width="200" height="51" /></p>
<p>The next token is equals or assigns. The parser knows things about this such as that it is an assignment and that assignment is a binary operator that has two operands, one on the left and one on the right. The variable from above is the left value, so it gets moved to the left side of the Assignment node that is now added to the tree to look like this:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2804" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-30.png" alt="" width="300" height="115" /></p>
<p>Continuing, the double token is next with value 3.14. This is the right value for the assignment:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2806" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-31.png" alt="" width="400" height="114" /></p>
<p>Moving along, the plus token is next. The parser knows this is the addition operator (BinaryOperator+) that takes two values (and is also left associative). This means that the addition is added to the tree with the double as its left value:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2808" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-32.png" alt="" width="400" height="177" /></p>
<p>After the plus token, an integer is next and this becomes the right value for the BinaryOperator+ node:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2809" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-33.png" alt="" width="500" height="178" /></p>
<p>Next is the multiply token, another binary operator that is left associative. So it gets the integer as its left value:</p>
<p>￼<img loading="lazy" decoding="async" class="alignnone wp-image-2810" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_09-42-34.png" alt="" width="500" height="241" /></p>
<p>The last token is another integer which becomes the right value for the multiplication:</p>
<p><img loading="lazy" decoding="async" class="alignnone wp-image-2811" src="https://blog.xojo.com/wp-content/uploads/2017/05/2017-05-17_14-33-23.png" alt="" width="600" height="241" /></p>
<p>And that is the final abstract syntax tree for our simple line of code. The Parser has done its work and has now created a tree that no longer represents the exact source code but is an idealized representation of what the user wrote.</p>
<p>This tree is then provided to the next component, the <a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Semantic Analyzer</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Compilers 101 &#8211; Overview and Lexer</title>
		<link>https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Wed, 06 Dec 2017 09:00:46 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LEXER]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2776</guid>

					<description><![CDATA[High-level posts with the goal giving you a basic understanding of the components of a compiler and how they all work together to create a native app.]]></description>
										<content:encoded><![CDATA[<p>At <a href="https://xojo.com/xdc/">XDC</a> 2016 there was a lot of interest in our <a href="https://www.xojo.com/store/#conference">Compiler session</a> and <a href="https://llvm.org">LLVM</a>. I’ve summarized a bit about LLVM in an <a href="https://blog.xojo.com/2017/12/04/llvm-everywhere/">earlier post</a>, but to take things further, we put together this series of blog posts on compilers.</p>
<p>These will all be at a high-level. None of these posts are going to teach you how to write a compiler. The goal of these posts is for you to have a basic understanding of the components of a compiler and how they all work together to create a native app.</p>
<p><span id="more-2776"></span></p>
<h2>Compiler Components</h2>
<p>A compiler is a complicated thing and consists of many components. In general the compiler is divided into two major parts: the front end and the back end. In turn, those two parts have their own components.</p>
<p>For the purposes of these posts, this is how we will be covering the components of the compiler:</p>
<h3>Front End</h3>
<p>The front end is responsible for taking the source code and converting it to a format that the back end can then use to generate binary code that can run on the target CPU architecture. The front end has these components:</p>
<ul>
<li>Lexer</li>
<li><a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Parser</a></li>
<li><a href="https://blog.xojo.com/2018/01/22/compilers-103-semantic-analyzer/">Semantic Analyzer</a></li>
<li><a href="https://blog.xojo.com/2018/01/24/compilers-104-ir-generation/">IR (intermediate representation) Generator</a></li>
</ul>
<h3>Back End</h3>
<p>The back end takes the IR, optionally optimizes it and then generates a binary (machine code) file that can be run on the target CPU architecture. These are the components of the back end:</p>
<ul>
<li><a href="https://blog.xojo.com/2018/01/31/compilers-106-optimizer/">Optimizer</a></li>
<li><a href="https://blog.xojo.com/2018/03/26/compilers-108-code-generation/">Code Generation</a></li>
<li><a href="https://blog.xojo.com/2018/04/02/compilers-109-linking-and-wrap-up/">Linker</a></li>
</ul>
<p>Each of these steps processes things to get it a little further along for the next step to handle.</p>
<p>The linker is not technically part of the compiler but is often considered part of the compile process.</p>
<h2>Lexer</h2>
<p>The lexer turns source code into a stream of tokens. This term is actually a shortened version of “<a href="https://en.wikipedia.org/wiki/Lexical_analysis">lexical analysis</a>”. A token is essentially a representation of each item in the code at a simple level.</p>
<p>By way of example, here is a line of source code that does a simple calculation:</p>
<pre>sum = 3.14 + 2 * 4</pre>
<p>To see how a lexer works, let’s walk through how it would tokenize the above calculation, scanning it from left-to-right and tracking its type, value and position in the source code (which helps with more precise reporting of errors):</p>
<ol>
<li>The first token it finds is “sum”
<ol>
<li>type: identifier</li>
<li>value: sum</li>
<li>start: 0</li>
<li>length: 3</li>
</ol>
</li>
<li>Token: =
<ol>
<li>type: equals or assigns</li>
<li>value: n/a</li>
<li>start: 4</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: 3.14
<ol>
<li>type: double</li>
<li> value: 3.14</li>
<li> start: 6</li>
<li>length: 4</li>
</ol>
</li>
<li>Token: +
<ol>
<li>type: plus</li>
<li>value: n/a</li>
<li>start: 11</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: 2
<ol>
<li>type: integer</li>
<li>value: 2</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: *
<ol>
<li>type: multiply</li>
<li>value: n/a</li>
<li>start: 15</li>
<li>length: 1</li>
</ol>
</li>
<li>Token: 4
<ol>
<li>type: integer</li>
<li>value: 4</li>
<li>start: 17</li>
<li>length: 1</li>
</ol>
</li>
</ol>
<p>As you can see, white space and comments are ignored. So after processing that single line of code there are 7 tokens that are handed off to the next part of the compiler, which is the Parser. The <a href="https://blog.xojo.com/2017/12/08/compilers-102-parser/">Parser</a> is covered in the next post. Stay tuned!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>LLVM Everywhere</title>
		<link>https://blog.xojo.com/2017/12/04/llvm-everywhere/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Mon, 04 Dec 2017 09:00:07 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2757</guid>

					<description><![CDATA[Some of the most recent new features added to Xojo, including iOS, 64-bit apps, and Raspberry Pi have been made possible by LLVM. Read on to learn more about it. In effect, LLVM enables us to better support the unknown future, including new and updated architectures. One such example is 64-bit ARM Linux, which will likely become necessary at some point.]]></description>
										<content:encoded><![CDATA[<p>Some of the most recent features added to Xojo, including iOS, 64-bit apps, and Raspberry Pi have been made possible by LLVM. Read on to learn more about it.</p>
<p><span id="more-2757"></span></p>
<h2>What is LLVM?</h2>
<p>On a high-level, LLVM is a collection of libraries and tools for building compilers. The LLVM project was started in the early 2000s by Chris Lattner (who eventually went to work at Apple and has now moved on to Tesla) and remains in active development. Because LLVM is a toolkit for building compilers and because it can target most CPU architectures, its use has become much more prominent in recent years. It has widespread industry backing with support from major companies including AMD, Apple, ARM, IBM, Intel, Google, Mozilla, Nvidia, Qualcomm, Sony, Samsung.<img loading="lazy" decoding="async" class="alignright wp-image-2762" src="https://blog.xojo.com/wp-content/uploads/2017/05/LLVM_Logo.png" alt="" width="256" height="193" /></p>
<p>The first appearance of LLVM in Xojo was when we started using it to compile and run XojoScript code (2010). Later we used LLVM to build iOS apps (2014), 64-bit apps for x86 (Windows, MacOS, Linux) and 32-bit apps for Raspberry Pi (2015), and most recently we’ve hooked up the Xojo debugger so it works with apps built using LLVM (2016).</p>
<p>In addition to now being used as part of Xojo’s compiler, LLVM is also used with other languages, including: Clang, D, Rust, OpenCL, and Swift.</p>
<h2>Why is Xojo using LLVM?</h2>
<p>First, a little background. A compiler consists of many things and is typically split into parts called the “front end” and the “back end”. LLVM has components for both front ends and back ends; Xojo uses it as a back end.</p>
<p>For 32-bit x86 apps, Xojo uses its own in-house, proprietary compiler first created in 2004/2005. This powerful and fast compiler handles the front end and back end, but it does have a couple limitations: it can only target 32-bit x86 and it does not do any optimizations.</p>
<p>But technology marches on and we knew we would eventually have to add support for x86-64 (64-bit) and ARM CPU architectures. Updating a compiler is a large undertaking, but fortunately the LLVM compiler toolkit started gaining traction in the industry and became a better alternative to creating our own x86-64 and ARM compiler back ends.</p>
<p>Today when you build an iOS app, a 64-bit app for Windows, MacOS or Linux, or an ARM app for Raspberry Pi you are using LLVM as the back end to generate your native, binary code.</p>
<p>By using LLVM, we are able to respond more quickly to changes in the industry and to add features our users want. As an example, we were able to rapidly add Raspberry Pi support (32-bit ARM Linux) by leveraging much LLVM work that had already been done for x86-64 and ARM for iOS.</p>
<p>As Joe Ranieri (the Xojo compiler guru) likes to say “Every single line of code [you write] is a liability and not an asset”. With LLVM we can implement more features in less time because we don’t have to recreate the wheel, so to speak.</p>
<p>In effect, LLVM enables us to better support the unknown future, including new and updated architectures. One such example is 64-bit ARM Linux, which will likely become necessary at some point.</p>
<h2>Learn More</h2>
<p>LLVM is great. We love it and are thrilled that it has allowed us to add significant capabilities to Xojo for you. A compiler is a complicated thing and we are pleased that Xojo hides the complexity of compiler technology so that you don&#8217;t have to worry about it. You just need to focus on making the best app you can, select your OS target, click build and let Xojo take care of the rest.</p>
<p>If this post has made you curious about LLVM and you&#8217;d like to learn more, I recommend the following:</p>
<ul>
<li><a href="https://en.wikipedia.org/wiki/LLVM">Wikipedia: LLVM</a></li>
<li><a href="http://llvm.org">LLVM official site</a></li>
<li><a href="http://atp.fm/205-chris-lattner-interview-transcript/">Accidental Tech Podcast: Interview with Chris Lattner</a>, creator of LLVM</li>
<li><a href="https://www.xojo.com/store/#conference">Joe Ranieri’s Compiler Session from XDC 2016</a></li>
</ul>
<p>More on our Compiler Series: <a href="https://blog.xojo.com/2017/12/06/compilers-101-overview-and-lexer/">Compilers 101 &#8211; Overview and Lexer</a></p>
<p>Download a PDF of the full Compiler series: <a href="http://files.xojo.com/Documentation/Xojo%20LLVM%20Everywhere.pdf">LLVM Everywhere</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What it means for your Xojo projects if Mac goes ARM</title>
		<link>https://blog.xojo.com/2017/09/29/what-it-means-for-your-xojo-projects-if-mac-goes-arm/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Fri, 29 Sep 2017 22:01:32 +0000</pubDate>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=3445</guid>

					<description><![CDATA[I've speculated for some time now that Apple might decide to start putting their own ARM-based processors in Mac desktop and laptop computers. If they did, it would not be a significant amount of work for Xojo and really no work for you at all except recompiling your projects.]]></description>
										<content:encoded><![CDATA[<p>I&#8217;ve speculated for some time now that Apple might decide to start putting their own ARM-based processors in Mac desktop and laptop computers. Apparently, I&#8217;m not <a href="https://www.macrumors.com/2017/09/29/apple-interested-processors-modems/">alone</a> in thinking this. It makes a lot of sense. Apple&#8217;s big advantage is being in control of all of the important aspects of their product lines and the processor is both figuratively and physically at the center of their products.</p>
<p><span id="more-3445"></span></p>
<p>So what if they did? Say next year at WWDC Apple announced that they were planning to move to ARM-based Macs. How would that affect you as a Xojo developer? As it turns out, not much because Xojo abstracts and shields you from those sorts of platform changes. For example, since 2003 our compiler has been a modern, two-pass compiler. The first pass converts Xojo code into a sort of meta-assembly code. The second pass does a nearly straight translation from this meta-assembly code to the machine code for the processor being targeted (x86 for example or ARM for iPhone and Raspberry Pi). Had Apple made this change years ago, it would have required us to spend the time to create a new backend for ARM. However, as you may know, we have been transitioning the backend of our compiler to the open source LLVM compiler, the same one that Apple provides with Xcode. That&#8217;s how we support ARM (and 64 bit) today. Should Apple announce they are switching to their own ARM-based processors for future Macs, we could relatively easily recompile the Xojo desktop frameworks for ARM and provide that as a new build option. It would not be a significant amount of work for us and really no work for you at all except recompiling your projects.</p>
<p>This is true for other platforms as well. Incidentally, we have already been through this before. Xojo originally supported both the 68000 and PowerPC processors. When Apple switched to the x86, we switched too and Xojo users had little to do but recompile their projects.</p>
<p>This is part of the value you get from Xojo: be mostly insulated from these kinds of changes.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Best-Laid Plans: 64-bit Windows Debugging</title>
		<link>https://blog.xojo.com/2017/07/26/the-best-laid-plans-64-windows-debugging/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Wed, 26 Jul 2017 16:20:32 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[64-bit]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[LLVM]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=3157</guid>

					<description><![CDATA[In his poem, &#8220;The Mouse&#8221;, Robert Burns wrote: The best-laid plans of mice and men oft go astray&#8230; As Burns so eloquently stated, no matter&#8230;]]></description>
										<content:encoded><![CDATA[<p>In his poem, &#8220;The Mouse&#8221;, Robert Burns wrote:</p>
<blockquote><p>The best-laid plans of mice and men oft go astray&#8230;</p></blockquote>
<p>As Burns so eloquently stated, no matter how carefully you plan sometimes things just don&#8217;t work out. Anyone who has done software development for long knows this all too well.</p>
<p><span id="more-3157"></span></p>
<p>While Xojo already has 64-bit debugging for macOS and Linux, we had planned to include 64-bit debugging for Windows in 2017 Release 2 which will be shipping next month. As you may know, we rely on the open source LLVM compiler and toolchain for our 64-bit support. This provides huge advantages for us and you with features like 64-bit, ARM and performance optimizing, all with a lot less work compared to providing the entire compiler toolchain ourselves. The downside is that we are now dependent upon the LLVM project. While the LLVM team has been making fast progress, Windows debugging is not quite ready. We are confident it will be ready soon but there&#8217;s so much great stuff in Xojo 2017r2, we don&#8217;t want to delay it any longer.</p>
<p>If you have an active Xojo Pro license, you can test all the great new stuff coming in 2017r2 now (64-bit XojoScript, Windows Resource Compiler, and more). If you don&#8217;t have Xojo Pro but would still like to contribute to testing Xojo releases before they ship, go <a href="https://forum.xojo.com/38207-welcoming-more-pre-release-testers">here</a> to find out more.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Where is 64-Bit Debugging for Windows?</title>
		<link>https://blog.xojo.com/2017/03/28/where-is-64-bit-debugging-for-windows/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Tue, 28 Mar 2017 19:30:22 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[Debugging]]></category>
		<category><![CDATA[LLVM]]></category>
		<category><![CDATA[Machine Code]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2522</guid>

					<description><![CDATA[Xojo 2017 Release 1 includes support for running and debugging 64-bit apps right from the IDE for macOS and Linux. Windows support is noticeably absent because we have been moving Xojo from our own compiler back end to using LLVM.]]></description>
										<content:encoded><![CDATA[<p><a href="http://developer.xojo.com/2017r1-release-notes">Xojo 2017 Release 1</a> includes support for running and debugging 64-bit apps right from the IDE for macOS and Linux. Windows support is noticeably absent. Why? The answer is a bit complicated but interesting.</p>
<p><span id="more-2522"></span></p>
<p>As you may know, Xojo&#8217;s compiler takes the code you write and translates it into a sort of meta-assembly language. Think of it as assembly code that is not specific to any particular processor. This part of the compiler is called the <em>Front End</em>. The <em>Back End</em> of the compiler takes that meta-assembly code and translates it into actual machine code for a particular processor such as x86 or ARM. We have been moving Xojo from our own compiler Back End to using an open source one known as <em>LLVM</em> which is used by Apple and others as well. It&#8217;s how we are building for 64-bit and it optimizes your code for speed, something our old compiler Back End did not do.</p>
<p>We depend on LLVM to provide us with the data we need to make debugging work. LLVM version 3.7 had the necessary support for macOS and Linux. LLVM version 4 has added this for Windows but it was released only a few weeks ago, not enough time for us to get it working for today&#8217;s release of Xojo 2017 Release 1. Although you don&#8217;t directly see LLVM when you use Xojo, it&#8217;s doing significant and important work. Switching from one major release of LLVM to another affects far more than just debugging so it must be done very early in our development of a release of Xojo. It&#8217;s likely that 64-bit debugging support for Windows will be available in Xojo 2017 Release 2.</p>
<p>64-bit support in Xojo may seem like a minor feature. After all, for most of you, switching from 32 to 64-bit is a single-click operation. However, for it to be that simple has required a huge amount of effort on our part. While you can still get by with 32-bit apps in most cases today, that won&#8217;t be true in the not-too-distant future. That&#8217;s why it&#8217;s critical we make it easy for you to switch. The importance of Xojo supporting 64-bit really can&#8217;t be overstated.</p>
<p>Remember that many features in Xojo take multiple release cycles to complete. That means that when the feature list is short, there&#8217;s working going on for future releases. When it&#8217;s long, much of that work may have been done during previous release cycles. It&#8217;s a curious fact of software development that sometimes features that seem simple on the outside are actually large and complex on the inside.</p>
<p>There&#8217;s a lot more coming for Xojo in 2017 so stay tuned.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
