C#: XNA and Xamarin

Started by
12 comments, last by Ravyne 9 years, 5 months ago

.Net is a runtime environment, it defines a sort of "virtual" computer platform that runs on top of a host operating system. The .Net framework refers to this runtime, plus the standard .Net core libraries. This is why the same .Net application can run run on Windows, Linux, and Mac -- just as long as the developer has chosen libraries that are available on all of those platforms. In Java, the Java Virtual Machine is equivilent to the .Net runtime, and there is a standard set of Java libraries as well. This description simplifies things a bit, but its sufficient for this discussion.

Mono is an open-source implementation of the .Net runtime and .Net framework which runs on Windows, Linux, Mac, etc. MonoGame is an open-source implementation of the XNA framework that also runs on Windows, Linux, and Mac. Thus, if you program for Mono and MonoGame, your apps will run on Windows, Linux, Mac, etc, with the same code -- in some cases you might have to, or want to, write a little platform-specific code to work around issues or to take advantage of platform-specific features, but otherwise your code should just work on any of the platforms that mono and monogame support.

Mono differs slightly from the .net runtime/framework in that it lags a bit behind Microsoft's official .Net runtime; However, they've just open-sourced a ton of .net, including the runtime. I expect that within the next year, Mono will either switch over to that core as is, or start pulling the newest parts they're still missing (C# 6.0 just hit preview, along with a version-bump of the runtime). A year from now, Mono and Microsoft's runtime should have feature parity.

Now, monogame itself might be targetting an older version of the framework (XNA would have), but I don't use it so I'm not sure. If so, you might not see any new-fangled goodness, but the existing support today should have already caught up to where XNA was. In theory, you should be able to take a monogame project, copy it over into XNA studio (which I think Microsoft still offers and you can still publish to Xbox 360?), and publish to Xbox 360 with little code changes (maybe none?). That's the power of the .net runtime and framework in a nutshell -- you can take an application (as a binary in some cases, or source code in others) and run it on a completely different hardware architecture, on a completely different OS, and a completely different .net runtime/framework implementation and it should "just work" for the most part.

throw table_exception("(? ???)? ? ???");

Advertisement

so is .Net like a language translator that takes a program in one language and translates the entire program into a new language making the program ready to be published instantly?

To get MonoGame on my mac laptop what do I need to do?

there are two options on the site:

MonoGame for VisualStudio

MonoGame on GitHub

What do these mean?

Well.. Yes and no. .NET is also an umbrella for several things.

A compiler translates code from one "language" to another. A C# compiler will typically translate C# code into CIL (sometimes called MSIL). This is something like abstracted machine code. Microsoft has one (csc.exe) and Mono has one (mcs). Their outputs are 100% compatible. This step is performed by the programmer before release.

CIL can then be compiled into real machine code. You typically use .NET for this on Windows and Mono on everything else. This compilation step is typically performed when you start the application through a process called Just In Time compilation or JIT for short.

Then there's libraries. Some libraries can be shared across operating systems and hardware platforms, others need specialized implementations for their respective OS/hardware. Mono provides the specialized ones for non-windows platforms and .NET provides them for Windows.

A Framework is usually a collection of libraries, tools and/or some form of methodology and/or structure. A framework is usually something you "build upon" where a library is usually something you "include".

About the MonoGame links, it seems the current release does not come prepackaged for anything but Windows (they are reworking their packaging). You can probably get by using the development build of MonoGame for MonoDevelop Mac.


so is .Net like a language translator that takes a program in one language and translates the entire program into a new language making the program ready to be published instantly?

Its a translator of sorts, yes -- but don't think of it as "I speak C#, and .net translates to some other programming language" -- at a very detailed level that's true, but its more helpful to you to think of it as "I speak .Net -> Mono understands .Net -> Mono speaks Windows, Mac, Linux, etc." Also, I speak MonoGame -> MonoGame exists on Windows, it speaks DirectX, etc; MonoGame exists on Linux, it speaks OpenGL, etc; MonoGame exists on Mac, it speaks OpenGL, etc. The libraries have to exist on each platform, because they have to tie to the platform itself to do the right thing, but as long as you speak the MonoGame library through .Net/Mono, it'll all work out on each of those platforms.

Anyways, at your level you don't need to worry too much about how it works, you just need to know that it does work, so long as you choose to use libraries that are available on all the platforms you want to support (like MonoGame, or any of the core framework libraries).

throw table_exception("(? ???)? ? ???");

This topic is closed to new replies.

Advertisement