<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<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/"
	>

<channel>
	<title>compiler &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/compiler/</link>
	<description>Feed of posts on WordPress.com tagged "compiler"</description>
	<pubDate>Tue, 21 May 2013 22:16:45 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Summary of Chapter 2]]></title>
<link>http://allaboutmynonexistedworld.wordpress.com/2013/03/02/summary-of-chapter-2/</link>
<pubDate>Sat, 02 Mar 2013 22:44:15 +0000</pubDate>
<dc:creator>JDL Wahaha</dc:creator>
<guid>http://allaboutmynonexistedworld.wordpress.com/2013/03/02/summary-of-chapter-2/</guid>
<description><![CDATA[A SIMPLE SYNTAX-DIRECTED TRANSLATION The syntax-directed techniques in this chapter can be used to c]]></description>
<content:encoded><![CDATA[A SIMPLE SYNTAX-DIRECTED TRANSLATION The syntax-directed techniques in this chapter can be used to c]]></content:encoded>
</item>
<item>
<title><![CDATA[Summary of Chapter 1]]></title>
<link>http://allaboutmynonexistedworld.wordpress.com/2013/03/02/summary-of-chapter-1/</link>
<pubDate>Sat, 02 Mar 2013 20:01:44 +0000</pubDate>
<dc:creator>JDL Wahaha</dc:creator>
<guid>http://allaboutmynonexistedworld.wordpress.com/2013/03/02/summary-of-chapter-1/</guid>
<description><![CDATA[ Language Processors. An integrated software development environment includes many different kinds o]]></description>
<content:encoded><![CDATA[ Language Processors. An integrated software development environment includes many different kinds o]]></content:encoded>
</item>
<item>
<title><![CDATA[first GUI program and a change in direction]]></title>
<link>http://127001tags.wordpress.com/2013/03/01/first-gui-program-and-a-change-in-direction/</link>
<pubDate>Fri, 01 Mar 2013 09:25:31 +0000</pubDate>
<dc:creator>larissafeng</dc:creator>
<guid>http://127001tags.wordpress.com/2013/03/01/first-gui-program-and-a-change-in-direction/</guid>
<description><![CDATA[Hello, all! I apologize for my lack of update &#8211; like I noted before, consistency can be a prob]]></description>
<content:encoded><![CDATA[<p>Hello, all!</p>
<p>I apologize for my lack of update &#8211; like I noted before, consistency can be a problem of mine. But here I am, so let me share what&#8217;s been/is on my mind.</p>
<p><strong>Although I wanted to have a specific theme/focus</strong> when I started this blog (e.g. NLP and related things),  it&#8217;s already become apparent that <strong>my interests and general projects tend to vary just a little too much for that</strong>: I&#8217;ll work on a Python project for 5 weeks, mess with an Arduino for one, study sound engineering on and off, come back and start on a big Python project, and concurrently start studying game design while still tinkering with my Arduino. It&#8217;s all still computer-science related, but the field is huge enough that I can&#8217;t really say there is any theme to what I tend to take on other than that, well, they&#8217;re computer related. And to complicate things, over the past little bit I&#8217;ve been straying further and further away from the natural language-related parts of computer science. This may be partially because I&#8217;m not taking any Ling classes right now and all CPSC ones (which isn&#8217;t exactly a great sign when it comes to exemplifying any attachment to the field), but I think it may be more so that I&#8217;m simply straying more and more to being interested in the general workings of computers and computer applications.</p>
<p>For the time being, then, <strong>I&#8217;m going to retract my previous statement that this blog serves the purpose to document my journey to being proficient at working with NLP</strong>. This blog is simply going to document my little projects and endeavors here and there in my journey to acquire a solid knowledge base in computer science, cool computer-y, techie, physics-y, and electronics-y things in general! I&#8217;m sure at some point a general direction for this blog will start to make itself clear, but it is still early. So I guess we&#8217;ll just have to see what this blog ends up growing into in the future.</p>
<p>So that aside, I&#8217;d like to apologize for the lack of update. First round of midterms at school hit, and I really didn&#8217;t do much else but study&#8230; and therefore didn&#8217;t do anything worth writing about.</p>
<p>Over reading week, however, I did spend a bit of time reading up and working on Java for my software construction course. Having had all my prior programming experience in Python (well, and Racket too I guess) and having never used it&#8217;s <a href="http://www.baskent.edu.tr/~tkaracay/etudio/ders/prg/pascal/PasHTM3/pas/pasl3001.html">Object Oriented Programming</a> (OOP) capabilities, the whole OOP mindset has been a little rough to adjust to. Nevertheless, now that I finally understand the difference between static and dynamic, objects and classes, interfaces, abstraction, implementation and so forth&#8230; I&#8217;m having trouble imagining how I would do certain things if the language were <em>not</em> object-oriented.</p>
<p>For example, after I discovered Java Docs 7 (I was using the old docs&#8230; they were horrible. I hope nobody ever makes as dumb a mistake as I did: not making sure the docs they&#8217;re using are the latest ones), <strong>I finally managed to make my very first <a href="http://en.wikipedia.org/wiki/Graphical_user_interface">GUI</a> &#8220;program&#8221; </strong>(as opposed to <a href="https://www.google.com/search?hl=en&#38;biw=1280&#38;bih=679&#38;q=Commsnf+line+interface&#38;bav=on.2,or.r_gc.r_pw.r_qf.&#38;bvm=bv.43148975,d.cGE&#38;um=1&#38;ie=UTF-8&#38;tbm=isch&#38;source=og&#38;sa=N&#38;tab=wi&#38;ei=9dQwUYDyD4bmiwKwxoGQAw#um=1&#38;hl=en&#38;tbm=isch&#38;q=Command+line+interface&#38;spell=1&#38;sa=X&#38;ei=A9UwUa2BBOj5iwKMh4DACw&#38;ved=0CFAQvwUoAA&#38;bav=on.2,or.r_gc.r_pw.r_qf.&#38;bvm=bv.43148975,d.cGE&#38;fp=f17356442b60ef5&#38;biw=1280&#38;bih=679">CLI</a>):</p>
<p><a href="http://127001tags.files.wordpress.com/2013/03/first-gui.jpg"><img class="alignnone  wp-image-74" alt="" src="http://127001tags.files.wordpress.com/2013/03/first-gui.jpg?w=300&#038;h=150" width="300" height="150" /></a></p>
<p>It&#8217;s a simple (slightly more elaborate than the traditional) &#8220;<a href="http://en.wikipedia.org/wiki/Hello_world_program">Hello World</a>&#8221; window with a menu, submenus, and a button&#8230; but I&#8217;m quite happy with it. I can&#8217;t imagine how a programming language could offer a user an elegant yet flexible way to create GUI applications without the concept of objects and classes, though. It&#8217;s just so intuitive to take an object and say &#8220;add this!&#8221; or &#8220;set this!&#8221;  (e.g. JFrame.setText(&#8220;Yo!&#8221;))  <em>The whole idea of OOP is just genius.</em></p>
<p><strong>Of course, thinking about how these different <a href="http://www.python.org/dev/peps/pep-0020/">philosophies</a> and <a href="http://en.wikipedia.org/wiki/Programming_paradigm">paradigms</a> got me thinking about programming language design</strong>, and just programming languages in general. It got me thinking about just how fascinating it is that each programming language really does have it&#8217;s own outlook, it&#8217;s own flavour. And that all these come from the meticulously thought-through decisions the creator of the language made in trying to instill their own beliefs about effective programming into the language.</p>
<p>All that got me thinking that I&#8217;d really like to understand this a lot better. And so, <strong>I&#8217;m toying with the idea of writing a simple <a href="http://en.wikipedia.org/wiki/Compiler">compiler</a> and programming language</strong>.  I know you&#8217;re thinking, &#8220;What&#8230;? That&#8217;s low-level shit for people with actual skills.&#8221; But although I know writing a compiler is considered by many programmers to be the ultimate challenge, I don&#8217;t think it necessarily HAS to be considered such a daunting task and such an impossible thing to do in every context.</p>
<p>In my case, I simply want to experience some of these decisions that have to be made, and use this project to further my understanding of the structure of certain languages and why their creators decided to structure the language that way. I want to discover more of what I believe, and what my philosophical views on what a &#8220;good&#8221; language should do. Of course, I&#8217;m not going to try to go write the newest C. The language is going to be relatively (okay, <a href="http://en.wikipedia.org/wiki/Very_high-level_programming_language">very</a>) <a href="http://www.webopedia.com/TERM/H/high_level_language.html">high-leveled</a>, and will probably be written in Java or Python. And it&#8217;ll really only be for me. But that&#8217;s all I&#8217;ll say about it for now. Who knows, maybe it&#8217;ll blossom into something else!</p>
<p><span style="color:#ff0000;">Edit: someone pointed out to me today that what I was kind of  intending to do &#8211; write something in Java/Python that will <a href="http://l2r.cs.uiuc.edu/~danr/Teaching/CS598-05/Lectures/Roxana.pdf">parse</a> a new language into Java/Python then compile accordingly &#8211; would really more or less just be a parser using the already-written JVM or Python interpreter. Oops. I&#8217;m not looking to simply write a <a href="http://searchsoa.techtarget.com/definition/parser">parser</a> (although I <em>was</em> introduced to <a href="http://www.regular-expressions.info/tutorial.html">regular expressions</a> today, and might just write a simple one to mess around with/practice using regexes), so it looks like I&#8217;m going to have to do a little more research on what exactly is required for a compiler as opposed to an interpreter, and so forth and so on. Will need to do a bit of mulling over what I&#8217;m really after, and do a little more research on what I&#8217;m going to get myself into. As always, I spoke a little too much a little too soon. Thanks, John!</span></p>
<p>In any case, I&#8217;ll keep you all posted on that latest project. Until then, you best believe I&#8217;ll be reading lots about how to go about it, as well as planning the most kickass syntax you will ever see. As well, I&#8217;ll keep working on my GUI skills in Java. My next goal? Learn how to implement Actions so I can actually make a simple, working interactive application.</p>
<p>It&#8217;s late, and so I leave you with a song from one of the best games I&#8217;ve played in a long time: <a href="http://www.youtube.com/watch?v=uqtSKkyJgFM">Braid</a>.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='640' height='390' src='http://www.youtube.com/embed/uejW9xIFCMw?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p>The entire soundtrack is fantastic, and the game itself is just ridiculous. If you haven&#8217;t heard of Braid, I highly recommend it as one of the most innovative puzzle games out there. I&#8217;d put it up there right alongside <a href="http://www.youtube.com/watch?v=TluRVBhmf8w">Portal</a>. Check it out!</p>
<p>And with that, adieu.</p>
<p>Larissa</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Tell us where to place them.]]></title>
<link>http://binkyproductions.wordpress.com/2013/03/01/tell-us-where-to-place-them/</link>
<pubDate>Fri, 01 Mar 2013 07:08:23 +0000</pubDate>
<dc:creator>binkyproductions</dc:creator>
<guid>http://binkyproductions.wordpress.com/2013/03/01/tell-us-where-to-place-them/</guid>
<description><![CDATA[Compiling.tv is getting ready for Season 2. We start filming this Saturday March 2nd. We want to hea]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><a href="http://binkyproductions.files.wordpress.com/2013/03/img783.jpg"><img class="aligncenter  wp-image-775" alt="IMG783" src="http://binkyproductions.files.wordpress.com/2013/03/img783.jpg?w=392&#038;h=294" width="392" height="294" /></a></p>
<p>Compiling.tv is getting ready for Season 2. We start filming this Saturday March 2nd. We want to hear ideas from our fans on where to place all these pool noodles. <a href="http://compiling.tv/tell-us-where-to-place-them/">Details are all on our official website.</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Assemblers are not compilers!]]></title>
<link>http://scalibq.wordpress.com/2013/02/28/assemblers-are-not-compilers/</link>
<pubDate>Thu, 28 Feb 2013 16:47:41 +0000</pubDate>
<dc:creator>Scali</dc:creator>
<guid>http://scalibq.wordpress.com/2013/02/28/assemblers-are-not-compilers/</guid>
<description><![CDATA[For some reason, people (read: newbies) often talk about &#8216;compiling assembly code&#8217;, or u]]></description>
<content:encoded><![CDATA[<p>For some reason, people (read: newbies) often talk about &#8216;compiling assembly code&#8217;, or using an &#8216;assembly compiler&#8217;. This is WRONG, people! And I will try to explain why, by offering a historical perspective, as usual.</p>
<p>Namely, if we go back to the early days of programming&#8230; The first programmable computers would take their input in the form of machine code: each instruction would be encoded as a set of bits, consisting of an opcode (the operation itself, such as &#8216;add&#8217; or &#8216;subtract&#8217;) and its operands (the data to operate on, which can be a constant, a register, or a memory location for example).</p>
<p>When writing a program, the programmer would have to first line out the program in pseudocode, and then convert it to machine code by hand. In order to make things easier, each opcode would have a &#8216;mnemonic&#8217;: a short name which described the instruction. The programmer could then first write down the program in a listing of mnemonics for each instruction, and then convert each instruction to its machine code representation.</p>
<p>Here is an example of some code written by Steve Wozniak (the co-founder of Apple, and designer of the early Apple computers):</p>
<p><a href="http://scalibq.files.wordpress.com/2013/02/woz2.jpg"><img class="alignnone size-medium wp-image-1052" alt="Steve Wozniak's floating point routines" src="http://scalibq.files.wordpress.com/2013/02/woz2.jpg?w=300&#038;h=218" width="300" height="218" /></a></p>
<p>As you can see, he&#8217;s written out the code in a number of columns. The first column is the memory address of each instruction, the second column contains the machine code bytes for that instruction, then follows the mnemonic representation of the code (the &#8216;human readable form&#8217;), and finally some comments.</p>
<p>Initially you would have to do this all by hand. The process of converting mnemonics to machine code became known as &#8216;assembling&#8217; the code, and automated tools were developed for this, which became known as &#8216;assemblers&#8217;. The first assembler was written for the EDSAC computer in 1949, and was called &#8220;initial orders&#8221;.</p>
<p>The first compiler however, was written by Grace Hopper in 1952, for the A-0 programming language. And that in itself already shows that compiling and assembling are not seen as the same thing. Namely, since we already had assemblers at that time, then why did Grace Hopper bother to coin the term &#8216;compiler&#8217;, rather than just re-using the term &#8216;assembler&#8217; to describe this new tool? Apparently there is a fundamental difference between the two types of tools.</p>
<p>The main difference between assembly language and other programming languages such as the A-0 language, is that assembly languages are always machine-dependent (after all, the mnemonics are merely a more human-readable form of the instructions that the machine supports, so different machines have different mnemonics), where other programming languages abstract away the physical machine, and work at a higher level. Many early compilers would also compile the higher level source listings into a machine-specific assembly listing, which would then be passed on to an assembler to generate the actual machine code.</p>
<p>Since a compiler works from a source listing at a higher level, it also needs to perform a more complex translation than an assembler. For an assembler there is generally a 1:1 mapping from mnemonics to machine code. There are some exceptions where a single instruction may be encoded in multiple ways, but generally any decisions an assembler needs to make at all during translation are very trivial and unambiguous (for example, picking the shortest encoding for a given instruction). For this reason, writing assembly code is as good as writing machine code by hand, as far as performance and size optimizations go.</p>
<p>Compilers however need to map variables used in the source code to machine-specific registers and memory locations, and try to decide the shortest and/or fastest possible sequence of instructions to translate the code. This causes complicated problems for register allocation and re-use for example. There is no 1:1 translation of high-level keywords and expressions to machine code. There are many possible alternatives, and a compiler will need to do a lot of analysis and use clever heuristics to try and come up with fast code.</p>
<p>Especially in the early days, compilers were rather naïve, and their translations would not come anywhere near assembly code optimized by hand. These days however, compilers have come a long way, and perhaps just as important: so have computers. Where early computers were still designed specifically for handwritten programs, over time more and more people started using compiled languages, and computers were designed more and more to make the job of compilers easier. Compilers generate code in an algorithmic way, and so they would only use a given subset of instructions. RISC CPUs would reduce the instructionset to only include the most-used instructions, and make these instructions run as fast as possible. Which would mean that the job of compilers became easier.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Episode 22 of Compiling.tv]]></title>
<link>http://binkyproductions.wordpress.com/2013/02/28/episode-22-of-compiling-tv/</link>
<pubDate>Thu, 28 Feb 2013 10:30:55 +0000</pubDate>
<dc:creator>binkyproductions</dc:creator>
<guid>http://binkyproductions.wordpress.com/2013/02/28/episode-22-of-compiling-tv/</guid>
<description><![CDATA[Das Bier! Watch Episode 22  live at Compiling.tv today! New episodes will be live each week on Thurs]]></description>
<content:encoded><![CDATA[<p><em>Das Bier!<br />
</em></p>
<p>Watch <strong>Episode 22 </strong> live at <a href="http://compiling.tv/s01e22/">Compiling.tv</a> today!</p>
<p style="text-align:left;">New episodes will be live each week on Thursdays. Season Finale goes live March 14th.</p>
<p><a href="http://compiling.tv/donations/">Become a Fan</a> to have free access to Exclusive Content Videos, Fun Facts and lots more!</p>
<p>A great many thanks to everyone who donated during the Indiegogo Campaign. The campaign is now closed, but we continue to accept <a href="http://compiling.tv/donations/">Open Donations</a> from anyone who wishes to contribute.</p>
<p><a href="http://binkyproductions.files.wordpress.com/2013/02/thumbnail-ep22-01.jpg"><img class="aligncenter size-large wp-image-772" alt="Thumbnail Ep22-01" src="http://binkyproductions.files.wordpress.com/2013/02/thumbnail-ep22-01.jpg?w=490&#038;h=275" width="490" height="275" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Partial Order and Total Order ]]></title>
<link>http://jindongpu.wordpress.com/2013/02/27/partial-order-and-total-order/</link>
<pubDate>Wed, 27 Feb 2013 17:45:12 +0000</pubDate>
<dc:creator>djin</dc:creator>
<guid>http://jindongpu.wordpress.com/2013/02/27/partial-order-and-total-order/</guid>
<description><![CDATA[Partial order set: consists a set and a binary relation (&lt;=). For certain pairs of elements in th]]></description>
<content:encoded><![CDATA[<p><strong>Partial order set</strong>: consists a set and a binary relation (&#60;=). For certain pairs of elements in the set, one of the elements precedes the other. (not every pairs are related).</p>
<p>Transitive: a &#60;= b and b &#60;= c -&#62; a &#60;= c;<br />
Antisymmetric: a&#60;= b and b &#60;=a -&#62; a = b;</p>
<p><a href="http://jindongpu.files.wordpress.com/2013/02/poset.jpg"><img class="aligncenter size-full wp-image-1187" alt="poset" src="http://jindongpu.files.wordpress.com/2013/02/poset.jpg?w=260&#038;h=235" width="260" height="235" /></a></p>
<p><strong>Total order set: </strong>every pair is related.</p>
<p>Besides transitive and antisymmetric, it also has comparability: for any a, b, either a &#60;= b or b &#60;= a;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[What is .Net Framework?]]></title>
<link>http://studydotnet.wordpress.com/2013/02/23/what-is-net-framework/</link>
<pubDate>Sat, 23 Feb 2013 15:46:45 +0000</pubDate>
<dc:creator>sujeetpaandey</dc:creator>
<guid>http://studydotnet.wordpress.com/2013/02/23/what-is-net-framework/</guid>
<description><![CDATA[As to build, develop, deploy and running windows and web based application we need to have a platfor]]></description>
<content:encoded><![CDATA[<p>As to build, develop, deploy and running windows and web based application we need to have a platform, an environment. For all these things Microsoft has provided a platform or we can say an environment which is know as <a class="zem_slink" title=".NET Framework" href="http://msdn.microsoft.com/netframework" target="_blank" rel="homepage">.Net Framework</a>, it is basically a programming model. The main propose of this model to help us to do the plumbing work for developer so that they can concentrate on the business logic. The model manages the core things on behalf of developers. The developer now does not need to manages the basic plumbing work. The .Net Framework contains a large probably the largest set of class libraries in the form of dll.</p>
<p>The .Net Architecture (.Net Framework) has the few different very important parts which we will discuss now:-</p>
<div id="attachment_12" class="wp-caption aligncenter" style="width: 310px"><a href="http://studydotnet.files.wordpress.com/2013/02/framework.jpg"><img class="size-medium wp-image-12 " title=".Net Framework" alt="framework" src="http://studydotnet.files.wordpress.com/2013/02/framework.jpg?w=300&#038;h=231" width="300" height="231" /></a><p class="wp-caption-text">.Net Framework</p></div>
<p><strong>CLR:- </strong>Common Language Runtime, it is also known as the .Net Runtime. It is a layer above the systems OS which handles the execution of applications. It  has the responsibility of providing the functionality like security, integration, memory management, process management, thread management, releasing unused memory. The advantage of CLR is it creates the whole environment to build the application for the developer that in the past they had to do their own.</p>
<p><b>MSIL:- </b>Microsoft Intermediate Language, the .Net framework is build to support many languages. So when we uses any .Net compliant language to build the application, the source code is not directly converts to executable binary code, rather than it is converted into a new language code which is known as MSIL. The MSIL is interpreted by the CLR. The advantage of MSIL is it is a platform independent code. When the program executes, this code is gets converted into the binary executable code which is also know is the native code or machine code. Now that&#8217;s how the .Net supports the  multiple languages.</p>
<p><strong>Compilers:- </strong>Just In Time Compilers (JITers) to execute the new IL code the Common Language Runtime uses the JIT compiler. The result of the JIT is comes in form of .exe or .dll which is used by the machine. But what is the different thing which makes the JIT compilers different from the other traditional compilers is that the JIT compiles the IL into native code whenever the requirement occurs means when the operation regarding that particular code portion is called the IL of that operation is converted or compiled into the machine code at that particular time.</p>
<p><strong>FCL:- </strong><a class="zem_slink" title="Framework Class Library" href="http://en.wikipedia.org/wiki/Framework_Class_Library" target="_blank" rel="wikipedia">Framework Class Library</a> that .Net framework contains the huge amount of classes also know as base classes for standard work. It contains tons of classes to provide the standard functions like I/O, String Manipulation  Security Management, Network Communications, Thread Management, Data Access and many more. These set of classes are managed in Namespaces.</p>
<p><strong>CLS:- </strong><a class="zem_slink" title="Common Language Infrastructure" href="http://en.wikipedia.org/wiki/Common_Language_Infrastructure" target="_blank" rel="wikipedia">Common Language Specification</a> the .Net Framework supports the multiple languages, but how it supports this. what makes a language .Net compliant language. The reason is the <strong>CLS </strong>every .Net compliant language has to fulfill some specification to qualify for a .Net compliant language.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Compiler 2/22/13: Vote Chicago and Dr. Watson]]></title>
<link>http://compinst.org/2013/02/22/compiler-22213-vote-chicago-and-dr-watson/</link>
<pubDate>Fri, 22 Feb 2013 16:00:27 +0000</pubDate>
<dc:creator>Rob Mitchum</dc:creator>
<guid>http://compinst.org/2013/02/22/compiler-22213-vote-chicago-and-dr-watson/</guid>
<description><![CDATA[A CITY PROJECT BATTLE ROYALE As the keynote speaker at the Urban Sciences Research Coordination Netw]]></description>
<content:encoded><![CDATA[<p><strong><a href="http://compinst.files.wordpress.com/2013/02/r-bloomberg4-large570.jpg"><img class="alignright size-large wp-image-338" alt="r-BLOOMBERG4-large570" src="http://compinst.files.wordpress.com/2013/02/r-bloomberg4-large570.jpg?w=500&#038;h=208" width="500" height="208" /></a>A CITY PROJECT BATTLE ROYALE</strong></p>
<p>As the keynote speaker at the <a href="http://compinst.org/2013/02/20/a-new-research-community-for-urban-data/">Urban Sciences Research Coordination Network kickoff</a> last Friday, the City of Chicago&#8217;s Brett Goldstein presented a blizzard of exciting city projects at various states of development. One slightly-under-wraps project Goldstein touched upon was the SmartData platform, an ambitious plan to craft a new tool for decision-making and city services out of the abundant raw material of city data. In collaboration with the Computation Institute and the <a href="http://urbanccd.org/">Urban Center for Computation and Data</a>, the city&#8217;s Innovation and Technology team hopes to create a tool that will analyze the city&#8217;s many large datasets in real time to help the city respond to challenges more quickly and efficiently, while providing frequently updated, useful information to its citizens.</p>
<p>Wednesday, that exciting new effort was announced as a finalist in the <a href="http://mayorschallenge.bloomberg.org/">Bloomberg Philanthropies Mayors Challenge</a>, a competition among ideas proposed by cities across the United States. As part of the judging, the public is invited to vote for their favorite project among the 20 finalists <a href="http://www.huffingtonpost.com/2013/02/19/vote-mayors-challenge-fan_n_2716857.html">at the Huffington Post</a>. We&#8217;re biased of course, but to help make the case for Chicago&#8217;s project, you can <a href="http://www.huffingtonpost.com/rahm-emanuel/mayors-challenge-chicago-_b_2711059.html?utm_hp_ref=mayors-challenge">read more about the SmartData platform here</a>, or watch a video about the concept featuring Mayor Rahm Emanuel below.</p>
<span class='embed-youtube' style='text-align:center; display: block;'><iframe class='youtube-player' type='text/html' width='560' height='315' src='http://www.youtube.com/embed/pR7du3mFuXI?version=3&#038;rel=1&#038;fs=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;wmode=transparent' frameborder='0'></iframe></span>
<p><!--more--><strong>COMPUTER IN A WHITE COAT</strong></p>
<p>Last year at the <a href="http://compinst.org/2012/11/16/a-helping-hand-for-uchicago-computation/">Research Computing Center opening reception</a>, attendees were given the chance to play Jeopardy against a legendary contestant: Watson. While most famous for once <a href="http://www.youtube.com/watch?v=YLR1byL0U8M">taking down Jeopardy grandmaster Ken Jennings</a> on television, Watson was actually developed by IBM to be a complex problem-solver for any field faced with a tidal wave of data. Medicine is one such field, and in the cover story of <em>The Atlantic</em> this month, Dr. Watson <a href="http://www.theatlantic.com/magazine/archive/2013/03/the-robot-will-see-you-now/309216/">gets the spotlight</a>. Much like Watson drew upon a vast storage of word associations to rapidly locate the right question on <em>Jeopardy</em>, IBM believes that the computer system will be able to quickly scan through an enormous corpus of medical literature and clinical information to find the right diagnosis for a patient, free from the bias or limitations of a regular human physician.</p>
<p>Beyond the details about the cover star, the article is a good overview of how data technology and computation are expected to transform the practice of medicine in the near future. Two main advantages of Watson pointed out by the article &#8212; the ability to handle &#8220;unstructured data&#8221; and the ability to convey uncertainty about a conclusion &#8211; reflect broader trends in computational research for medicine and biology, as well as other projects on climate change and the humanities. The article also covers health IT trends such as personalized medicine, using smartphones to monitor/transmit medical data and tele-health interventions.</p>
<blockquote><p>In the future as the innovators imagine it—“Health 2.0,” as some people have started calling it—you would be in constant contact with the health-care system, although you’d hardly be aware of it. The goal would be to keep you healthy—and any time you were in danger of becoming unhealthy, to ensure you received attention right away. You might wear a bracelet that monitors your blood pressure, or a pedometer that logs movement and exercise. You could opt for a monitoring system that makes sure you take your prescribed medication, at the prescribed intervals. All of these devices would transmit information back to your provider of basic medical care, dumping data directly into an electronic medical record.</p></blockquote>
<p><strong>OTHER NEWS IN COMPUTATIONAL SCIENCE</strong></p>
<p>Many experts believe that quantum computers will someday become necessary to keep improvements in processor speed along the exponential track of Moore&#8217;s Law. But in the meantime, <a href="http://www.sciencemag.org/content/339/6121/798">two</a> <a href="http://www.sciencemag.org/content/339/6121/794">new</a> papers published in <em>Science</em> this week propose an intermediate step towards quantum computation, demonstrating how a relatively easily-scaled method called photonic boson sampling can be used to solve certain matrix calculations <a href="http://www.sciencemag.org/content/339/6121/767">faster than a &#8220;classical&#8221; computer</a>.</p>
<p>Can big data build a better lie detector? An interesting <a href="http://www.datanami.com/datanami/2013-02-16/big_data_backs_world_s_largest_lie_detector.html?featured=top">article at Datanami</a> talks about how fraud prevention services are using data algorithms akin to a souped up version of Facebook&#8217;s new graph search to put together the history of a given person&#8230;and sniff out if they are up to no good.</p>
<p>Is the human brain computable? That&#8217;s going to be one of science&#8217;s biggest debates over the next decade as both <a href="http://www.popsci.com/science/article/2013-02/how-simulate-human-brain-one-neuron-time-13-billion">Europe</a> and the <a href="http://www.nytimes.com/2013/02/18/science/project-seeks-to-build-map-of-human-brain.html?pagewanted=all&#38;_r=0">United States</a> plan to launch massive and expensive efforts to simulate and/or map the human brain. But some scientists, including brain-machine interface researcher Miguel Nicolelis, <a href="http://www.technologyreview.com/view/511421/the-brain-is-not-computable/">are skeptical</a> that engineering will ever be capable of reproducing the complex abilities and functions of the human brain.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Episode 21 of Compiling.tv]]></title>
<link>http://binkyproductions.wordpress.com/2013/02/21/episode-21-of-compiling-tv/</link>
<pubDate>Thu, 21 Feb 2013 10:30:20 +0000</pubDate>
<dc:creator>binkyproductions</dc:creator>
<guid>http://binkyproductions.wordpress.com/2013/02/21/episode-21-of-compiling-tv/</guid>
<description><![CDATA[Who said bubble dialogue was only for comic books! Watch Episode 21  live at Compiling.tv today! New]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><em>Who said bubble dialogue was only for comic books!<br />
</em></p>
<p>Watch <strong>Episode 21 </strong> live at <a href="http://compiling.tv/s01e21/">Compiling.tv</a> today!</p>
<p>New episodes will be live each week on Thursdays.</p>
<p><a href="http://compiling.tv/donations/">Become a Fan</a> to have free access to Exclusive Content Videos, Fun Facts and lots more!</p>
<p>A great many thanks to everyone who donated during the Indiegogo Campaign. The campaign is now closed, but we continue to accept <a href="http://compiling.tv/donations/">Open Donations</a> from anyone who wishes to contribute.</p>
<p style="text-align:center;"><a href="http://binkyproductions.files.wordpress.com/2013/02/thumbnail-ep21-04.jpg"><img class="aligncenter  wp-image-737" alt="Thumbnail Ep21-04" src="http://binkyproductions.files.wordpress.com/2013/02/thumbnail-ep21-04.jpg?w=441&#038;h=248" width="441" height="248" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Back from Silicon Valley]]></title>
<link>http://pointersgonewild.wordpress.com/2013/02/20/back-from-silicon-valley/</link>
<pubDate>Wed, 20 Feb 2013 20:21:01 +0000</pubDate>
<dc:creator>Maxime Chevalier</dc:creator>
<guid>http://pointersgonewild.wordpress.com/2013/02/20/back-from-silicon-valley/</guid>
<description><![CDATA[How Mozilla sees itself I&#8217;m back to Canada after a two week visit to the Mozilla offices in Mo]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><a href="http://pointersgonewild.files.wordpress.com/2013/02/dscn0859.jpg"><img class="aligncenter" alt="DSCN0859" src="http://pointersgonewild.files.wordpress.com/2013/02/dscn0859.jpg?w=300&#038;h=225" width="300" height="225" /></a>How Mozilla sees itself</p>
<p>I&#8217;m back to Canada after a <a title="Visiting Mozilla" href="http://pointersgonewild.wordpress.com/2013/01/31/visiting-mozilla/">two week visit</a> to the Mozilla offices in Mountain View. The visit started with a presentation of Higgs and my PhD research work, which was made available online <a href="https://air.mozilla.org/higgs-jit/">on Air Mozilla</a>. Then, over the next two weeks, I had several one on one meetings with several members of the JS engine and research teams at Mozilla. The Mozilla people were all extremely friendly and forthcoming. Because of Mozilla&#8217;s open culture, I was able to get answers to just about any question I might want to ask about their work. I was also invited to give a talk at Apple and briefly meet with the JavaScriptCore team. This trip was a great opportunity to discuss and refine my research ideas, as well as to gain specific insights into the workings of production JavaScript JIT compilers.</p>
<p style="text-align:center;"><a href="http://pointersgonewild.files.wordpress.com/2013/02/dscn0850.jpg"><img class="aligncenter size-medium wp-image-1133" alt="DSCN0850" src="http://pointersgonewild.files.wordpress.com/2013/02/dscn0850.jpg?w=300&#038;h=246" width="300" height="246" /></a>Speaking at Apple</p>
<p>There were also unexpected benefits to my visit. The presentation I gave at Mozilla, which was made available online, garnered some attention on twitter and reddit. As a result, I received invitations to meet from <a href="http://alexgaynor.net/">Alex Gaynor</a> of the PyPy project and from <a href="https://twitter.com/ariyahidayat">Ariya Hidayat</a> of the Esprima parser project (both of which I promptly accepted). I was also invited by Andrei Alexandrescu himself to talk about Higgs and my experience using the D programming language at <a href="http://dconf.org/schedule/chevalier_boisvert.html">DConf 2013</a>. Finally, I had the pleasant surprise of getting pull requests on the <a href="https://github.com/maximecb/Higgs">Higgs github repository</a>.</p>
<p style="text-align:center;"><a href="http://pointersgonewild.files.wordpress.com/2013/02/dscn0606.jpg"><img class="aligncenter size-medium wp-image-1134" alt="DSCN0606" src="http://pointersgonewild.files.wordpress.com/2013/02/dscn0606.jpg?w=300&#038;h=213" width="300" height="213" /></a>A taste of America</p>
<p>Being in the Silicon Valley area, I also took the opportunity to visit San Francisco on the weekends. I went to an outdoor pub with some friends and got invited to a barbecue party where I was introduced to the infamous <a href="http://cardsagainsthumanity.com/">Cards Against Humanity</a>. San Francisco is a charming city with its own highly liberal hippie subculture. It has cute little boutiques and cafés, streetfood, and beautiful parks. Public transportation seems rather good, at least in the city itself (I can&#8217;t speak so highly of the suburbs).</p>
<p style="text-align:center;"><a href="http://pointersgonewild.files.wordpress.com/2013/02/dscn0867.jpg"><img class="aligncenter size-medium wp-image-1135" alt="DSCN0867" src="http://pointersgonewild.files.wordpress.com/2013/02/dscn0867.jpg?w=300&#038;h=225" width="300" height="225" /></a>San Francisco</p>
<p><span style="font-size:13px;">The bay area, and San Francisco, are truly different from what I&#8217;m used to. It seems everyone is involved with technology, or with a startup, in one way or another. Everyone has a smartphone and Apple TV. People use apps on their phones to summon cabs. The rents are very high and almost everybody has housemates (even couples). Because so many people are in tech, the online communities of the bay area are also more active than elsewhere. </span>Getting to experience Silicon Valley was an interesting experience, and makes me understand why so many tech companies choose to establish themselves in the area: nowhere else are people this excited about tech.</p>
<p>At this point, you might be wondering what I&#8217;ve done with my research during this trip, besides talking to many people. For one, I started looking more seriously into the area of trace compilation. The Mozilla people have let me know that they had multiple issues with their TraceMonkey JIT, which eventually led to its retirement. One of these issues was trace explosion: the generation of too many independent traces. Another was constant fallback to the interpreter. What I want to do with Higgs, is implement something closer to <a href="http://impact.crhc.illinois.edu/shared/report/phd-thesis-rick-hank.pdf">region-based compilation</a>, and attempt to solve some of these tracing problems.</p>
<p>In terms of code, I started planning the implementation of a simple backend and tracing JIT for Higgs, so that I can begin experimenting with these concepts. I already made some minor refactorings that will be necessary for this JIT to be possible. I also took the time to fix many (dozens of) bugs that were preventing Higgs from running SunSpider and V8 benchmarks. The good news is that Higgs is now much more standards compliant than before, and even better tested. I updated the lists of supported features and supported benchmarks on the <a title="Higgs" href="http://pointersgonewild.wordpress.com/higgs/">Higgs page</a> to reflect this.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[In-Memory Run-Time Code Generation With .NET - Part 4]]></title>
<link>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation-pt4/</link>
<pubDate>Sun, 17 Feb 2013 20:02:31 +0000</pubDate>
<dc:creator>mhusseini</dc:creator>
<guid>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation-pt4/</guid>
<description><![CDATA[Table Of Contents This article is split into 5 posts. Introduction General Approach Generation Model]]></description>
<content:encoded><![CDATA[<h3>Table Of Contents</h3>
<p>This article is split into 5 posts.</p>
<ol>
<li><a href="/2013/02/17/in-memory-run-time-code-generation">Introduction</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Approach">General Approach</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Model">Generation Model</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2">Templating Engines</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#T4">T4</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#StringTemplate">StringTemplate</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#DotLiquid">DotLiquid</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3">Code Generation From Source</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#CodeDom">CodeDom</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#Roslyn">Roslyn</a></li>
<li>Mono</li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4">Code Generation From Model</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Emit">Emit</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Trees">Expression Trees</a></li>
<li>Mono Cecil</li>
</ul>
</li>
<li>Loading
<ul>
<li>Dependency Injection</li>
<li>Managed Extensibility Framework</li>
<li>Reflection</li>
</ul>
</li>
</ol>
<h1>In-Memory Run-Time Code Generation With .NET &#8211; Part 4</h1>
<h2>Code Generation From Model</h2>
<p>Instead of using templaing engines to create source code that need compilation, MSIL can be created using either <a href="http://msdn.microsoft.com/en-us/library/3y322t50.aspx" title="Using Reflection Emit at MSDN">Reflection Emit</a> or by constructing <a href="http://msdn.microsoft.com/en-us/library/bb397951.aspx" title="Expression Trees at MSDN">Linq Expression Trees</a> and compiling those.</p>
<h3><a name="Emit"></a>Reflection Emit</h3>
<p>A more direct approach to generating types to runtime is to <a href="http://msdn.microsoft.com/en-us/library/3y322t50.aspx" title="Using Reflection Emit at MSDN">directly generate MSIL code</a>. The .NET Framework supplies all nesseccary classes to do so. This approach is very fast, since no source code must be parsed and compiled. On the other hand, the MSIL output must be hand-coded, which is a difficult and error-prone venture. The following class generates the types that were generated by the code templates in the previouse sections. To abbreviate the lengthy code, the generation of properties that return view model lists is skipped.</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
internal class TypeGenerator
{
    private readonly TypeGenerationModel _model;
    private readonly Dictionary&#60;Type, Type&#62; _viewModelTypes;
    private readonly TypeBuilder _typeBuilder;

    public Type GeneratedType { get; private set; }

    public static Assembly Generate(IEnumerable&#60;TypeGenerationModel&#62; models)
    {
        var appDomain = AppDomain.CurrentDomain;
        var assemblyName = new AssemblyName(&#34;dynamicassembly&#34;);
        var assemblyBuilder = appDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
        var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, assemblyName.Name + &#34;.dll&#34;);
        var viewModelTypes = new Dictionary&#60;Type, Type&#62;();

        foreach (var model in models.Reverse())
        {
            var generator = new Typeil(moduleBuilder, model, viewModelTypes);
            viewModelTypes.Add(model.ModelType, generator.GeneratedType);
        }

        return assemblyBuilder;
    }

    private TypeGenerator(ModuleBuilder moduleBuilder, TypeGenerationModel model, Dictionary&#60;Type, Type&#62; viewModelTypes)
    {
        var baseType = typeof (ViewModelBase&#60;&#62;).MakeGenericType(model.ModelType);
        _model = model;
        _viewModelTypes = viewModelTypes;
        _typeBuilder = moduleBuilder.DefineType(_model.Namespace + &#34;.&#34; + _model.Name, TypeAttributes.Public, baseType);

        GeneratedType = Generate();
    }

    private Type Generate()
    {
        //
        // Create constructor
        //
        var baseConstructor = _typeBuilder.BaseType.GetConstructor(BindingFlags.NonPublic &#124; BindingFlags.Instance, null, new[] {_model.ModelType}, new ParameterModifier[0]);
        var constructorBuilder = _typeBuilder.DefineConstructor(MethodAttributes.Public, CallingConventions.Standard, new[] {_model.ModelType});
        var il = constructorBuilder.GetILGenerator();

        il.Emit(OpCodes.Ldarg_0);                   // Load the address of &#34;this&#34; onto the stack
        il.Emit(OpCodes.Ldarg_1);                   // Load the first parameter onto the stack
        il.Emit(OpCodes.Call, baseConstructor);     // Call the constructor of the base class
        il.Emit(OpCodes.Ret);                       // Return

        //
        // Create properties
        //
        foreach (var property in _model.Properties)
        {
            CreateProperty(property, _typeBuilder);
        }

        foreach (var property in _model.ViewModelProperties)
        {
            CreateViewModelProperty(property, _typeBuilder);
        }
        
        // In this sample, we wont generate this kind of property.
        //foreach (var property in _model.ViewModelListProperties)
        //{
        //    CreateViewModelListProperty(property, typeBuilder);
        //}

        //
        // Finish up
        //
        return _typeBuilder.CreateType();
    }

    private void CreateProperty(PropertyGenerationModel property, TypeBuilder typeBuilder)
    {
        var propertyType = property.ElementType;
        var propertyBuilder = typeBuilder.DefineProperty(property.Name, PropertyAttributes.None,
                                                         propertyType, null);

        if (property.CanGet)
        {
            var thisModelGetter = typeBuilder.BaseType.GetProperty(&#34;Model&#34;).GetGetMethod();
            var modelPropertyGetter = _model.ModelType.GetProperty(property.Name).GetGetMethod();

            CreateGetMethod(property, typeBuilder, propertyBuilder, propertyType, il =&#62;
            {
                // return Model.PROPERTY;
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Call, thisModelGetter);         // Call &#34;this&#34;.&#34;get_Model()&#34;
                il.Emit(OpCodes.Callvirt, modelPropertyGetter); // Call &#34;this&#34;.&#34;get_Model()&#34;.

                // &#34;get_PROPERTY()&#34;
                il.Emit(OpCodes.Ret);                           // Return
            });
        }

        if (property.CanSet)
        {
            var thisModelGetter = typeBuilder.BaseType.GetProperty(&#34;Model&#34;).GetGetMethod();
            var modelPropertyGetter = _model.ModelType.GetProperty(property.Name).GetGetMethod();
            var modelPropertySetter = _model.ModelType.GetProperty(property.Name).GetSetMethod();
            var notificationMethod = typeBuilder.BaseType.GetMethod(&#34;OnPropertyChanged&#34;, BindingFlags.NonPublic &#124; BindingFlags.Instance);

            CreateSetMethod(property, typeBuilder, propertyBuilder, propertyType, il =&#62;
            {
                var labelElse = il.DefineLabel();

                // if(this.Model.PROPERTY == value) return;
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Call, thisModelGetter);         // Call &#34;this&#34;.&#34;get_Model()&#34;
                il.Emit(OpCodes.Callvirt, modelPropertyGetter); // Call &#34;this&#34;.&#34;get_PROPERTY()&#34;.

                // &#34;get_PROPERTY()&#34;
                il.Emit(OpCodes.Ldarg_1);                       // Load the parameter onto the stack
                il.Emit(OpCodes.Bne_Un_S, labelElse);           // If the last both values on the stack are not equal, jump to the label
                il.Emit(OpCodes.Ret);                           // Return
                il.MarkLabel(labelElse);

                // this.Model.PROPERTY = value;
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Call, thisModelGetter);         // Call &#34;this&#34;.&#34;get_Model()&#34;
                il.Emit(OpCodes.Ldarg_1);                       // Load the parameter onto the stack
                il.Emit(OpCodes.Callvirt, modelPropertySetter); // Call &#34;this&#34;.&#34;set_PROPERTY()&#34;

                // OnPropertyChanged(&#34;PROPERTY&#34;);
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Ldstr, property.Name);          // Load the string onto the stack
                il.Emit(OpCodes.Call, notificationMethod);      // Call OnPropertyChanged()

                il.Emit(OpCodes.Ret);                           // Return
            });
        }
    }

    private void CreateViewModelProperty(PropertyGenerationModel property, TypeBuilder typeBuilder)
    {
        var propertyType = _viewModelTypes[property.ElementType];
        var fieldBuilder = typeBuilder.DefineField(&#34;_&#34; + property.Name, propertyType, FieldAttributes.Private);
        var propertyBuilder = typeBuilder.DefineProperty(property.Name, PropertyAttributes.None, propertyType, null);

        if (property.CanGet)
        {
            // Get the view _model constructor that takes only the _model as parameter

            var ctor = propertyType.GetConstructor(new[] {property.ElementType});
            var thisModelGetter = typeBuilder.BaseType.GetProperty(&#34;Model&#34;).GetGetMethod();
            var modelPropertyGetter = _model.ModelType.GetProperty(property.Name).GetGetMethod();

            CreateGetMethod(property, typeBuilder, propertyBuilder, propertyType, il =&#62;
            {
                var labelElse = il.DefineLabel();

                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Ldfld, fieldBuilder);           // Get the value of &#34;this&#34;.&#34;_field&#34; and push in onto the stack
                                                                                            
                // if(this._field == null)
                il.Emit(OpCodes.Brtrue_S, labelElse);           // If the value on the stack is not null, jump to the label
                // {
                // this._field = new ViewModel(this.Model.Property);
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Call, thisModelGetter);         // Call &#34;this&#34;.&#34;get_Model()&#34;
                il.Emit(OpCodes.Callvirt, modelPropertyGetter); // Call &#34;this&#34;.&#34;Model&#34;.&#34;get_PROPERTY()&#34;
                il.Emit(OpCodes.Newobj, ctor);                  // Create a new instance of the view model and push it onto the stack
                il.Emit(OpCodes.Stfld, fieldBuilder);           // Replace &#34;this&#34;.&#34;_field&#34; by the value on the stack
                // }
                il.MarkLabel(labelElse);

                // Return this._field;
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Ldfld, fieldBuilder);           // Get the value of &#34;this&#34;.&#34;_field&#34; and push it onto the stack

                il.Emit(OpCodes.Ret);                           // Return
            });
        }

        if (property.CanSet)
        {
            var valueModelGetter = propertyType.BaseType.GetProperty(&#34;Model&#34;).GetGetMethod();
            var modelPropertySetter = typeBuilder.BaseType.GetProperty(&#34;Model&#34;).PropertyType.GetProperty(property.Name).GetSetMethod();
            var thisModelGetter = typeBuilder.BaseType.GetProperty(&#34;Model&#34;).GetGetMethod();
            var notificationMethod = typeBuilder.BaseType.GetMethod(&#34;OnPropertyChanged&#34;, BindingFlags.NonPublic &#124; BindingFlags.Instance);

            CreateSetMethod(property, typeBuilder, propertyBuilder, propertyType, il =&#62;
            {
                var labelElse = il.DefineLabel();

                // if(this._field == value) return;
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Ldfld, fieldBuilder);           // Get the value of &#34;this&#34;.&#34;_field&#34; and push in onto the stack
                il.Emit(OpCodes.Ldarg_1);                       // Load the first parameter onto the stack
                il.Emit(OpCodes.Bne_Un_S, labelElse);           // If the last both values on the stack are not equal, jump to the label
                il.Emit(OpCodes.Ret);                           // Return
                il.MarkLabel(labelElse);

                // this._field = value;
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Ldarg_1);                       // Load the parameter onto the stack
                il.Emit(OpCodes.Stfld, fieldBuilder);           // Replace &#34;this&#34;.&#34;_field&#34; by the value on the stack

                // this.Model.PROPERTY = value.Model;
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Call, thisModelGetter);         // Call &#34;this&#34;.&#34;get_Model()&#34;
                il.Emit(OpCodes.Ldarg_1);                       // Load the parameter (&#34;value&#34;) onto the stack
                il.Emit(OpCodes.Callvirt, valueModelGetter);    // Call &#34;value&#34;.&#34;get_Model()&#34;
                il.Emit(OpCodes.Callvirt, modelPropertySetter); // Call &#34;this&#34;.&#34;Model&#34;.&#34;set_PROPERTY()&#34;

                // OnPropertyChanged(&#34;PROPERTY&#34;);
                il.Emit(OpCodes.Ldarg_0);                       // Load the address of &#34;this&#34; onto the stack
                il.Emit(OpCodes.Ldstr, property.Name);          // Load the string onto the stack
                il.Emit(OpCodes.Call, notificationMethod);      // Call OnPropertyChanged()

                il.Emit(OpCodes.Ret);                           // Return
            });
        }
    }

    private static void CreateGetMethod(PropertyGenerationModel property, TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, Type propertyType, Action&#60;System.Reflection.Emit.ILil&#62; emit)
    {
        var methodBuilder = typeBuilder.DefineMethod(&#34;Get_&#34; + property.Name, MethodAttributes.Public &#124; MethodAttributes.HideBySig, propertyType, Type.EmptyTypes);
        var il = methodBuilder.GetILGenerator();
        emit(il);
        propertyBuilder.SetGetMethod(methodBuilder);
    }

    private static void CreateSetMethod(PropertyGenerationModel property, TypeBuilder typeBuilder, PropertyBuilder propertyBuilder, Type propertyType, Action&#60;System.Reflection.Emit.ILil&#62; emit)
    {
        var methodBuilder = typeBuilder.DefineMethod(&#34;Set_&#34; + property.Name, MethodAttributes.Public &#124; MethodAttributes.HideBySig, null, new[] {propertyType});
        var il = methodBuilder.GetILGenerator();
        emit(il);
        propertyBuilder.SetSetMethod(methodBuilder);
    }
}
</pre>
<h3><a name="Trees"></a>Expression Trees</h3>
<p>A furthur approach to generate code at runtime is the generation of <a href="http://msdn.microsoft.com/en-us/library/bb397951.aspx" title="Expression Trees at MSDN">Linq expression trees</a>. Expression trees are not suitable in all cases. For example, with expression trees, the keyword &#8220;this&#8221; cannot be expressed. Also, constructors cannot be created. These two limitations prohibit using Linq expression trees to generate method bodies as the ones in the previouse section, even if Linq expressions can be compiled into types created via Reflection with the TypeBuilder class.</p>
<p>Dispite the limitation stated bove, Linq expresion trees can be very usefull when the generated code can run in a static methods. Consider the following method. It parses filter descriptions like &#8220;FirstName=Munir;LastName=Husseini&#8221; and creates expressions that compare the querable item&#8217;s properties with the specified values.</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
public static IQueryable&#60;T&#62; Where&#60;T&#62;(this IQueryable&#60;T&#62; query, string description)
{
    var parameter = Expression.Parameter(typeof (T), &#34;item&#34;);
    var comparisons =
        from s in description.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries)
        let s2 = s.Split(new[] {'='}, StringSplitOptions.RemoveEmptyEntries)
        let propertyName = s2[0]
        let value = s2[1]
        let property = typeof (T).GetProperty(propertyName)
        select Expression.Equal(
            Expression.Property(parameter, property),
            Expression.Convert(Expression.Constant(value), property.PropertyType));

    var expressionStack = new Stack&#60;Expression&#62;(comparisons);

    while (expressionStack.Count &#62; 1)
    {
        var left = expressionStack.Pop();
        var right = expressionStack.Pop();
        var and = Expression.And(left, right);

        expressionStack.Push(and);
    }

    var filterExpression = expressionStack.Pop();
    var lambda = Expression.Lambda&#60;Func&#60;T, bool&#62;&#62;(filterExpression, parameter);

    return query.Where(lambda);
}
</pre>
<p>Using the method above, the following two objects query2 and query3 will be equally filtered.</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
IQueryable&#60;Person&#62; query = ... // Load from database
var query2 = query.Where(p =&#62; p.FirstName == &#34;Munir&#34; &#38;&#38; p.LastName == &#34;Husseini&#34;);
var query3 = query.Where(&#34;FirstName=Munir;LastName=Husseini&#34;);
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[In-Memory Run-Time Code Generation With .NET - Part 3]]></title>
<link>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation-pt3/</link>
<pubDate>Sun, 17 Feb 2013 20:01:08 +0000</pubDate>
<dc:creator>mhusseini</dc:creator>
<guid>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation-pt3/</guid>
<description><![CDATA[Table Of Contents This article is split into 5 posts. Introduction General Approach Generation Model]]></description>
<content:encoded><![CDATA[<h3>Table Of Contents</h3>
<p>This article is split into 5 posts.</p>
<ol>
<li><a href="/2013/02/17/in-memory-run-time-code-generation">Introduction</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Approach">General Approach</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Model">Generation Model</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2">Templating Engines</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#T4">T4</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#StringTemplate">StringTemplate</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#DotLiquid">DotLiquid</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3">Code Generation From Source</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#CodeDom">CodeDom</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#Roslyn">Roslyn</a></li>
<li>Mono</li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4">Code Generation From Model</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Emit">Emit</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Trees">Expression Trees</a></li>
<li>Mono Cecil</li>
</ul>
</li>
<li>Loading
<ul>
<li>Dependency Injection</li>
<li>Managed Extensibility Framework</li>
<li>Reflection</li>
</ul>
</li>
</ol>
<h1>In-Memory Run-Time Code Generation With .NET &#8211; Part 3</h1>
<h2><a name="GenerationFromModel"></a>Code Generation From Source</h2>
<p>Once source code is generated, it needs to get compiled into MSIL.</p>
<h3><a name="CodeDom"></a>CodeDom</h3>
<p><a href="http://msdn.microsoft.com/en-us/library/650ax5cx.aspx" title="Dynamic Source Code Generation and Compilation on MSDN">The .NET framework provides compilers for C#, VB and JScript</a>. These are the classes Microsoft.CSharp.CSharpCodeProvider, Microsoft.VisualBasic.VBCodeProvider and Microsoft.JScript.JScriptCodeProvider, repectivly. These classes are thin wrappers around the native compilers csc.exe, vbc.exe and jsc.exe. Since theses compilers operate on files on the file system, the wrapper classes need to save the source files into temporary files to be able to pass them to the compilers. Likewise, the compiled assemblies are (temporarily) saved to disk and then loaded by the wrappers. Because of that, true in-memory assembly generation is not possible with these classes. Also, these classes need full-trust permissions.</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
public static Assembly Compile(string[] sources, bool isDebug, string tempDir, params AssemblyName[] referencedAssemblies)
{
    var codeProvider = new CSharpCodeProvider(new Dictionary&#60;string, string&#62; {{&#34;CompilerVersion&#34;, &#34;v4.0&#34;}});

    var assemblyReferences = new[]
        {
            &#34;System.dll&#34;,
            &#34;System.Core.dll&#34;,
            &#34;mscorlib.dll&#34;
        }
        .Union(from ass in referencedAssemblies
                select new Uri(ass.CodeBase).LocalPath)
        .Distinct(StringComparer.OrdinalIgnoreCase)
        .ToArray();

    var parameters = new CompilerParameters
        {
            GenerateInMemory = true,
            GenerateExecutable = true,
            IncludeDebugInformation = isDebug,
            OutputAssembly = Path.Combine(tempDir, &#34;generatedassembly.dll&#34;)
        };

    parameters.ReferencedAssemblies.AddRange(assemblyReferences);

    if (tempDir.Length &#62; 0) parameters.TempFiles = new TempFileCollection(tempDir);
    parameters.TempFiles.KeepFiles = isDebug;

    var compilerResults = codeProvider.CompileAssemblyFromSource(parameters, sources);

    if (compilerResults.Errors.HasErrors)
    {
        var message = string.Join(&#34;\r\n&#34;, compilerResults.Errors);
        throw new ApplicationException(message);
    }

    return compilerResults.CompiledAssembly;
}
</pre>
<p>The compiler option can be set with the class CompilerParameters. Among others, there ist a property called GenerateInMemory. If this is set to true, the compiled assemblies get deleted after being loaded into memory. Using this setting, an in-memory generation can be mimiked. On the other hand, assemblies that are loaded into memory but deleted from disk cannot be referenced by newer compilations. So if for instance different assenmblies must be generated that reference each other, the property GenerateInMemory must be set to false.</p>
<h3><a name="Roslyn"></a>Roslyn</h3>
<p><a href="http://msdn.microsoft.com/en-us/vstudio/roslyn.aspx" title="Microsoft® Roslyn CTP">&#8220;Project Roslyn&#8221;</a> is Microsoft&#8217;s new approach towards purely managed C#and VB compilers. In contrast to CodeDom, Roslyn does generate assemblies in memory without having to read or wrtie files to disk. Currently being in CTP status, not all functionality is implemented, yet. For example, it cannot reference assemblies that are not located on the files sysetm. So currently, if multiple assemblies that reference each other should be generated, true in-memory generation is not possible, either.</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
public static Assembly Compile(string[] sources, bool isDebug, string tempDir, params AssemblyName[] referencedAssemblies)
{
    var assemblyFileName = tempDir + &#34;gen&#34; + Guid.NewGuid().ToString().Replace(&#34;-&#34;, &#34;&#34;) + &#34;.dll&#34;;
    var assemblyPath = Path.GetFullPath(assemblyFileName);

    var compilation = Compilation.Create(assemblyFileName,
                                            new CompilationOptions(OutputKind.DynamicallyLinkedLibrary))
                                    .AddSyntaxTrees(from source in sources
                                                    select SyntaxTree.ParseCompilationUnit(source))
                                    .AddReferences(from ass in referencedAssemblies
                                                select new AssemblyFileReference(new Uri(ass.CodeBase).LocalPath))
				                              //select new AssemblyObjectReference(Assembly.Load(ass)))
                                    .AddReferences(from ass in new[]
                                                {
                                                    &#34;System&#34;,
                                                    &#34;System.Core&#34;,
                                                    &#34;mscorlib&#34;
                                                }
                                                select new AssemblyNameReference(ass));

    EmitResult emitResult;

    //using (var stream = new MemoryStream())
    using (var stream = new FileStream(assemblyPath, FileMode.Create, FileAccess.Write))
    {
        emitResult = compilation.Emit(stream);
    }

    if (!emitResult.Success)
    {
        var message = string.Join(&#34;\r\n&#34;, emitResult.Diagnostics);
        throw new ApplicationException(message);
    }

    return Assembly.LoadFile(assemblyPath);
}
</pre>
<p>In the code above, there are two commented-out lines. The first on uses the type AssemblyFileReference which is currently not implemented. This type would allow referencing assemblies from memory. The second commented-out line regards where the complied asssembly is written to. Once in-memory references are implemented, complied assemblies can be written into memory and referenced by other assemblies to be generated.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[In-Memory Run-Time Code Generation With .NET - Part 2]]></title>
<link>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation-pt2/</link>
<pubDate>Sun, 17 Feb 2013 19:59:39 +0000</pubDate>
<dc:creator>mhusseini</dc:creator>
<guid>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation-pt2/</guid>
<description><![CDATA[Table Of Contents This article is split into 5 posts. Introduction General Approach Generation Model]]></description>
<content:encoded><![CDATA[<h3>Table Of Contents</h3>
<p>This article is split into 5 posts.</p>
<ol>
<li><a href="/2013/02/17/in-memory-run-time-code-generation">Introduction</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Approach">General Approach</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Model">Generation Model</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2">Templating Engines</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#T4">T4</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#StringTemplate">StringTemplate</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#DotLiquid">DotLiquid</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3">Code Generation From Source</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#CodeDom">CodeDom</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#Roslyn">Roslyn</a></li>
<li>Mono</li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4">Code Generation From Model</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Emit">Emit</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Trees">Expression Trees</a></li>
<li>Mono Cecil</li>
</ul>
</li>
<li>Loading
<ul>
<li>Dependency Injection</li>
<li>Managed Extensibility Framework</li>
<li>Reflection</li>
</ul>
</li>
</ol>
<h1>In-Memory Run-Time Code Generation With .NET &#8211; Part 2</h1>
<h2><a name="Engines"></a>Templating Engines</h2>
<p>Templating engines allow a very flexible and quite easy, because human-readable definition of the code to be generated. Following, three templating engines are introduced. The main differences between these engines in the context of this article is the level of separation between the WHAT and the HOW.</p>
<p>While T4 or the ASP.NET view engines compile into C#, which bascially allows doing anything C# is capable of inside of the view, StringTemplate brings its own compiler that enforces a strict View-Model-separation. Only read-only on the model or text output operations are allowed inside of the view. DotLiquid does the same, and only processes known and secure model types.</p>
<h3><a name="T4"></a>T4</h3>
<p>The most common templating engine in the .NET world is probably the <a href="http://msdn.microsoft.com/en-us/library/vstudio/bb126445.aspx" title="Code Generation and T4 Text Templates on MSDN">T4 Text Template</a>. Since Visual Studio 2010, it comes in two flavors: regular and preprocessed. regular text templates are processed within Visual Studio itself (or a templating host created at runtime and loaded with the template). preprocessed text templates are transformed into C# classes that can be called at runtime for processing. Regular T4 templates need some infrastructure to run, which in turn needs refrences to Visual Studio assemblies. Also, a lot of that infrastructure is practically undocumented, which makes hosting and processing regular T4 templates in custom code not the easiest thing to do. Becasue of that, only preprocessed templates are discussed in this article. Please read <a href="/2012/05/15/95" title="Code Generation And Manipulation Using T4 Templates And Visual Studio Automation By Sample">my other article</a> about some neet stuff you can do with hosted template processing.</p>
<p>Consider a simple T4 template that is saved in a file called ViewModelTemplate.tt. Visual Studio generates a class named ViewModelTemplate. This generated class has a method called TransformText which renders the template into a string. The generated class ViewModelTemplate can be extended by adding a partial class with the same name. Here, a partial class is added that contains a property to store the generation model:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
partial class ViewModelTemplate
{
	public TypeGenerationModel Model { get; set; }
}
</pre>
<p>Inside the T4 template, the property Model can be accessed for information about the type to generate. The template generates three types of properties: properties that only wrap access to the underlying data model, properties that return other data view models and properties that return lists of data view models. The T4 template may look like this:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
&#60;#@ template language=&#34;C#&#34; #&#62;
&#60;#@ import namespace=&#34;System.Linq&#34; #&#62;
using System.Collections.Generic;
using System.Linq;

namespace &#60;#= Model.Namespace #&#62;
{
  public class &#60;#= Model.Name #&#62; : Demo.ViewModelBase&#60;&#60;#= Model.ModelTypeName #&#62;&#62;
  {
&#60;#foreach(var property in Model.Properties.Where(p =&#62; !p.IsViewModel))
  {#&#62;
    public &#60;#= property.TypeName #&#62; &#60;#= property.Name #&#62;
    {
&#60;#  if(property.CanGet) 
    {#&#62; 
      get 
      { 
        return Model.&#60;#= property.Name #&#62;; 
      } 
&#60;#  }        
    if(property.CanSet) 
    {#&#62; 
      set 
      { 
        if(Model.&#60;#= property.Name #&#62; == value) return;
        Model.&#60;#= property.Name #&#62; = value; 
        OnPropertyChanged(&#34;&#60;#= property.Name #&#62;&#34;);
      } 
&#60;#  }#&#62;      
    }
&#60;#} 
  
  foreach(var property in Model.Properties.Where(p =&#62; p.IsViewModel &#38;&#38; !p.IsList))
  {#&#62;
    private &#60;#= property.TypeName #&#62; _&#60;#= property.Name #&#62;;
    public &#60;#= property.TypeName #&#62; &#60;#= property.Name #&#62;
    {
&#60;#  if(property.CanGet) 
    {#&#62; 
      get 
      { 
        if(_&#60;#= property.Name #&#62; == null) _&#60;#= property.Name #&#62; = new &#60;#= property.TypeName #&#62;(Model.&#60;#= property.Name #&#62;);
        return _&#60;#= property.Name #&#62;; 
      } 
&#60;#  }        
    if(property.CanSet) 
    {#&#62; 
      set 
      { 
        if(_&#60;#= property.Name #&#62; == value) return;
        _&#60;#= property.Name #&#62; = value; 
        Model.&#60;#= property.Name #&#62; = value.Model; 
        OnPropertyChanged(&#34;&#60;#= property.Name #&#62;&#34;);
      } 
&#60;#  }#&#62;      
    }
&#60;#} 
  
  foreach(var property in Model.Properties.Where(p =&#62; p.IsViewModel &#38;&#38; p.IsList &#38;&#38; p.CanGet))
  {#&#62;
    private List&#60;&#60;#= property.TypeName #&#62;&#62; _&#60;#= property.Name #&#62;;
    public List&#60;&#60;#= property.TypeName #&#62;&#62; &#60;#= property.Name #&#62;
    {
      get 
      { 
        if(_&#60;#= property.Name #&#62; == null) _&#60;#= property.Name #&#62; = new List&#60;&#60;#= property.TypeName #&#62;&#62;(Model.&#60;#= property.Name #&#62;.Select(m =&#62; new &#60;#= property.TypeName #&#62;(m)));
        return _&#60;#= property.Name #&#62;; 
      } 
    }
&#60;#}#&#62;
    public &#60;#= Model.Name #&#62;(&#60;#= Model.ModelTypeName #&#62; model) : base(model)
    {
    }
  }
}
</pre>
<p>Executing a T4 template is very easy since the template itself is already a .NET class.</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
public class CodeGenerator
{
    public static string Generate(TypeGenerationModel model)
    {
        var template = new ViewModelTemplate { Model = model };
        return template.TransformText();
    }
}
</pre>
<p>The main program can call the above class now:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
static void Main(string[] args)
{
    var generationModels = CreateGenerationModels(typeof(Person), &#34;Generated&#34;);
    var sources = generationModels.Select(T4.CodeGenerator.Generate);

    // ... rest of the work here ...
}
</pre>
<h3><a name="StringTemplate"></a>StringTemplate</h3>
<p><a href="http://www.stringtemplate.org/" title="Official web site of StringTemplate">StringTemplate</a> is a templating engine created by the ANTLR team. It is available for Java, Pyhton and the .NET framework. There are many differences between T4 and StringTemplate, but the main difference that is of matter in this case is that of the strict model-view separation. This means that inside StringTemplate templates, invoking methods or operators is not allowed. Although StringTemplate supports if-conditions, these conditions only match boolean values and the existance of the expression (comparable to JavaScript&#8217;s undefined).</p>
<p>To be able to use StringTemplate, the generation model from above must be extended by properties that replace the property filters in the T4 template. So instead of filtering the properties inside the template, the filtering must be applied inside the generation model:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
/// &#60;summary&#62;
/// Defines the type that will be generated.
/// &#60;/summary&#62;
public class TypeGenerationModel
{
    // ... properties omitted ...

    /// &#60;summary&#62;
    /// Gets the regular properties to generate.
    /// &#60;/summary&#62;
    public IEnumerable&#60;PropertyGenerationModel&#62; Properties { get; private set; }

    /// &#60;summary&#62;
    /// Gets the properties to generate that return view model types.
    /// &#60;/summary&#62;
    public IEnumerable&#60;PropertyGenerationModel&#62; ViewModelProperties { get; private set; }

    /// &#60;summary&#62;
    /// Gets the properties to generate that return lists of view model types.
    /// &#60;/summary&#62;
    public IEnumerable&#60;PropertyGenerationModel&#62; ViewModelListProperties { get; private set; }

    /// &#60;summary&#62;
    /// Initializes a new instance of the &#60;see cref=&#34;TypeGenerationModel&#34;/&#62; class.
    /// &#60;/summary&#62;
    /// &#60;param name=&#34;modelType&#34;&#62;Type of the data model for which to generate the view model.&#60;/param&#62;
    /// &#60;param name=&#34;namespace&#34;&#62;The @namespace of the generated view model.&#60;/param&#62;
    public TypeGenerationModel(Type modelType, string @namespace)
    {
        Namespace = @namespace;
        ModelType = modelType;
        ModelTypeName = modelType.GetTypeName();
        Name = modelType.Name;

        var allProperties = ModelType
            .GetProperties(BindingFlags.Instance &#124; BindingFlags.Public)
            .Select(p =&#62; new PropertyGenerationModel(this, p))
            .Where(p =&#62; p.CanGet &#124;&#124; p.CanSet)
            .ToList();

        Properties = allProperties.Where(p =&#62; !p.IsViewModel);

        ViewModelProperties = allProperties.Where(p =&#62; p.IsViewModel &#38;&#38; !p.IsList);

        ViewModelListProperties = allProperties.Where(p =&#62; p.IsViewModel &#38;&#38; p.IsList &#38;&#38; p.CanGet)
    }
}
</pre>
<p>The T4 template from above can quite easily be transformed into StringTemplate syntax:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
using System.Collections.Generic;
using System.Linq;

namespace $Model.Namespace$
{
   public class $Model.Name$ : Demo.ViewModelBase&#60;$Model.ModelTypeName$&#62;
   {
   $Model.Properties:
   {
      property&#124;
      public $property.TypeName$ $property.Name$
      {      
      $if(property.CanGet)$
         get 
         { 
            return Model.$property.Name$; 
         \} 
      $endif$
               
      $if(property.CanSet)$
         set 
         { 
            if(Model.$property.Name$ == value) return;
            Model.$property.Name$ = value; 
            OnPropertyChanged(&#34;$property.Name$&#34;);
         \} 
      $endif$         
      \}
   }$ 
   
   $Model.ViewModelProperties:
   {
      property&#124;
      private $property.TypeName$ _$property.Name$;
      public $property.TypeName$ $property.Name$
      {
      $if(property.CanGet)$
         get 
         { 
            if(_$property.Name$ == null) _$property.Name$ = new $property.TypeName$(Model.$property.Name$);
            return _$property.Name$; 
         \} 
      $endif$
            
      $if(property.CanSet)$
         set 
         { 
            if(_$property.Name$ == value) return;
            _$property.Name$ = value; 
            Model.$property.Name$ = value.Model; 
            OnPropertyChanged(&#34;$property.Name$&#34;);
         \} 
      $endif$
      \}
   }$
   
   $Model.ViewModelListProperties:
   {
      property&#124;
      private List&#60;$property.TypeName$&#62; _$property.Name$;
      public List&#60;$property.TypeName$&#62; $property.Name$
      {
         get 
         { 
            if(_$property.Name$ == null) _$property.Name$ = new List&#60;$property.TypeName$&#62;(Model.$property.Name$.Select(m =&#62; new $property.TypeName$(m)));
            return _$property.Name$; 
         \} 
      \}
   }$
      public $Model.Name$($Model.ModelTypeName$ model) : base(model)
      {
      }
   }
}
</pre>
<p>A StringTemplate template must be loaded into the StringTemplate engine. While StringTemplate offers functionality for more complex scenarios (e.g. dynamically loading sub templates), here only a basic set of this functionality is required:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
public static string Generate(TypeGenerationModel model)
{
    var template = new Antlr4.StringTemplate.Template(Resource.STViewModelTemplate, '$', '$');
    template.Add(&#34;Model&#34;, model);

    return template.Render();
}
</pre>
<p>The main program can call the above class now:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
static void Main(string[] args)
{
    var generationModels = CreateGenerationModels(typeof(Person), &#34;Generated&#34;);
    var sources = generationModels.Select(ST.CodeGenerator.Generate);

    // ... rest of the work here ...
}
</pre>
<h3><a name="DotLiquid"></a>DotLiquid</h3>
<p><a href="http://dotliquidmarkup.org/" title="Official web site of DotLiquid">DotLiquid</a> is the new kid on the block. It is a port of Ruby&#8217;s Liquid Markup. Like StringTemplate, DotLiquid does not allow calling any methods from inside the view. On the other hand, it does allow comparison operators. The main difference to other templating engines is that only certain types of models get processed. This means that only basic types like strings or integers or types that derive from DotLiquid.Drop are allowed as models. DotLiquid&#8217;s syntax is simmilar to that of StringTemplate. The above template looks for DotLiquid like this:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
using System.Collections.Generic;
using System.Linq;

namespace {{ Model.namespace }}
{
	public class {{ Model.name }}: Demo.ViewModelBase&#60;{{ Model.model_Type_name }}&#62;
	{
	{% for property in Model.Properties -%}
		public {{ property.type_name }} {{ property.name }}
		{
		{% if property.CanGet %}
			get 
			{ 
				return Model.{{ property.name }}; 
			} 
		{% endif %}
		{% if property.CanSet %}
			set 
			{ 
				if(Model.{{ property.name }} == value) return;
				Model.{{ property.name }} = value; 
				OnPropertyChanged(&#34;{{ property.name }}&#34;);
			} 
		{% endif %}	
		}
	{% endfor -%}
	
	{% for property in Model.view_model_properties -%}
		private {{ property.type_name }} _{{ property.name }};
		public {{ property.type_name }} {{ property.name }}
		{
		{% if property.CanGet %}
			get 
			{ 
				if(_{{ property.name }} == null) _{{ property.name }} = new {{ property.type_name }}(Model.{{ property.name }});
				return _{{ property.name}}; 
			} 
		{% endif %}
		{% if property.CanSet %}
			set 
			{ 
				if(_{{ property.name }} == value) return;
				_{{ property.name }} = value; 
				Model.{{ property.name }} = value.Model; 
				OnPropertyChanged(&#34;{{ property.name }}&#34;);
			} 
		{% endif %}
		}
	{% endfor -%}
	
	{% for property in Model.view_model_list_properties -%}
		private List&#60;{{ property.type_name }}&#62; _{{ property.name }};
		public List&#60;{{ property.type_name }}&#62; {{ property.name }}
		{
			get 
			{ 
				if(_{{ property.name }} == null) _{{ property.name }} = new List&#60;{{ property.type_name }}&#62;(Model.{{ property.name }}.Select(m =&#62; new {{ property.type_name }}(m)));
				return _{{ property.name }}; 
			} 
		}
	{% endfor -%}

		public {{ Model.name }}({{ Model.model_Type_name }} model) : base(model)
		{
		}
	}
}
</pre>
<p>The code needed to execute thee template loosk like this:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
public class CodeGenerator
{
    public static string Generate(TypeGenerationModel model)
    {
        var template = DotLiquid.Template.Parse(Resource.DotLiquid_ViewModelTemplate);
        return template.Render(DotLiquid.Hash.FromAnonymousObject(new { Model = model }));
    }
}
</pre>
]]></content:encoded>
</item>
<item>
<title><![CDATA[In-Memory Run-Time Code Generation With .NET]]></title>
<link>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation/</link>
<pubDate>Sun, 17 Feb 2013 13:38:02 +0000</pubDate>
<dc:creator>mhusseini</dc:creator>
<guid>http://mhusseini.wordpress.com/2013/02/17/in-memory-run-time-code-generation/</guid>
<description><![CDATA[Table Of Contents This article is split into 5 posts. Introduction General Approach Generation Model]]></description>
<content:encoded><![CDATA[<h3>Table Of Contents</h3>
<p>This article is split into 5 posts.</p>
<ol>
<li><a href="/2013/02/17/in-memory-run-time-code-generation">Introduction</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Approach">General Approach</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation#Model">Generation Model</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2">Templating Engines</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#T4">T4</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#StringTemplate">StringTemplate</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt2#DotLiquid">DotLiquid</a></li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3">Code Generation From Source</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#CodeDom">CodeDom</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt3#Roslyn">Roslyn</a></li>
<li>Mono</li>
</ul>
</li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4">Code Generation From Model</a>
<ul>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Emit">Emit</a></li>
<li><a href="/2013/02/17/in-memory-run-time-code-generation-pt4#Trees">Expression Trees</a></li>
<li>Mono Cecil</li>
</ul>
</li>
<li>Loading
<ul>
<li>Dependency Injection</li>
<li>Managed Extensibility Framework</li>
<li>Reflection</li>
</ul>
</li>
</ol>
<h1>In-Memory Run-Time Code Generation With .NET &#8211; Part 1</h1>
<h2><a name="Introduction"></a>Introduction</h2>
<p>In this series, I will show how to generate, compile and load .NET code at runtime using different techniques. Since this series will be somewhat lengthy, I’ll need some time to complete it. In the meanwhile, preliminary result will be published.</p>
<p>
    For illustration purposes, a simple example is used throughout this article. The scenario of the example is a MVVM application with 100s of models. Many of these models need a corresponding view model that wrapes the models properties into <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged.aspx" title="INotifyPropertyChanged at MSDN">e.g. notifiying properties</a>.<br />
    A possible approach to build such an application could be to build a view model base class, that &#8220;magically&#8221; wrapps around a model class and instantly generates a matching view model with all the models properties. This article demonstrates how to do that.
</p>
<h3><a name="Approach"></a>General Approach</h3>
<p>
    As often in software developement, the recommended approach here is to separate WHAT will be generated from HOW it is generated, i.e. to define a model and a view.<br />
    The objective here is to generate .NET assemblies that contain classes that can dynamically be instanciated and used.
</p>
<p>
    A data model that describes the classes contained in such an assembly will be referred to as the <i>generation model</i>.<br />
    The object that will generate these classes (using either of the techniques discussed in this article) will be referred to as the <i>generation view</i>.
</p>
<p>The models, view models and views of the example application will be referred to as the <i>runtime</i> models, view models and views.</p>
<p>The idea how to create a &#8220;magic&#8221; view model is the following: at runtime&#8230;</p>
<ol>
<li>&#8230;the runtime model is analyzed via reflection to determine the properties of the runtime view model to generate. These properties and other configuration parameters make up the generation model
    </li>
<li>Call a generation view with the generation model as a parameter to generate an assembly. The generation view could use one of the techniques discussed in this article:
<ol>
<li>Generate source code and compile it into MSIL using templating engines or pure string-concatenation, generate source code of any .NET langauge (in this article, C# is used) and compile it into a .NET assembly.
            </li>
<li>Directly generate MSIL code. The .NET framework allowes to emit MSIL opcodes into dynamic assemblies. This can be done directly using Reflection or by abstraction using Linq Expression Trees.
            </li>
</ol>
</li>
<li>Load the generated types. Once the view model assemblies are generated, the appropriate types must be loaded and instanciated with model instances as constructor parameters.
    </li>
</ol>
<p>In short, these steps are:</p>
<p>Data Model &#8594; Generation Model &#8594; (Source Code &#8594;) Dynamic Assembly &#8594; Loading.</p>
<h3><a name="Model"></a>Generation Model</h3>
<p>
    The generation model will define types and properties to be generated. Therefore, there are two classes that make up the generation model: TypeGenerationModel and PropertyGenerationModel.
</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
/// &#60;summary&#62; 
/// Defines the type that will be generated.
/// &#60;/summary&#62;
public class TypeGenerationModel
{
    /// &#60;summary&#62;
    /// Gets the namespace of the generated view model.
    /// &#60;/summary&#62;
public string Namespace { get; private set; }

    /// &#60;summary&#62;
    /// Gets the name of the generated view model for which to generate the view model.
    /// &#60;/summary&#62;
    public string Name { get; private set; }

    /// &#60;summary&#62;
    /// Gets the type of the data model.
    /// &#60;/summary&#62;
    public Type ModelType { get; private set; }

    /// &#60;summary&#62;
    /// Gets the type name of the data model.
    /// &#60;/summary&#62;
    public string ModelTypeName { get; private set; }

    /// &#60;summary&#62;
    /// Gets the properties to generate.
    /// &#60;/summary&#62;
    public IEnumerable&#60;propertygenerationmodel&#62; Properties { get; private set; }

    /// &#60;summary&#62;
    /// Initializes a new instance of the &#60;see cref=&#34;TypeGenerationModel&#34;/&#62; class.
    /// &#60;/summary&#62;
    /// &#60;param name=&#34;modelType&#34;&#62;Type of the data model for which to generate the view model.&#60;/param&#62;
    /// &#60;param name=&#34;namespace&#34;&#62;The @namespace of the generated view model.&#60;/param&#62;
    public TypeGenerationModel(Type modelType, string @namespace)
    {
        Namespace = @namespace;
        ModelType = modelType;
        ModelTypeName = modelType.GetTypeName();
        Name = modelType.Name;
        Properties = ModelType
                    .GetProperties(BindingFlags.Instance &#124; BindingFlags.Public)
                    .Select(p =&#62; new PropertyGenerationModel(this, p))
                    .Where(p =&#62; p.CanGet &#124;&#124; p.CanSet)
                    .ToList();
    }
}

/// &#60;summary&#62;
/// Defines a view model's property that will be generated.
/// &#60;/summary&#62;
public class PropertyGenerationModel
{

    /// &#60;summary&#62;
    /// Gets the full name of the property type.
    /// &#60;/summary&#62;
    public string TypeName { get; private set; }

    /// &#60;summary&#62;
    /// Gets the name of the property.
    /// &#60;/summary&#62;
    public string Name { get; private set; }

    /// &#60;summary&#62;
    /// Gets a value indicating whether this property leads to another generation model.
    /// &#60;/summary&#62;
    public bool IsGenerationModel { get; private set; }

    /// &#60;summary&#62;
    /// Gets a value indicating whether this instance is a list.
    /// &#60;/summary&#62;
    public bool IsList { get; private set; }

    /// &#60;summary&#62;
    /// Gets or sets a value indicating whether this property has a setter.
    /// &#60;/summary&#62;
    public bool CanSet { get; private set; }

    /// &#60;summary&#62;
    /// Gets or sets a value indicating whether this property has a getter.
    /// &#60;/summary&#62;
    public bool CanGet { get; private set; }

    /// &#60;summary&#62;
    /// Gets or sets the type of the element returned by the property.
    /// &#60;/summary&#62;
    public Type ElementType { get; private set; }

    /// &#60;summary&#62;
    /// Initializes a new instance of the &#60;see cref=&#34;PropertyGenerationModel&#34;/&#62; class.
    /// &#60;/summary&#62;
    /// &#60;param name=&#34;parent&#34;&#62;The type model that contains the property.&#60;/param&#62;
    /// &#60;param name=&#34;property&#34;&#62;The property info to generate from.&#60;/param&#62;
    public PropertyGenerationModel(TypeGenerationModel parent, PropertyInfo property)
    {
        // Let the property of the view model as the property of the model.
        Name = property.Name;

        var getter = property.GetGetMethod();
        CanGet = getter != null &#38;&#38; getter.IsPublic;

        var setter = property.GetSetMethod();
        CanSet = setter != null &#38;&#38; setter.IsPublic;

        // In this small demo, only support Lists to contain child view models.
        IsList = property.PropertyType.IsGenericType &#38;&#38; property.PropertyType.GetGenericTypeDefinition() == typeof(List&#60;&#62;);

        // If this is a list, we'll need type of the elements,
        // not of the property itseld.
        var itemType = IsList
                    ? property.PropertyType.GetGenericArguments().First()
                    : property.PropertyType;

        // Assume that all models are in one assembly and can be
        // identified by just being in that assembly.
        IsViewModel = itemType.Assembly == property.DeclaringType.Assembly;

        ElementType = IsGenerationModel ? itemType : property.PropertyType;

        // Get the type name in a format that can be placed into code
        // (i.e. MyType&#60;T&#62; rather than MyType`1 for generic types)
        TypeName = IsGenerationModel
                    ? parent.Namespace + &#34;.&#34; + itemType.Name
                    : property.PropertyType.GetTypeName();
    }
}
</pre>
<p>Since the data model may reference other data models, the types of these data models need to be collected and added to the generation model as well. The following code creates a generation model from the root type and traverses the proeprties until all data model types are collected:</p>
<pre class="brush: csharp; title: ; wrap-lines: false; notranslate" title="">
internal class Program
{
    private static void Main(string[] args)
    {
        var generationModels = CreateGenerationModels(typeof(Person), &#34;Generated&#34;);

        // ... rest of the work here ...
    }

    public static IEnumerable&#60;TypeGenerationModel&#62; CreateGenerationModels(Type type, string @namespace, HashSet&#60;Type&#62; processedTypes)
    {
        if (processedTypes == null) processedTypes = new HashSet&#60;Type&#62;();
        processedTypes.Add(type);

        var model = new TypeGenerationModel(type, @namespace);
        yield return model;

        var models = from p in model.Properties
                     where p.IsGenerationModel &#38;&#38; !processedTypes.Contains(p.ElementType)
                     from m in CreateGenerationModels(p.ElementType, @namespace, processedTypes)
                     select m;


        foreach (var referencedModel in models)
        {
            yield return referencedModel;
        }
    }
}
</pre>
<p>
    The runtime view models (the types that will be generated) will inherit a common base class called ViewModelBase. This base class contains common code needed to do some of the &#8220;magic&#8221;. For instance, if one of the models properties isn&#8217;t a simple type, but another model a collection of other models, then the properties values must be wrapped in a view model as well. The base class contains the methods needed to do this kind of stuff.
</p>
<p>The next sections will describe generation views that use this generation model to generate the described types.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Constructor syntax]]></title>
<link>http://javanoobie.com/2013/02/14/constructor-syntax/</link>
<pubDate>Thu, 14 Feb 2013 13:37:09 +0000</pubDate>
<dc:creator>Glenn H</dc:creator>
<guid>http://javanoobie.com/2013/02/14/constructor-syntax/</guid>
<description><![CDATA[The basic syntax for a constructor in Java is: public Classname (param list) [throws exception...] p]]></description>
<content:encoded><![CDATA[<h2>The basic syntax for a <a title="Constructors" href="http://javanoobie.com/2013/02/14/constructors/">constructor</a> in Java is:</h2>
<p><code>public Classname (param list) [throws exception...]</code></p>
<p><strong>public</strong>: Indicates the constructor is available to other <a title="Class" href="http://javanoobie.com/2013/02/14/class/">classes</a>.</p>
<p><strong>Classname</strong>: MUST be the same as the class containing the constructor.</p>
<div class="wp-caption alignright" style="width: 250px"><a href="http://www.flickr.com/photos/80072069@N00/155604654" target="_blank"><img class="zemanta-img-inserted zemanta-img-configured" title="Construction Work" alt="Construction Work" src="http://farm1.static.flickr.com/53/155604654_271132f38a_m.jpg" width="240" height="160" /></a><p class="wp-caption-text">Construction Work (Photo credit: gullevek)</p></div>
<p><strong>(param list)</strong>: Can be empty or accept parameters.</p>
<ul>
<li>A class can have multiple constructors as long as each has a unique list of parameters.</li>
<li>One constructor in a class can contain <em>NO</em> <a title="Abbreviations" href="http://javanoobie.com/abbreviations/" target="_blank">params</a>.</li>
<li>No two constructors in a class can have the same number of params because the compiler will not be able to tell them apart even if the types in the param list are different.</li>
</ul>
<p>If you create a class without declaring any constructors, Java creates a default constructor with NO parameters and NO statements. It does not do anything other than allow your class to be instantiated.</p>
<p>If you create a class with constructors of your own making, but do NOT create a zero parameter constructor and then try to use the class with a zero paremeter call, you will get a compile error.</p>
<p>[Source: See <a href="http://www.amazon.com/gp/product/0470371722/ref=as_li_qf_sp_asin_tl?ie=UTF8&#38;camp=1789&#38;creative=9325&#38;creativeASIN=0470371722&#38;linkCode=as2&#38;tag=javanoobie-20" target="_blank">jaiofd3d</a><img style="border:none!important;margin:0!important;" alt="" src="http://www.assoc-amazon.com/e/ir?t=javanoobie-20&#38;l=as2&#38;o=1&#38;a=0470371722" width="1" height="1" border="0" /> p. 246f]</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Grace Hopper on Letterman]]></title>
<link>http://thatlonecreature.wordpress.com/2013/02/14/grace-hopper-on-letterman/</link>
<pubDate>Thu, 14 Feb 2013 12:45:28 +0000</pubDate>
<dc:creator>Lazy Worm</dc:creator>
<guid>http://thatlonecreature.wordpress.com/2013/02/14/grace-hopper-on-letterman/</guid>
<description><![CDATA[The pioneer of computers &amp; computing, an admiral of the US Navy. Her credentials are too long to]]></description>
<content:encoded><![CDATA[<p><span style="font-size:13px;line-height:19px;">The pioneer of computers &#38; computing, an admiral of the US Navy. Her credentials are too long to list&#8230;</span></p>
<p>This lady was know as the Queen of software then. Grace Hopper (1906 &#8211; 1992) once walked around with a quote: &#8220;Nobody believed that I had a running compiler and nobody would touch it. They told me computers could only do arithmetic.&#8221; As always with all great people, no one listened.</p>
<p>Visit this link to watch the video: <a href="http://www.myvidster.com/video/425708/Grace_Hopper_on_Letterman" rel="nofollow">http://www.myvidster.com/video/425708/Grace_Hopper_on_Letterman</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Array allocation in C++]]></title>
<link>http://developerblog.redhat.com/2013/02/12/array-allocation-in-c-2/</link>
<pubDate>Tue, 12 Feb 2013 16:49:09 +0000</pubDate>
<dc:creator>Florian Weimer</dc:creator>
<guid>http://developerblog.redhat.com/2013/02/12/array-allocation-in-c-2/</guid>
<description><![CDATA[This technical article covers a subtlety in C++ array allocation and how we changed the GNU C++ comp]]></description>
<content:encoded><![CDATA[This technical article covers a subtlety in C++ array allocation and how we changed the GNU C++ comp]]></content:encoded>
</item>
<item>
<title><![CDATA[JVM compliling -&gt; interperting]]></title>
<link>http://cs2014fredrik.wordpress.com/2013/02/12/jvm-compliling-interperting/</link>
<pubDate>Tue, 12 Feb 2013 10:04:05 +0000</pubDate>
<dc:creator>fredx30</dc:creator>
<guid>http://cs2014fredrik.wordpress.com/2013/02/12/jvm-compliling-interperting/</guid>
<description><![CDATA[Most programming languages use only either Compilers or Interpreters  Java uses both. It compiles to]]></description>
<content:encoded><![CDATA[<p>Most programming languages use only either Compilers or Interpreters  Java uses both. It compiles to LLL(LOW LEVEL LANGUAGE) then uses an interpreter the JVM to converti it into machine code one line at a time. The JVM varies on the different OSes.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Debian Is Still Being Made To Build With LLVM/Clang]]></title>
<link>http://thelinuxsite.wordpress.com/2013/02/10/debian-is-still-being-made-to-build-with-llvmclang/</link>
<pubDate>Sun, 10 Feb 2013 20:55:35 +0000</pubDate>
<dc:creator>0XV01D</dc:creator>
<guid>http://thelinuxsite.wordpress.com/2013/02/10/debian-is-still-being-made-to-build-with-llvmclang/</guid>
<description><![CDATA[Debian developers are still working on making the operating system compiler agnostic so that its pac]]></description>
<content:encoded><![CDATA[<p>Debian developers are still working on making the operating system compiler agnostic so that its packages can be built with LLVM/Clang and other compilers rather than continuing in a monogamist relationship with GCC. <!--more--></p>
<p>In March of last year is when I first wrote about <a href="http://www.phoronix.com/scan.php?page=news_item&#38;px=MTA2NjQ">LLVM/Clang being toyed with for Debian</a>. Nearly one year ago it was found that LLVM&#8217;s C/C++ compiler was actually building much of the Debian archive while providing better compiler warnings/errors than GCC. The results were more positive than originally anticipated with less than 10% of the packages having problems being built with the alternative open-source compiler.</p>
<p>The Debian developers working on Clang support aren&#8217;t doing so because they want to deprecate GCC but rather they want to provide their users with greater options and Clang does have some rather nice error/warnings (although GCC&#8217;s reporting has improved recently too), static analysis tools, and other features to benefit developers. Pushing the packages through multiple compilers also generally ensures better code quality too.</p>
<p>In July was <a href="http://www.phoronix.com/scan.php?page=news_item&#38;px=MTEzODQ">another LLVM/Clang update for Debian</a>. It was reiterated the Clang work wasn&#8217;t to wage some GPL vs. BSD war in the Debian camp but for technical reasons. With the code at that time, just over 10% of the Debian archive was having problems being built under the latest LLVM/Clang over GCC.</p>
<p>At FOSDEM 2013 last weekend was another presentation by Sylvestre Ledru on building Debian with LLVM/Clang. Embedded below is the WebM video of this presentation. For those just wanting build results and other technical details, visit <a href="http://clang.debian.net/">clang.debian.net</a>.</p>
<p><a href="http://video.fosdem.org/2013/crossdistro/Make_Debian_compiler_agnostic___Building_Debian_with_LLVM_Clang.webm">http://video.fosdem.org/2013/crossdistro/Make_Debian_compiler_agnostic___Building_Debian_with_LLVM_Clang.webm</a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[FreeBSD Works On C11, C++11 Support]]></title>
<link>http://thelinuxsite.wordpress.com/2013/02/10/freebsd-works-on-c11-c11-support/</link>
<pubDate>Sun, 10 Feb 2013 16:17:43 +0000</pubDate>
<dc:creator>0XV01D</dc:creator>
<guid>http://thelinuxsite.wordpress.com/2013/02/10/freebsd-works-on-c11-c11-support/</guid>
<description><![CDATA[FreeBSD (Photo credit: Wikipedia) FreeBSD developers are working on enabling support for the C11 and]]></description>
<content:encoded><![CDATA[<div class="wp-caption alignright" style="width: 310px"><a href="http://en.wikipedia.org/wiki/File:Freebsd_logo.svg" target="_blank"><img class="zemanta-img-inserted zemanta-img-configured" title="FreeBSD" alt="FreeBSD" src="http://upload.wikimedia.org/wikipedia/en/thumb/d/df/Freebsd_logo.svg/300px-Freebsd_logo.svg.png" width="300" height="120" /></a><p class="wp-caption-text">FreeBSD (Photo credit: Wikipedia)</p></div>
<p>FreeBSD developers are working on enabling support for the C11 and C++11 programming language standards within their operating system.</p>
<p>Shared during the BSD track at <a href="http://www.phoronix.com/scan.php?page=search&#38;q=FOSDEM+2013">FOSDEM 2013</a> by David Chisnall was an update on the FreeBSD&#8217;s support for C11 and C++11, the latest revisions to the C and C++ programming languages. While most of the work resides within the compilers supporting these latest standards, FreeBSD is looking to take proper use of the new features and functionality. <!--more--></p>
<p>During the quick overview for those not up to speed on the latest ISO standards of these languages, C11 introduces features like alignment specifies, multi-threading support as part of the standard, a memory model, various cosmetic improvements to the code, static assertions, and unicode support. C++11 introduces better locale support, atomics/threads/thread-local storage, smart pointers, tuples, and various language changes.</p>
<p>FreeBSD system header files have already been updated to reflect the C++11 changes and their preferred LLVM/Clang compiler <a href="http://www.phoronix.com/scan.php?page=news_item&#38;px=MTA5NzU">already has begun its C11/C++11 support</a>. FreeBSD is just shipping GCC 4.2.1 (the last GPLv2 FSF GCC compiler release) and are deprecating the compiler so they aren&#8217;t really concerned about the GCC support for C++11/C11. LLVM/Clang has most pieces in place while the rest should be dropped in soon. There&#8217;s also some support via libc++, LLVM&#8217;s own more permissively licensed C++ standard library.</p>
<p>In terms of the current status in broad terms for C++11 on FreeBSD, &#8220;most of C++11 works.&#8221; For the latest C revision on FreeBSD, &#8220;most of the interesting bits of C11 work.&#8221; However, there is still lots of missing pieces for C11/C++11 on FreeBSD that still need to be implemented. For more specific details about the current state in FreeBSD, see the <a href="https://fosdem.org/2013/schedule/event/supporting_the_new_c_standards_in_freebsd/attachments/slides/161/export/events/attachments/supporting_the_new_c_standards_in_freebsd/slides/161/C11.pdf">FOSDEM PDF slides</a>.</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Compiler 2/8/13: Where the CI Meets Breaking Bad]]></title>
<link>http://compinst.org/2013/02/08/compiler-2813-where-the-ci-meets-breaking-bad/</link>
<pubDate>Fri, 08 Feb 2013 22:37:40 +0000</pubDate>
<dc:creator>Rob Mitchum</dc:creator>
<guid>http://compinst.org/2013/02/08/compiler-2813-where-the-ci-meets-breaking-bad/</guid>
<description><![CDATA[THE CI&#8217;S MOST FAMOUS CAR WASH OWNER A recurring theme of Breaking Bad is getting out of diffic]]></description>
<content:encoded><![CDATA[<p><strong><a href="http://compinst.files.wordpress.com/2013/02/marius-stan-untitled1.png"><img class="alignleft size-full wp-image-310" alt="Marius Stan.Untitled1" src="http://compinst.files.wordpress.com/2013/02/marius-stan-untitled1.png?w=132&#038;h=157" width="132" height="157" /></a>THE CI&#8217;S MOST FAMOUS CAR WASH OWNER</strong></p>
<p>A recurring theme of <em>Breaking Bad</em> is getting out of difficult situations with science. Yet, you still probably wouldn&#8217;t expect to run into a character from the hit TV show on the campus of Argonne National Laboratory or University of Chicago. But if you happen to spot a man who looks just like protagonist Walter White&#8217;s former boss at his car wash job, no need for a double take &#8212; you&#8217;re not losing your mind. Marius Stan, a Computation Institute Senior Fellow and Argonne scientist studying computational chemistry and physics, provides the memorable eyebrows and Romanian curses for the role of <a href="http://breakingbad.wikia.com/wiki/Bogdan_Wolynetz">Bogdan</a>, a character who has appeared in a handful of episodes of the AMC drug-trade drama.</p>
<p>This week <a href="http://articles.chicagotribune.com/2013-02-04/news/ct-met-scientist-breaking-bad-20130204_1_walter-white-crystal-meth-amc-drama">in the <em>Chicago Tribune</em></a>, reporter Ted Gregory profiled Stan and told the story of how he got involved with the show when he lived in Albuquerque, before moving to Chicago. Stan might humbly list &#8220;Breaking Bad, Bogdan&#8221; below a computational microscope and a book about modeling and simulation in materials science on <a href="http://www.ci.uchicago.edu/people/profile.php?id=1139">his CI web page</a>. But his colleague, CI fellow Andrew Siegel, said most people at Argonne find his moonlighting career &#8220;extremely cool.&#8221;</p>
<blockquote><p>&#8220;Everybody finds it hilarious and great. In science, you&#8217;re so uncool, at least in this country, and the world of acting is so opposite of that. It&#8217;s a funny convergence of things.&#8221;</p></blockquote>
<p><strong>THE MATH INSIDE ELECTRICAL OUTLETS</strong></p>
<p>Electrical power grids present a complex and challenging mathematical problem, with questions of how to efficiently produce, store and distribute the energy. To study the mathematics behind tomorrow&#8217;s power lines, Argonne National Laboratory and Computation Institute scientists formed the Multifaceted Mathematics for Complex Energy Systems Project (M2ACS), which recently received <a href="http://www.mcs.anl.gov/news/detail.php?id=901">a $17.5 million grant from the Department of Energy</a>. The project will bring together experts from several different areas of mathematical study, including optimization, dynamical systems, uncertainty quantification, random processes, data analysis, discrete mathematics and linear algebra to find new techniques needed to drive next-generation &#8220;smart&#8221; power grids and other technologies.</p>
<p><!--more-->CI senior fellow <a href="http://www.mcs.anl.gov/~anitescu/">Mihai Anitescu</a>, who is leading the project, described their approach:</p>
<blockquote><p>&#8220;To address these challenges, we will develop, analyze, and integrate predictive models of system behavior, new optimization-based sampling approaches, and new analysis methods and scalable algorithms that can exploit the rich mathematical structure,&#8221; said Mihai Anitescu, Argonne computational mathematician and director of M2ACS. &#8220;Our aim is to create the mathematical underpinnings of the future engineering analysis tools that will ensure the efficiency and resiliency of critical energy systems planning and operations.&#8221;</p></blockquote>
<p><strong>OTHER NEWS IN COMPUTATIONAL SCIENCE</strong></p>
<p>Many of the world&#8217;s largest cities grew to their current size with a minimum of urban planning, chaotic growth outpacing attempts to create an orderly, efficient layout. But as Elizabeth Leake <a href="http://www.datanami.com/datanami/2013-01-30/escience_and_a_tale_of_two_cities.html">writes at Datanami</a>, our current age of open data and powerful computation creates new opportunities for effective urban planning in cities new and old. Leake reports from last year&#8217;s <a href="http://www.ci.uchicago.edu/escience2012/">International Conference on eScience in Chicago</a>, describing the panel led by the CI&#8217;s <a href="http://www.mcs.anl.gov/~catlett/">Charlie Catlett</a> on &#8220;Designing and operating cities using open data&#8221; (also <a href="http://compinst.org/2012/10/10/escience-2012-day-1/">covered on ScaleOut</a>) and the <a href="http://aurin.org.au/">Australia Urban Research Infrastructure Network</a> in Melbourne, Australia. The article includes examples of how the two cities use datasets to track obesity, walkability and food deserts in their respective neighborhoods.</p>
<p>Computation is also making its way into journalism, which is increasingly excited by the promise of data-driven investigations and interactive graphics. For those who couldn&#8217;t attend, the <a href="http://www.reporterslab.org/compj-2013-recap/">2013 Computation + Journalism conference</a>, held last week at Georgia Tech, was helpfully recapped by Reporters&#8217; Lab.</p>
<p>A new journal on Big Data called, helpfully, <em>Big Data</em>, premiered with <a href="http://online.liebertpub.com/toc/big/0/0">its first issue in January</a> with articles on visualization, life sciences data and &#8220;thought crime.&#8221;</p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[Episode 19 of Compiling.tv]]></title>
<link>http://binkyproductions.wordpress.com/2013/02/07/episode-19-of-compiling-tv/</link>
<pubDate>Thu, 07 Feb 2013 10:30:57 +0000</pubDate>
<dc:creator>binkyproductions</dc:creator>
<guid>http://binkyproductions.wordpress.com/2013/02/07/episode-19-of-compiling-tv/</guid>
<description><![CDATA[DUAH! Watch Episode 19  live at Compiling.tv today! New episodes will be live each week on Thursdays]]></description>
<content:encoded><![CDATA[<p style="text-align:center;"><em>DUAH!</em></p>
<p>Watch <strong>Episode 19 </strong> live at <a href="http://compiling.tv/s01e19/">Compiling.tv</a> today!</p>
<p>New episodes will be live each week on Thursdays.</p>
<p><a href="http://compiling.tv/donations/">Become a Fan</a> to have free access to Exclusive Content Videos, Fun Facts and lots more!</p>
<p>Hurry! Only 8 days left to the fundraising campaign. Visit the <a href="http://igg.me/p/260488?a=1656112">Indiegogo Campaign page</a> today to make your donation and claim your perk.</p>
<p style="text-align:center;"><a href="http://binkyproductions.files.wordpress.com/2013/02/thumbnail-ep19-04.jpg"><img class="aligncenter  wp-image-721" alt="Thumbnail Ep19-04" src="http://binkyproductions.files.wordpress.com/2013/02/thumbnail-ep19-04.jpg?w=441&#038;h=248" width="441" height="248" /></a></p>
]]></content:encoded>
</item>
<item>
<title><![CDATA[7 ways to improve your application's performance with the new Developer Toolset 1.1 release]]></title>
<link>http://developerblog.redhat.com/2013/02/04/7-ways-to-improve-your-applications-performance-with-the-new-developer-toolset-1-1-release/</link>
<pubDate>Mon, 04 Feb 2013 14:12:54 +0000</pubDate>
<dc:creator>Matt Newsome</dc:creator>
<guid>http://developerblog.redhat.com/2013/02/04/7-ways-to-improve-your-applications-performance-with-the-new-developer-toolset-1-1-release/</guid>
<description><![CDATA[Are you missing out on opportunities to increase your applications&#8217; performance? As an applica]]></description>
<content:encoded><![CDATA[Are you missing out on opportunities to increase your applications&#8217; performance? As an applica]]></content:encoded>
</item>

</channel>
</rss>
