<?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>lotm Archives - ClickedyClick</title>
	<atom:link href="https://gergely.imreh.net/blog/tag/lotm/feed/" rel="self" type="application/rss+xml" />
	<link>https://gergely.imreh.net/blog/tag/lotm/</link>
	<description>Life in real, complex and digital.</description>
	<lastBuildDate>Tue, 08 Dec 2015 05:18:51 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	
	<item>
		<title>Language of the Month: Rust, the results</title>
		<link>https://gergely.imreh.net/blog/2015/12/lotm-rust-results/</link>
					<comments>https://gergely.imreh.net/blog/2015/12/lotm-rust-results/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Mon, 07 Dec 2015 06:13:43 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[bitmessage]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[rust]]></category>
		<guid isPermaLink="false">https://gergely.imreh.net/blog/?p=2167</guid>

					<description><![CDATA[<p>Every now and then I do a &#8220;Language of the Month&#8221; feature when I spend one month to learn a new programming language. This last month in November I&#8217;ve spent with Rust, and it&#8217;s time to take stock. Will look at the impression I had in this short time, show one project that I get done [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2015/12/lotm-rust-results/">Language of the Month: Rust, the results</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Every now and then I do a &#8220;Language of the Month&#8221; feature when I spend one month to learn a new programming language. This last month in November <a href="https://gergely.imreh.net/blog/2015/11/language-of-the-month-rust/">I&#8217;ve spent with Rust</a>, and it&#8217;s time to take stock. Will look at the impression I had in this short time, show one project that I get done in Rust, and some ideas what I&#8217;d like to do with Rust in the future!</p>
<h2>Experience</h2>
<p>According to my time log, I have spent about 20 hours this month learning Rust. That&#8217;s way too little to have a good understanding, but definitely enough to have some educated guesses (and excitement, and horror , as appropriate). This time I&#8217;m generally very impressed as Rust comes across as indeed a very modern and smart language, although that modernness is mostly in the tooling and non-essential parts. It is also changing very quickly, for good and bad. Here are some, admittedly subjective and incomplete list of observations. Good is what I like, Bad what&#8217;s less nice IMHO, and Ugly is what&#8217;s imperfect or confusing (at this stage of my Rust learning):</p>
<h3>Good</h3>
<p>It&#8217;s great to see that <strong>documentation</strong> is a not an afterthought, but a <a href="https://doc.rust-lang.org/stable/book/documentation.html">core part</a>, that is making use a lot of modern development experience. Having a standard way to include example code in docstrings and actual tests are run on them to make sure the examples are also up-to-date with the code is a very cool concept. Also being able to auto-generate HTML documentation from the code is probably going to be standard in most new languages (I think <a href="http://golang.org/">Go</a> does that also, and other languages have gained similar optional tools)</p>
<p><span id="more-2167"></span></p>
<p>It&#8217;s also great to see how <strong>testing</strong> is a not an afterthought either. There are <a href="https://doc.rust-lang.org/stable/book/testing.html">a bunch of different ways</a> of including tests (in the same file, test file, directory with test, in documentation&#8230;), though most of the time there&#8217;s probably one way that fits the project the best and can use that.</p>
<p>Rust has some very interesting foundations, mostly on top of the <a href="https://doc.rust-lang.org/stable/book/references-and-borrowing.html">memory model</a> and <a href="https://doc.rust-lang.org/stable/book/traits.html">traits</a>, that take quite a bit of time to wrap one&#8217;s head around (I&#8217;m not there yet), but goes a very long way to <strong>eliminate programming by accident</strong> (or <a href="https://en.wikipedia.org/wiki/Programming_by_permutation">programming by permutation</a>): it makes the it much harder to write something, see whether it works as hoped, and if not, then try to change something little and try again. Here it does not really work anymore as there are way too many things that have to be correct for the code to run, and the best to get there is to <em>actually understand</em> how the code should work.</p>
<p><strong>Traits</strong> are intriguing, <a href="https://doc.rust-lang.org/stable/book/traits.html">they</a> remind me a bit of Python&#8217;s <a href="https://en.wikipedia.org/wiki/Duck_typing">duck typing</a>, though only similar. This also includes <a href="https://doc.rust-lang.org/book/generics.html">generics</a>, or parametric polymorphism. <a href="http://manishearth.github.io/blog/2015/05/27/wrapper-types-in-rust-choosing-your-guarantees/">Composed types</a> are also the bomb &#8211; once you understand it and stop doing permutations of them to try to get the code to compile. :)</p>
<p>Interesting use <strong>semicolons</strong>,  in particular for returning value when it is omitted on the last expression in a function (a bit like <a href="https://en.wikipedia.org/wiki/MATLAB">Matlab</a>, where it is used as which function results to print on the debug console, and which just use silently).</p>
<p>Having a way to mark <strong>unimplemented</strong> sections (as <a href="https://doc.rust-lang.org/std/macro.unimplemented!.html">part of the standard library</a>) is very pragmatic, I&#8217;m sure it came out of a lot of engineering experience.</p>
<p><a href="https://doc.rust-lang.org/book/strings.html">Strings</a> being <strong>UTF-8 by default</strong> is a great choice and probably necessary nowadays, even if more complex. (Python goes a long way, but not quite there yet)</p>
<p>I&#8217;m glad to see that <strong>lists can have trailing commas</strong> after the last element. That&#8217;s a little thing, but boy how much I cannot stand Javascript lists because of the lack of this leniency.</p>
<p><strong>Macros</strong> are a whole different level of power, if and when <a href="https://doc.rust-lang.org/stable/book/macros.html">understood</a>. It feels strange sometimes to mix &#8220;normal&#8221; functions and method with something that is just &#8220;sort of like a function&#8221;, but this is all part of the metal model. I see that they are useful, though they also come across as necessary only because of the design principles used in the language (and its relative verbosity). That also mean, that advanced Rust probably makes more use of macros than beginner&#8217;s Rust.</p>
<p><a href="https://doc.rust-lang.org/stable/book/enums.html">Enums</a> are data types containing a list of variants. <strong>Coverage checking in enum matching</strong> (&#8220;did I handle all possible cases?&#8221;) shows again that plenty of lessons learned are put to use in making Rust.</p>
<p><strong>Loop labels</strong> are cool too, they can come handy with <a href="http://rustbyexample.com/flow_control/loop/nested.html">nested loops</a> to handle things clearly with less boilerplate / extra variables.</p>
<p><strong>Cargo</strong> is a very interesting <a href="https://crates.io/">package manager</a>. Have separate concept for binaries and libraries, for debug and release builds, running tests, lint, documentation, set up cross-compiling, and so on. I can also see from bits and pieces that there&#8217;s a lot to learn about this too to enable really cool use cases.</p>
<h3>Bad</h3>
<p>Most of the difficulty I had was connected to the combined fact of Rust is <strong>pretty new and changes quickly</strong>. Because of this others&#8217; projects where I found answers to my questions could be already obsolete, the docs don&#8217;t go into enough detail to actually understand things well enough without a lot of practical trial and error, could find a programming pattern for a problem and it being already removed from the language, or the fact that (I think) the nightly builds are recommended to be used as they have the latest features enabled? This of course is not all bad, I feel that being a Rust developer now one could really leave a mark and contribute, learn a lot in unchartered territory and teach a lot of people because too few teachers are out there. It&#8217;s only troublesome when one just want to &#8220;solve a problem&#8221;, but then maybe other language is better to use.</p>
<p>Would love to see <strong>more documentation</strong> (and actual practical examples) to explore the memory model, reference and borrowing, traits, macros &#8211; these most powerful and useful parts of the language. This is connected to the previous step, and I think it&#8217;s up to us users to use them more, boil the examples down by experience and write the things up&#8230;</p>
<h3>Ugly</h3>
<p><strong>Type declarations</strong> are required for functions, but for variable assignments they are inferred. The <a href="https://doc.rust-lang.org/book/functions.html">docs say</a> it&#8217;s a sweet spot, but it strikes me a bit of schizophrenic. I often find that adding an explicit type to assignments makes things work a lot better here.</p>
<p>I find the <strong>docstrings</strong> hard to get going, eg. making them compatible to generate the library docs from inline documentation. I might have done something wrong, but even the example code in the Rust book does not seem to play with doc generation very well. Also include example code and testing code in the docstrings and the confusion amplifies.</p>
<p>The <strong>difference of method syntax</strong> between <a href="https://doc.rust-lang.org/book/method-syntax.html">associated functions and method calls</a> is probably a necessary one, it still feels somehow a bit of mental burden to carry (at least in the beginning, I&#8217;m sure it&#8217;s a beginner&#8217;s issue).</p>
<p><strong>Diverging functions</strong> are an interesting beast too: there&#8217;s a <a href="https://doc.rust-lang.org/reference.html#diverging-functions">different declaration</a> for functions that have no return value. I kinda see how doing things this way can fit Rust&#8217;s model of doing things, but is it really necessary to create a whole new concept and different patterns for it? I guess this case could be handled conceptually in many ways and this is just one&#8230;</p>
<p><strong>Need to import types</strong> from the standard library to be able to use some of their features, but some other features work automatically. This feels a bit of a halfway solution, though, might be necessary to keep the resulting binaries down (by not including what&#8217;s not needed), but that could probably be achieved more automatically?</p>
<p><strong>Attributes</strong> are flags in the code to (sort of) <a href="http://rustbyexample.com/attribute.html">tell Rust</a> to how to handle the different code sections. Enabling debug mode, adding info about tests (that the next test should actually fail to consider it a pass, etc..), and a lot more. They are very powerful so could be considered good, but there are so many of them and so sparsely discussed most of the time that they belong for me more to this section. Need more documentation, I believe.</p>
<h2>Project: Bitmessage Proof-of-Work library</h2>
<p>I wanted to actually do a project in Rust for practical experience. To do something short but still somewhat useful, I decided to create a <a href="https://bitmessage.org/wiki/Main_Page">Bitmessage</a> proof-of-work (PoW) library. I&#8217;ve already worked on it for a bit for other projects (trying to make some  OpenGL, and Parallella accelerated versions) so it was kinda familiar and tractable task in during the month.</p>
<p>The Bitmessage <a href="https://bitmessage.org/wiki/Proof_of_work">proof of work</a> in pseudocode is something like:</p>
<pre class="lang:default decode:true" title="Bitmessage proof-of-work pseudocode">initialHash = hash(dataToCheck)
resultHash = hash(hash( nonce || initialHash ))
trialValue = the first eight bytes of resultHash converted to an integer</pre>
<p>where &#8220;hash&#8221; is <a href="https://en.wikipedia.org/wiki/SHA-2">SHA512</a>, and the trialValue is compared to a target calculated from  the time-to-live of the message to be sent.</p>
<p>I took most of the inspiration from the Python version of this in the reference client, that reads:</p>
<pre class="lang:python decode:true" title="Bitmessage Proof-of-Work in Python">trialValue, = unpack('&gt;Q',hashlib.sha512(hashlib.sha512(pack('&gt;Q',nonce) + initialHash).digest()).digest()[0:8])</pre>
<p>Hard to beat a practical one-liner for clarity, but there&#8217;s a bit to say about performance.</p>
<p>I ended up creating <a href="https://github.com/imrehg/bmpow-rust">bmpow-rust</a>, that runs multithreaded calculation for this algorithm, using the <a href="https://github.com/DaGenix/rust-crypto">rust-crypto</a>. I&#8217;ve been through quite a bit of trial and error, both for the PoW algorithm and the threading.</p>
<p>For the PoW the hardest part was casting the data into suitable types that the different functions can pass them around correctly. How to get data from a caller in a shared library, how to <a href="https://github.com/BurntSushi/byteorder">set the endiannes</a>, how to pass it to the hasing function, then get the data out again. I know the current version is not great, especially as some modifications to the code that I think should not change the outcome actually does end up with changing it.</p>
<p>Basic threading  is dead simple as Rust promises it to be, but then the issue I had there is how to send data out of the different threads when a thread finds the right nonce and signal to the other threads to stop working. <a href="http://rustbyexample.com/std_misc/channels.html">Channels</a> are there to help (and they are brilliant), but the the memory model (borrowing and referencing) didn&#8217;t fit to how I thought it should be. Tried out 2-3 other libraries that implement similar messaging methods between threads, but in the end it turned out that channels are indeed the right choice &#8211; the trick was that I didn&#8217;t need to explicitly shut down threads, they were killed when the calling function finished, making the whole setup much simpler. I know I should add some more error checking into the code for niceness, though I think not strictly required by the problem being solved (and race conditions doesn&#8217;t matter, if multiple threads find nonces, any of them are suitable).</p>
<p>The result is this (likely horrifyingly bad) code to find the right nonce (so it does more than the pseudocode above):</p>
<pre class="lang:rust decode:true " title="Bitmessage proof-of-work worker">fn bmpow(target: u64, hash: [u8; 64], starter: u64, stepsize: u64, chan_out: Sender&lt;u64&gt;) {
    let mut nonce: u64 = starter;
    let mut algoresult;

    loop {
        let mut wtr = vec![];
        let mut result: [u8; 64] = [0; 64];
        let mut hasher_inner = Sha512::new();
        let mut hasher_outer = Sha512::new();

        nonce += stepsize;
        match wtr.write_u64::&lt;BigEndian&gt;(nonce) {
            Ok(_) =&gt; {},
            Err(e) =&gt; { println!("error writing endian: {}", e) },
        }
        hasher_inner.input(&amp;wtr);
        hasher_inner.input(&amp;hash);

        hasher_inner.result(&amp;mut result);
        hasher_outer.input(&amp;result);

        let mut result_outer: [u8; 64] = [0; 64];
        hasher_outer.result(&amp;mut result_outer);

        let mut r2 = vec![0; 64];
        hasher_outer.result(&amp;mut r2);
        let mut rdr = Cursor::new(r2);
        // Converting from BigEndian to the endinannes of the system
        algoresult = rdr.read_u64::&lt;BigEndian&gt;().unwrap();
        if algoresult &lt; target {
            chan_out.send(nonce).unwrap();
            return;
        }
    }
}</pre>
<p>The resulting library is pretty good, compared to the multithreaded Python solution that clocks in ~400,000 check/s on my X201, on single thread it does 800,000+ check/s. When using multiple threads, it does not scale linearly, though, and much more variable: I&#8217;m getting 800,000 &#8211; 1,800,000 hash/s, different on each run. I guess spreading the work between cores is not very consistent in Rust yet? Will need to investigate more as the  higher performance would be very nice to have reliably.</p>
<p>In the meantime, the <a href="https://github.com/imrehg/bmpow-rust">library is available on Github</a>. Feel free to send me a bitmessage at <span class="lang:default decode:true crayon-inline ">BM-NBooR8MZhawaba2hW6nwPHvNiQKrTVCB</span> .</p>
<h2>Future</h2>
<p>I&#8217;ll definitely explore Rust more, it&#8217;s a very interesting language, and even through the difficulties understanding some parts I felt a strange happiness working with it. It feels good, even though I don&#8217;t quite know why, yet.</p>
<p>Some projects that I took a note to do (eventually):</p>
<p>An <strong>IPython kernel</strong> for Rust. Not sure whether it really makes sense, or even possible, but when I see s<a href="https://github.com/ipython/ipython/wiki/IPython-kernels-for-other-languages">o many languages listed</a> to have kernels for <a href="http://jupyter.org/">IPython/Jupyter</a>, it has to be!</p>
<p>Rust is aimed to be a systems programming language, and it&#8217;s fun to see how people use it to cross-compile for different architectures. Combining inspiration from <a href="http://www.randomhacks.net/bare-metal-rust/">Bare Metal Rust</a> and some other language&#8217;s demo to cross-compile for the Pebble (lost the link), thinking about making <strong>Rust binding for the Pebble SDK</strong> to make watchfaces and apps in Rust. This is not a fully formed idea, and there other who already done some first steps (e.g. <a href="https://github.com/franc0is/RustyPebble">a Pebble app written in Rust</a>), but I&#8217;m sure there&#8217;s a lot more path to map.</p>
<p>These are just samples, more ideas will likely come as I have more projects to do (boy, do I have a lot of projects already that I want to do&#8230;)</p>
<h2>Links of Note</h2>
<p>Some links that might be useful for others as well:</p>
<ul>
<li><a href="https://github.com/kud1ing/awesome-rust">Awesome Rust</a>: a collection of awesome rust code and resources, a lot of things!</li>
<li><a href="https://play.rust-lang.org/">Rust Playground</a></li>
<li><a href="https://crates.io/">Cargo</a>, though I&#8217;m sure every Rust programmer knows this</li>
<li><a href="http://rustbyexample.com/">Rust by Example</a></li>
<li><a href="https://doc.rust-lang.org/stable/reference.html">Rust Reference</a>, the <a href="https://doc.rust-lang.org/std/">Rust Standard Library</a></li>
<li><a href="http://lucumr.pocoo.org/2015/5/27/rust-for-pythonistas/">Rust for Pythonistas</a>, <a href="https://www.gitbook.com/book/aminb/rust-for-c/details">Rust for C++ Programmers</a></li>
</ul>
<p>Similar writeups than this:</p>
<ul>
<li><a href="http://zsiciarz.github.io/24daysofrust/">24 Days of Rust</a> (might be a bit old now, though)</li>
<li><a href="http://scattered-thoughts.net/blog/2015/06/04/three-months-of-rust/">Three Months of Rust</a></li>
</ul>
<p>Also, thanks for <a href="https://this-week-in-rust.org/">This Week in Rust</a> to mention my the previous post of this Language of the Month feature, and all the people who left a comment there to educate me about Rust, really appreciated!</p>
<p>The post <a href="https://gergely.imreh.net/blog/2015/12/lotm-rust-results/">Language of the Month: Rust, the results</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2015/12/lotm-rust-results/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Rust</title>
		<link>https://gergely.imreh.net/blog/2015/11/language-of-the-month-rust/</link>
					<comments>https://gergely.imreh.net/blog/2015/11/language-of-the-month-rust/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Fri, 06 Nov 2015 14:41:16 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[rust]]></category>
		<guid isPermaLink="false">https://gergely.imreh.net/blog/?p=2129</guid>

					<description><![CDATA[<p>I found it hard to believe, that it&#8217;s been 4 years now since I finished the previous installment of &#8220;language of the month&#8221; column, in which I pick a programming language and dive in for a month to see something new. In that 4 years I have learned a lot of programming for sure &#8211; though probably [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2015/11/language-of-the-month-rust/">Language of the Month: Rust</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I found it hard to believe, that it&#8217;s been 4 years now since I finished the previous installment of &#8220;<a href="/blog/tag/lotm/">language of the month</a>&#8221; column, in which I pick a programming language and dive in for a month to see something new. In that 4 years I have learned a lot of programming for sure &#8211; though probably very little computer science, and barely any new languages. It&#8217;s time to chance, and for the revival of this I&#8217;m checking out <a href="https://www.rust-lang.org/">Rust</a>.</p>
<p><span id="more-2129"></span></p>
<p>A bit about the LotM first, though. I was previously learning <a href="https://gergely.imreh.net/blog/2011/10/language-of-the-month-javascript/">Javascript</a>, <a href="https://gergely.imreh.net/blog/2011/09/language-of-the-month-prolog-part-2/">Prolog</a>, <a href="https://gergely.imreh.net/blog/2011/07/language-of-the-month-lua-part-2/">Lua</a>, and <a href="https://gergely.imreh.net/blog/2011/06/language-of-the-month-scala-part-3/">Scala</a>. Each time aim is to go beyond the tutorials and example code, and do something more that lets me discover the the language&#8217;s real face &#8211; strengths and weaknesses included. At the beginning of the month announcing the language like in this post, and at the end of the month in another post recap what have I learned.</p>
<h2>Getting started</h2>
<p>First start with a confession &#8211; I actually wanted to try out &#8220;the language that <a href="http://www.itworld.com/article/2978142/development/why-john-carmack-thinks-racket-is-aces-for-beginning-programmers.html">John Carmack</a> is playing with these days&#8221;, but then messed up since that is <a href="http://racket-lang.org/">Racket</a>, not Rust. I guess I&#8217;m <a href="https://news.ycombinator.com/item?id=9253585">not the only one</a> making this mistake, and never mind, that will be good for another month! I guess maybe Rust has enough mindshare on <a href="https://news.ycombinator.com">Hacker News</a> to stick in my mind.</p>
<p>So then, <a href="https://www.rust-lang.org/">Rust</a> is a systems programming language that aims to be safe, fast, and play with threads nicely. <a href="https://en.wikipedia.org/wiki/Rust_(programming_language)">Its Wikipedia article</a> has a bit more too. Searching for books, tutorials, examples, and projects that use it didn&#8217;t turn up as many sources as the previous languages I tried (though it&#8217;s much younger language too, so that&#8217;s only fair, I guess). On the other hand, it has an extensive <a href="https://doc.rust-lang.org/stable/book/">official book</a>, so that was a good place to start.</p>
<h2>First Impressions</h2>
<p>So far I&#8217;ve spent two half-evening with Rust, besides collecting the learning material I went through the first few sections of the book (no I&#8217;m in the middle of section 4, <a href="https://doc.rust-lang.org/stable/book/effective-rust.html">Effective Rust</a>).</p>
<p>Setting up Rust was pretty simple, I got to know Cargo, its package manager (and sort of build system, and sort of tooling, I guess), and did code the guided examples (both the binary and library ones), though the testing and documentation sections just read through.</p>
<pre class="lang:rust decode:true">// FizzBuzz not from the docs
fn main() {
    for num in (1..36) {
        if num % 15 == 0 {
            println!("Fizz Buzz");
        } else if num % 3 == 0 {
            println!("Fizz");
        } else if num % 5 == 0 {
            println!("Buzz");
        } else {
            println!("{}", num);
        }
    }
}</pre>
<p>So far it&#8217;s relatively straightforward, interesting, but I have seen very little where its strength lies. Having first class concept of documentation in code, directly including tests, debug &amp; release builds by default, easy project setup boilerplating are good, though I guess those sort of should be default for every new language as &#8220;best practice&#8221;.</p>
<p>What I&#8217;ve seen a bit instead, is quite a bit of arbitrariness in language. I do accept that it would be strange if first time seeing a new language  everything made sense, and try to cut it some slack. Still, for example why is there so much mixing between lowercase and uppercase type names, as well as abbreviated and not abbreviated versions, eg. <span class="lang:rust decode:true  crayon-inline ">String</span>  and <span class="lang:rust decode:true  crayon-inline ">&amp;str</span> ? I wonder. Having seen a few expression compositions in the <a href="https://doc.rust-lang.org/stable/book/learn-rust.html">tutorial projects</a>, they also feel quite arbitrary (ie. the method names don&#8217;t give a good idea what they are supposed to be doing &#8211; why <span class="lang:rust decode:true  crayon-inline ">.unwrap()</span> after a thread <span class="lang:rust decode:true  crayon-inline ">.join()</span> ? Will get there, but it&#8217;s hazy at the moment.) That might be just the issue of the tutorials, so I give that time too. And try to remember, that even though e.g. Python feels so &#8220;homely&#8221; now for me, there must have been some time when it wasn&#8217;t. Curiosity will help with this, and Rust has my attention.</p>
<p>In the meantime onwards with the documentation, and I&#8217;m looking for some project ideas and others&#8217; existing projects to look at (suggestions are welcome).</p>
<p>The post <a href="https://gergely.imreh.net/blog/2015/11/language-of-the-month-rust/">Language of the Month: Rust</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2015/11/language-of-the-month-rust/feed/</wfw:commentRss>
			<slash:comments>14</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Javascript</title>
		<link>https://gergely.imreh.net/blog/2011/10/language-of-the-month-javascript/</link>
					<comments>https://gergely.imreh.net/blog/2011/10/language-of-the-month-javascript/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Sun, 02 Oct 2011 10:29:18 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[lotm]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=528</guid>

					<description><![CDATA[<p>Continuing the Language of the Month serious after a little bit of break when I was busy with other stuff: May: Scala June: Lua July/August: Prolog September: Javascript It is very long overdue, since I was looking at Javascript like&#8230;. 14 years now? But never really spent time to understand it because I never needed [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/10/language-of-the-month-javascript/">Language of the Month: Javascript</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Continuing the Language of the Month serious after a little bit of break when I was busy with other stuff:</p>
<ul>
<li>May: <a title="Language of the Month: Scala" href="http://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/" target="_blank">Scala</a></li>
<li>June: <a title="Language of the Month: Lua" href="http://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/" target="_blank">Lua</a></li>
<li>July/August: <a title="Language of the Month: Prolog" href="http://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/" target="_blank">Prolog</a></li>
<li>September: Javascript</li>
</ul>
<figure id="attachment_535" aria-describedby="caption-attachment-535" style="width: 150px" class="wp-caption aligncenter"><a href="http://gergely.imreh.net/blog/wp-content/uploads/2011/10/Introduction-tojavascript-programming.png"><img decoding="async" class="size-thumbnail wp-image-535" title="Javascript icon" src="http://gergely.imreh.net/blog/wp-content/uploads/2011/10/Introduction-tojavascript-programming-150x150.png" alt="Javascript icon" width="150" height="150" srcset="https://gergely.imreh.net/blog/wp-content/uploads/2011/10/Introduction-tojavascript-programming-150x150.png 150w, https://gergely.imreh.net/blog/wp-content/uploads/2011/10/Introduction-tojavascript-programming.png 256w" sizes="(max-width: 150px) 100vw, 150px" /></a><figcaption id="caption-attachment-535" class="wp-caption-text">Just a Javascript icon...</figcaption></figure>
<p>It is very long overdue, since I was looking at Javascript like&#8230;. 14 years now? But never really spent time to understand it because I never needed it really. I&#8217;m old enough to remember that when I started to browse the web, every time there was a page using Javascript, people&#8217;s sentiment was <em>&#8220;oh, no, that&#8217;s going to be very slow, I don&#8217;t even want to check this site anymore&#8221;</em>. Pretty much like it was/is with Flash later on.</p>
<p>Compare this to now, how 100% static sites are practically disappeared, and no web developer worth their salt should skip on learning it. I&#8217;m glad that browsers spent a lot of time improving performance and that so many interesting projects came out of it.</p>
<p>My impression of the current state of the art is that using HTML + CSS + Javascript now it is easier than ever to make good front-ends for programs. I&#8217;m mostly a command-line guy (and that&#8217;s pretty easy with many scripting languages as well as Python that I use), but I cannot deny that I&#8217;m the minority. Still, when i need convenience, I can even imagine people creating local (meaning not internet-enabled) software with those things.</p>
<p>Since more and more people had similar idea and started to work on it, there are plenty of projects that make this even easier, like <a title="jQuery home page" href="http://jquery.com/" target="_blank">jQuery</a> and all its plugins. I don&#8217;t think people need a lot of introduction and already can do a lot of things easier using that. One drawback is that many things could be just as easily done in pure Javascript but people quite often don&#8217;t know that. I certainly have to learn a lot more.</p>
<p>In this month I was reading a few books and sites that people recommended on <a title="Hacker News homepage" href="http://news.ycombinator.net" target="_blank">Hacker News</a>, as well as I used it to do a few actual projects. Now that&#8217;s a change compared to the previous Language of the Month columns.</p>
<h2>Projects</h2>
<p><a title="WatchDoc homepage on Github" href="http://imrehg.github.com/WatchDoc/" target="_blank">WatchDoc</a>: a Chrome extension that notifies you when your shared documents on Google Docs change. Chrome extensions are merely HTML+CSS+JS code, so it was a perfect way to try a few things. <em><del>(Will write it up here later)</del> (<a title="WatchDoc – an experiment in Chrome Extensions" href="http://gergely.imreh.net/blog/2011/10/watchdoc/" target="_blank">wrote up here</a>).</em></p>
<p><a title="NowJS homepage" href="http://nowjs.com/" target="_blank">NowJS</a> real time games hackathon: NowJS is a real-time communication plugin for NodeJS, the JS server. I wanted to make a game for this hackathon, but run out of time. Spent some time working with it, and it&#8217;s actually pretty awesome when I started to understand it, I&#8217;m do want to finish the game at a later time (it&#8217;s a multiplayer trivia game) . <em>(Will write it up here later)</em></p>
<p><a title="Venus &amp; Mars Facebook app homepage" href="https://radiant-winter-3461.herokuapp.com/" target="_blank">Venus &amp; Mars</a>: a little afternoon project using Facebook to help my friend&#8217;s research assignment at her university. Listing people&#8217;s status updates separated by gender. It looks awfully ugly, because I just wanted to make it work, but for the fun of it it&#8217;s NodeJS so good to practice my JS-foo.  <em>(Will write it up here later)</em></p>
<h2>Impressions</h2>
<p>I definitely going to learn more of it, because now that I start to understand I quite like it, and I cannot imagine it going away anytime soon. Now that it is just a matter of seconds to set up a project on the web (really, on <a title="Heroku homepage" href="http://www.heroku.com/" target="_blank">Heroku</a>, <a title="Google AppEngine home page" href="https://appengine.google.com/" target="_blank">Appengine</a>, <a title="dotCloud home page" href="https://www.dotcloud.com/" target="_blank">dotCloud</a> are all one click away) there&#8217;s no good excuse not to do that.</p>
<h3>Good</h3>
<ul>
<li><a title="Introduction to JSON" href="http://json.org/" target="_blank">JSON</a>, &#8217;nuff said. That&#8217;s just such a good data format that is both human and machine readable. Seem to be pretty much the</li>
<li>No problem (it seems) with Unicode and international characters. Though I think it uses UTF-16 while many other code is using UTF-8, not sure if that makes any difference.</li>
<li>Feels quite light and flexible (from the language point of view, not necessarily the resources needed)</li>
<li>Since the source of websites is necessarily open, it is possible to learn from others&#8217; examples much easier than otherwise.</li>
</ul>
<h3>Bad</h3>
<ul>
<li>Feels like it has a lot of baggage from it&#8217;s long(ish) and torrid life, which makes it feel a bit inconsistent. E.g. the first day of the month is 1, but the first month (January) is 0.</li>
<li>People generally seem to write pretty bad Javascript code. Because it&#8217;s so easy everyone can make some useful project, but they are full of bugs. Fortunately it&#8217;s Open Source, so I can try to figure it out, and I did find a handful of upstream bugs. But the stress&#8230;. huh&#8230;</li>
</ul>
<h3>Ugly</h3>
<ul>
<li>Formatting of JS code can be pretty unreadable (especially comparing with Python where formatting is not optional). It is made more difficult when I&#8217;m editing JS within a HTML file, since Emacs cannot handle that well.</li>
<li>Up until quite recently there weren&#8217;t any really good tools to troubleshoot things. Fortunately there&#8217;s <a title="Chrome homepage" href="http://www.google.com/chrome" target="_blank">Chrome</a> and it&#8217;s Javascript console, and <a title="Firebug home page" href="http://getfirebug.com/" target="_blank">Firebug</a> for Firefox. There are still some mysterious errors and the debugging has to be planned well ahead.</li>
<li>There are many things that are straightforward but require a lot of typing. Fortunately projects like jQuery are trying to fix that, but still there&#8217;s a long way to go.</li>
<li>Just like in Lua, for keys in dictionaries the quotation marks are not required and they are still understood as strings. These kind of magic can be convenient but there are occasions when confusing.</li>
</ul>
<h2>Links</h2>
<h3>Books</h3>
<ul>
<li><a title="Javascript: The Definitive Guide book homepage" href="http://shop.oreilly.com/product/9780596805531.do" target="_blank">Javascript: The Definitive Guide</a> &#8211; how to do things in browser, very modern, even jQuery, teaches some strange practices like single line non {} functions and missing semicolons (for many pages!)</li>
<li><a title="Javascript: The Good Parts book homepage" href="http://shop.oreilly.com/product/9780596517748.do" target="_blank">Javascript: The Good Parts</a>, a good quick overview, also recommended by many</li>
</ul>
<h3>Interesting Javascript projects and sites</h3>
<ul>
<li><a title="jQuery homepage" href="http://jquery.com/" target="_blank">jQuery</a>: making it easier to use JS, especially with respect to HTML DOM manipulation</li>
<li><a title="Node.js homepage" href="http://nodejs.org/" target="_blank">Node.js</a>: server side JS, thus it is possible for the first time (?) to use the same language for the front and back end on the web</li>
<li><a title="jsFiddle home page" href="http://jsfiddle.net/" target="_blank">jsFiddle</a>: easy online editor, prototyping and code sharing for the web (JavaScript, MooTools, jQuery, Prototype, YUI, Glow and Dojo, HTML, CSS)</li>
</ul>
<p><em>(last edited 2011-10-03)</em></p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/10/language-of-the-month-javascript/">Language of the Month: Javascript</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/10/language-of-the-month-javascript/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Prolog, part 2</title>
		<link>https://gergely.imreh.net/blog/2011/09/language-of-the-month-prolog-part-2/</link>
					<comments>https://gergely.imreh.net/blog/2011/09/language-of-the-month-prolog-part-2/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Wed, 07 Sep 2011 09:38:50 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[books]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[prolog]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=451</guid>

					<description><![CDATA[<p>If something, then this is a belated post. Prolog was the language of July and now it&#8217;s September. Anyway, before I completely fail, let&#8217;s just wrap it up and go on the next language with this one month hiatus in August. I really enjoyed the language and one month is indeed barely enough to start [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/09/language-of-the-month-prolog-part-2/">Language of the Month: Prolog, part 2</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>If something, then this is a belated post. Prolog was the <a title="Language of the Month: Prolog" href="http://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/" target="_blank">language of July</a> and now it&#8217;s September. Anyway, before I completely fail, let&#8217;s just wrap it up and go on the next language with this one month hiatus in August.</p>
<p>I really enjoyed the language and one month is indeed barely enough to start doing something useful. So I have to come back to it again and maybe keep reading about it in the meantime. It&#8217;s actually quite interesting to try to figure out Prolog code on paper, without actually running something. I think one of the books I was reading had plenty of exercises like this: <em>without running the code</em>, can you guess what is it doing? Needless to say, there were plenty of tricky bits/</p>
<h2>From the comments</h2>
<p>During two months, some additional resources did show up. A dear commenter on the previous post recommended me the following book: <a title="The Craft of Prolog on Goodreads" href="http://www.goodreads.com/book/show/3062424-the-craft-of-prolog" target="_blank">Richard O&#8217;Keefe: The Craft of Prolog</a>. I got about a third, maybe halfway through it and it&#8217;s interesting, written long time ago in a style that since gone out of fashion, unfortunately. It&#8217;s a programming book that is fun to read and one can see that the author is very knowledgeable. Some aspects of the book didn&#8217;t age very well, though. The author keeps comparing Prolog to other languages &#8211; many of them are not very widely available either. Also, some of the language features are specific to his version of Prolog, that wasn&#8217;t the same one I was using. Would recommend, though!</p>
<p>This last part, the different implementations of the same language, can be a real problem. Of the three compilers available for me, all of them had specific strengths and weaknesses. Guess they are converging, but not quite yet. So far I was mostly using <a title="SWI Prolog homepage" href="http://www.swi-prolog.org/" target="_blank">SWI Prolog</a>, but this might change in the future.</p>
<p>The said commenter also recommended a cross-compiler, doing Prolog-to-C magic, for portability and other goodness. Can grab it from here: <a title="Prolog to C compiler" href="http://ftp.shaw.ca/irvinsh/prolog.tar.gz" target="_blank">http://ftp.shaw.ca/irvinsh/prolog.tar.gz</a> I haven&#8217;t had time to try it yet, but once I have, I&#8217;ll do a comparison.</p>
<h2>From the web</h2>
<p>From a friend&#8217;s recommendation I was checking out <a title="Bookboon homepage" href="http://bookboon.com/uk/" target="_blank">a site with free textbooks</a>. They are all advertisement-sponsored, which is an intriguing idea (for another post). The <a title="Bookboon - IT and Programming" href="http://bookboon.com/uk/textbooks/it-programming" target="_blank">IT section</a> had not one but two books on Prolog: <a title="Book - Prolog Techniques" href="http://bookboon.com/uk/textbooks/it-programming/prolog-techniques-applications-of-prolog" target="_blank">Prolog Techniques</a> and <a title="Book - Applications of Prolog" href="http://bookboon.com/uk/textbooks/it-programming/applications-of-prolog" target="_blank">Applications of Prolog</a>.</p>
<figure id="attachment_492" aria-describedby="caption-attachment-492" style="width: 420px" class="wp-caption aligncenter"><a href="http://gergely.imreh.net/blog/wp-content/uploads/2011/08/prolog_books.jpg"><img fetchpriority="high" decoding="async" class="size-full wp-image-492" title="Prolog book covers" src="http://gergely.imreh.net/blog/wp-content/uploads/2011/08/prolog_books.jpg" alt="Two prolog book covers" width="420" height="297" /></a><figcaption id="caption-attachment-492" class="wp-caption-text">Free textbooks on Prolog from Bookboon</figcaption></figure>
<p>This latter one has a Hungarian author so I&#8217;m even more intrigued, we used to have great computer scientists (<a title="John von Neumann on Wikipedia" href="http://en.wikipedia.org/wiki/Von_Neumann" target="_blank">John von Neumann / Neumann János</a>, anyone?), so I hope we keep up that tradition. (Oh, yeah, and had great physicists as well, maybe I can do more on that front later).</p>
<p>I was only skimmed them a little bit, but looks like these will be good addition for my &#8220;programming for fun and efficiency&#8221; library.</p>
<p>Will update the original <a title="Language of the Month: Prolog" href="http://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/" target="_blank">LotM:Prolog</a> page with these links as well. Now onto September&#8217;s Language, fortunately I have idea what I want to learn for the next ~3.5 weeks. October will be something Artificial Intelligence related since I signed up for the <a title="Stanford's Artificial Intelligence class" href="http://ai-class.com" target="_blank">AI-class.</a></p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/09/language-of-the-month-prolog-part-2/">Language of the Month: Prolog, part 2</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/09/language-of-the-month-prolog-part-2/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Prolog</title>
		<link>https://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/</link>
					<comments>https://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Sun, 17 Jul 2011 12:57:49 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[prolog]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=413</guid>

					<description><![CDATA[<p>New month, new programming language to learn, the 3rd one in this series. So the repertoire so far contains: May: Scala June: Lua July: Prolog Prolog It is again a very different choice, logic programming. Been playing with it for the last two weeks or so, and it really makes me think differently about programming [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/">Language of the Month: Prolog</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>New month, new programming language to learn, the 3rd one in this series. So the repertoire so far contains:</p>
<ul>
<li>May: <a title="Language of the Month: Scala" href="http://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/" target="_blank">Scala</a></li>
<li>June: <a title="Language of the Month: Lua" href="http://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/" target="_blank">Lua</a></li>
<li>July: Prolog</li>
</ul>
<h2>Prolog</h2>
<p>It is again a very different choice, logic programming. Been playing with it for the last two weeks or so, and it really makes me think differently about programming and programs. Logic and complex thinking was always a favorite past-time of me (e.g. solving puzzles and such), but only now I realized that I do have a lot to practice in this area.</p>
<p>Prolog is also one of the older languages (feels like a &#8220;classmate&#8221; of Lisp and Fortran) so it was the first language in the series where I could actually go to a library, take out some books to learn it, and that book wasn&#8217;t hopelessly out of date (try to do the same thing with Python or Ruby&#8230;). Since these books were also written by academics and not necessarily computer scientists, their whole approach is different, in a way more curious, though probably less practical.</p>
<p>In the end, I think what I would like to gain is a tool that I can use to attack problems that are intractable or at least very difficult in other languages.</p>
<h3>Start</h3>
<p>One of the first thing I found hard to figure out was how to actually run a program. So in a nutshell: even if most of the interaction is within an interpreter-like environment, all the basics have to be prepared in a file and loaded.</p>
<p>E.g. I prepare a file like this (based on Ender&#8217;s Game), call it <strong>ender.pl</strong>:</p>
<pre lang="prolog">%% Genealogy of Ender's Game.
% Facts
male(ender).
male(peter).
male('john paul').
female(valentine).
female(theresa).

parent('john paul', ender).
parent('john paul', peter).
parent('john paul', valentine).
parent(theresa, ender).
parent(theresa, peter).
parent(theresa, valentine).

% Predicates
father(X, Y) :-
	male(X),
	parent(X, Y).
mother(X, Y) :-
	female(X),
	parent(X, Y).

sibling(X, Y) :-
	father(F, X), mother(M, X),
	father(F, Y), mother(M, Y),
	X \= Y.
brother(X, Y) :-
	male(X),
	sibling(X, Y).
sister(X, Y) :-
	female(X),
	sibling(X, Y).</pre>
<p>Then starting Prolog I can load the file with the <strong>[&#8216;ender.pl&#8217;].</strong> form, and ask questions like who is Ender&#8217;s sister? Who are Theresa&#8217;s kids? Who are Peter&#8217;s siblings?</p>
<pre lang="Prolog">?- ['ender.pl'].
% ender.pl compiled 0.00 sec, 144 bytes
true.

?- sister(Sis, ender).
Sis = valentine ;
false.

?- mother(theresa, Kid).
Kid = ender ;
Kid = peter ;
Kid = valentine.

?- sibling(peter, X).
X = ender ;
X = valentine ;
false.</pre>
<p>Well, this is laughably simple, and I&#8217;m beyond this already, but it&#8217;s good for a first illustration.</p>
<p>By the way, it looks like 90% of elementary Prolog examples use family trees (Nordic or Greek gods, literary, real families&#8230;)</p>
<p>Now let&#8217;s get in there and learn some more stuff&#8230;</p>
<h2>Links</h2>
<h3>Tutorials &amp; Info</h3>
<ul>
<li><a title="A Short Tutorial on Prolog" href="http://www.doc.gold.ac.uk/~mas02gw/prolog_tutorial/prologpages/" target="_blank">A Short Tutorial on Prolog</a></li>
<li><a title="Adventure in Prolog homepage" href="http://www.amzi.com/AdventureInProlog/index.php" target="_blank">Adventure in Prolog</a></li>
<li><a title="Lecture 13 in the Lecture Series on Artificial Intelligence by Prof. P. Dasgupta, " href="http://www.youtube.com/watch?v=jySpg72Vbc4" target="_blank">Logic Programing lecture</a> and <a title="Lecture 14 in Lecture Series on Artificial Intelligence by Prof. P. Dasgupta" href="http://www.youtube.com/watch?v=iJhtgWAGUAQ" target="_blank">Prolog Programming</a> (videos)</li>
<li><a title="Prolog on Wikipedia" href="http://en.wikipedia.org/wiki/Prolog" target="_blank">Prolog on Wikipedia</a></li>
</ul>
<h3>Books</h3>
<ul>
<li><a title="The Art of Prolog book homepage" href="http://mitpress.mit.edu/catalog/item/default.asp?ttype=2&amp;tid=8327" target="_blank">The Art of Prolog</a></li>
</ul>
<h3>Compilers</h3>
<ul>
<li><a title="SWI Prolog homepage" href="http://www.swi-prolog.org/" target="_blank">SWI Prolog</a></li>
<li><a title="GNU Prolog homepage" href="http://www.gprolog.org/" target="_blank">GNU Prolog</a></li>
<li><a title="Yet Another Prolog homepage" href="http://www.dcc.fc.up.pt/~vsc/Yap/" target="_blank">Yet Another Prolog (YAP)</a></li>
</ul>
<h3>Code</h3>
<ul>
<li><a title="Solve Einstein’s Riddle using Prolog" href="http://www.baptiste-wicht.com/2010/09/solve-einsteins-riddle-using-prolog/" target="_blank">Einstein&#8217;s Riddle in Prolog</a></li>
</ul>
<p>The post <a href="https://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/">Language of the Month: Prolog</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/07/language-of-the-month-prolog/feed/</wfw:commentRss>
			<slash:comments>5</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Lua, part 2</title>
		<link>https://gergely.imreh.net/blog/2011/07/language-of-the-month-lua-part-2/</link>
					<comments>https://gergely.imreh.net/blog/2011/07/language-of-the-month-lua-part-2/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Mon, 04 Jul 2011 15:43:01 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[lua]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=366</guid>

					<description><![CDATA[<p>I&#8217;m a few days behind schedule since Lua was June&#8217;s language, but here it comes, some summary of my experience, after setting things up in the first part. Overview I really liked this language, and I&#8217;m sure I&#8217;ll keep learning it. Very useful and lots of interesting concepts. I haven&#8217;t seen an embedded language before, [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/07/language-of-the-month-lua-part-2/">Language of the Month: Lua, part 2</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I&#8217;m a few days behind schedule since Lua was June&#8217;s language, but here it comes, some summary of my experience, after setting things up in the <a title="Language of the Month: Lua" href="http://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/" target="_blank">first part</a>.</p>
<figure id="attachment_392" aria-describedby="caption-attachment-392" style="width: 300px" class="wp-caption aligncenter"><a href="http://gergely.imreh.net/blog/wp-content/uploads/2011/07/vlcsnap-151508.png"><img decoding="async" class="size-medium wp-image-392 " title="Moon" src="http://gergely.imreh.net/blog/wp-content/uploads/2011/07/vlcsnap-151508-300x225.png" alt="A Trip to the Moon / Le Voyage dans la Lune" width="300" height="225" /></a><figcaption id="caption-attachment-392" class="wp-caption-text">Lua is not this painful, indeed, just the opposite</figcaption></figure>
<h2>Overview</h2>
<p>I really liked this language, and I&#8217;m sure I&#8217;ll keep learning it. Very useful and lots of interesting concepts. I haven&#8217;t seen an embedded language before, and some parts</p>
<p>Most of what I picked up was from <a title="Beginning Lua Programming book's site" href="http://www.wrox.com/WileyCDA/WroxTitle/Beginning-Lua-Programming.productCd-0470069171.html" target="_blank">Beginning Lua Programming</a> and <a title="Programming in Lua, First Edition" href="http://www.lua.org/pil/index.html" target="_blank">Programming in Lua</a>. <a title="Lua Missjons on Github" href="https://github.com/kikito/lua_missions" target="_blank">Lua Missions</a> was another very useful experience: a &#8220;fill in the blank&#8221; type of source code collection, which drilled my understanding of the Lua concepts. Some sections felt a little short, so maybe later I&#8217;ll think whether there are any more questions I can come up with. Very well worth the time!</p>
<p>There are two things that stand out: tables and local environments.</p>
<h3>Tables</h3>
<p>If I have to refer to my knowledge of Python, then Lua tables are like Python lists and dicts rolled into one and then some. Here&#8217;s one such table:</p>
<pre lang="lua">x = {1, 2, 3, y = "something", ["or else"]="what"}</pre>
<p>The first three elements are giving an array (and one can loop over them), then the last two are key-value pairs. One tricky thing is that the &#8220;y&#8221; there is actually a string (the same as [&#8220;y&#8221;]), just made it more readable with syntactic sugar. Since variables (references to variables) can be keys as well, this can get confusing if one has a variable called &#8220;y&#8221;&#8230; There are quite a few things about tables that are confusing, but actually pretty consistent so my fuses are not blowing that much as they were in the beginning (for example: how the length is looked up, how to iterate through the different values) .</p>
<p>They are very complex animals so some things are quite complex to do, which in turn enables quite complex things to be done. Pretty much any kind of data structure can be built upon them. So all in all, I&#8217;m enjoying them with all their quirks. Also, &#8220;weak tables&#8221; are an interesting concept (where certain table entries can garbage collected).</p>
<h3>Scopes</h3>
<p>In Python, the name spaces and environments seem to be on the sidelines (at least what I&#8217;ve seen so far): people need it and have to us it, but nothing more than that. In Lua this is taken to a whole new level: scopes can be essential parts of the way algorithms are implemented and neat tricks can be played.</p>
<p>I tried to come up with some good example and failed, here&#8217;s a &#8220;duh&#8221; one:</p>
<pre lang="lua">function newCounter ()
    local i = 0
    return function ()   -- anonymous function
        i = i + 1
        return i
    end
end

c1 = newCounter()
print(c1())  -- 1
print(c1())  -- 2</pre>
<p>This is a bit like Python&#8217;s &#8220;<a title="yield explained on StackOverflow" href="http://stackoverflow.com/questions/231767/the-python-yield-keyword-explained/231855#231855" target="_blank">yield</a>&#8221; type of generator, without anything special.</p>
<p>Also, in Python there are only two kinds of variables (I think): local and global: either just for you or for everyone. Here they have one more: upvalues, where the variable is local to a parent, so children environment can access them but the parent&#8217;s parents cannot. They are strange beasts as well, e.g. the code itself cannot really know if a variable is upvalue or global, only that it can access that.</p>
<p>And of course these scopes help embedding to not just be possible but straightforward and powerful. Local environments can be restricted, some things selectively enabled, and all this transparently, so the script running might not even know that it&#8217;s being in the Matrix.</p>
<h2>The Lua Experience</h2>
<h3>Good</h3>
<ul>
<li>Fast, both start up and running</li>
<li>Language itself is quite small, possible to wrap one&#8217;s head around quite easily</li>
<li>Written in ANSI C, so basically on every architecture where one can run C, one can have Lua as well</li>
<li>Quite a few program has Lua interpreter or interface built in, see the <a title="List of Lua-enabled applications" href="http://en.wikipedia.org/wiki/Lua_(programming_language)#Applications" target="_blank">list of these at Wikipedia</a></li>
<li>Tables are great and once one mastered them, are really Swiss Army Knives</li>
<li>Built in interpreter (though could use a little love like <a title="iPython homepage" href="http://ipython.scipy.org/moin/" target="_blank">iPython</a>)</li>
<li>The &#8220;&#8230;&#8221; syntax for variable number of arguments</li>
<li>Astrological naming convention &#8211; modules are <em>rocks</em>, the exercises I linked previously are missions, web framework is <a title="Kepler: the Lua Web Framework homepage" href="http://www.keplerproject.org/" target="_blank">Kepler</a>&#8230;</li>
</ul>
<h3>Bad</h3>
<ul>
<li>There seem to be a lot of reserved names (e.g. in <a title="Metatables section Programming in Lua" href="http://www.lua.org/pil/index.html#13" target="_blank">metatables</a>) that would be pretty much impossible to figure out with a book (and/or an iPython-like helpful environment), though this is a problem probably only when starting out with Lua</li>
</ul>
<h3>Ugly</h3>
<ul>
<li>While some complex things can be solved, some simple things can require complex coding (e.g. in case of the tables when using &#8220;<a title="__index in Programming in Lua" href="http://www.lua.org/pil/13.4.1.html" target="_blank">__index</a>&#8221; and &#8220;<a title="__newindex in Programming in Lua" href="http://www.lua.org/pil/13.4.2.html" target="_blank">__newindex</a>&#8220;) and there are things that are not even possible. Or I just misunderstood some sections of the book.</li>
<li>Using a lot of syntactic sugar (especially in the <a title="Object Oriented programming of Lua" href="http://www.lua.org/pil/index.html#16" target="_blank">object oriented section</a>), that I feel need some more practice to pick up, as things can be done in multiple ways</li>
<li>The tables&#8217; syntactic sugar covered way of handling string keys, convenient when things go well, mighty confusing at even the slightest problem</li>
<li>Too few projects using Lua, too few sources of information (this is not the language&#8217;s fault, though)</li>
</ul>
<h2>Project</h2>
<p>Originally I wanted to do some useful programming in every language I learn during the Language of the Month series. I failed with Scala (lazy), and now failed with Lua too (underestimating the difficulty). I&#8217;m using VLC a lot and it has Lua scripting enabled, so I wanted to do a plugin that can be useful for me later as well. This didn&#8217;t work out very well, mainly because it feels the VLC Lua interface is not very well documented, one mostly have to find some examples that exist already and use them. I ended up wasting a lot of time and still don&#8217;t quite understand how to do certain things I would like for my code, and don&#8217;t even know if it&#8217;s possible to do or not. Will come back to it later, until that here are a few links that helped me to get started:</p>
<ul>
<li><a title="Instructions to code your own VLC Lua scripts." href="http://www.videolan.org/developers/vlc/share/lua/README.txt" target="_blank">VLC Lua FAQ</a> &#8211; detailed list of available API functions, but almost no context and examples</li>
<li><a title="Lua script souces" href="http://git.videolan.org/gitweb.cgi?p=vlc.git;a=tree;f=share/lua;h=1bd0a9fe2ddcf6a07b8910bbb25dc7f66c832b5c;hb=HEAD" target="_blank">Lua extensions in the VLC git repo</a> &#8211; one can pick up something by checking out those examples</li>
<li><a title="Extending VLC with Lua" href="http://www.coderholic.com/extending-vlc-with-lua/" target="_blank">Example: Streaming Radio Player Extension</a> &#8211; someone who have gone further down this road than me and has a working extension. Very educational, especially to see how concise and straightforward it can be, because the VLC Lua API seems to be thought out well.</li>
</ul>
<p>Again, hopefully pick this up later (I mean it).</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/07/language-of-the-month-lua-part-2/">Language of the Month: Lua, part 2</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/07/language-of-the-month-lua-part-2/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Lua</title>
		<link>https://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/</link>
					<comments>https://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/#respond</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Sun, 05 Jun 2011 08:25:34 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[lua]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=353</guid>

					<description><![CDATA[<p>New month, new language. So far in this series: May: Scala June: Lua I think I do want to amend the original rules set up for this Language of the Month series. At first I though I can write a new project in any language I learn. That is probably too ambitious. So new rules: every [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/">Language of the Month: Lua</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>New month, new language. So far in this series:</p>
<ul>
<li>May: <a title="Language of the Month: Scala" href="http://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/" target="_blank">Scala</a></li>
<li>June: Lua</li>
</ul>
<p>I think I do want to amend the original rules set up for this Language of the Month series. At first I though I can write a new project in any language I learn. That is probably too ambitious. So new rules: <em>every month write a new project in the given language OR contribute to an open-source project in that language.</em> This should take away most of the stress and add some social aspect as well. :)</p>
<h2>Lua</h2>
<p>I&#8217;m intrigued by this language because of it&#8217;s niche: scripting language within other software. How one sets out to do something like this? What are the requirements for the language, in terms of design, syntax and so on?</p>
<figure id="attachment_352" aria-describedby="caption-attachment-352" style="width: 256px" class="wp-caption aligncenter"><a href="http://gergely.imreh.net/blog/wp-content/uploads/2011/06/lua.gif"><img loading="lazy" decoding="async" class="size-full wp-image-352" title="lua" src="http://gergely.imreh.net/blog/wp-content/uploads/2011/06/lua.gif" alt="Lua programming language logo" width="256" height="255" /></a><figcaption id="caption-attachment-352" class="wp-caption-text">See, the moon!</figcaption></figure>
<h3>First impressions</h3>
<p>So far I was trying out some code snippets and example scripts. First thing to notice was that Lua is pretty darn quick to start. And pretty quick to run as well, though I haven&#8217;t used it for very heavy computation yet. E.g. the &#8220;get_all_factors&#8221; code at the <a title="Lua Crash Course" href="http://luatut.com/crash_course.html" target="_blank">Lua Crash Course</a> (using a larger example number, 1029384756) is timed at ~7ms, wheres the same version on Python (the language that I probably know best and compare other languages to) runs ~10x slower. The snappiness of a scripting language is a surprisingly happy feeling. :)</p>
<p><a title="Lua on Wikipedia: Tables" href="http://en.wikipedia.org/wiki/Lua_(programming_language)#Tables" target="_blank">Tables</a> look very interesting, how the same thing can implement several data structures at once (it&#8217;s like Python&#8217;s dict, list and kinda-struct at the same time).</p>
<p>Quite intriguing that the Lua Virtual Machine is stack based, probably that&#8217;s the reason the language is so embeddable. A while back I was <a title="Language choice for small memory footprint" href="http://stackoverflow.com/questions/5004882/language-choice-for-small-memory-footprint" target="_blank">looking for</a> a language with small resource (especially memory) requirements. I had a few suggestions (Dalvik, Forth) that were interesting, but maybe Lua is the one?</p>
<p>The &#8220;local&#8221; keyword (and the reasons for having it) seems to be a possible source of many harder to debug scenarios. Got to keep this in mind, again not being in Pythonland anymore.</p>
<p>Interesting how the &#8220;function&#8221; can be defined inline, so looks like there&#8217;s essentially no need for a special &#8220;lambda&#8221; keyword, at the expense of tying a few characters more&#8230;</p>
<p>The interpreter is quite well done (with it&#8217;s intelligent indentation probably even better then ipython, though would love to see more colours ^^)</p>
<p>As an exercise, here&#8217;s a version of <a title="FizzBuzz definition" href="http://www.codinghorror.com/blog/2007/02/why-cant-programmers-program.html" target="_blank">FizzBuzz</a>:</p>
<pre lang="lua">function fizzbuzz(num)
   --[[--
   The usual FizzBuzz from Jeff Atwood
   Doing it a bit roundabout to try some Lua language features
   --]]--
   local answer = ""

   if (num % 5) == 0 then
      answer = "Fizz"
   end
   if (num % 3) == 0 then
      answer = answer .. "Buzz"
   end

   if answer ~= "" then
      print(answer)
   else
      print(num)
   end
end

-- Run the thing
for num=1,100,1 do
   fizzbuzz(num)
end</pre>
<h2>Links</h2>
<p>This section will be updated gradually as I find more information.</p>
<p>(<strong>Edit:</strong> added the <a title="Language of the Month: Lua, part 2" href="http://gergely.imreh.net/blog/2011/07/language-of-the-month-lua-part-2/">second part of this experiment</a>.)</p>
<h3>Install</h3>
<ul>
<li><a title="Lua website" href="http://www.lua.org/" target="_blank">Lua</a></li>
<li><a title="LuaJIT website" href="http://luajit.org/" target="_blank">LuaJIT</a></li>
<li><a title="Lua Live Demo site" href="http://www.lua.org/demo.html" target="_blank">Lua Live Demo</a></li>
</ul>
<h3>Tutorials</h3>
<ul>
<li><a title="Lua Tutorial" href="http://luatut.com/" target="_blank">A crash course on Lua</a>, very short but poignant</li>
<li><a title="Lua Users Wiki - tutorial directory" href="http://lua-users.org/wiki/TutorialDirectory" target="_blank">Tutorial directory</a> on Lua Users Wiki</li>
<li><a title="Lua for Beginners site" href="http://lua.gts-stolberg.de/en/index.php" target="_blank">Lua for Beginners</a></li>
<li><a title="Lua on Wikipedia" href="http://en.wikipedia.org/wiki/Lua_(programming_language)" target="_blank">Lua on Wikipedia</a>, a quick overview</li>
</ul>
<h3>Books</h3>
<ul>
<li><a title="Beginning Lua Programming book website" href="http://www.wrox.com/WileyCDA/WroxTitle/Beginning-Lua-Programming.productCd-0470069171.html" target="_blank">Beginning Lua Programming</a></li>
<li><a title="Programming in Lua book site" href="http://www.lua.org/pil/" target="_blank">Programming in Lua</a></li>
</ul>
<h3>Articles and info</h3>
<ul>
<li><a title="Google search for Lua on Hacker News" href="http://www.google.com/search?q=Lua+site%3Anews.ycombinator.net" target="_blank">Lua mentions on Hacker News</a> (search results)</li>
<li><a title="Slideshare: search for Lua" href="http://www.slideshare.net/search/slideshow?searchfrom=header&amp;q=lua" target="_blank">Presentations on Slideshare</a> (search results)</li>
<li><a title="Youtube: WoW scripting with Lua" href="http://www.youtube.com/watch?v=4_l-_r6hnvk" target="_blank">World of Warcraft AI scripting with Lua</a> (video)</li>
</ul>
<h3>Source of code</h3>
<ul>
<li><a title="Search for Lua on Github" href="https://github.com/languages/Lua" target="_blank">Lua code on Github</a></li>
<li><a title="Google Code Search for Lua" href="http://www.google.com/codesearch?q=lang:lua" target="_blank">Lua search on Google Code Search</a>, add a keyword, e.g. &#8220;function&#8221; to actually see something</li>
</ul>
<h3>Projects using Lua</h3>
<ul>
<li><a title="Luatex homepage" href="http://www.luatex.org/" target="_blank">LuaTex</a>, a scripting enabled version of pdfTex</li>
<li><a title="LuaForge, a collection of projects" href="http://luaforge.net/" target="_blank">LuaForge</a>, collection of projects</li>
<li><a title="Lua on Wikipedia: Applications" href="http://en.wikipedia.org/wiki/Lua_%28programming_language%29#Applications" target="_blank">Lua: Applications</a> (on the Wikipedia page)</li>
</ul>
<p>The post <a href="https://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/">Language of the Month: Lua</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/06/language-of-the-month-lua/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Scala, part 3</title>
		<link>https://gergely.imreh.net/blog/2011/06/language-of-the-month-scala-part-3/</link>
					<comments>https://gergely.imreh.net/blog/2011/06/language-of-the-month-scala-part-3/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Wed, 01 Jun 2011 07:25:31 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[scala]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=341</guid>

					<description><![CDATA[<p>This is a post I should have written yesterday, actually, since it is already June, ready for the next &#8220;Language of the Month&#8220;. Still, let&#8217;s finish off this May Edition. Taking score First, I should have spent more time on practicing Scala, as I haven&#8217;t actually finished anything in the end. It is probably an [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/06/language-of-the-month-scala-part-3/">Language of the Month: Scala, part 3</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>This is a post I should have written yesterday, actually, since it is already June, ready for the next &#8220;<a title="Language of the Month: Scala" href="http://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/" target="_blank">Language of the Month</a>&#8220;. Still, let&#8217;s finish off this May Edition.</p>
<h2>Taking score</h2>
<p>First, I should have spent more time on practicing Scala, as I haven&#8217;t actually finished anything in the end. It is probably an excuse, but after using <a title="Python website" href="http://www.python.org/" target="_blank">Python</a> for such a long time, getting used to a compiled language with its own weird path-, naming- and import conventions, was just a little bit too much. Mostly I was reading the <a title="Programming Scala book homepage" href="http://pragprog.com/titles/vsscala/programming-scala" target="_blank">Pragmatic Bookshelf: Programming Scala</a>, practicing the examples within. That book uses Scala 2.7.x and the current version is <a title="Scala 2.9.0.1 release notes" href="http://www.scala-lang.org/node/9708" target="_blank">2.9.0.1</a>, so there are a few things that work differently and I ended up having strange error messages with little to no clue how to fix them (mostly imports, and some method signatures must have changed as well). So it was a limited but exciting success.</p>
<figure id="attachment_348" aria-describedby="caption-attachment-348" style="width: 300px" class="wp-caption aligncenter"><a href="http://gergely.imreh.net/blog/wp-content/uploads/2011/06/Scala_screenshot_small.png"><img loading="lazy" decoding="async" class="size-medium wp-image-348" title="Scala screenshot" src="http://gergely.imreh.net/blog/wp-content/uploads/2011/06/Scala_screenshot_small-300x214.png" alt="Scala screenshot" width="300" height="214" /></a><figcaption id="caption-attachment-348" class="wp-caption-text">Using them example code</figcaption></figure>
<p>All in all, I liked the language even if I don&#8217;t have a clear usage case for it in my mind (just yet). Some bullet-points of my experience:</p>
<h3>Good</h3>
<ul>
<li>Different way of thinking about &#8220;batch&#8221; operations (i.e. foldLeft)</li>
<li>Once I figure out the Actors that well that I can write related code without referring to the tutorials, that&#8217;s going to be a very powerful tool</li>
<li>Pattern matching, pattern matching everything. This is one thing that blown my mind in the little Haskell I checked so far, and missing from Python a lot.</li>
<li>Flexibility with class definitions, they can handle so many different situations in a very logical and powerful way</li>
</ul>
<h3>Bad</h3>
<ul>
<li>Length of compilation and program start. Will have to get used to it, though I read some hints that this can be improved.</li>
</ul>
<h3>Ugly</h3>
<ul>
<li>Pretty frequent need of using things directly from Java, so one is never quite independent</li>
<li>Special methods that have reserved name for certain functionality (act, apply, &#8230;) that are non-obvious, and not easily distinguished from the arbitrarily defined methods.</li>
</ul>
<h2>Future</h2>
<p>Definitely will come back to it and learn it in more detail. It looks like a fine language to do parts of larger projects in. In the meantime I will update the link collection in the <a title="Language of the month: Scala, part 2" href="http://gergely.imreh.net/blog/2011/05/language-of-the-month-scala-part-2/" target="_blank">previous post</a> with new links that I find. I certainly notice more and more <a title="Scala on Hacker News" href="http://www.google.com.tw/search?&amp;q=scala+site%3Anews.ycombinator.net" target="_blank">Scala posts on Hacker News</a> these days.</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/06/language-of-the-month-scala-part-3/">Language of the Month: Scala, part 3</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/06/language-of-the-month-scala-part-3/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the month: Scala, part 2</title>
		<link>https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala-part-2/</link>
					<comments>https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala-part-2/#respond</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Fri, 20 May 2011 14:52:04 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[scala]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=324</guid>

					<description><![CDATA[<p>For the last 3 weeks or so I was checking out Scala, and will do for a little while more, so just want to do a little catch up where things are at the moment. Start I tried to find a couple of starting points to start to know about Scala. First thought video tutorials [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala-part-2/">Language of the month: Scala, part 2</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>For the last 3 weeks or so I was <a title="Language of the Month: Scala" href="http://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/" target="_blank">checking out Scala</a>, and will do for a little while more, so just want to do a little catch up where things are at the moment.</p>
<h3>Start</h3>
<p>I tried to find a couple of starting points to start to know about Scala. First thought video tutorials or talks would be useful, so been around checking on YouTube. It seems the mainly referenced intro is <a title="Scala intro on Youtube" href="http://www.youtube.com/watch?v=zqFryHC018k" target="_blank">Scala: a scalable language</a>. Well, it told me a lot about how Scala compares to other languages and how is it better than those, but not much to start learning it. Though the talk made it sound like it is one of the best and most modern languages out there, taking the most useful ideas from loads of other languages.</p>
<p>Had a copy of the <a title="Pragmatic programmer book homepage" href="http://pragprog.com/titles/vsscala/programming-scala" target="_blank">Pragmatic programmer: Programming Scala</a>, and just finished going through it. By that I mean that skimmed all the chapters and did try some of the code samples that looked interesting or strange. Not bad, but from the book I just have a very limited answer to the question of: &#8220;but what is it really great for?&#8221; Concurrency, sure, but that is probably not all.</p>
<p>I don&#8217;t know a language before I code enough in it, but before I know it I don&#8217;t have to much inspiration what to code. In this case, programming puzzle sites come very handy, though not all of them support Scala. I went to <a title="Coderloop puzzles" href="http://www.coderloop.com/puzzles" target="_blank">Coderloop</a> because they do and I can submit my solution for performance testing, or could use <a title="Project Euler home" href="http://projecteuler.net/" target="_blank">Project Euler</a> because they are language agnostic (one sends the results only).</p>
<h3>Experience</h3>
<p>Since Scala is built upon the Java Virtual Machine and supports pretty much all of Java, it feels a little Frankenstein language: every now and then, even for some things that should be quite commonly used, things have to be programmed in Java. Lots of language features are cool, though, even if most of it feels just syntactic sugar. In a way, maybe the whole language is just that? It&#8217;s not bad, makes things very concise and powerful, but always feels there&#8217;s something more in the background.</p>
<p>Actors and concurrency are pretty cool, though. In the talks I&#8217;ve seen people compared them to Erlang, just even more powerful. This is something more to play around with, would like to make something interesting, scalable and fault-tolerant &#8211; those are the fun stuff aren&#8217;t they? (But this also makes me want to try Erlang soon so I can compare).</p>
<p>Since I was doing mostly Python lately, it feels a bit weird to use a compiled language. For simple programs, it takes quite a long time to do that compilation, enough to wind me up a little when I was troubleshooting. That said, maybe I&#8217;m doing a little bit too much &#8220;<a title="Programming by Accident on Wikipedia" href="http://en.wikipedia.org/wiki/Programming_by_permutation" target="_blank">programming by accident</a>&#8220;, so I deserve it? Also, starting a Scala program takes a while as well, though once it is up and running, it&#8217;s pretty fast.</p>
<p>At this point, I&#8217;m not totally sure yet what project to make until the end of the month. I need more programming itches to scratch. The only ideas I came up so far are self-playing games with actors. Or some server/provider. Well, just keep brainstorming, something better has to come up. Maybe when I dive a little bit more into it, since at the moment I cannot really &#8220;think Scala&#8221; yet.</p>
<p>There&#8217;s also a web framework for it, called <a title="Lift, the Scala web framework" href="http://liftweb.net/">Lift</a>, which is probably not surprising. The close connection wit Java (and hence with so many of enterprise software) and event based, fault tolerant concurrency is just too juicy. Not sure if anyone&#8217;s hosing it, tough (got to check out), either way I can just try it on my local network. I wonder how does it compare to <a title="Building (for) fun" href="http://gergely.imreh.net/blog/2011/04/building-for-fun/">Django</a>, since that&#8217;s what I have a bit of experience with.</p>
<h3>Links</h3>
<h4>Information</h4>
<ul>
<li><a title="Scala API" href="http://www.scala-lang.org/api/current/index.html" target="_blank">Scala language reference</a></li>
<li><a title="Programming in Scala" href="http://www.artima.com/pins1ed/" target="_blank">Programming in Scala</a></li>
<li><a title="Programming Scala" href="http://programming-scala.labs.oreilly.com/" target="_blank">Programming Scala</a></li>
<li><a title="Scala by Example PDF" href="http://www.scala-lang.org/docu/files/ScalaByExample.pdf" target="_blank">Scala by Example</a> (PDF)</li>
<li><a title="Hidden Features of Scala on StackOverflow" href="http://stackoverflow.com/questions/1025181/hidden-features-of-scala" target="_blank">Hidden features of Scala</a></li>
</ul>
<h4>Example sources</h4>
<ul>
<li><a title="Scala on Github" href="https://github.com/scala/scala" target="_blank">Scala source repo, now on Github</a></li>
<li><a title="Google Code" href="http://code.google.com/hosting/search?q=label:scala" target="_blank">Google Code &#8211; Scala tag</a></li>
<li><a title="Github language search for Scala" href="https://github.com/languages/Scala" target="_blank">Github &#8211; Scala tag</a></li>
<li><a title="SourceForge" href="http://sourceforge.net/search/index.php?words=scala" target="_blank">SourceForge &#8211; Scala Tag</a></li>
<li><a title="GSoC" href="http://www.scala-lang.org/gsoc2011" target="_blank">Google Summer of Code Scala projects</a></li>
</ul>
<h4>Companies using Scala</h4>
<ul>
<li><a title="Typesafe homepage" href="http://typesafe.com/" target="_blank">Typesafe</a>, a new company launched by Scala&#8217;s creator</li>
<li>Linkedin <a title="Linkedin: Scala to Scale" href="http://www.youtube.com/watch?v=J85F2C13r4Q" target="_blank">part 1</a>, <a title="Linkedin, part 2" href="http://www.youtube.com/watch?v=9Hen_0HS5Ic" target="_blank">part 2</a></li>
<li><a title="Foursquare moves to Scala, announcement" href="http://www.scala-lang.org/node/5130" target="_blank">Foursquare</a></li>
</ul>
<h4>Others writing about Scala</h4>
<ul>
<li><a title="Computing Thoughts Blog post" href="http://www.artima.com/weblogs/viewpost.jsp?thread=328540" target="_blank">The Static Language that Feels Dynamic</a></li>
</ul>
<p><em>(Last updated: 2011 June 23)</em></p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala-part-2/">Language of the month: Scala, part 2</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala-part-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Language of the Month: Scala</title>
		<link>https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/</link>
					<comments>https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/#comments</comments>
		
		<dc:creator><![CDATA[Gergely Imreh]]></dc:creator>
		<pubDate>Mon, 02 May 2011 13:54:40 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[lotm]]></category>
		<category><![CDATA[scala]]></category>
		<guid isPermaLink="false">http://gergely.imreh.net/blog/?p=272</guid>

					<description><![CDATA[<p>I was thinking what what to write about, but then I realized that is doing this whole blogging thing completely the wrong way. I should be thinking what to do and interesting things to write about will come out of that. It always does. I was watching the Programming Paradigms lecture series from Stanford. I [&#8230;]</p>
<p>The post <a href="https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/">Language of the Month: Scala</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>I was thinking what what to write about, but then I realized that is doing this whole blogging thing completely the wrong way. I should be thinking what to do and interesting things to write about will come out of that. It always does.</p>
<p>I was watching the <a title="Programming paradigms course home page" href="http://see.stanford.edu/see/courseinfo.aspx?coll=2d712634-2bf1-4b55-9a3a-ca9d470755ee" target="_blank">Programming Paradigms</a> lecture series from Stanford. I quite enjoy it, mostly because Jerry Cain seems to be a good lecturer. A <a title="Jerry Cain's RateMyProfessors profile" href="http://www.ratemyprofessors.com/ShowRatings.jsp?tid=13890" target="_blank">quick check</a> confirms that others feel that too. I haven&#8217;t finished it yet (24 lectures in to the 27 long series, each ~50 minutes), he talked a lot about C, then Scheme, now about Python. He also mentioned a couple of other languages he suggest for the students to try. That got me thinking: I love languages (human and programming as well) and always looking out to learn more things. Why not do some more exploration in this area &#8211; trying out languages that are quite different from each other and see what can I take home from each. I did have similar idea last year, &#8220;Language of the Week&#8221;, but one week is just too little to get to any practical depth in a language and that idea died. Now, I&#8217;m hoping to resurrect it in the form of &#8220;Language of the Month&#8221;. It is conveniently the beginning of a month so I can just start right now. :) Also, let&#8217;s make it round &#8211; a 12 language series, one for each month until the same time next year. That should be a challenge. So I made a 12 item list for planning:</p>
<ul>
<li><a title="Haskell on Wikipedia" href="http://en.wikipedia.org/wiki/Haskell_(programming_language)" target="_blank">Haskell</a></li>
<li><a title="Erlang on Wikipedia" href="http://en.wikipedia.org/wiki/Erlang_(programming_language)" target="_blank">Erlang</a></li>
<li><a title="Lua on Wikipedia" href="http://en.wikipedia.org/wiki/Lua_(programming_language)" target="_blank">Lua</a></li>
<li><a title="Smalltalk on Wikipedia" href="http://en.wikipedia.org/wiki/Smalltalk" target="_blank">Smalltalk</a></li>
<li><a title="Prolog on Wikipedia" href="http://en.wikipedia.org/wiki/Prolog" target="_blank">Prolog</a></li>
<li><a title="Lisp on Wikipedia" href="http://en.wikipedia.org/wiki/Common_Lisp" target="_blank">Lisp</a> / <a title="Scheme on Wikipedia" href="http://en.wikipedia.org/wiki/Scheme_(programming_language)" target="_blank">Scheme</a></li>
<li><a title="OCaml on Wikipedia" href="http://en.wikipedia.org/wiki/Objective_Caml" target="_blank">OCaml</a></li>
<li><a title="Forth on Wikipedia" href="http://en.wikipedia.org/wiki/Forth_(programming_language)" target="_blank">Forth</a></li>
<li><a title="Go on Wikipedia" href="http://en.wikipedia.org/wiki/Go_(programming_language)" target="_blank">Go</a></li>
<li><a title="Scala on Wikipedia" href="http://en.wikipedia.org/wiki/Scala_(programming_language)" target="_blank">Scala</a></li>
<li>?</li>
<li>?</li>
</ul>
<p>Many of these I was planning to check out for a long time and now I have proper motivation. Some of them I got intrigued about while I was checking this <a title="Wikipedia list of programming languages" href="http://en.wikipedia.org/wiki/List_of_programming_languages" target="_blank">humbling list</a>. Note, that &#8220;?&#8221; are not weird languages, but I keep things open to add more as I get more experience with this (you too can give me recommendation in the comments!:). Also note the absence of some languages, like C and Ruby: those I <em>really</em> should know more, that&#8217;s why I won&#8217;t do them here, they have enough intrinsic motivation, here I want to try somewhat more off-the-path things.</p>
<p><strong>The simple rule for this series is</strong>: every month choose one new language and by the end of the month implement something <em>practical</em> in that language. Something that scratches a real life programming itch. Other than this, all bets are off. See what I can learn.</p>
<p>Now the hard part: which one to start with, since the above list is rather a &#8220;set&#8221; &#8211; ordering is not included. I did roll a dice, but didn&#8217;t like the result (like most rolls of dice:), so let&#8217;s just choose one: <strong>The Language of the Month for May is Scala</strong> (because I know absolutely nothing about that, unlike some of the others).</p>
<p>Let the coding begin&#8230;</p>
<figure id="attachment_271" aria-describedby="caption-attachment-271" style="width: 474px" class="wp-caption aligncenter"><a href="http://gergely.imreh.net/blog/wp-content/uploads/2011/05/blank.png"><img loading="lazy" decoding="async" class="size-full wp-image-271 " title="Fill in the blank" src="http://gergely.imreh.net/blog/wp-content/uploads/2011/05/blank.png" alt="Emacs editor screen, ready to accept source code input" width="474" height="325" /></a><figcaption id="caption-attachment-271" class="wp-caption-text">What will this space contain?</figcaption></figure>
<p>The post <a href="https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/">Language of the Month: Scala</a> appeared first on <a href="https://gergely.imreh.net/blog">ClickedyClick</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://gergely.imreh.net/blog/2011/05/language-of-the-month-scala/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Object Caching 22/58 objects using APC
Page Caching using Disk: Enhanced 
Lazy Loading (feed)

Served from: gergely.imreh.net @ 2026-06-12 05:47:15 by W3 Total Cache
-->