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

<channel>
	<title>Reviving The Health Revolution &#187; Programming</title>
	<atom:link href="http://healthblog.vitraag.com/topics/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://healthblog.vitraag.com</link>
	<description>A view from inside the HealthVault</description>
	<lastBuildDate>Tue, 27 Jul 2010 18:12:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>F# &#8211; Functional Approach</title>
		<link>http://healthblog.vitraag.com/2009/12/f-functional-approach/</link>
		<comments>http://healthblog.vitraag.com/2009/12/f-functional-approach/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 03:30:55 +0000</pubDate>
		<dc:creator>vaibhavb</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://healthblog.vitraag.com/?p=227</guid>
		<description><![CDATA[Functional programming is becoming more and more mainstream these days. C# 3.0, Python &#38; Ruby have embodied many of the functional approaches. Microsoft even is releasing F# as first class language in Visual Studio 2010. F# is complaint in syntax with OCaml. Back in the day (at UC Santa Cruz) I wrote a language translator [...]]]></description>
			<content:encoded><![CDATA[<p>Functional programming is becoming more and more mainstream these days. C# 3.0, Python &amp; Ruby have embodied many of the functional approaches. Microsoft even is releasing F# as first class language in <a title="Microsoft Visual Studio" href="http://msdn.microsoft.com/vstudio/">Visual Studio</a> 2010. F# is complaint in syntax with <a class="zem_slink" title="Objective Caml" href="http://caml.inria.fr/" rel="homepage">OCaml</a>. Back in the day (at <a href="http://dvlab.cse.ucsc.edu/">UC Santa Cruz</a>) I wrote a <a href="http://dvlab.cse.ucsc.edu/Dvlab?action=AttachFile&amp;do=get&amp;target=blifmv-to-rm.tgz">language translator</a> using OCaml and loved the symbolic computation capability a functional language provides.</p>
<p>In this version of interesting programming concepts, I would like to highlight type system based pattern matching available in F#/OCAML, its very unique and extremely useful if you are parsing a structured list or working on a symbol table:</p>
<pre class="code"><font size="2"><span style="color: blue">type </span>Expr =
  | Num <span style="color: blue">of </span>int
  | Add <span style="color: blue">of </span>Expr * Expr
  | Mul <span style="color: blue">of </span>Expr * Expr
  | Var <span style="color: blue">of </span>string

<span style="color: blue">let rec </span>Evaluate (env:Map&lt;string,int&gt;) exp =
    <span style="color: blue">match </span>exp </font><font size="2"><span style="color: blue">with
    </span>| Num n <span style="color: blue">-&gt; </span>n
    | Add (x,y) <span style="color: blue">-&gt; </span>Evaluate env x + Evaluate env y
    | Mul (x,y) <span style="color: blue">-&gt; </span>Evaluate env x * Evaluate env y
    | Var id    <span style="color: blue">-&gt; </span>env.[id]</font></pre>
<p>In fact listed below is most of the code for code-generator main loop from <a href="http://dvlab.cse.ucsc.edu/Dvlab?action=AttachFile&amp;do=get&amp;target=blifmv-to-rm.tgz">my tool</a> translating Berkeley Logic Interchange format (<a href="http://vlsi.colorado.edu/~vis/doc/blifmv/blifmv/blifmv.html">BLIF</a>) to <a href="http://www.eecs.berkeley.edu/~tah/Publications/reactive_modules.html">Reactive Modules</a> :</p>
<pre class="code"><font size="2"><span style="color: blue">let </span>emit_atoms() =
  <span style="color: blue">let </span>vemit_atom a b = </font><font size="2"><span style="color: blue">begin
    match </span>b </font><font size="2"><span style="color: blue">with
      </span>Symb(Input,_,None) <span style="color: blue">-&gt; </span>()
    | Symb(_,_,None) <span style="color: blue">-&gt; </span>emit_unmarked_atom a
    | Symb(_,_,TableAtom
         (Controls(p),Awaits(q),Relations(r))) </font><font size="2"><span style="color: blue">-&gt;
           begin
         </span>emit_atom_start ();
         emit_table_io_stmts p q;
         emit_init_update ();
         emit_relations p q r;
         emit_atom_end ();
           </font><font size="2"><span style="color: blue">end
    </span>| Symb(_,_,ResetAtom
         (Controls(p),Awaits(q),Relations(r))) </font><font size="2"><span style="color: blue">-&gt;
           begin
         </span>emit_atom_start ();
         emit_reset_io_stmts p q;
         emit_init_update ();
         emit_relations p q r;
         emit_atom_end ();
           </font><font size="2"><span style="color: blue">end
</span>...
    | Symb(_,_,SameAs(t)) <span style="color: blue">-&gt; </span>()
    | _ <span style="color: blue">-&gt; </span>raise (Failure(<span style="color: maroon">&quot;Unknown Error&quot;</span>))
  </font><font size="2"><span style="color: blue">end
  in
  </span>Hashtbl.iter vemit_atom symTab;</font></pre>
<p>In closing, I would like to show how one can use C# <strong>select</strong> as an equivalent to <strong>map</strong> in functional languages.</p>
<pre class="code"><font size="2"><span style="color: green">// Get elements in the store where filenames are GUIDs
</span><span style="color: blue">public </span><span style="color: #2b91af">IEnumerable</span>&lt;<span style="color: #2b91af">Guid</span>&gt; GetKeys()
{
    <span style="color: blue">string</span>[] files = <span style="color: #2b91af">Directory</span>.GetFiles(_StorePath);
    </font><font size="2"><span style="color: green">// functional equivalent: return files.map(|t| new Guid(t))
    </span><span style="color: blue">return </span>(files.Select( p =&gt; <span style="color: blue">new </span><span style="color: #2b91af">Guid</span>(
            <span style="color: #2b91af">Path</span>.GetFileName(p))));
}</font></pre>
<p>Feel free to share your bits and pieces of functional goodness in the comments below!</p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2009/12/f-functional-approach/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Memoization</title>
		<link>http://healthblog.vitraag.com/2009/12/memoization/</link>
		<comments>http://healthblog.vitraag.com/2009/12/memoization/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 03:30:21 +0000</pubDate>
		<dc:creator>vaibhavb</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://healthblog.vitraag.com/2009/12/memoization/</guid>
		<description><![CDATA[I have been meaning to write short posts about interesting programming concepts and alternative programming movements (like alt.net). Topic of this post is an interesting programming concept called Memoization and its implementation in C# as a method attribute. 
Memoization is an optimization technique which speeds up a program by remembering the values returned by function [...]]]></description>
			<content:encoded><![CDATA[<p>I have been meaning to write short posts about interesting programming concepts and alternative programming movements (like <a href="http://altdotnet.org/">alt.net</a>). Topic of this post is an interesting programming concept called Memoization and its implementation in C# as a method attribute. </p>
<p><a href="http://en.wikipedia.org/wiki/Memoization">Memoization</a> is an optimization technique which speeds up a program by remembering the values returned by function calls for specific input values, its also known as tabling.</p>
<p>Many of the new languages (Ruby, Python, C#) provide a very neat way to implement Memoization and many functional languages (Lisp, OCaml) have it as a first class construct for the runtime. Here is a my cheap implementation showing how one can use an integer based <strong>Memo </strong>attribute in C#</p>
<pre class="code"><span style="color: blue"><font size="2">class </font></span><font size="2"><span style="color: #2b91af">Test
</span>{&#160;&#160; [<span style="color: #2b91af">Memo</span>]
    <span style="color: blue">public int </span>DoSomething(<span style="color: blue">int </span>i)
    {
        <span style="color: blue">for </span>(<span style="color: blue">int </span>k = 0; k &lt; 10000; k++)
        {
            <span style="color: blue">int </span>j = 0;
            j = j + 500;
        }
        <span style="color: #2b91af">Console</span>.WriteLine(<span style="color: #a31515">&quot;DoSomething &quot; </span>+ i);
        <span style="color: blue">return </span>i + 5;
    }
}</font></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Here is a simple driver which implements the Memoization :</p>
<pre style="width: 551px; height: 746px" class="code"><font size="2"><span style="color: blue">static void </span>Main(<span style="color: blue">string</span>[] args)
 {
     <span style="color: #2b91af">Debug</span>.WriteLine(<span style="color: #a31515">&quot;Invoking Memoizable Code&quot;</span>);

     <span style="color: #2b91af">Type </span>t = <span style="color: blue">typeof</span>(<span style="color: #2b91af">Test</span>);
     <span style="color: #2b91af">Test </span>objT = <span style="color: blue">new </span><span style="color: #2b91af">Test</span>();

     </font><font size="2"><span style="color: green">// Implement Memoization
     </span><span style="color: #2b91af">Dictionary</span>&lt;<span style="color: blue">int</span>, <span style="color: blue">int</span>&gt; <a class="zem_slink" title="Memoization" href="http://en.wikipedia.org/wiki/Memoization" rel="wikipedia">memoize</a> = <span style="color: blue">new </span><span style="color: #2b91af">Dictionary</span>&lt;<span style="color: blue">int</span>, <span style="color: blue">int</span>&gt;();
     <span style="color: #2b91af">MethodInfo</span>[] mi = t.GetMethods();
     <span style="color: blue">foreach </span>(<span style="color: #2b91af">MethodInfo </span>m <span style="color: blue">in </span>mi)
     {
         <span style="color: blue">foreach </span>(<span style="color: #2b91af">Attribute </span>a <span style="color: blue">in </span>m.GetCustomAttributes(<span style="color: blue">false</span>))
         {
             <span style="color: blue">if </span>(a <span style="color: blue">is </span><span style="color: #2b91af">MemoAttribute</span>)
             {
                 <span style="color: blue">for </span>(<span style="color: blue">int </span>i = 0; i &lt; 2; i++)
                 {
                     <span style="color: blue">int </span>j;
                     <span style="color: blue">if </span>(memoize.TryGetValue(i, <span style="color: blue">out </span>j))
                     {
                         <span style="color: #2b91af">Debug</span>.WriteLine(<span style="color: #a31515">&quot;Remembered &quot; </span>+ i);
                         <span style="color: blue">continue</span>;
                     }
                     </font><font size="2"><span style="color: blue">else
                     </span>{
                         j = (<span style="color: blue">int</span>) m.Invoke(objT, <span style="color: blue">new object</span>[]{i});
                         memoize[i] = j;
                         <span style="color: #2b91af">Debug</span>.WriteLine(<span style="color: #a31515">&quot;Memorized &quot; </span>+ i);
                     }
                 }
             }
         }
     }
     <span style="color: #2b91af">Console</span>.ReadLine();
 }</font></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>May be in comments you can suggest ways to implement a more generic Memo attribute (similar to Python’s @memo).</p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2009/12/memoization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Security Resources for .NET Web Applications</title>
		<link>http://healthblog.vitraag.com/2008/11/security-resources-for-net-web-applications/</link>
		<comments>http://healthblog.vitraag.com/2008/11/security-resources-for-net-web-applications/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 22:43:57 +0000</pubDate>
		<dc:creator>vaibhavb</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web development]]></category>

		<guid isPermaLink="false">http://healthblog.vitraag.com/?p=48</guid>
		<description><![CDATA[Web applications have a class of security vulnerabilities, at times much widespread and trivial than the infamous buffer overflow.
Here are some interesting Security resources on .NET Web Application:

.NET Security at MSDN &#8211; I specially like Improving Web Application Security white paper.
AntiXSS Library - Microsoft Anti-Cross Site Scripting library to protect web apps from XSS.
FxCop - [...]]]></description>
			<content:encoded><![CDATA[<p>Web applications have a class of security vulnerabilities, at times much widespread and trivial than the infamous <a class="zem_slink" title="Buffer overflow" rel="wikipedia" href="http://en.wikipedia.org/wiki/Buffer_overflow">buffer overflow</a>.</p>
<div id="attachment_49" class="wp-caption alignright" style="width: 310px"><a href="http://healthblog.vitraag.com/wp-content/uploads/2008/11/aa302415_fa2sn01en-usmsdn_10.gif"><img class="size-medium wp-image-49" title=".NET Web Application Security (from MSDN)" src="http://healthblog.vitraag.com/wp-content/uploads/2008/11/aa302415_fa2sn01en-usmsdn_10-300x248.gif" alt=".NET Web Application Security" width="300" height="248" /></a><p class="wp-caption-text">.NET Web Application Security</p></div>
<p>Here are some interesting Security resources on .NET Web Application:</p>
<ul>
<li><a href="http://msdn.microsoft.com/en-us/library/aa286519.aspx">.NET Security at MSDN</a> &#8211; I specially like <a href="http://msdn.microsoft.com/en-us/library/ms994921.aspx">Improving Web Application Security </a>white paper.</li>
<li><a href="http://msdn.microsoft.com/en-us/library/aa973813.aspx">AntiXSS Library </a>- Microsoft Anti-<a class="zem_slink" title="Cross-site scripting" rel="wikipedia" href="http://en.wikipedia.org/wiki/Cross-site_scripting">Cross Site Scripting</a> library to protect web apps from XSS.</li>
<li><a href="http://msdn.microsoft.com/en-us/library/bb429476(vs.80).aspx">FxCop </a>- A tools which analyses managed code assemblies</li>
<li><a href="http://www.codeplex.com/guidanceExplorer">Guidance Explorer</a> &#8211; Developer guidance (a 15000 foot view though)</li>
<li>.NET Security Blogs: <a href="http://blogs.msdn.com/shawnfa/">Shawnfa</a>, <a href="http://blogs.msdn.com/michael_howard/">Michael Howard</a>, <a href="http://blogs.msdn.com/CLRSecurity/">CLRSecurity</a></li>
<li><a href="http://msdn.microsoft.com/en-us/security/default.aspx">MSDN Security Developer Center </a>- General guidance on writing secure code. The featured video on <a href="http://http://msdn.microsoft.com/en-us/security/cc424865.aspx">exporting and importing certificates </a>would be helpful for doing certificate management as a <a class="zem_slink" title="Microsoft HealthVault" rel="wikipedia" href="http://en.wikipedia.org/wiki/Microsoft_HealthVault">HealthVault</a> application.</li>
<li><strong>Update</strong> &#8211; <a href="http://msdn.microsoft.com/en-us/library/ms978516.aspx">Threat modeling web applications </a>is a great read. The SDL <a href="http://download.microsoft.com/download/E/5/3/E5318D25-7AEF-4A66-A147-81BBA727F2C1/SDLTM.msi ">Threat modeling tool</a> and <a href="http://social.msdn.microsoft.com/Forums/en-US/sdlthreatmodeling/threads/ ">forum</a> are of great utility as well.</li>
</ul>
<p>Please leave a comment if you know of any valuable security resources.</p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2008/11/security-resources-for-net-web-applications/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Whats your &#8220;editor&#8221; personality</title>
		<link>http://healthblog.vitraag.com/2008/07/whats-your-editor-personality/</link>
		<comments>http://healthblog.vitraag.com/2008/07/whats-your-editor-personality/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 08:05:22 +0000</pubDate>
		<dc:creator>vaibhavb</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Editors]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://healthblog.vitraag.com/?p=39</guid>
		<description><![CDATA[Emacs? Vi? Visual Studio? TextMate?? Whats your favorite editor?
I started with Emacs and got to a point where I could write some elisp to work with a new language, but it just was too heavy weight and more often seemed to be bloat and cruft than necessary. Then I moved to Microsoft and gradually my [...]]]></description>
			<content:encoded><![CDATA[<p><a class="zem_slink" title="Emacs" rel="homepage" href="http://www.gnu.org/software/emacs/">Emacs</a>? <a class="zem_slink" title="Vi" rel="wikipedia" href="http://en.wikipedia.org/wiki/Vi">Vi</a>? <a class="zem_slink" title="Microsoft Visual Studio" rel="homepage" href="http://msdn.microsoft.com/vstudio/">Visual Studio</a>? <a href="http://en.wikipedia.org/wiki/Textmate">TextMate?? </a>Whats your favorite <a class="zem_slink" title="Visual editor" rel="wikipedia" href="http://en.wikipedia.org/wiki/Visual_editor">editor</a>?</p>
<p>I started with Emacs and got to a point where I could write some elisp to work with a new language, but it just was too heavy weight and more often seemed to be bloat and cruft than necessary. Then I moved to <a class="zem_slink" title="Microsoft" rel="homepage" href="http://www.microsoft.com/worldwide/">Microsoft</a> and gradually my editor became Visual Studio (and Notepad). It happened that way since it turned out to be a common denominator, and Visual Studio has amazing intellisense~</p>
<p>However more of late I have think vi (especially Vim) is a great tool. Since i work a lot with Non Microsoft programming language Vi seems to be the just right choice and it lean and mean!! Yep i do kick myself for not defecting to this camp earlier in my education.</p>
<p>Very recently @ OSCON i got in conversation with _those_ mac guys who love TextMate. It really interesting how TextMate has put the realm of XML declaration for a language as powerful as Context free grammer, and CSS with all the design and color gu &#8211; in to the editor world. It has an amazing community managed code / snippet repository which folks can use to share code with one another&#8230;!</p>
<div class="zemanta-pixie" style="margin-top: 10px; height: 15px;"><a class="zemanta-pixie-a" title="Zemified by Zemanta" href="http://reblog.zemanta.com/zemified/5a2e6ac3-47ba-4fd2-90f3-2cae18004268/"><img class="zemanta-pixie-img" style="border: medium none; float: right;" src="http://img.zemanta.com/reblog_e.png?x-id=5a2e6ac3-47ba-4fd2-90f3-2cae18004268" alt="Zemanta Pixie" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2008/07/whats-your-editor-personality/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The New Economy Computing &#8211; Big $(n)</title>
		<link>http://healthblog.vitraag.com/2008/05/the-new-economy-computing-big-n/</link>
		<comments>http://healthblog.vitraag.com/2008/05/the-new-economy-computing-big-n/#comments</comments>
		<pubDate>Tue, 27 May 2008 21:57:31 +0000</pubDate>
		<dc:creator>vaibhavb</dc:creator>
				<category><![CDATA[Ideas]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://healthblog.vitraag.com/?p=31</guid>
		<description><![CDATA[I guess in the new recession economy computing has gotten an interesting metric  . Big $ performance of your program! With Amazon&#8217;s S3 charging for space, EC3 charging for computing and Google charging similarly on the app engine platform we have a new metric to reckon Big $ performance of your service/ web-app! 
]]></description>
			<content:encoded><![CDATA[<p>I guess in the new recession economy computing has gotten an interesting metric <img src='http://healthblog.vitraag.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . <a href="http://highscalability.com/cloud-programming-directly-feeds-cost-allocation-back-software-design">Big $ performance</a> of your program! With Amazon&#8217;s S3 charging for space, EC3 charging for computing and Google charging similarly on the app engine platform we have a new metric to reckon Big $ performance of your service/ web-app! </p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2008/05/the-new-economy-computing-big-n/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQ to HealthVault</title>
		<link>http://healthblog.vitraag.com/2008/02/linq-to-healthvault/</link>
		<comments>http://healthblog.vitraag.com/2008/02/linq-to-healthvault/#comments</comments>
		<pubDate>Thu, 21 Feb 2008 08:58:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HealthVault]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.healthblog.vitraag.com/?p=19</guid>
		<description><![CDATA[I&#8217;m not sure how much value it add, but may we it will be interesting to have a LINQ to HealthVault, something like
var query = from Person                      where Person.Name.Contains(&#8220;Katie&#8221;)      [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure how much value it add, but may we it will be interesting to have a LINQ to HealthVault, something like</p>
<p>var query = from Person<br />                      where Person.Name.Contains(&#8220;Katie&#8221;)<br />                      select Record</p>
<p>Charlie has a great post on expression tree <a href="http://blogs.msdn.com/charlie/archive/2008/01/31/expression-tree-basics.aspx">basics</a>, and this examples details how to implement a <a href="http://msdn2.microsoft.com/en-us/library/bb546158.aspx">LINQ to Terraserver</a> provider.</p>
<p>However, at this point I&#8217;m not entirely sure about the utility of such a feature for HealthVault as the system is less where clause dependant and the SDK already does a decent job of giving out data-types.</p>
]]></content:encoded>
			<wfw:commentRss>http://healthblog.vitraag.com/2008/02/linq-to-healthvault/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
