<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:series="http://unfoldingneurons.com/"
	>

<channel>
	<title>The Rebertian Times &#187; programming</title>
	<atom:link href="http://blog.rebertia.com/tag/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.rebertia.com</link>
	<description>All my thoughts that are fit to blog. Which mostly consists of stuff about programming.</description>
	<lastBuildDate>Mon, 09 May 2011 20:44:16 +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>Functional OCaml Cheatsheet</title>
		<link>http://blog.rebertia.com/2010/10/31/functional-ocaml-cheatsheet/</link>
		<comments>http://blog.rebertia.com/2010/10/31/functional-ocaml-cheatsheet/#comments</comments>
		<pubDate>Mon, 01 Nov 2010 01:11:20 +0000</pubDate>
		<dc:creator>Chris Rebert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[cheat]]></category>
		<category><![CDATA[cheatsheet]]></category>
		<category><![CDATA[CSE130]]></category>
		<category><![CDATA[notes]]></category>
		<category><![CDATA[OCaml]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[sheet]]></category>

		<guid isPermaLink="false">http://blog.rebertia.com/?p=290</guid>
		<description><![CDATA[Having learned functional OCaml during CSE 130 (btw, Prof. Lerner is great), here&#8217;s a version of my midterm notes for future reference (unfortunately, without syntax highlighting; I can&#8217;t find a SyntaxHighlighter brush for OCaml): (* An OCaml comment. (* You can nest them. *) *) Some infix operators: Equality: = (*though also used in Let-In for [...]]]></description>
			<content:encoded><![CDATA[<p>Having learned functional <a href="http://en.wikipedia.org/wiki/Objective_Caml">OCaml</a> during <a href="http://cseweb.ucsd.edu/classes/fa10/cse130/">CSE 130</a> (btw, <a href="http://www.cs.ucsd.edu/~lerner/">Prof. Lerner</a> is great), here&#8217;s a version of my midterm notes for future reference (unfortunately, without syntax highlighting; I can&#8217;t find a <a href="http://alexgorbatchev.com/SyntaxHighlighter/">SyntaxHighlighter</a> brush for OCaml):</p>
<pre class="brush:text">(* An OCaml comment. (* You can nest them. *) *)

Some infix operators:
Equality: =  (*though also used in Let-In for assignment*)
Inequality: !=
String concatenation: ^
Integer modulo: mod
Floating-point arithmetic: /. +. -. (* etc.; they all have extra periods*)

(* Let-In expressions *)
(* Vaguely imperative, less-indented style *)
let x = q in
let y = w in
q + w
(* Functional, more-indented style *)
let x = q in
    let y = w in
        x + y
(* Using tuple unpacking *)
let x, y = q, w in x + y (* we're not concerned with indents in this example *)

If-Then-Else:
if x then y else z

Lists:
[] (* Empty list*)
[1; 2; 3; 4] (* List literal *)
x::xs (* Cons operator *)
xs @ ys (* List concatenation operator *)

Tuples:
let triple = (x, y, z) ;;
Tuple types are *-separated and parenthesized: (a * b * c)

Functions:
(* Named functions *)
let add x y = x + y ;;
(* Anonymous functions; "lambda"s *)
let otherwise_nameless_add = fun x y -&gt; x + y ;;
(* Recursive functions *)
let rec factorial = if n &lt;= 1 then 1 else n*(factorial n-1)
    (* The "rec" is required; you can also include it harmlessly when declaring non-recursive functions. *)

<a href="http://en.wikipedia.org/wiki/Algebraic_data_type">Algebraic datatypes:</a>
type expr =
    | VariableX
    | Negative of expr
    | Plus of expr * expr
(* Calling constructors *)
let sum = Plus(VariableX, VariableX) ;;
(* Declaring a generic ADT *)
type 'a list =
    | Nil
    | Cons of 'a * 'a list

Pattern matching
let as_string sum =
    match sum with
        | VariableX -&gt; "x"  (* Yes, you could leave the "|" out for the first case, but I find that annoyingly irregular. *)
        | Negative(ex) -&gt; "-" ^ (as_string ex)
        | Plus(left,right) -&gt; "(" ^ (as_string left) ^ " + " ^ (as_string right) ^ ")"
Parens are unfortunately often necessary for nested match-es.

Types of somewhat interesting functions:
List.map: ('a -&gt; 'b) -&gt; 'a list -&gt; 'b list
List.left_fold: ('a   -&gt; 'b       -&gt; 'a       ) -&gt; 'a  -&gt; 'b list -&gt; 'a
(*               accum   list item   new accum     init              result
                (----------"reducer"---------*)</pre>
<img src="http://blog.rebertia.com/?ak_action=api_record_view&id=290&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.rebertia.com/2010/10/31/functional-ocaml-cheatsheet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Of Braces and Semicolons</title>
		<link>http://blog.rebertia.com/2010/01/24/of-braces-and-semicolons/</link>
		<comments>http://blog.rebertia.com/2010/01/24/of-braces-and-semicolons/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 16:52:35 +0000</pubDate>
		<dc:creator>Chris Rebert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[braces]]></category>
		<category><![CDATA[iguana]]></category>
		<category><![CDATA[indentation]]></category>
		<category><![CDATA[language design]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[semicolons]]></category>
		<category><![CDATA[whitespace]]></category>

		<guid isPermaLink="false">http://blog.rebertia.com/?p=206</guid>
		<description><![CDATA[Finally, a post that lives up to the second part of this blog&#8217;s tagline by being about programming! (Well, there was C in a (Nutshell)2, but my point is it&#8217;s been a while.) Now, I&#8217;m a would-be language designer. Programming language theory fascinates me, and to that end I&#8217;ve read a number of books on [...]]]></description>
			<content:encoded><![CDATA[<p>Finally, a post that lives up to the second part of this blog&#8217;s tagline by being about programming! (Well, there was <a href="http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/">C in a (Nutshell</a>)<sup><a href="http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/">2</a></sup>, but my point is it&#8217;s been a while.)</p>
<p>Now, I&#8217;m a would-be language designer. <a href="http://en.wikipedia.org/wiki/Programming_language_theory">Programming language theory</a> fascinates me, and to that end I&#8217;ve read a number of books on different languages to try and get a feeling for all the various approaches and paradigms. I&#8217;ve also read many interesting blog posts found via <a href="http://www.reddit.com/r/programming">proggit</a> (and some via <a href="http://lambda-the-ultimate.org/">Lambda the Ultimate</a>) which argue about language issues.</p>
<p>From all this, I&#8217;ve reached some conclusions which I&#8217;m going to try and lay out in a series of blog posts.</p>
<p>In this first post, I&#8217;ll cover:</p>
<h2>The Problem of Delimiting Blocks</h2>
<p>All modern languages are block-structured. (Thank you <a href="http://en.wikipedia.org/wiki/Go_To_Statement_Considered_Harmful">Dijkstra</a>!) That is, code segments are semantically and syntactically organized into a tree. Let&#8217;s start with an example of some code in a <a href="http://en.wikipedia.org/wiki/Blub">Blub</a>-average of today&#8217;s most popular languages:</p>
<pre class="brush:csharp">
class Foo(Object)
{
    void bar()
    {
        if (baz)
            quxx();
    }
}</pre>
<p>The first problem we have is which <a href="http://en.wikipedia.org/wiki/Brace_style">brace style</a> is the &#8220;Right One&#8221;. This is a perennial holy war. The style in this example wastes lines just for parentheses. On the other hand, it makes it very easy to perceive the block structure of the code. <a href="http://www.catb.org/jargon/html/O/on-the-gripping-hand.html">On the gripping hand</a>, in practice, programmers don&#8217;t really care about the braces (except when the compiler gives a syntax error about them being wrong), and instead pay attention to the indentation. Secondly, we have the sub-problem of whether one-statement blocks should have braces around them; we have clarity and maintainability (what if the block expands beyond the one statement and someone forgets to add the braces? In many cases, this leads to subtle bugs the compiler does not warn you about.) versus wasting space and causing unnecessary scrolling. At any rate, we are led to the obvious question of: Why not use the indentation programmers insert anyway to delimit blocks and do away with the braces altogether? And indeed, some languages have tried this. The posterboy is <a href="http://en.wikipedia.org/wiki/Python_(programming_language)">Python</a> (my current favorite existing language).</p>
<p>However, this solution has problems of its own:</p>
<ol>
<li>Copy-pasting code into environments where indentation is not preserved (e.g. some online forums) causes it to become unintelligible (well, in practice, one can apply some heuristics and try and re-indent it manually, but there&#8217;s no way to ensure you got it exactly right, and if the code is long enough, it&#8217;s a real PITA; whereas code using braces can be automatically re-indented by several tools)</li>
<li>As one sees every so often in the Python community, there are people who harbor unreasonable hate towards syntax-significant indentation. From what I understand, most of these people have bad memories from some early version of <a href="http://en.wikipedia.org/wiki/FORTRAN">FORTRAN</a> and their fear is completely irrational. But if you want your language to be a very popular one, you&#8217;re probably going to have to accommodate these people.</li>
<li>We&#8217;re still left with the second code formatting holy-war of spaces vs. tabs as the indentation character. (BTW, have you seen <a href="http://en.wikipedia.org/wiki/Unix-like">*NIX</a>&#8216;s default <a href="http://en.wikipedia.org/wiki/Tab_stop">tabstop</a> of 8? Personally, it makes my eyes bleed.)</li>
</ol>
<p>Of course, along with braces are their friends the semicolons, and they annoy the heck out of me; they&#8217;re just plain unnatural. I should not have to always remember to end a line with anything other than a linebreak, because 90% of the time, <strong>statements are only one line long</strong>; the <em>other 10%</em> are the ones I should have to type extra characters for, and only then after considering refactoring the line so it&#8217;s more readable anyway. This is basic <a href="http://en.wikipedia.org/wiki/Huffman_coding">Huffman coding</a> people! Optimize for the <a href="http://en.wikipedia.org/wiki/Pareto_principle">overwhelmingly common case</a>, not the exceptional one. (If this was a research paper, I would back up this 90-10 distribution with some empirical statistics, but since this is just a blog post, I&#8217;m not gonna bother.)</p>
<p>So, in summation, semicolons and braces are bad design choices. Eliminating the semicolons is relatively simple. As for the braces, our choices for what to replace them with are <a href="http://en.wikipedia.org/wiki/Off-side_rule">the off-side rule</a> (i.e. syntactically-significant indentation) or begin-end keywords ala <a href="http://en.wikipedia.org/wiki/ALGOL">ALGOL</a> or Pascal. Though I personally prefer the former, I opt for the latter due to the aforementioned issues with the former. Now, does this actually solve our problems, or is this a meaningless textual substitution? We&#8217;ll get to that in just a sec. There is a downside to vanilla begin-end though, and that is that it looks retro/outdated (i.e. like <a href="http://en.wikipedia.org/wiki/Pascal_(programming_language)">Pascal</a>) or like a <a href="http://en.wikipedia.org/wiki/Scripting_language">scripting language</a> (using the pejorative connotation; i.e. like <a href="http://en.wikipedia.org/wiki/Bourne_shell">sh</a> or <a href="http://en.wikipedia.org/wiki/BASIC">BASIC</a>). However, if we do it intelligently, like <a href="http://en.wikipedia.org/wiki/Ruby_(programming_language)">Ruby</a> does, we can reduce the resemblance and make the substitution meaningful. All we need to do is realize that the <code>begin</code> keyword is technically superfluous and that we can force <code>end</code> to always go on a line of its own. Here&#8217;s an example of code in this style:</p>
<pre class="brush:ruby">class Foo(Object)
    void bar()
        if baz
            quxx()
        end
    end
end</pre>
<p>Advantages:</p>
<ul>
<li>No <a href="http://en.wikipedia.org/wiki/Dangling_else">dangling else</a> problem as long as you have a <code>elif</code> construct.</li>
<li>Only one indentation style (Well, you could not indent the <code>end</code>s, but since they require their own line, there&#8217;s no particular reason not to.)</li>
<li>No space is wasted compared to the more compact of the 2 main brace styles.</li>
<li>The required <code>end</code>s solve the &#8220;what if this one-line code block grows to multiple lines?&#8221; problem</li>
</ul>
<p>Now, in <a href="http://rebertia.com/wiki/Iguana">Iguana</a>, I plan to alter this just slightly by allowing 1-line blocks to use colons and skip the <code>end</code> keyword; this let&#8217;s us re-special-case one-line bodies without any ambiguity or strain on the parser while continuing to avoid the multiline growth problem. Here&#8217;s what this looks like:</p>
<pre class="brush:ruby">class Foo(Object)
    void bar()
        if baz: quxx()
    end
end</pre>
<p>Of course, in this particularly simple example, you could also write it like this:</p>
<pre class="brush:py">class Foo(Object): void bar(): if baz: quxx()</pre>
<p>But I would hope your code reviewers would thoroughly chastise you if you did, so please don&#8217;t.</p>
<p>I agree it is not the cleanest or most obvious approach, but it&#8217;s a compromise between theoretically-best and familiar-enough-to-be-popular.</p>
<img src="http://blog.rebertia.com/?ak_action=api_record_view&id=206&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.rebertia.com/2010/01/24/of-braces-and-semicolons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CodeRally</title>
		<link>http://blog.rebertia.com/2009/06/01/coderally/</link>
		<comments>http://blog.rebertia.com/2009/06/01/coderally/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 07:51:34 +0000</pubDate>
		<dc:creator>Chris Rebert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[college]]></category>
		<category><![CDATA[contest]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[UCSD]]></category>

		<guid isPermaLink="false">http://blog.rebertia.com/?p=170</guid>
		<description><![CDATA[[Meta-note: Yes, I realize this is a bit dated and definitely out of chronological order; So sue me.] Earlier this quarter, I, in partnership with Nick, participated in a programming contest put on by the CSE Department. It used a Java framework called &#8220;CodeRally&#8221; and involved programming an AI for a car on a virtual [...]]]></description>
			<content:encoded><![CDATA[<p>[<strong>Meta-note</strong>: Yes, I realize this is a bit dated and definitely out of chronological order; So sue me.]</p>
<p>Earlier this quarter, I, in partnership with Nick, participated in a programming contest put on by the CSE Department. It used a Java framework called &#8220;CodeRally&#8221; and involved programming an AI for a car on a virtual track. The cars start out at random locations and score points by doing various things, such as going through the track flags in order, throwing and hitting other cars with spare tires, etc. until time runs out. We named our AI &#8220;King Regicide&#8221; (all credit to <a href="http://unterseeboot.blogspot.com">my Desmondian counterpart</a> for the name).</p>
<p>Our initial strategy we dubbed &#8220;tirespamming&#8221;; that is, just try and hit people with tires constantly and ignore trying to go around the track circuit. We got it partially working, but then decided that due to the point spread we should focus on writing logic to go around the track circuit. After fixing a particularly nasty bug that sometimes surfaced when turning from say 5° to 355°, we tuned the tire-firing logic and did decently in simulated contests. We also wrote some smart logic for when to activate our emergency shields. We had dreams of writing some code to evade tires, but we never got around to it.</p>
<p>We ended up finishing 19th in the second qualifying round, one short of the top 18 who got to advance to the final round. However, a couple instructors and TAs, who were ineligible to win any titles/prizes, finished ahead of us, and due to the aforementioned random starting locations there was a large random factor involved and not enough rounds were done, in my opinion, to mitigate this, so we got slightly screwed over. Oh well. Se la vie.</p>
<p>This was almost made up for by the hilarity of &#8220;Disappointer&#8221;, Prof. Dana Dahlstrom&#8217;s entry in the contest. I forget the exact details, but I believe that after a set amount of time stuck in a pileup (see next paragraph), it would extricate itself, tirespam the car who caused the pile-up and throw all available tires at it, and then go back to being stuck. All assembled got a grand laugh out of it.</p>
<p>On an interesting note, the biggest problem in the contests ended up being &#8220;pileups&#8221;. These are when one car runs out of fuel while going around the circuit, and another car hits it and is too stupid to go around it. Yet more cars would then also pile-up behind these cars, blocking the inner cars from moving at all. This would usually cascade until all the cars were motionless and part of the pile-up. Only one or two cars had AIs which were smart enough to deal with this situation, and interestingly they weren&#8217;t even the top finishers. We tried to add such a feature near the end of the contest, but completely ran out of time.</p>
<p>In the end, those who actually won the contest admitted that their AIs didn&#8217;t do anything particularly fancy compared to the average entrant: just go around the circuit, throw tires occasionally, and activate shields when necessary; I believe this further supports my assertion about the large, unaddressed random factors involved.</p>
<p>All in all, it was grand fun even though we were robbed of our chance to advance to the finals, and I look forward to next year&#8217;s contests. Props to the Dini Group for sponsoring the contest and providing caffeine and food!</p>
<img src="http://blog.rebertia.com/?ak_action=api_record_view&id=170&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.rebertia.com/2009/06/01/coderally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C in a Nutshell in a Nutshell</title>
		<link>http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/</link>
		<comments>http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/#comments</comments>
		<pubDate>Sat, 04 Apr 2009 22:12:19 +0000</pubDate>
		<dc:creator>Chris Rebert</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[notes]]></category>
		<category><![CDATA[nutshell]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://blog.rebertia.com/?p=133</guid>
		<description><![CDATA[I recently finished reading C in a Nutshell, which I highly recommend as an excellent C reference and tutorial to anyone with programming experience. I previously learned some MS Visual C++ at CyberCamps some years ago, but finding the language a bit clunky, I searched around the web, found Python and have been in love [...]]]></description>
			<content:encoded><![CDATA[<p>I recently finished reading <a href="http://www.amazon.com/C-Nutshell-OReilly-Peter-Prinz/dp/0596006977/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1238891376&amp;sr=8-1"><em>C in a Nutshell</em></a>, which I highly recommend as an excellent C reference and tutorial to anyone with programming experience. I previously learned some MS Visual C++ at CyberCamps some years ago, but finding the language a bit clunky, I searched around the web, found Python and have been in love with it ever since. But since every programmer should know (at least most of) C, and I had a C/Assembly course coming up, I resolved to learn C properly; hence the book. Anyway, here are my notes from it, both as a memo to myself and in the hope that others might find it mildly useful:</p>
<h1>Interesting trivia</h1>
<ul>
<li><code>index[array]</code> ≡ <code>array[index]</code> ≡  <code>*(array + index)</code></li>
<li>arguments to a function may be evaluated in <strong><em>any</em></strong> order by the compiler</li>
<li>The <code>signed</code>-ness of plain <code>char</code> is compiler-dependent</li>
</ul>
<h1><a href="http://en.wikipedia.org/wiki/C99">C99</a> Hotness</h1>
<ul>
<li>Boolean type introduced:</li>
</ul>
<pre class="brush:c">#include &lt;stdbool.h&gt;
bool a = true, b = false;</pre>
<ul>
<li><code>//</code>-comments formally allowed</li>
<li>declarations can go <strong><em>anywhere<span style="font-weight: normal;"><span style="font-style: normal;"> within a function; C89 forces you to declare <strong>everything</strong> at the </span>start<span style="font-style: normal;"> of the function</span></span></em></strong></li>
</ul>
<h1>Syntax</h1>
<pre class="brush:c">#include &lt;something_in_std_lib.h&gt;
#include "your_own_lib.h"
enum SomeEnum {A, B, C};
typedef someDeclaration newTypeAlias;</pre>
<ul>
<li><code>const</code> keyword, like Java&#8217;s <code>final</code></li>
<li><code>static</code> keyword means private to this source file, like C#&#8217;s <code>internal</code></li>
</ul>
<h1>Basics</h1>
<pre class="brush:c">int main(int argc, char * argv[])
char aStringVariable[length];</pre>
<ul>
<li><code>EXIT_SUCCESS</code>, <code>EXIT_FAILURE</code> defined in <code>stdlib.h</code></li>
</ul>
<h1>Function pointers</h1>
<pre class="brush:c">int foo(char);//declare function
int (*funcPtr)(char) = foo;
int result = funcPtr('a');//use func pointer</pre>
<h1>Objects</h1>
<h2>Defining</h2>
<pre class="brush:c">struct Foo
//unions use same syntax, just w/ different keyword
{
    int a;
    char b;
}</pre>
<h2>Using</h2>
<pre class="brush:c">/* C99: */ struct Foo bar = {.b = 'Q', .a = 42};
/* C89: */ struct Foo baz = {42, 'Q'};</pre>
<h1>Defining <a href="http://en.wikipedia.org/wiki/C_preprocessor">macros</a></h1>
<ul>
<li>Function-like macros: <code>#define foo(a,b) ((a)-(b))</code></li>
<li>The <code>##</code> operator within macros:
<ul>
<li>Given: <code>#define foo(x) MSG_##x</code></li>
</ul>
<ul>
<li>Then: <code>foo(A)</code> ≡ <code>MSG_A</code></li>
</ul>
</li>
<li>The <code>#</code> operator within macros &#8211; converts operand to string</li>
</ul>
<h1>Useful macros</h1>
<p><a href="http://en.wikipedia.org/wiki/Assertion_(computing)">Assertions</a>:</p>
<pre class="brush:c">#include &lt;assert.h&gt;
assert(booleanExpression);</pre>
<ul>
<li><code>#define NDEBUG</code> &#8211; disables asserts</li>
<li><code>#error "Message"</code> &#8211; causes compile error with given message</li>
<li>Conditional compilation: <code>#if</code>, <code>#elif</code>, <code>#else</code>, <code>#endif</code></li>
</ul>
<h1>Metadata macros</h1>
<ul>
<li><code>__func__</code> &#8211; name of current function</li>
<li><code>__LINE__</code> &#8211; current line number</li>
<li><code>__FILE__</code> &#8211; name of current file</li>
<li><code>__TIME__</code> &#8211; time of compilation</li>
<li><code>__DATE__</code> &#8211; date of compilation</li>
</ul>
<h1>Standards macros</h1>
<ul>
<li><code>__STDC__</code> &#8211; bool for whether compiler is C89-compliant</li>
<li><code>__STDC_VERSION__</code> &#8211; <code>199901L &gt;=</code> if C99-compliant</li>
<li><code>__STDC_IEC_559__</code> &#8211; bool for <a href="http://en.wikipedia.org/wiki/IEEE_754">IEEE-754</a> compliance</li>
</ul>
<h1><a href="http://en.wikipedia.org/wiki/C_standard_library">Stdlib</a> survey</h1>
<ul>
<li><code><a href="http://en.wikipedia.org/wiki/Stdlib.h">stdlib.h</a></code>: <code><a href="http://en.wikipedia.org/wiki/Malloc">malloc</a>()</code>, <code>free()</code>, array sorting, binary search, str-&gt;num conversion, random numbers</li>
<li><code><a href="http://en.wikipedia.org/wiki/Stddef.h">stddef.h</a></code>: defines <code><a href="http://en.wikipedia.org/wiki/Null_pointer">NULL</a></code>, <code><a href="http://en.wikipedia.org/wiki/Size_t">size_t</a></code></li>
<li><code><a href="http://en.wikipedia.org/wiki/String.h">string.h</a></code>: also includes general array/memory stuff</li>
<li><code><a href="http://en.wikipedia.org/wiki/Math.h">math.h</a></code>, <code><a href="http://en.wikipedia.org/wiki/Time.h">time.h</a></code>: speak for themselves</li>
<li><code><a href="http://en.wikipedia.org/wiki/Errno.h">errno.h</a></code>: defines <code>errno</code> global var</li>
<li><code><a href="http://en.wikipedia.org/wiki/Ctype.h">ctype.h</a></code>: ASCII character classification</li>
<li><code><a href="http://en.wikipedia.org/wiki/Fenv.h">fenv.h</a></code>: controls floating point rounding mode, etc [<strong>C99 only</strong>]</li>
<li><code><a href="http://en.wikipedia.org/wiki/Limits.h">limits.h</a></code>: limits of integer types</li>
<li><code><a href="http://en.wikipedia.org/wiki/Float.h">float.h</a></code>: describes properties of float representation</li>
<li>See also <a href="http://rebertia.com/wiki/C_Stdlib_Notes">my summary </a>of the essential parts of the stdlib</li>
</ul>
<h1><a href="http://en.wikipedia.org/wiki/GNU_Compiler_Collection">GCC</a> options</h1>
<ul>
<li><code>-o exec_name</code> (instead of <code>a.out</code>)</li>
<li><code>-Idir_name:other_dir_name</code> (places to also look for headers)</li>
<li><code>-fsyntax-only</code> (just check syntax)</li>
<li><code>-ansi</code> (use C89)</li>
<li><code>-std=c99</code> (use C99)</li>
<li><code>-Wall</code> (warn about a bunch of stuff)</li>
<li><code>-pedantic</code> (adhere pedantically to standard)</li>
<li><code>-Wextra</code> (warn about strange/pointless code)</li>
<li><code>-g</code> (add debug info)</li>
<li><code>-pg</code> (add profiling hooks)</li>
</ul>
<img src="http://blog.rebertia.com/?ak_action=api_record_view&id=133&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.rebertia.com/2009/04/04/c-in-a-nutshell-in-a-nutshell/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

