<?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>The Developer's Blog</title>
	<atom:link href="http://www.coolbasic.com/blog/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.coolbasic.com/blog</link>
	<description>Game making should be easy for everyone!</description>
	<lastBuildDate>Tue, 19 Jul 2011 13:32:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Compiler news</title>
		<link>http://www.coolbasic.com/blog/?p=361</link>
		<comments>http://www.coolbasic.com/blog/?p=361#comments</comments>
		<pubDate>Tue, 19 Jul 2011 13:31:31 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[CoolBasic Classic]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=361</guid>
		<description><![CDATA[1,900 word wall-of-text incoming… I returned to CoolBasic project after three months of learning XNA 3D game programming, and have been continuing to develop the CoolBasic Classic compiler for the last two weeks. Although the main focus has been with the compiler I also designed a new look &#038; feel for the web portal, and [...]]]></description>
			<content:encoded><![CDATA[<p>1,900 word wall-of-text incoming…</p>
<p>I returned to CoolBasic project after three months of learning XNA 3D game programming, and have been continuing to develop the CoolBasic Classic compiler for the last two weeks. Although the main focus has been with the compiler I also designed a new look &#038; feel for the web portal, and it’s being reviewed by the rest of the Team. This entry, however, will be all about the compiler and what’s been done recently.</p>
<p>Can it produce byte code yet? Yes, to some extent. The underlying mechanics are in place, but nothing is written to any file yet. Basically, it can process expressions. This includes (but is not limited to) calculating the result value of a constant expression, resolving names (i.e. mapping the identifier names to their declared symbols), function overload resolution, automatic type conversions, and filling in the missing arguments for optional function parameters. A lot of thought has been put to optimize performance here. In fact, all those things mentioned above are done in a single iteration over the postfix presentation of the expression. I had to inspect how the .NET framework internally works with arrays, stacks, lists, and type conversion to make sure my algorithms were efficient enough. I actually ended up writing a few own implementations for those highly specialized cases I needed (where the framework equivalent would allocate memory in an inefficient way or do more work than needed, for example).</p>
<p>I’m about to go technical…</p>
<p><strong>Expression pre-evaluation</strong><br />
Where I left off before my XNA experimentations, was the constant expression pre-evaluation. This is when the actual expression processor needs to be implemented. You first convert the expression into postfix notation and then evaluate it. Naturally constant expressions can contain constant symbols as well, so a circular reference safety check exists. Identifier names are resolved during evaluation because we need to know the data type of each value in order to determine the final data type and the ultimate value in case of a constant expression. </p>
<p>The expression processor is a single method any statement or symbol processor can call. Therefore we don’t know whether the expression is a constant expression or not (i.e. whether its value can be fully pre-calculated). When a symbol is encountered the first time, it will be “processed” (as in a constant symbol’s value needs to be known before it can be used in other expressions). Since the expression processor can be called by a function symbol’s own processor, in order to pre-evaluate optional parameters’ values, a circular reference safety check must exist for functions as well.</p>
<p>The constant symbol and parameter symbol processors simply check whether the result value was a constant and give an error if it isn’t. In addition, before the pre-evaluated value is assigned to a constant symbol or parameter symbol, it’s converted to the destination data type. I had to write my own optimized routines for this because the .NET framework is clearly a bit too slow with anything<-->string. And I learned how much pain in the ass it can be to convert a double value to string (just have a look at <a href="http://www.koders.com/c/fid706CF8D256007C8D684E51FC4D35912168B034FB.aspx" title="dtoa.c reference">dtoa.c</a> to get the idea) – I ended up implementing a much simpler algorithm for that conversion.</p>
<p>Even though constant value expressions are fully pre-calculated, I plan to add an expression simplifier for non-constant expressions as well in the future. It would basically turn expressions like <code>a+b+2*20-c</code> into <code>a+b-c+40</code>. However, this is a very difficult topic that will need much research in terms of grouping and ordering analysis, and I simply don’t want to be held back because of it (even though I have a partial implementation of it in the V3 compiler already). I don’t see it that important at the moment (in order to get this thing out someday I’ll leave it for now).</p>
<p><strong>Name resolution</strong><br />
The expression is processed once token by token. Each encountered identifier is resolved by its name. This process is called name resolution. I have three special resolvers: Type resolver, Symbol resolver, and Overload resolver. The type resolver is called by a symbol processor (each symbol is validated by its own processor). A symbol processor exists for all symbol types. Most symbol processors resolve the associated data type, but some do additional work such as constant symbol processor who calls the expression processor in order to cache the pre-calculated value. The type resolver is the simplest one: since all type symbols must be declared in the root scope we can direct the search to that to begin with, and also only look for symbols classified as Type.</p>
<p>The identifier resolver is a tad more complex. It is told the context symbol and/or scope and whether the search should be locked to that context only or should it also be extended to upper levels if the name is not found immediately (one example of a locked context would be the dot notation path “<code>a.b.c</code>”). Unlocked search is recursive. In CoolBasic Classic, the main program exists in root scope, but it is not the root symbol; the Global symbol is the ultimate root node of the symbol tree, and all imported framework/engine functions such as <code>LoadImage</code> or <code>MoveObject</code> exist there. This means that you can override them by defining your own functions with the same name. The reason we tell the resolver both the context symbol and scope is that, for example, functions’ parameters don’t have scope during optional expression evaluation. In order to access constant symbols defined in the main program’s context, the search needs to get one symbol level up instead of scope level. Furthermore, functions’ local scopes are isolated from the main program (for obvious reasons), and local identifier, a variable or constant, name resolution cannot therefore access the main program’s base scope’s local variables and constants.</p>
<p>The overload resolution is an interesting one. First of all, name resolution has already succeeded on a function group symbol. Yes, we now have an extra container for all functions of the same name. It stores all overloads of that function. All we need to do is to pick the right overload and map the identifier to its symbol. So we pass a snapshot of the calculation stack to the overload resolver, and based on the data types of those values, the most appropriate overload is chosen. This means that you could have two functions of the same name, say <code>Abs</code> (like ‘absolute value’) that takes and returns an integer, and one that takes and returns a float. The compiler would then pick the right one based on the context in the expression, avoiding unnecessary casting and loss of precision due to choosing the wrong one. Should there be more than one equally qualified overload candidates, an error is generated. Should there be no qualified overloads at all, an error is also generated.</p>
<p><strong>Completing expressions</strong><br />
Now what’s really new here is the injection system. It allows the addition of tokens in the middle of the token list without causing “memory move” operations like <code>List<T>.Insert()</code> does (and yet we’re not operating with a linked list here – it’s not efficient enough in .NET, and I want to avoid the memory overhead generated by it). Omitted arguments for those function parameters classified as “optional” are a good example of injected tokens. But the feature also has one other very important use, for we’re also injecting type conversion tokens. This works with intrinsic data types (integer, float and string). Whenever a value of the wrong type is provided, CoolBasic Classic will try to convert the value to the correct destination type. For example, if you provide array indices as floats, they’ll be automatically converted to integers. Similarly, the function overload resolver tells back which values need to be converted and to which intrinsic data type.</p>
<p>We’ll probably be adding explicit type conversion operators to the language at some point as well; we’re just not sure about their naming yet. Just don’t be disappointed if you don’t see them in the first alpha or beta.</p>
<p>Another cool feature I’ve mentioned before is the presence of short-circuit <code>And</code> and <code>Or</code> operators. They are now fully implemented. They’re different from other operators in that while pre-calculation occurs in the same way as processing any binary operator in a postfix calculation stack, they actually produce byte code with conditional jumps instead of a single operator instruction. The hardest part was to infer the offset of the jump because type conversion instructions as well as loading omitted optional parameters to the instructions list occurs all the time (so that the offset cannot be determined during the conversion from infix to postfix). However, I came up with a clever mechanic that allows the reliable offset calculation without having to give up the idea of a single processing pass.</p>
<p><strong>Byte code generation</strong><br />
I mentioned at the start of this blog post that I’m already able to produce byte code that would calculate the expression’s value in real Cool VES environment. A lot of different small parts had to be implemented before this goal was reached, but I think it’s now working quite well. The expression processor, in addition to calculating the result value, generates the full instruction set, including conversion instructions, short-circuit magic, and injected parameters.</p>
<p>One particularly tricky part was to implement dot notation path processing. While simple paths such as “<code>a.b.c</code>” are quite easy to pull off (just lock the name resolution context to the data type of the previous member’s value), it gets a little more complicated when assignment and arrays come in to play. I hate “exceptions to processing rules” so I had to come up with a unified model that just supports normal values, dot fields, dot array fields, and normal arrays. Array variables are always pointers to their actual buffers, but the value indicated by the index (or indices) on top of stack must be read by another instruction. And since context must be locked for the name resolution to succeed, unlike functions, the array field loader instruction cannot occur after argument values (and you cannot access elements not on top of stack which I could’ve done by creating my own custom stack structure, but it’d still be fundamentally wrong thing to do). So for an array access you need two instructions; one before and one after the arguments. Just like how C# and VB.NET compilers do it. It works now. Actually, byte code generated by CoolBasic Classic compiler is VERY similar to Microsoft CIL (Common Intermediate Language) generated by .NET compilers. For example, there’s no single instruction for operator “<code><=</code>”, but it’s expressed with the combination of <code>cgt</code>, <code>ldc.i4 0</code> and <code>ceq</code> instead – i.e. “not greater”.</p>
<p>Still few operators lack implementation of pre-evaluation support, but those should be painless to write in no time. One of these is the assignment operator (that again is a bit of a “different” case from the others), but perhaps I’ll get into that in the next blog post. Now this huge central piece is mainly done, the next big goal is to start iterating actual statements like If, While, For etc. Pretty much <em>branching</em> in general.</p>
<p>TL;DR<br />
Expressions are now processed, and refined into real byte code that can execute on Cool VES platform. The next phase would be to process all statements, and with the help of the expression processor, create the final byte code output we can execute!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=361</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiler part 1/2 is done</title>
		<link>http://www.coolbasic.com/blog/?p=353</link>
		<comments>http://www.coolbasic.com/blog/?p=353#comments</comments>
		<pubDate>Sat, 12 Mar 2011 19:32:15 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[CoolBasic Classic]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=353</guid>
		<description><![CDATA[One another big part of the CoolBasic Classic Compiler is now complete. The CB classic compiler is a standard 2-pass compiler, meaning that it consists of two major sweeps over the code in its transformation from textual representation into a byte code (the binary form is then consumed by the Cool VES runtime and game [...]]]></description>
			<content:encoded><![CDATA[<p>One another big part of the CoolBasic Classic Compiler is now complete. The CB classic compiler is a standard 2-pass compiler, meaning that it consists of two major sweeps over the code in its transformation from textual representation into a byte code (the binary form is then consumed by the Cool VES runtime and game engine). There&#8217;s but one purpose for the first pass; It parses all code lines and creates lists of symbols, like functions and variables. It also picks all tokens that form expressions. Expressions are used in statements such as If, While, and assignment. We chose the 2-pass approach so that, for example, functions don&#8217;t need to be declared &#8220;above&#8221; any statements that use them. The first pass is thus essentially a gathering phase, and that is now complete. The current status is illustrated in the image below:</p>
<p><img src="http://www.coolbasic.com/common/images/archives/2011/03/cb_csharp_compiler_status_20110309.png" alt="CoolBasic Classic Compiler - status 3/2011" /></p>
<p><strong>Green:</strong> done<br />
<strong>Yellow:</strong> in the progress</p>
<p>Personally speaking, writing parsers for 40 different kinds of statements was a little repetitive and mechanical work (yes, we use specialized parsers instead of a state table and stack), but the boring part is now done. I&#8217;d say we&#8217;re definitely getting somewhere here. There are already 20,431 lines of C# code in 270 files, so the compiler project alone is pretty huge.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=353</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CB Comic #4</title>
		<link>http://www.coolbasic.com/blog/?p=349</link>
		<comments>http://www.coolbasic.com/blog/?p=349#comments</comments>
		<pubDate>Wed, 09 Mar 2011 16:50:32 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Comic]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=349</guid>
		<description><![CDATA[Introducing KilledWhale (the smartass).]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.coolbasic.com/common/images/cbcomic/cbcomic004.jpg" alt="CB Comic #4" /></p>
<p>Introducing <strong>KilledWhale</strong> (the smartass).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=349</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Experimental file diff</title>
		<link>http://www.coolbasic.com/blog/?p=341</link>
		<comments>http://www.coolbasic.com/blog/?p=341#comments</comments>
		<pubDate>Sun, 13 Feb 2011 17:24:59 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=341</guid>
		<description><![CDATA[Before we begin, I&#8217;d like to say that the feature demonstrated herein will NOT be part of the first release of Cool Developer and CoolBasic Classic, but I&#8217;m merely playing with a cool idea instead. I&#8217;ve been interested in versioning and Source Control technologies in general lately. One part of version controlling is the ability [...]]]></description>
			<content:encoded><![CDATA[<p>Before we begin, I&#8217;d like to say that the feature demonstrated herein will <strong>NOT</strong> be part of the first release of Cool Developer and CoolBasic Classic, but I&#8217;m merely playing with a cool idea instead. </p>
<p>I&#8217;ve been interested in <em>versioning</em> and <em>Source Control</em> technologies in general lately. One part of version controlling is the ability to handle conflicts when two or more developers check out a file for editing, do their changes and then check them back in. Two simultanous check-outs will often result in a conflict within the source file, and these conflicts have to be resolved through merging. Merging means that both developers&#8217; modifications and fixes are applied to the source file, without the other&#8217;s changes getting lost in the process. Merging is one thing, but analyzing the differences is another. I decided to try out some difference tracking techniques.</p>
<p>First of all, there are number of algorithms available. Some are easier to understand than others, and some support more features (such as the ability to detect moved lines and code blocks). The most popular method I found was the <a href="http://en.wikipedia.org/wiki/Longest_common_subsequence_problem">Longest common subsequence problem</a>, and it is, in fact, used in most Version Control software. It&#8217;s a good method of producing a script that can be used to &#8220;patch&#8221; the destination file with tiny changes so that it&#8217;ll transform to that of the source file. Basically you get a set of &#8220;<em>add this to place X</em>&#8221; and &#8220;<em>remove this from place Y</em>&#8220;. Unfortunately, while this technique indeed gets the job done nicely, visualizing these kinds of changes can be confusing. When a conflict occurs, for example, determining whether the merge would break something, can be tricky.</p>
<p>In addition, due to how LCS works, comparing two very big files (10,000 lines or more) quickly starts to eat giant chunks of memory because the algorithm operates with a matrix of <code>n*m</code>, where <code>n</code> is the number of code lines within the first file, and <code>m</code> is the number of code lines within the second one. There are a number of ways how to optimize memory consuption and matrix size, but that is out of scope of this blog bost.</p>
<p>Ideally, when a developer encounters a conflict (and a merge needs to be done), he or she will be provided with two source files side-by-side; one from the server and the other is the local file. This view should visually present those parts that differ between the two versions. If the developer spots a problem that would break the code upon auto-merge, there should be a way to edit the file before committing. LCS cannot by itself provide good enough visual presentation because it can only tell insertions and deletions, but not modifications. For example, editing a single line would produce both &#8220;delete&#8221; and &#8220;addition&#8221; changesets.</p>
<p>Then I came across with this <a href="http://bramcohen.livejournal.com/73318.html">Patience Diff</a> algorithm. All in all, it would seem to fit to the purpose perfectly &#8211; it offers a very nice and clear presentation of changesets between two files and doesn&#8217;t take an awfully lot of memory either. I spent hours and hours trying to find a .NET implementation of it, but as of yet there apparently just aren&#8217;t any (the number of &#8220;good&#8221; C# implementations of the other algorithms is substantially small aswell). So I started working with a proof-of-concept. I spent a little less than 2 days on this challenge, and finally came up with a working solution. When I&#8217;m writing this, my work is the only C# implementation of the Patience Diff algorithm that I know of <img src='http://www.coolbasic.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . As a side note, there&#8217;s seemingly only one Version Control product that uses Patience Diff as its main tool, Bazaar, but apparently one can optionally enable it for Git aswell.</p>
<p>Here&#8217;s a sample of two slightly different files: the left side represents the original document, whereas the edited version is on the right:</p>
<p><a href="http://www.coolbasic.com/common/images/archives/2011/02/cb_cool_developer_experimental_diff_analysis_files_fullsize.png" title="Different files"><img src="http://www.coolbasic.com/common/images/archives/2011/02/cb_cool_developer_experimental_diff_analysis_files_resized.png" alt="Different files"/></a></p>
<p>The following difference graph can be generated from them (green = insert, red = delete, yellow = modify):</p>
<p><a href="http://www.coolbasic.com/common/images/archives/2011/02/cb_cool_developer_experimental_diff_analysis_diffview_fullsize.png" title="Difference analysis"><img src="http://www.coolbasic.com/common/images/archives/2011/02/cb_cool_developer_experimental_diff_analysis_diffview_resized.png" alt="Difference analysis"/></a></p>
<p>So what does this mean for CoolBasic? I don&#8217;t really know yet, but I have some ideas <img src='http://www.coolbasic.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=341</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compiler analysis techniques</title>
		<link>http://www.coolbasic.com/blog/?p=333</link>
		<comments>http://www.coolbasic.com/blog/?p=333#comments</comments>
		<pubDate>Mon, 31 Jan 2011 16:25:01 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[CoolBasic Classic]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=333</guid>
		<description><![CDATA[The CoolBasic Classic compiler has progressed again, and this time I&#8217;d like to share some interesting new features about its internal architecture. Using C# enables me to do certain things much more easily than the old procedural approach and the Object Oriented design really starts to kick in. The new compiler is highly structural, and [...]]]></description>
			<content:encoded><![CDATA[<p>The CoolBasic Classic compiler has progressed again, and this time I&#8217;d like to share some interesting new features about its internal architecture. Using C# enables me to do certain things much more easily than the old procedural approach and the Object Oriented design really starts to kick in. The new compiler is highly structural, and it now records much more data about declared symbols, scopes, and execution paths. This also serves as a good foundation for some code analysis techniques. For example, the compiler will emit warnings for variables, types, and functions that are declared but never used, as well as if a variable is used before it has been initialized. Warnings like these will encourage the users to write better and cleaner code. </p>
<p>The original CoolBasic has almost no optimizations regarding the generated byte code. This is now different: Constant value analysis can ignore code branches (such as If/Else) if the condition can be evaluated to True or False at compile time. Thus, redundant code will not even make it to the final compiled program. Also, since we have constant value pre-evaluation, some expressions will be simplified before conversion to byte code. This ought to improve the runtime performance. In addition, thanks to internal scope-specific dictionaries, resolving branch targets does not produce linear search to all recorded labels (user-defined or generated). This should improve compile time performance greatly for large programs.</p>
<p>We&#8217;ll see how far we end up going with code analysis in the future&#8230; I&#8217;d love to collect data such as Cyclomatic Complexity or Number of Executable Statements in order to derive a general Maintainability Index out of the given source code.</p>
<p><strong>Local scoping</strong><br />
All scopes now have their own list of local variables. This means that the user can declare variables in a code block such as If, For, or Case. These variables are allocated when the execution begins in that block and they will cease to exist after the execution exits the scope. Therefore, it is possible to declare several variables that have the same name as long as they aren&#8217;t conflicting in an enclosing block. Consider the following example:</p>
<pre>Dim a As Integer

If a = 1 Then
    Dim b As Integer = 2
    // Variable 'b' is only visible within this If block.

    // You cannot declare variable 'a' here because it is already declared
    // outside.
EndIf

If a = 1 Then
    Dim b As Integer = 3
    // Variable 'b' is visible within this If block and any child blocks.
    // Variable 'b' is different than the one declared in the previous
    // If block.

    For i As Integer = 1 To 10
        // Variable 'i' is only visible within this For block.

        // Varible 'b' is also visible here since it was declared
        // in an enclosing block.
        b = b + 1
    Next
EndIf</pre>
<p>It is also possible to declare scope specific constants in the same way. Upon entering a scope the Runtime will ensure that all of its local variables are initialized with zero. Similarly, local arrays and strings can now be freed upon leaving the scope.</p>
<p><strong>Short-circuit And/Or</strong><br />
We&#8217;ll also change the way how the Boolean <code>And</code> and <code>Or</code> operators work. They have become &#8216;short-circuit&#8217;, meaning that if the end result of the Boolean operation can be determined by just evaluating the first (left) operand, then the program will not evaluate the right half at all. Again this will improve runtime performance, but users need to pay close attention to their code if the right side has any function calls that need to be executed regardless of the end result of the Boolean operation. This is easily fixed, though, by storing the right side expression into a temporary variable first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=333</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello 2011!</title>
		<link>http://www.coolbasic.com/blog/?p=329</link>
		<comments>http://www.coolbasic.com/blog/?p=329#comments</comments>
		<pubDate>Wed, 12 Jan 2011 15:56:11 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=329</guid>
		<description><![CDATA[Okay&#8230; where to start. The year changed. Gosh, that went fast. I can remember me writing tons of stuff and assembling the DevTeam 12 months back like it was yesterday. Obviously we didn&#8217;t make it in 2010 like originally planned, but the CoolBasic Classic project continues still. Actually, I just went ahead and changed the [...]]]></description>
			<content:encoded><![CDATA[<p>Okay&#8230; where to start. The year changed. Gosh, that went fast. I can remember me writing tons of stuff and assembling the DevTeam 12 months back like it was yesterday. Obviously we didn&#8217;t make it in 2010 like originally planned, but the CoolBasic Classic project continues still. Actually, I just went ahead and changed the year from 2010 to 2011 on coolbasic.com (&#8230;and yes, it&#8217;s a common joke amongst project managers that deadlines should indicate month, but intentionally leave the year unspecified <img src='http://www.coolbasic.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). I&#8217;ve been a little slacky the past few weeks, I admit, but it&#8217;s been hectic at work and other members of the Team have had all kinds of stuff going on in their lives (who wouldn&#8217;t). It being a year now, the DevTeam members&#8217; contracts are closing to an end soon, naturally. This means it&#8217;s time for a round of renewals! That being said, few people are leaving their duties due to a number of things, but the majority has expressed their interest of continuing in the Team. And that&#8217;s great! For now, we have decided not to open new positions, and will recruit more only when needed &#8211; who knows, perhaps some of the original members will make a come-back. The organization structure is going to change a little bit, and details will be published later.</p>
<p>So what&#8217;s been done since last time&#8230; well, most of it has been management oriented. I feel it&#8217;s most convinient for you if I just list the things:</p>
<ul>
<li>We have explored alternatives to SVN version control, like Mercurial</li>
<li>We actually purchased a Virtual Server for web hosting</li>
<li>We now have domain <strong>coolbasic.fi</strong> (and it&#8217;s already operational on the Virtual Server)</li>
<li>We have configured PHP and MySQL databases</li>
<li>We have explored ways to use LDAP authentication services</li>
<li>We have explored ways to improve forum experience through measures in order to shut down spam</li>
<li>The PureBasic accounts have been terminated since we now use other tools</li>
</ul>
<p>The web host isn&#8217;t fully configured yet, but we&#8217;re working on it. When that&#8217;s done, we can set up a true testing environment for web developing (full copy of the portal, forums, everything).</p>
<p>I saved some money for not having to purchase a new set of PureBasic one-year licenses, but then again&#8230; I did purchase the Virtual Server, and it costs roughly the same. No gain there. In addition, I just recently purchased a license of <a href="http://www.jetbrains.com/resharper/">Resharper</a> which was around 200 €. I use it together with StyleCop at work, so I&#8217;m quite used to it. Coding without these essential tools feels somehow awfully wrong nowadays. Resharper is an extension for Visual Studio that provides advanced code analysis and refactoring tools that will help you write better code that is styled and constructed according to &#8220;best practises&#8221;. It helps to improve code readability and maintainability, and overall I think the gain is notable. I&#8217;ll be spending at least a few days refactoring my existing code now&#8230;</p>
<p>Fortunate me, I&#8217;ve had a chance to experiment some of my compiler specific ideas at work as well (I&#8217;m working on a project where I am able to use this expertise of mine), so even though not much code have been added to the CBC compiler project for the past 2 months, I, in fact, have done something useful that will help me achieve my goal in the CoolBasic project (I proved some techniques and theories work in practise).</p>
<p>Until next time&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=329</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Got it working with Linux!</title>
		<link>http://www.coolbasic.com/blog/?p=327</link>
		<comments>http://www.coolbasic.com/blog/?p=327#comments</comments>
		<pubDate>Sun, 07 Nov 2010 12:18:17 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=327</guid>
		<description><![CDATA[One of the to-be-implemented-next features of the Cool Developer editor is to get it perform an actual &#8220;Build &#038; Run&#8221; action using the CoolBasic Classic compiler and the Cool VES linker. Once this is done it&#8217;s obviously possible to start coding in CoolBasic (although the runtime and compiler aren&#8217;t fully working yet). Anyways, to get [...]]]></description>
			<content:encoded><![CDATA[<p>One of the to-be-implemented-next features of the Cool Developer editor is to get it perform an actual &#8220;Build &#038; Run&#8221; action using the CoolBasic Classic compiler and the Cool VES linker. Once this is done it&#8217;s obviously possible to start coding in CoolBasic (although the runtime and compiler aren&#8217;t fully working yet). Anyways, to get this wheel rolling I prepared a dummy compiler and a dummy linker executables that can be used for to simulate a Build process. To hook &#8216;em up I also prepared a CoolBasic Classic Cool VES game project template that Cool Developer consumes. The project template consists of a set of XML files that describe the allowed project items and how they&#8217;re presented in the editor. They also define how this project type needs to be built. Currently, the CoolBasic Cool VES project has two build steps: <strong>1)</strong> compilation, and <strong>2)</strong> linking. If one fails, the entire chain fails, and is also terminated immediately.</p>
<p>I mentioned &#8220;dummy executables&#8221;. In actuality, they&#8217;re the real CoolBasic Classic compiler and the real Cool VES linker, but they aren&#8217;t feature-complete yet. For example, the compiler only has lexical analysis and the linker only creates an empty (yet valid and runnable) executable. Both can be tested by intentionally providing invalid source (such as CB source with invalid parentheses or mismatched string quotation). This enables us to test error reporting and build step chaining properly back in Cool Developer.</p>
<p>I uploaded this package for the DevTeam a few days ago, however, it was only for Windows. I decided the sooner I can verify that it works on Linux as well the better. Finding out that you have to change half of your code when it&#8217;s time to deliver would such big-time. So I installed Linux on a VMWare virtual machine this weekend. I then went ahead and fetched Mono and set up the CoolBasic Classic compiler and Cool VES linker projects in MonoDevelop. They both compile out-of-the-box and seem to work properly. I was a bit surprised how easy it was. I have zero Linux experience. None, whatsoever. Now I just need to figure out how to share a folder (or something) so that my Windows 7 host and my Ubuntu can share stuff&#8230; or just link them both to SVN somehow. Lots of research work to do.</p>
<p>I haven&#8217;t yet gotten started with the Parsers, but let&#8217;s see what the forthcoming week produces.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=327</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Definition file implementation</title>
		<link>http://www.coolbasic.com/blog/?p=325</link>
		<comments>http://www.coolbasic.com/blog/?p=325#comments</comments>
		<pubDate>Mon, 01 Nov 2010 07:33:23 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Compiler]]></category>
		<category><![CDATA[CoolBasic Classic]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=325</guid>
		<description><![CDATA[Today&#8217;s post is a status update to CoolBasic Classic compiler. From the architectural aspect, most entities and interfaces are now implemented. The most notable ones include messages, symbols, keywords, operators, tokens and definition nodes. There are already almost 130 files in the C# project. Also the lexer is now fully operational so the first &#8220;major&#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Today&#8217;s post is a status update to CoolBasic Classic compiler. From the architectural aspect, most entities and interfaces are now implemented. The most notable ones include messages, symbols, keywords, operators, tokens and definition nodes. There are already almost 130 files in the C# project. Also the lexer is now fully operational so the first &#8220;major&#8221; part is done. </p>
<p>Late yesterday I finished the Cool Framework Definition File importer. What this means is that the compiler can now be made aware of Cool VES symbols such as functions and constants. For example, the constant &#8220;<code>PI</code>&#8221; is built-in to Cool VES in the same way as &#8220;<code>KEY_ESC</code>&#8221; or &#8220;<code>COLOR_RED</code>&#8221; will be in the future. I also tested how overloaded functions import, and that part is covered as well. Overall, the importer should be done now.</p>
<p>What about if the user wants to declare a function or constant of the same name as one already provided by the framework definition? For example, a user-defined function named &#8220;<code>LoadObject</code>&#8221; (which has the identical fingerprint with the framework version). Which would the program end up invoking? In such situation there&#8217;s two options: <strong>1)</strong> Report compile error for ambiguous symbol, or <strong>2)</strong> Resolve always to the user-defined symbol first. I don&#8217;t like the first option because it has the potential to break code if the framework changes (such symbol is added in the future, for instance). </p>
<p>One important thing to know about <em>Name Resolution</em> is that it bubbles up the tree. That is, if no match is found in the current context, query the search in its parent symbol&#8217;s context until a match is found or the entire tree has been processed. It never iterates the children of an upper level, though. In CoolBasic Classic the prime scope is the <em>Root</em> &#8211; all functions and the main program belong to the Root. In addition, there&#8217;s one more scope the Root belongs to, but to which the user has no access. It&#8217;s the <em>Global</em> scope, and that&#8217;s where the imported symbols go. Thus, Name Resolution will stop at the root level (user code) if the match is found, and will only proceed to the Global context if it wasn&#8217;t. Therefore, user-defined symbols will override any identical framework symbols. There&#8217;s one thing to note, though. If the signatures don&#8217;t match, but the names do, Name Resolution stops at the Root scope and will report possible compile error if no compatible signatures can be found (so it&#8217;s still possible for a framework update to break existing code, but only if the user intentionally tries to invoke the framework version).</p>
<p>The image below illustrates the current compiler status. Green boxes are considered &#8220;ready&#8221;.<br />
<img src="http://www.coolbasic.com/common/images/archives/2010/10/cb_csharp_compiler_status_20101031.png" alt="CoolBasic Classic compiler status (2010-11-01)" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=325</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The &#8216;Classic&#8217; compiler in C#</title>
		<link>http://www.coolbasic.com/blog/?p=322</link>
		<comments>http://www.coolbasic.com/blog/?p=322#comments</comments>
		<pubDate>Wed, 27 Oct 2010 08:07:53 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Compiler]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=322</guid>
		<description><![CDATA[First things first: I&#8217;d like to correct the wording in one of my previous post’s statements. I mentioned this &#8220;another compiler that didn&#8217;t turn out that good&#8221;. Some people are now under the impression that C# is to blame for the project in question being now in a frozen state. Maybe I phrased it poorly, [...]]]></description>
			<content:encoded><![CDATA[<p>First things first: I&#8217;d like to correct the wording in one of my previous post’s statements. I mentioned this &#8220;another compiler that didn&#8217;t turn out that good&#8221;. Some people are now under the impression that C# is to blame for the project in question being now in a frozen state. Maybe I phrased it poorly, but the fact that it was developed in C# at first, has little to do with its failure. The author clarified to me that he dropped C# and switched over to C++ just for the sake of re-writing, and not due to performance issues. Personally, I don&#8217;t buy that, but that doesn&#8217;t matter. What matters is that a lot of people are paying a lot of attention to what I actually say, and I should be more careful how to express my thoughts in this blog. So let me emphasize once and for all&#8230; the other compiler project was &#8216;successfully&#8217; developed in C#, and later in C++, but is now paused for an undetermined time due to completely unrelated reasons. There. Case closed. He&#8217;s watching my blog very closely, though <img src='http://www.coolbasic.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>And then onto other issues at hand. The new compiler (written in C#) is progressing nicely. In the beginning there&#8217;s naturally lots of plain setup to do just to get most of the needed entities created. It&#8217;ll get more interesting soon, though. For the past week, I&#8217;ve used approximately 4 to 6 hours almost every day after work to establish the new compiler solution. That&#8217;s a healthy 12-14 hours of programming a day <img src='http://www.coolbasic.com/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  . Time flows easily when you listen to inspirational music. Currently, the compiler parses the command line arguments, initializes a build job, and invokes the lexer on the source file. Half of all token types are already recognized, and there&#8217;s also one dummy parser (which, for testing purposes, only prints all tokens to the console output). I expect to finish the lexical analysis on the remaining token types soon. And then I can start implementing the statement parsers &#8211; which ought to be interesting because I now have some new tools at my disposal, thanks to object oriented platform.</p>
<p>I decided to take a little different approach for error reporting. All old compilers shut down the process immediately after encountering the first compile error. This new design doesn&#8217;t do that, but the compiler creates a list of compile errors instead and prints them to the standard error stream. This allows Cool Developer editor to compose a neat listing the user can then iterate through and fix more issues at once before re-building. This will probably save time on trial-error, and thus enhance productivity. Basically, this concept requires the compiler to be able to recover from compile errors and simply continue the process from the next statement. Oh, architectural joy! In addition, the compiler now also supports <em>warnings</em> i.e. messages that don&#8217;t count as errors, but still hold information about problems in code. Warnings don&#8217;t cause the compilation to fail, but they too will be listed in Cool Developer&#8217;s user interface.</p>
<p>As a bonus, you&#8217;d call the CoolBasic Classic compiler from command line like this (subject to change):</p>
<p><code>cbccompiler mygame.cbc /out mygame.obj /def coolves.fw</code></p>
<p>You can optionally enable Finnish interface by adding <code>/lang fi</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=322</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Possible platform changes</title>
		<link>http://www.coolbasic.com/blog/?p=320</link>
		<comments>http://www.coolbasic.com/blog/?p=320#comments</comments>
		<pubDate>Thu, 21 Oct 2010 10:03:42 +0000</pubDate>
		<dc:creator>Zero</dc:creator>
				<category><![CDATA[Game Creation Tools]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://www.coolbasic.com/blog/?p=320</guid>
		<description><![CDATA[We recently had a discussion at our regular DevTeam meeting about exploring other possibilities for a proper development platform (and for the record, that meeting was one of the longest so far). There is a number of reasons why we think we should migrate away from a certain programming language, and base our code upon [...]]]></description>
			<content:encoded><![CDATA[<p>We recently had a discussion at our regular DevTeam meeting about exploring other possibilities for a proper development platform (and for the record, that meeting was one of the longest so far). There is a number of reasons why we think we should migrate away from a certain programming language, and base our code upon a &#8220;more supported&#8221; platform. For example, when the Chipmunk physics library updated not so long ago, several problems emerged regarding cross-compiler generated code, and ultimately broke some compatibility. Now, one would expect that since it&#8217;s C it was standard enough to &#8220;just work&#8221; every time. In reality, however, our developers have had hard time with importing and invoking (consider SSE2 and dozens of compiler flags in the equation) the 3rd party libraries. We&#8217;ve got Chipmunk working in the current build, but there&#8217;s a high probability that it&#8217;ll break again in future coming library updates. All in all, fighting these kinds of problems is indeed quite frustrating (and uncalled for), especially when debugging these things is very difficult &#8211; if not impossible.</p>
<p>I think that procedural coding in general, an inadequate editor, a bit too simple tools, and a somewhat limited debugger will not serve our best interests in the long run. To me personally, it&#8217;s not too encouraging to open up our current development environment and start writing productive code anymore. I&#8217;m a professional C# developer, and this procedural coding (I once preferred) is becoming a mental burden for me. It has definitely affected my motivation in a negative way. I know I said a year ago that in order to create a fast and compact compiler, a procedural approach would be ideal. But I consider pleasant and powerful tools equally important because it enhances productivity of the programmer and maintainability of the project. I&#8217;m referring to Visual Studio (which in my opinion is the best IDE out there) as well as to Intellisense, refactoring, code analysis, unit testing, and other very powerful tools provided by it. After all, I think that if the compiler required a tad more memory and it took 2 seconds longer to build a game, it wouldn&#8217;t hurt too much (in a year the computers running the compiler are probably multiple times faster anyways).</p>
<p>So we&#8217;ve come to a point where we&#8217;re going to port our existing code over to C++ and C#. This will make a whole lot of new possibilities available to us: We can now harness the power of modern development environments, get more productive, and we no longer have to worry about the import files. We can trust that the generated ASM is correct and that using external libraries won&#8217;t conflict (that much, at least). There are pros and cons in object oriented design, but overall I&#8217;m confident that the marginal speed gain provided by procedural coding style isn&#8217;t going to outweigh anything. One of the most important things is that the developers are happy and get to work on something they enjoy.</p>
<p>The Cool VES game engine is going to be re-written in C++. This still enables us to inject ASM to where speed is critical. We&#8217;re also experimenting with a new multimedia library that ought to ease our job when implementing certain command sets in the future. We also continue developing Cool VES for both Windows and Linux.</p>
<p>I also mentioned C#. That&#8217;s for the CoolBasic Classic compiler! Now, this is quite interesting because there has been one project (that has nothing to do with us) I&#8217;m aware of, that attempted to write a compiler in C# about a year ago. It didn&#8217;t turn out that well, and currently the project in question is apparently frozen. One would think that this should be considered a warning example, but yet I&#8217;m willing to try doing the same thing because I really think it&#8217;s possible and quite doable. Yes, there are some serious challenges, and the architecture plays an exceptionally big role here. C# makes it possible to create a very high-level and sophisticated core for the compiler, and I&#8217;m very excited about it. Only a day after the meeting, I already had an initial architecture plan and a Visual Studio solution in place. Given that procedural model is seriously impacting my motivation, I actually believe I&#8217;ll get the job done faster now that I have good tools &#8211; even when it means I basically have to start over.</p>
<p>Many people associate C# to the Windows operating system. While it is true that C# is largely used to write software for the Microsoft .NET Framework, not everyone is aware that you can target programs written in C# to other platforms as well, like Linux. Just as Cool VES is intended to have both Windows and Linux versions, CoolBasic Classic compiler should also be available on Linux. I&#8217;ll be using Mono for that, but more information about that will be published at a later time.</p>
<p>If this becomes an epic fail, I can always revert back to the old compiler, although I highly doubt that. &#8220;I want to believe&#8221; <img src='http://www.coolbasic.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  . In fact, I should have known better when I made the decision of the development environment almost a year ago. I hope I get it right this time&#8230;</p>
<p><strong><em>TLDR; We decided to start using more powerful development tools, and we&#8217;re all now more productive and happy.</em></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coolbasic.com/blog/?feed=rss2&#038;p=320</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

