<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[enterprise development - Endless Wyrd]]></title><description><![CDATA[The official blog of The Wizard & The Wyrd, LLC.  We are engaged in software and systems research and development with an emphasis on information security, evolutionary machine learning, and AI.]]></description><link>http://wizardandthewyrdblog.azurewebsites.net/</link><generator>Ghost 0.5</generator><lastBuildDate>Tue, 14 Apr 2026 23:55:44 GMT</lastBuildDate><atom:link href="http://wizardandthewyrdblog.azurewebsites.net/tag/enterprise-development/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[F#, C#, and dotPeek]]></title><description><![CDATA[<p>As development continues on Arcana ERP, we see that in order to fulfill our design goals of high availability and distributed concurrency, portions of ArcanaErp.Core are being re-written piece by piece in F# (a general purpose functional programming langauge, targeting .NET, and originally developed at <a href="https://en.wikipedia.org/wiki/Microsoft_Research">Microsoft Research, Cambridge</a>).</p>

<p>An interesting outcome of this experiment is that we can see concise, expressive, and terse idiomatic F# "expand" into equivalent, and more verbose, C#:</p>

<h2 id="fsource">F# Source  </h2>

<pre><code class="language-fsharp">namespace ArcanaErp.Core.Lambda

open System

module Interfaces =

    type IBaseErpModel =
        abstract member Id : int with get, set
        abstract member Description : string with get, set
        abstract member ExternalIdentifier : string with get, set
        abstract member ExternalIdSource : string with get, set
        abstract member CreatedAt : DateTime with get, set
        abstract member UpdatedAt : DateTime with get, set
</code></pre>

<h2 id="dotpeekdc">dotPeek'd C#  </h2>

<pre><code class="language-csharp">using Microsoft.FSharp.Core;  
using System;

namespace ArcanaErp.Core.Lambda  
{
  [CompilationMapping(SourceConstructFlags.Module)]
  public static class Interfaces
  {
    [CompilationMapping(SourceConstructFlags.ObjectType)]
    [Serializable]
    public interface IBaseErpModel
    {
      int Id { get; set; }

      string Description { get; set; }

      string ExternalIdentifier { get; set; }

      string ExternalIdSource { get; set; }

      DateTime CreatedAt { get; set; }

      DateTime UpdatedAt { get; set; }
    }
  }
}
</code></pre>

<h1 id="abiggerexample">A Bigger Example  </h1>

<h2 id="firstinf">First, in F#  </h2>

<p>The previous example was fairly straightforward.  We see some extra curly braces and some attributes we can get rid of.  Here is a sample from the FSharp.Core assembly in the <a href="https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/seq.fs">Microsoft.FSharp.Collections namespace</a>:</p>

<pre><code class="language-fsharp">        [&lt;CompiledName("IterateIndexed")&gt;]
        let iteri f (source : seq&lt;'T&gt;) = 
            checkNonNull "source" source
            use e = source.GetEnumerator()
            let f = OptimizedClosures.FSharpFunc&lt;_,_,_&gt;.Adapt(f)
            let mutable i = 0 
            while e.MoveNext() do
                f.Invoke(i, e.Current);
                i &lt;- i + 1;
</code></pre>

<h2 id="decompiledtoc">Decompiled to C#  </h2>

<pre><code class="language-csharp">    [CompilationArgumentCounts(new int[] {1, 1})]
    [CompilationSourceName("iteri")]
    public static void IterateIndexed&lt;T&gt;(FSharpFunc&lt;int, FSharpFunc&lt;T, Unit&gt;&gt; action, IEnumerable&lt;T&gt; source)
    {
      if ((object) source == null)
        throw new ArgumentNullException("source");
      System.Collections.Generic.IEnumerator&lt;T&gt; enumerator = source.GetEnumerator();
      try
      {
        OptimizedClosures.FSharpFunc&lt;int, T, Unit&gt; fsharpFunc = OptimizedClosures.FSharpFunc&lt;int, T, Unit&gt;.Adapt(action);
        int num = 0;
        while (enumerator.MoveNext())
        {
          fsharpFunc.Invoke(num, enumerator.Current);
          ++num;
        }
      }
      finally
      {
        IDisposable disposable = enumerator as IDisposable;
        if (disposable != null)
          disposable.Dispose();
      }
    }
</code></pre>

<h1 id="wrappingup">Wrapping Up  </h1>

<p>It is clear to see that F# is the winner here.  The F# code is more compact, more expressive, and easier to reason about (after, admittedly, a small learning curve on the F# syntax).  </p>

<p>Writing software as complex as an ERP systems, and enterprise software in general, requires code that can be reasoned about fairly easily.  On all accounts, for us, F# makes sense.</p>]]></description><link>http://wizardandthewyrdblog.azurewebsites.net/initial-experiments-with-fsharp-and-csharp/</link><guid isPermaLink="false">462503e0-324f-481f-8057-e48aad63bbda</guid><category><![CDATA[enterprise development]]></category><category><![CDATA[F#]]></category><category><![CDATA[FSharp]]></category><category><![CDATA[dotPeek]]></category><category><![CDATA[Programming]]></category><dc:creator><![CDATA[Ramon J. Long III]]></dc:creator><pubDate>Tue, 13 Oct 2015 04:34:15 GMT</pubDate></item></channel></rss>