I learned seven programming languages
&gt; It&#x27;s hard to feel happy grinding out a contrived LINQ expression for the same result as a &quot;practically English&quot; list comprehension in Python.<p>I feel the other way. LINQ is great for building pipelines. List comprehensions are kinda like English, but it gets ugly when you use the flattening feature, or when you want something more than just map and filter.<p>Looking at their C# code, they’re going at it in a fairly low-level way, with a lot of aliases for numeric types and a lot of casting between them. For example:<p><pre><code>    private static f32 distinct_arrangements_for(DieVal[] dieval_vec) { 
        var key_counts = dieval_vec.GroupBy(x=&gt;x).Select(g=&gt;(g.Key, (u8)g.Count()));
        uint divisor=1;
        uint non_zero_dievals=0;
        foreach (var (key, count) in key_counts){  
            if (key != 0){  
                divisor *= factorial(count);
                non_zero_dievals += count;
            } 
        } 
        return factorial(non_zero_dievals) &#x2F; divisor;
    } 
</code></pre>
If you take out the unnecessary number type abuse and just use `int` everywhere, you get something much clearer:<p><pre><code>    private static float DistinctArrangementsFor(DieVal[] dievals) { 
        var dievalCounts = dievals
            .GroupBy(x =&gt; x)
            .Where(group =&gt; group.Key != 0)
            .Select(group =&gt; group.Count())
            .ToArray();
        var divisor = dievalCounts
            .Select(factorial)
            .Aggregate(1, (a, b) =&gt; a * b);
        var nonZeroDievals = dievalCounts.Sum();
        return factorial(nonZeroDievals) &#x2F; divisor;
    }
</code></pre>
Also, even with all this hard work with weird types, this function has a suspicious return type, since it does integer division and returns a float.<p>There are a few more weird things, like not using switch statements&#x2F;switch expressions, or this function:<p><pre><code>    &#x2F;&#x2F; calculate relevant counts for gamestate: required lookups and saves
    public int counts() { 
        var ticks = 0; 
        var false_true = new bool[] {true, false};
        var just_false = new bool[] {false};
        foreach (var subset_len in Range(1,open_slots.Count)){
            var combos = open_slots.Combinations(subset_len);
            foreach (var slots_vec in combos ) { 
                var slots = new Slots(slots_vec.ToArray());
                var joker_rules = slots.has(YAHTZEE); &#x2F;&#x2F; yahtzees aren&#x27;t wild whenever yahtzee slot is still available 
                var totals = Slots.useful_upper_totals(slots); 
                foreach (var _ in totals) {
                    foreach (var __ in joker_rules? false_true : just_false ){
                        &#x2F;&#x2F; var slot_lookups = (subset_len * subset_len==1? 1 : 2) * 252; &#x2F;&#x2F; * subset_len as u64;
                        &#x2F;&#x2F; var dice_lookups = 848484; &#x2F;&#x2F; &#x2F;&#x2F; previoiusly verified by counting up by 1s in the actual loop. however chunking forward is faster 
                        &#x2F;&#x2F; lookups += (dice_lookups + slot_lookups); this tends to overflow so use &quot;normalized&quot; ticks below
                        ticks++; &#x2F;&#x2F; this just counts the cost of one pass through the bar.tick call in the dice-choose section of build_cache() loop
        } } } }
        return (int)ticks;
    } 
</code></pre>
There are a few weird things, like the pointless foreach loops at the end (which could be replaced with a bit of arithmetic) or the use of a foreach loop where a regular for loop would be better.<p>If this code was rewritten in more idiomatic C#, it could be the basis of a good comparison between languages’ performance and syntax. But I’m not sure if it’s a good example at this point.