What is new in Mono?
July 2013
miguel@gnome.org
Agenda
• Today:
– What is new in Mono-land.
– Major Work-in-Progress Projects
• Tomorrow:
– Brainstorming session
– Future of Mono and .NET
MONO 3.2
Mono 3.2
• Core .NET 4.5 support
– Base Class Libraries
– C# 5
• Available today:
– Desktop
– Server
– Mobile
• 2.10.x is no longer supported
What is new in Mono 3.2
• Vastly improved SGen GC
– Now the default!
• Micro-optimizations
– Mobile-driven
• Consume PCL binaries
• Shipping OSS Microsoft frameworks
• New Mono frameworks
SGen Garbage Collector
• Our Precise, generational collector
• Now the default for Mono
– “mono” now runs mono –gc=sgen
– libmono is Boehm
– libmono-sgen is Sgen
• Sgen is now faster on almost every workload
• MonoDevelop/Xamarin Studio
– Been using it as a default since February
What is new?
• Major collectors:
– Copy collector (old, reference code)
– Mark and Sweep
• Minor collectors:
– Now with support for cementing
• Help game developers love GC
• dtrace probes
Mark and Sweep
• Dynamic heap by default
– Can specify fixed heap if desired
• Allocates blocks of memory to bucket sizes
– Think of the spirit to “slab” allocation
– Support changes in workloads with evacuation
• Concurrent Marking, Lazy Sweeping
Disabling Major Collector
New API on Mono.Runtime (mscorlib.dll)
if (!Mono.Runtime.SetGCAllowSynchronousMajor (false))
Console.WriteLine ("Sorry, the GC won't cooperate.");
// your low-latency code here
Mono.Runtime.SetGCAllowSynchronousMajor (true);
• Exposed on Mobile.
• Use System.Reflection to find it on desktop editions.
dtrace probes on MacOS
Major collections and minor collections pause times visualized
http://schani.wordpress.com/2012/11/02/sgen-and-dtrace/
STATIC BUILD IMPROVEMENTS
Static Compilation
• For systems that don’t support JITing
– Apple’s iOS devices
– Consoles (PlayStation, Xbox)
– Security: when not shipping IL
• Limited generics support
– Static analysis limitations
– Some dynamisms in .NET idioms
• LINQ and Value Types
“Attempting to JIT compile method”
System.ExecutionEngineException: Attempting to JIT
compile method Foo[]:Bar`1
“Attempting to JIT compile method”
System.ExecutionEngineException: Attempting to JIT
compile method Foo[]:Bar`1
iOS Development Improvements
• Improve development cycle
• Incremental Builds
– Disable linker (compile everything)
– Cache resulting native code aggressively
• Incremental Upload
– Only uploads changes
– Main executable, libraries or resources
Incremental Deployment
(With Build Caching)
0
10
20
30
40
50
60
70
80
Hello World Large App
Seconds
Old
New
Deployment times can now be as short as one second.
Incremental Deployment
(With Build Caching)
0
5
10
15
20
25
30
35
40
Hello World Large App
Seconds
6.2
6.4
Deployment times can now be as short as one second.
Build Speed Improvements
0
10
20
30
40
50
60
70
80
Hello World Large App
Seconds
6.2
6.4
6.4+Incremental
MICROSOFT OPEN SOURCE CODE
Now Bundled with Mono
• Reactive Extensions
– Possible on iOS with new code gen changes
• F# everywhere
• Razor
• Entity Framework
• ASP.NET WebStack
MonoDevelop Xamarin Studio
MonoDevelop / Xamarin Studio
MonoDevelop Core MonoDevelop Core
Android Mac iOS
Branding Add-In
Open source
Commercial
CROSS PLATFORM FRAMEWORKS
Cocos2D XNA
• XNA port of the popular Cocos2D API
– Over 4,000 games built with this API
– Well documented, well known
• MonoGame brings it everywhere
– iOS, Android, Windows Phone (7 and 8)
– Mac
– Windows (GL, DX, , Windows Store)
– Xbox360, Ouya
– Play Station Mobile (PS Vita + Sony Androids)
Using Cocos2D XNA Today
• Available as:
– NuGet Packages
– Templates for VS and Xamarin Studio
• Source code:
– http://github.com/mono/cocos2d-xna
• Getting Started:
– http://docs.xamarin.com/guides/cross-platform/cocos2d_xna
Angry Ninjas - Full Open Source Game
https://github.com/xamarin/AngryNinjas
Cocos2D Crash Course
• Mike Bluestein’s talk tomorrow
Xamarin.Mobile
• Base class library
for mobile services
• Mike Bluestein’s talk
Xamarin.Auth
• Clients for OAuth 1 and OAuth 2
– Includes variations
• Stores user credentials
• Support non-standard auth schemes
• Cross Platform
Xamarin.Auth
using Xamarin.Auth;
var auth = new OAuth2Authenticator (
clientId: "App ID from https://developers.facebook.com/apps",
scope: "",
authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));
auth.Completed += (sender, eventArgs) => {
DismissViewController (true, null);
if (eventArgs.IsAuthenticated) {
// Use eventArgs.Account to do wonderful things
}
}
PresentViewController (auth.GetUI (), true, null);
// 1. Create the service
Xamarin.Social
• Posts statuses, links, images/media to social networks
– Access social network APIs using authenticated requests.
– Automatically and securely store user credentials using
Xamarin.Auth.
– Cross Platform
• Extensible, currently has support for:
– App.net
– Facebook
– Flickr
– Pinterest
– Twitter
Using Xamarin.Social
var facebook = new FacebookService {
ClientId = MyFacebook_AppId
RedirectUrl = new System.Uri (MyRedirectUrl)
};
// 2. Create an item to share
var item = new Item { Text = "Xamarin.Social is the bomb" };
item.Links.Add (new Uri
("http://github.com/xamarin/xamarin.social"));
// 3. Present the UI on iOS
var shareController = facebook.GetShareUI (item, result => {
// result lets you know if the user shared the item or canceled
DismissViewController (true, null);
});
PresentViewController (shareController, true, null);
Now all Open Source
• All frameworks:
– Cocos2D XNA
• http://github.com/mono/cocos2d-xna
– Xamarin.Auth
• http://github.com/xamarin/Xamarin.Auth
– Xamarin.Mobile
• http://github.com/xamarin/Xamarin.Mobile
– Xamarin.Social
• http://github.com/xamarin/Xamarin.Social
• Taking patches!
WORK IN PROGRESS
PLAYSCRIPT
PlayScript
• Started by Zynga
– Xamarin working to integrate into Mono
– Rescuing Flash Developers!
• ActionScript look-alike language
– Superset of ActionScript
– With C# 5 features
– Optional strongly-typed
• Encouraged for performance
PlayScript Compiler
• Dual Compiler
– playsc foo.play
• Compiles PlayScript to foo.exe
– playsc bar.cs
• Compiles C# to bar.exe
– playsc foo.play bar.cs
• Compiles PlayScript foo.play and C# bar.cs
• Into foo.exe
• Allows blending C# and PlayScript code in one
assembly
PlayScript Compiler
• Based on Mono’s C# compiler
– Altered to accept PlayScript language
• Side effects:
– Compiler as a service support for PlayScript
– Full Xamarin Studio integration
• code completion
• Docs
• Project support
PlayScript Libraries
• pscorlib
– Provides core library for PlayScript/ActionScript
• Flash Stage3D
– GPU accelerated framework
– Used by gaming frameworks
Ported Frameworks
• Starling Framework
• 2D Game Engine
• Powers Angry Birds
• Away3D
• 3D Game Engine
• Physics
PlayScript today
• Compiles existing large ActionScript projects
– Some missing language features
– Actively working to improve language
– Merging into Mono (playscript branch)
– Everywhere Mono runs
• On GitHub:
– Project: http://github.com/playscript
C++ INTEROP
Evolving Cxxi
• Couple of years ago Cxxi project was launched
• Used GCC-XML to parse C++ definitions
• Runtime creation of C# to C++ bridges
– Reflection.Emit
– Pluggable VTable ABIs
CppSharp
• New C++ binding technology from Mono
• Produces C# libraries to consume C++ code
– Use Clang for higher fidelity
– Static compilation (to support iOS, Consoles)
– Customize binding for .NET consistency
– Direct calls to C++ (no intermediate glue)
– Imports C++ Doxygen docs into C# docs
http://github.com/mono/CppSharp
Generating a binding
Sources
Generated
Final Library Foo.dll
libFoo.so
C++
Headers
C++
Source
Foo.cs
C++
Headers
C# API
Driver
public class Sample : ILibrary
{
public Sample(LanguageGeneratorKind kind) : base("Sample", kind) {}
public override void SetupPasses(Driver driver, PassBuilder passes)
{
passes.RenameDeclsUpperCase(RenameTargets.Any);
passes.FunctionToInstanceMethod();
}
public override void Preprocess(Driver driver, Library lib)
{
lib.SetClassAsValueType("Foo");
lib.SetNameOfFunction("FooAdd", "FooCalc");
lib.IgnoreClassField("Foo", "b");
}
static class Program
{
public static void Main(string[] args)
{
ConsoleDriver.Run(new
Sample(LanguageGeneratorKind.CPlusPlusCLI));
ConsoleDriver.Run(new Sample(LanguageGeneratorKind.CSharp));
}
}
NATIVE INTEROP
Assembly in C#
• Allow developers to inline assembly code
– Micro-optimizations
– Optimize a code path
– Use arch-specific features
• You can not get more native than that.
Assembly in C#
• Allow developers to inline assembly code
– Micro-optimizations
– Optimize a code path
– Use arch-specific features
Example
unsafe int Clear (IntPtr buffer, int count)
{
asm.BindIntPtr (0, buffer);
asm.BindInt (1, count);
asm.Emitx86 (@”
push %ecx
push %edi
mov %eax,%edi
mov %ebx,%ecx
xor %eax,%eax
rep stosb
mov $1,%eax
pop %edi
pop %ecx
”);
return asm.FetchInt (0);
}
unsafe int Clear (IntPtr buffer, int count)
{
asm.BindIntPtr (0, buffer);
asm.BindInt (1, count);
asm.Emitx86 (@”
push %ecx
push %edi
mov %eax,%edi
mov %ebx,%ecx
xor %eax,%eax
rep stosb
mov $1,%eax
pop %edi
pop %ecx
”);
return asm.FetchInt (0);
}
In case there are any doubts
Example
unsafe int Clear (IntPtr buffer, int count)
{
asm.BindIntPtr (0, buffer);
asm.BindInt (1, count);
asm.Emitx86 (@”
push %ecx
push %edi
mov %eax,%edi
mov %ebx,%ecx
xor %eax,%eax
rep stosb
mov $1,%eax
”);
return asm.FetchInt (0);
}
• Bind Parameters
• Let Mono know which
parameters you will pass
Example
unsafe int Clear (IntPtr buffer, int count)
{
asm.BindIntPtr (0, buffer);
asm.BindInt (1, count);
asm.Emitx86 (@”
push %ecx
push %edi
mov %eax,%edi
mov %ebx,%ecx
xor %eax,%eax
rep stosb
mov $1,%eax
”);
return asm.FetchInt (0);
}
• Bind Parameters
• Let Mono know which
parameters you will pass
• Assembly code as a string
• Assembled by LLVM
• Mono JIT Calling conventions
Example
unsafe int Clear (IntPtr buffer, int count)
{
asm.BindIntPtr (0, buffer);
asm.BindInt (1, count);
asm.Emitx86 (@”
push %ecx
push %edi
mov %eax,%edi
mov %ebx,%ecx
xor %eax,%eax
rep stosb
mov $1,%eax
”);
return asm.FetchInt (0);
}
• Bind Parameters
• Let Mono know which
parameters you will pass
• Assembly code as a string
• Assembled by LLVM
• Mono JIT Calling conventions
• Fetch result value
Example
unsafe int Clear (IntPtr buffer, int count)
{
asm.BindIntPtr (0, buffer);
asm.BindInt (1, count);
asm.Emitx86 (@”
push %ecx
push %edi
mov %eax,%edi
mov %ebx,%ecx
xor %eax,%eax
rep stosb
mov $1,%eax
”);
return asm.FetchInt (0);
}
• Bind Parameters
• Let Mono know which
parameters you will pass
• Assembly code as a string
• Assembled by LLVM
• Mono JIT Calling conventions
• Fetch result value
Passing parameters, extracting
• Input parameters:
– asm.BindXXX (int incomingParameter, XXX value);
• Emit assembly code:
– asm.Emit (string code)
– Assembled with LLVM assembler
– Injected into resulting assembly
– Follow Mono native rules for preserving register usage
• Output parameters:
– asm.FetchXXX (int resultParamter)
How it works
• Platform.Native.dll
– Contains stub methods
– Allows same source to build on .NET and Mono
• Follow our previous efforts:
– Like SIMD
– On Mono, the runtime recognizes some calls
EmitXxx ignored for other platforms
// Highly optimized native way of getting a native one!
unsafe int GetOneConstant ()
{
asm.Emitx86 (“mov $1,%eax”);
asm.EmitArm (“mov r0,#1”);
asm.Emitx64 (“mov $1,%rax”);
return asm.FetchInt (0);
}
For more complex code, use asm.Arch:
unsafe int GetOneConstant ()
{
if (asm.Arch == Arch.x86) {
asm.Emitx86 (“mov $1,%eax”);
return asm.FetchInt (0);
} else
return 1;
}
WHAT IS NEXT?
Future for Mono
• Community feedback on features needed
• Brainstorming session tomorrow!
– Where should Mono and .NET go?
– Bring your favorite feature request

More Related Content

PDF
[부스트캠프 Tech Talk] 고지형_내 자식 하나쯤은 있어야죠
PPTX
XDebug For php debugging
PPTX
Cheap ci for javascript devs
PDF
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
PDF
Windows azure and linux
PDF
Daniel Steigerwald - Este.js - konec velkého Schizma
PPTX
How to Write UI Automated Tests
PDF
Docker jako prostředí pro automatizaci testů
[부스트캠프 Tech Talk] 고지형_내 자식 하나쯤은 있어야죠
XDebug For php debugging
Cheap ci for javascript devs
Daniel Steigerwald: EsteJS - javascriptové aplikace robusně, modulárně a komf...
Windows azure and linux
Daniel Steigerwald - Este.js - konec velkého Schizma
How to Write UI Automated Tests
Docker jako prostředí pro automatizaci testů

What's hot (20)

PPTX
Php[tek] 2016 - BDD with Behat for Beginners
PDF
Ať se z kódu nepráší! 2013
PPTX
Introduction to Qt
PPTX
Dial up your flow
PPTX
Forseti driven javascript
PPTX
VS2015 C++ new features
PPTX
JavaScript와 TypeScript의 으리 있는 만남
PDF
Grunt JS - Getting Started With Grunt
PPT
Headless BDD & Responsive Test Automation
PDF
Pre-render Blazor WebAssembly on static web hosting at publishing time
PDF
Power Apps + C#
PDF
Why don't you Groovy?
PDF
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
PDF
카카오 공용준님의 "DevOps: on going pursuit of effectiveness"
PPTX
Containerized build
PDF
Hot Chocolate: You got cocoa in my PHP
PPT
Introduction to composer
ODP
BDD using Behat, Selenium,Sahi and SauceLabs
PPTX
Rusty Python
PPTX
WebAssembly: In a Nutshell
Php[tek] 2016 - BDD with Behat for Beginners
Ať se z kódu nepráší! 2013
Introduction to Qt
Dial up your flow
Forseti driven javascript
VS2015 C++ new features
JavaScript와 TypeScript의 으리 있는 만남
Grunt JS - Getting Started With Grunt
Headless BDD & Responsive Test Automation
Pre-render Blazor WebAssembly on static web hosting at publishing time
Power Apps + C#
Why don't you Groovy?
WHAT / WHY / HOW WE’RE ENGINEERING AT SMARTSTUDY (English)
카카오 공용준님의 "DevOps: on going pursuit of effectiveness"
Containerized build
Hot Chocolate: You got cocoa in my PHP
Introduction to composer
BDD using Behat, Selenium,Sahi and SauceLabs
Rusty Python
WebAssembly: In a Nutshell
Ad

Viewers also liked (8)

PPTX
PDF
Easyloggingpp
PDF
Twitter의 snowflake 소개 및 활용
PPTX
MsgPack 정리
PDF
NLog 소개
PPTX
signal과 slot, 그리고 jl_signal 라이브러리
PDF
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발
PPTX
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
Easyloggingpp
Twitter의 snowflake 소개 및 활용
MsgPack 정리
NLog 소개
signal과 slot, 그리고 jl_signal 라이브러리
KGC2015_C# 스크립트를 사용한 게임서버 모니터링 시스템개발
GDC Europe 2014: Unreal Engine 4 for Programmers - Lessons Learned & Things t...
Ad

Similar to Monkey space 2013 (20)

PDF
Introduction to Cross Platform Development with Xamarin/ Visual Studio
PPTX
PDF
Introduction to MonoTouch and Monodroid/Mono for Android
PPTX
C# everywhere: Xamarin and cross platform development
PPTX
TestUpload
PPT
David buksbaum a-briefintroductiontocsharp
PPTX
Windows 8 für .net Entwickler
PPTX
What is new in .NET 4.5
PDF
Mono for Android... for Google Devs
KEY
Cross Platform Development with Xamarin
PPTX
Binding Objective-C Libraries, Miguel de Icaza
PPTX
Introduction to MonoTouch
PPTX
MonoTouch 5.2 Introduction
PDF
Xamarin Under The Hood - Dan Ardelean
DOCX
C# tutorial
PPTX
Next .NET and C#
PDF
Dotnet interview qa
PPTX
Introducing Xamarin 3
PDF
Xamarin for (not only) Android developers
PPTX
Xamarin - Under the bridge
Introduction to Cross Platform Development with Xamarin/ Visual Studio
Introduction to MonoTouch and Monodroid/Mono for Android
C# everywhere: Xamarin and cross platform development
TestUpload
David buksbaum a-briefintroductiontocsharp
Windows 8 für .net Entwickler
What is new in .NET 4.5
Mono for Android... for Google Devs
Cross Platform Development with Xamarin
Binding Objective-C Libraries, Miguel de Icaza
Introduction to MonoTouch
MonoTouch 5.2 Introduction
Xamarin Under The Hood - Dan Ardelean
C# tutorial
Next .NET and C#
Dotnet interview qa
Introducing Xamarin 3
Xamarin for (not only) Android developers
Xamarin - Under the bridge

Recently uploaded (20)

PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PDF
Co-training pseudo-labeling for text classification with support vector machi...
PDF
Statistics on Ai - sourced from AIPRM.pdf
PDF
Early detection and classification of bone marrow changes in lumbar vertebrae...
PPTX
Microsoft User Copilot Training Slide Deck
PPTX
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
PPTX
Configure Apache Mutual Authentication
PPTX
Internet of Everything -Basic concepts details
PDF
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
DOCX
search engine optimization ppt fir known well about this
PPTX
MuleSoft-Compete-Deck for midddleware integrations
PDF
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PDF
Data Virtualization in Action: Scaling APIs and Apps with FME
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
4 layer Arch & Reference Arch of IoT.pdf
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
Co-training pseudo-labeling for text classification with support vector machi...
Statistics on Ai - sourced from AIPRM.pdf
Early detection and classification of bone marrow changes in lumbar vertebrae...
Microsoft User Copilot Training Slide Deck
AI IN MARKETING- PRESENTED BY ANWAR KABIR 1st June 2025.pptx
Configure Apache Mutual Authentication
Internet of Everything -Basic concepts details
AI.gov: A Trojan Horse in the Age of Artificial Intelligence
search engine optimization ppt fir known well about this
MuleSoft-Compete-Deck for midddleware integrations
The-Future-of-Automotive-Quality-is-Here-AI-Driven-Engineering.pdf
Custom Battery Pack Design Considerations for Performance and Safety
Data Virtualization in Action: Scaling APIs and Apps with FME
Enhancing plagiarism detection using data pre-processing and machine learning...
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Improvisation in detection of pomegranate leaf disease using transfer learni...
sbt 2.0: go big (Scala Days 2025 edition)
4 layer Arch & Reference Arch of IoT.pdf

Monkey space 2013

  • 1. What is new in Mono? July 2013 [email protected]
  • 2. Agenda • Today: – What is new in Mono-land. – Major Work-in-Progress Projects • Tomorrow: – Brainstorming session – Future of Mono and .NET
  • 4. Mono 3.2 • Core .NET 4.5 support – Base Class Libraries – C# 5 • Available today: – Desktop – Server – Mobile • 2.10.x is no longer supported
  • 5. What is new in Mono 3.2 • Vastly improved SGen GC – Now the default! • Micro-optimizations – Mobile-driven • Consume PCL binaries • Shipping OSS Microsoft frameworks • New Mono frameworks
  • 6. SGen Garbage Collector • Our Precise, generational collector • Now the default for Mono – “mono” now runs mono –gc=sgen – libmono is Boehm – libmono-sgen is Sgen • Sgen is now faster on almost every workload • MonoDevelop/Xamarin Studio – Been using it as a default since February
  • 7. What is new? • Major collectors: – Copy collector (old, reference code) – Mark and Sweep • Minor collectors: – Now with support for cementing • Help game developers love GC • dtrace probes
  • 8. Mark and Sweep • Dynamic heap by default – Can specify fixed heap if desired • Allocates blocks of memory to bucket sizes – Think of the spirit to “slab” allocation – Support changes in workloads with evacuation • Concurrent Marking, Lazy Sweeping
  • 9. Disabling Major Collector New API on Mono.Runtime (mscorlib.dll) if (!Mono.Runtime.SetGCAllowSynchronousMajor (false)) Console.WriteLine ("Sorry, the GC won't cooperate."); // your low-latency code here Mono.Runtime.SetGCAllowSynchronousMajor (true); • Exposed on Mobile. • Use System.Reflection to find it on desktop editions.
  • 10. dtrace probes on MacOS Major collections and minor collections pause times visualized http://schani.wordpress.com/2012/11/02/sgen-and-dtrace/
  • 12. Static Compilation • For systems that don’t support JITing – Apple’s iOS devices – Consoles (PlayStation, Xbox) – Security: when not shipping IL • Limited generics support – Static analysis limitations – Some dynamisms in .NET idioms • LINQ and Value Types
  • 13. “Attempting to JIT compile method” System.ExecutionEngineException: Attempting to JIT compile method Foo[]:Bar`1
  • 14. “Attempting to JIT compile method” System.ExecutionEngineException: Attempting to JIT compile method Foo[]:Bar`1
  • 15. iOS Development Improvements • Improve development cycle • Incremental Builds – Disable linker (compile everything) – Cache resulting native code aggressively • Incremental Upload – Only uploads changes – Main executable, libraries or resources
  • 16. Incremental Deployment (With Build Caching) 0 10 20 30 40 50 60 70 80 Hello World Large App Seconds Old New Deployment times can now be as short as one second.
  • 17. Incremental Deployment (With Build Caching) 0 5 10 15 20 25 30 35 40 Hello World Large App Seconds 6.2 6.4 Deployment times can now be as short as one second.
  • 18. Build Speed Improvements 0 10 20 30 40 50 60 70 80 Hello World Large App Seconds 6.2 6.4 6.4+Incremental
  • 20. Now Bundled with Mono • Reactive Extensions – Possible on iOS with new code gen changes • F# everywhere • Razor • Entity Framework • ASP.NET WebStack
  • 21. MonoDevelop Xamarin Studio MonoDevelop / Xamarin Studio MonoDevelop Core MonoDevelop Core Android Mac iOS Branding Add-In Open source Commercial
  • 23. Cocos2D XNA • XNA port of the popular Cocos2D API – Over 4,000 games built with this API – Well documented, well known • MonoGame brings it everywhere – iOS, Android, Windows Phone (7 and 8) – Mac – Windows (GL, DX, , Windows Store) – Xbox360, Ouya – Play Station Mobile (PS Vita + Sony Androids)
  • 24. Using Cocos2D XNA Today • Available as: – NuGet Packages – Templates for VS and Xamarin Studio • Source code: – http://github.com/mono/cocos2d-xna • Getting Started: – http://docs.xamarin.com/guides/cross-platform/cocos2d_xna
  • 25. Angry Ninjas - Full Open Source Game https://github.com/xamarin/AngryNinjas
  • 26. Cocos2D Crash Course • Mike Bluestein’s talk tomorrow
  • 27. Xamarin.Mobile • Base class library for mobile services • Mike Bluestein’s talk
  • 28. Xamarin.Auth • Clients for OAuth 1 and OAuth 2 – Includes variations • Stores user credentials • Support non-standard auth schemes • Cross Platform
  • 29. Xamarin.Auth using Xamarin.Auth; var auth = new OAuth2Authenticator ( clientId: "App ID from https://developers.facebook.com/apps", scope: "", authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"), redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html")); auth.Completed += (sender, eventArgs) => { DismissViewController (true, null); if (eventArgs.IsAuthenticated) { // Use eventArgs.Account to do wonderful things } } PresentViewController (auth.GetUI (), true, null); // 1. Create the service
  • 30. Xamarin.Social • Posts statuses, links, images/media to social networks – Access social network APIs using authenticated requests. – Automatically and securely store user credentials using Xamarin.Auth. – Cross Platform • Extensible, currently has support for: – App.net – Facebook – Flickr – Pinterest – Twitter
  • 31. Using Xamarin.Social var facebook = new FacebookService { ClientId = MyFacebook_AppId RedirectUrl = new System.Uri (MyRedirectUrl) }; // 2. Create an item to share var item = new Item { Text = "Xamarin.Social is the bomb" }; item.Links.Add (new Uri ("http://github.com/xamarin/xamarin.social")); // 3. Present the UI on iOS var shareController = facebook.GetShareUI (item, result => { // result lets you know if the user shared the item or canceled DismissViewController (true, null); }); PresentViewController (shareController, true, null);
  • 32. Now all Open Source • All frameworks: – Cocos2D XNA • http://github.com/mono/cocos2d-xna – Xamarin.Auth • http://github.com/xamarin/Xamarin.Auth – Xamarin.Mobile • http://github.com/xamarin/Xamarin.Mobile – Xamarin.Social • http://github.com/xamarin/Xamarin.Social • Taking patches!
  • 35. PlayScript • Started by Zynga – Xamarin working to integrate into Mono – Rescuing Flash Developers! • ActionScript look-alike language – Superset of ActionScript – With C# 5 features – Optional strongly-typed • Encouraged for performance
  • 36. PlayScript Compiler • Dual Compiler – playsc foo.play • Compiles PlayScript to foo.exe – playsc bar.cs • Compiles C# to bar.exe – playsc foo.play bar.cs • Compiles PlayScript foo.play and C# bar.cs • Into foo.exe • Allows blending C# and PlayScript code in one assembly
  • 37. PlayScript Compiler • Based on Mono’s C# compiler – Altered to accept PlayScript language • Side effects: – Compiler as a service support for PlayScript – Full Xamarin Studio integration • code completion • Docs • Project support
  • 38. PlayScript Libraries • pscorlib – Provides core library for PlayScript/ActionScript • Flash Stage3D – GPU accelerated framework – Used by gaming frameworks
  • 39. Ported Frameworks • Starling Framework • 2D Game Engine • Powers Angry Birds • Away3D • 3D Game Engine • Physics
  • 40. PlayScript today • Compiles existing large ActionScript projects – Some missing language features – Actively working to improve language – Merging into Mono (playscript branch) – Everywhere Mono runs • On GitHub: – Project: http://github.com/playscript
  • 42. Evolving Cxxi • Couple of years ago Cxxi project was launched • Used GCC-XML to parse C++ definitions • Runtime creation of C# to C++ bridges – Reflection.Emit – Pluggable VTable ABIs
  • 43. CppSharp • New C++ binding technology from Mono • Produces C# libraries to consume C++ code – Use Clang for higher fidelity – Static compilation (to support iOS, Consoles) – Customize binding for .NET consistency – Direct calls to C++ (no intermediate glue) – Imports C++ Doxygen docs into C# docs http://github.com/mono/CppSharp
  • 44. Generating a binding Sources Generated Final Library Foo.dll libFoo.so C++ Headers C++ Source Foo.cs C++ Headers C# API Driver
  • 45. public class Sample : ILibrary { public Sample(LanguageGeneratorKind kind) : base("Sample", kind) {} public override void SetupPasses(Driver driver, PassBuilder passes) { passes.RenameDeclsUpperCase(RenameTargets.Any); passes.FunctionToInstanceMethod(); } public override void Preprocess(Driver driver, Library lib) { lib.SetClassAsValueType("Foo"); lib.SetNameOfFunction("FooAdd", "FooCalc"); lib.IgnoreClassField("Foo", "b"); } static class Program { public static void Main(string[] args) { ConsoleDriver.Run(new Sample(LanguageGeneratorKind.CPlusPlusCLI)); ConsoleDriver.Run(new Sample(LanguageGeneratorKind.CSharp)); } }
  • 47. Assembly in C# • Allow developers to inline assembly code – Micro-optimizations – Optimize a code path – Use arch-specific features • You can not get more native than that.
  • 48. Assembly in C# • Allow developers to inline assembly code – Micro-optimizations – Optimize a code path – Use arch-specific features
  • 49. Example unsafe int Clear (IntPtr buffer, int count) { asm.BindIntPtr (0, buffer); asm.BindInt (1, count); asm.Emitx86 (@” push %ecx push %edi mov %eax,%edi mov %ebx,%ecx xor %eax,%eax rep stosb mov $1,%eax pop %edi pop %ecx ”); return asm.FetchInt (0); }
  • 50. unsafe int Clear (IntPtr buffer, int count) { asm.BindIntPtr (0, buffer); asm.BindInt (1, count); asm.Emitx86 (@” push %ecx push %edi mov %eax,%edi mov %ebx,%ecx xor %eax,%eax rep stosb mov $1,%eax pop %edi pop %ecx ”); return asm.FetchInt (0); } In case there are any doubts
  • 51. Example unsafe int Clear (IntPtr buffer, int count) { asm.BindIntPtr (0, buffer); asm.BindInt (1, count); asm.Emitx86 (@” push %ecx push %edi mov %eax,%edi mov %ebx,%ecx xor %eax,%eax rep stosb mov $1,%eax ”); return asm.FetchInt (0); } • Bind Parameters • Let Mono know which parameters you will pass
  • 52. Example unsafe int Clear (IntPtr buffer, int count) { asm.BindIntPtr (0, buffer); asm.BindInt (1, count); asm.Emitx86 (@” push %ecx push %edi mov %eax,%edi mov %ebx,%ecx xor %eax,%eax rep stosb mov $1,%eax ”); return asm.FetchInt (0); } • Bind Parameters • Let Mono know which parameters you will pass • Assembly code as a string • Assembled by LLVM • Mono JIT Calling conventions
  • 53. Example unsafe int Clear (IntPtr buffer, int count) { asm.BindIntPtr (0, buffer); asm.BindInt (1, count); asm.Emitx86 (@” push %ecx push %edi mov %eax,%edi mov %ebx,%ecx xor %eax,%eax rep stosb mov $1,%eax ”); return asm.FetchInt (0); } • Bind Parameters • Let Mono know which parameters you will pass • Assembly code as a string • Assembled by LLVM • Mono JIT Calling conventions • Fetch result value
  • 54. Example unsafe int Clear (IntPtr buffer, int count) { asm.BindIntPtr (0, buffer); asm.BindInt (1, count); asm.Emitx86 (@” push %ecx push %edi mov %eax,%edi mov %ebx,%ecx xor %eax,%eax rep stosb mov $1,%eax ”); return asm.FetchInt (0); } • Bind Parameters • Let Mono know which parameters you will pass • Assembly code as a string • Assembled by LLVM • Mono JIT Calling conventions • Fetch result value
  • 55. Passing parameters, extracting • Input parameters: – asm.BindXXX (int incomingParameter, XXX value); • Emit assembly code: – asm.Emit (string code) – Assembled with LLVM assembler – Injected into resulting assembly – Follow Mono native rules for preserving register usage • Output parameters: – asm.FetchXXX (int resultParamter)
  • 56. How it works • Platform.Native.dll – Contains stub methods – Allows same source to build on .NET and Mono • Follow our previous efforts: – Like SIMD – On Mono, the runtime recognizes some calls
  • 57. EmitXxx ignored for other platforms // Highly optimized native way of getting a native one! unsafe int GetOneConstant () { asm.Emitx86 (“mov $1,%eax”); asm.EmitArm (“mov r0,#1”); asm.Emitx64 (“mov $1,%rax”); return asm.FetchInt (0); } For more complex code, use asm.Arch: unsafe int GetOneConstant () { if (asm.Arch == Arch.x86) { asm.Emitx86 (“mov $1,%eax”); return asm.FetchInt (0); } else return 1; }
  • 59. Future for Mono • Community feedback on features needed • Brainstorming session tomorrow! – Where should Mono and .NET go? – Bring your favorite feature request

Editor's Notes

  • #22: Performance, upstreamed contributions, stability, bug fixing, improved debugging
  • #28: Geo locationContactsCamera
  • #47: Mono and .NET offer C and C++ bridgesSometimes you just want to be a real man