Is Xamarin planning on generating Web App components based on C#

bobk544bobk544 USMember ✭✭

Hello, is Xamarin planning on generating Web App components based on C#?

For example the GWT generates Web components based on Java and this group http://www.saltarelle-compiler.com/ is generating Javascript based on C#, so it seems logical that Xamarin would have something in the pipeline along these lines?

Sure would be nice to know in advance, thanks for any insights or rumors!

Posts

  • JonDouglasJonDouglas USXamarin Team, University, Developer Group Leader Xamurai

    There's a bit of talk on twitter about that!

    Here's something @CraigDunn did with Xamarin.Forms / Razor - https://github.com/conceptdev/xamarin-forms-samples/tree/master/RestaurantGuide

    Here's something @crdeutsch did for MonoTouch - https://github.com/crdeutsch/MonoTouch-JsBridge

    And here's something that Frank Krueger did recently - https://github.com/praeclarum/Netjs

  • PeterDavisPeterDavis USMember ✭✭✭

    @bobk544‌ We use Saltarelle. It's awesome. We've managed to become almost exclusively a C# shop. In our web apps, our JavaScript is cross-compiled from C# with Saltarelle. In our phone apps, our Android and iPhone apps are cross-compiled from C# with Xamarin. Awesome stuff! Lets programmers stop worrying about syntax in differing languages and focus on pumping out code.

  • RichardHopkinsRichardHopkins JPMember, University ✭✭✭

    @PeterDavis‌

    How stable is Saltarelle, Peter? I've not come across it before. C# to Javascript sounds pretty enticing.

  • bobk544bobk544 USMember ✭✭

    Ok thanks all sounds good! checking out those links now!

  • PeterDavisPeterDavis USMember ✭✭✭
    edited May 2014

    @RichardHopkins‌ It's very stable. We have TONS of code in Saltarelle. In fact, our company's LOB web site is written in it. It's got tons of data entry screens.

    My first thought about something like Saltarelle was, "There's no way this is going to feel natural and right." But I was wrong. The way it wraps stuff makes it very easy to get up and running fast. They've written a subset of the .NET framework in JavaScript, so you actually have an mscorlib.js, for example, so you can take advantage of a lot of the .NET paradigms you're already used to.

    Saltarelle has wrappers for knockout, Node.js, jquery, jqueryUI, and a number of other libraries. Our group has put out a wrapper for a subset of the Infragistics controls on github as well. It's actually pretty trivial to wrap javascript libraries, so if you have, for example, in-house custom libraries of stuff, it's really easy to wrap them and make them callable from Saltarelle C#. It generates very readable JavaScript that's easy to follow in the debugger, so it's not like you can't do JavaScript debugging. It's really not an issue at all.

    I'm really just totally blown away by it, as are the other developers here. We all have a hate-hate relationship with JavaScript, so we're thrilled to not have to code in it.

    We use Knockout and have an MVVM setup. We've written a wrapper for jQuery's ajax calls, so here's an example of doing a POST:

    Communicator comm = new Communicator();
    comm.Type(Constants.POST)
        .Url(Gems_global.Instance.GetFullUrl(POST_GETALERTS))
        .SendData(new { warehouseCode = _model.WarehouseCode.Value });
    comm.EventCommands.SuccessCommands = success =>
    {
        string data = success.GetReturnData<string>();
        PriceAlerts pa = Json.Parse<PriceAlerts>(data);
        if (pa != null)
        {
            _model.LineItemPriceAlert.Value = pa.LineItemPriceAlert;
            _model.TransactionPriceAlert.Value = pa.TransactionPriceAlert;
        }
    };
    comm.Execute();
    

    A little jQuery & jQuery UI:

    private void SetupDateTimeEditor()
    {
        jQueryObject datepicker = (jQueryObject)jQuery.Select("#transMaint_Input_DateTime").DatePicker(new DatePickerOptions()
        {
            MinDate = new JsDate(1930, 1, 1),
            MaxDate = new JsDate(2100, 12, 31)
        });
        GemsHelper.Mask(datepicker, "99/99/9999");
        datepicker.Blur((evt, ui) =>
        {
            if (_model.DateTimeValue.Value == "__/__/____")
            {
                _model.DateTimeValue.Value = string.Empty;
            }
            _model.DateTimeValueValid.Value = true;
        });
    }
    

    Everything just feels very natural when you're coding in it. It doesn't seem awkward or "wrong" in any way, which was one of my bigger concerns when I was looking at this type of technology.

  • RichardHopkinsRichardHopkins JPMember, University ✭✭✭

    @PeterDavis‌

    Thanks for such an informative post. I'll definitely be checking this out as soon as I have a spare few hours to take a good look at it.

  • bobk544bobk544 USMember ✭✭

    Yes this is this is really good to know Peter, thanks for the information!!!

Sign In or Register to comment.