Git Product home page Git Product logo

csharpzorkmachine's Introduction

##Zork Machine in C# #

Eric Lippert is writing a wonderful blog series, in which he implements a Z-Machine (the virtual machine layer for playing Zork and similar games) in OCaml.

I don't know any OCaml at all, and I wanted to follow along, so I am writing the same code in C#.

Please feel free to make comments or suggestions.

I think, so far, that there is a lot more ceremony in the C# code then in the OCaml code.

For example, my BitSize is a struct in its own source file, and Eric's whole implementation is just type bit_size = Bit_size of int

At first, I was making a million little .cs files that look like this:

public struct SpecialCaseOfInt 
{
    private int value;
    public SpecialCaseOfInt(int value) 
    {
        this.value = value; 
    }
    public int Value { get {return this.value; } }
}

That gets pretty annoying, and is not nearly as succinct as the OCaml type system.

I am on the fence about whether to keep these all in their own files. The downside is that I have a whole file where OCaml just has a one liner, but the plus side is that I have a convenient place to keep helper functions.

All these types are as immutable as possible. They are structs, just because they are wrappers around a single value, and all operations that are defined for them return a mutated copy, but don't mutate the original instance.

csharpzorkmachine's People

Contributors

willmurphyscode avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.