Is it possible to use Clojure CLR with C # in Xamarin?

I like Clojure. This is by far my favorite language.

I just found Xamarin that allows you to have cross-platform applications, making full use of native libraries. The language used is C #.

Now I am wondering if there is a way to program most of my Xamarin applications in Clojure (CLR) instead of C #.

+6
source share
2 answers

So, Clojure CLR will allow you to use any libraries that it can load. For example, I loaded the Oracle.DataAccess and NLog libraries in the Clojure CLR, so theoretically you can load the Xamarin libraries the same way:

;;; not sure which library you want to include, using this as a placeholder (assembly-load-from "C:/Path/To/Xamarin.Core.dll") 

Thus, Xamarin itself is also an IDE and a set of build tools on top of its own libraries and build tools, so it may not be possible to fully integrate the two. Also, I think Xamarin works exclusively with C #, so coding in Clojure is probably not possible ... directly.

What you can do is create several libraries in the Clojure CLR and compile them into DLLs that you can connect to so you can build the bulk of your logic in Clojure, and then create some simple C # that use your Xamarin application.

I would like to hear that you are trying, and whether you can do it.

Good luck

+2
source

Maybe yes in Android, but in the case of iOS, I would say that this is unlikely, because the latter is a platform that has many limitations around the generated code, reflection, and the like. And Clojure, being dynamically typed, has a good chance of being affected.

Honestly, Clojure in the .NET world will do better with F # (also functional, immutable by default, etc.), which is the language that has just been adopted as official Xamarin (which means you can use it in Android both iOS and Mac).

It is also statically typed (unlike Clojure), so this could mean that it is also faster. Give it a try!

0
source

Source: https://habr.com/ru/post/943935/


All Articles