We are designing a generic Android application using Xamarin Forms. At the same time, we need some texts that the user enters to be treated a bit differently for some of the customers, ie. run them through a custom transformation.
Instead of having to build a different version of our generic app, it would be great if we could define those transformations as an external dependency, as a pluggable "dll" or a text file with a script, maybe something like MoonSharp.
Does anyone have experience with something similar and how to achieve that in Xamarin Forms?
We did end up using the MoonSharp framework and the Lua scripting in two different projects, one on Xamarin, and another one on a classic windows service C# application. It was a great tool and gets the job done!
Related
Are there any advancements in this area? I want to be able to write purely functional code on Android in Haskell or similar languages. I've tried some examples with Scala but it seems to be a pain to get started. Are there any other functional JVM languages which I can use to write Android applications?
Edit: functional languages that write native android applications. My mistake about the JVM.
I doubt that you can find anything mature for writing Haskell-like code for Android. You do need to implement Java abstractions which are required by Android API (implement activity, etc.).
But if you really want to write for Android in a purely functional style you can try to implement your business logic in a pure functional language that compiles to JVM and call it from your Java classes. That approach would be much simpler than trying to implement it entirely in pure functional style.
As your language choice, you can try
Frege, it even has a library for android - froid
Eta lang, it is very new and probably nobody has tried to use it for Android yet
I you want a painless solution in terms of Gradle builds etc., you have only two options: Java and Kotlin, of which of course you should choose Kotlin ;)
Kotlin has most of the things you need to write in functional style:
functions as first class citizen
higher-order functions
immutable collections
var and val like in Scala
if-else as a statement
elements of pattern matching (where statement)
tail recursion
and more...
If you also include funKTionale and kotlinx.collections.immutable, you'll have all the functional goodies like: Option, Try, currying, memoization, persistent data structures and so on...
To start with Kotlin just install the latest Android Studio 3 Preview, which already has built-in Kotlin support.
BTW, don't be so polarized into "pure" functional ;) After all, being 100% "pure" means no side-effects, which means your app can't interact with the user ;)
Hope this helps :)
I've never tried it personally, but you can do F# programming using Xamarin.Android (and, I believe, with Xamarin Forms too). You can see the guide here. (It also includes sample code).
As some background, F# is the .NET Framework's functional language. It is derived from ML; in fact, many ML scripts can be compiled almost "directly" as F# (with the caveat that you may have to do some renaming because F# has some additional keywords that ML doesn't have in order to support several .NET-specific extensions).
Xamarin allows for native development for Android, iOS, and Windows phone. Xamarin Forms allows for a single code-base for all three platforms (it's a competitor to Ionic).
One more quick point: Android does not use the JVM, even if you're writing apps in Java. (In fact, Android does not even support all Java 8 features yet). Through Android 4.4 it used Dalvik; after that, it started using Android Runtime.
You could also try using a JVM language like Scala to create a JAR file and create a bindings library for it.
Please also note that you'll end up using at least somewhat of a mixed paradigm - for example, things like Activities are objects, and the XML files used to define an Android screen is, for all practical purposes, declarative. Edit: This last point is slightly debatable - see the comments.
One final possibility: I haven't checked this out too closely, but try also this link for a site claiming you can do Scala in Android.
Between Pure functional and Java, there is a way which is IMO Pragmatic functional. For instance Redux achieves that in the React arena.
My goal is to write an app (Activity) having an immutable state that advanced as a result of interactions is functional.
In the browser you can see that done with elm (Haskel like language which is also web platform)
Since we want an Android app, I opened the Android Studio used the wizard to create and app with Navigaton Drawer Action bar (with Drawer, FloatingActionBar),
Then converted it to use Elm concepts of immutable model functional approach into a working POC based on a small ElmBase class and idioms.
The code is written in Kotlin (JetBrains tool of choice for the JVM).
You can find the app at my GitHub https://github.com/saffih/ElmDroid The sweet spot of that approach is that it leverages Kotlin being strongly typed and the editor does code completions very well,
making lot's of the code completed for me in a way I have never seen before - amazing experience (But it require using idioms like the sealed class and when properly).
I want to develop application in android and iOS both.
But i am confuse between native development and development using react and node.js etc.
Please help me to choose (If possible specify reason).
P.S Here cost is not an issue.
If you need high performance and attractive UI and don't want to be blocked by some functionalities that may not br provided by cross platform, I recommend you to use native platform. But if your app doesn't need to be very attractive and doesn't need too much processing, then you can use cross-platform. Actually for many features you need to add plugins if you are building cross platform app and adding number of plugins makes your application slower.
OK, well there isn't much data to go on, but there are several options if you want to write cross platform apps.
There is:
Sencha Touch - HTML and JavaScript
PhoneGap - HTML, JavaScript and CSS
QT - C++ and QML
Appmethod - C++ and Object Pascal
Xamarin - C#
Visual Studio - looks like you can do C# or C++, or Unity for games.
and probably a lot more...
Why would you choose one of these instead of writing in the native language for the platform?
Well, the pros seem to outweigh the cons. If you are targeting several platforms, I would choose one of the options above, simply because you only have to write everything once. If you did it native for each platform, you would write everything twice or maybe three or even four times. Using one of the above tools will be much easier and save you time, and they might be just as seamless and workable as native development.
To simply answer your question, If you would like to be able to write your app once, and be able to manage all future updates by managing only one code base, do cross platform using one of the above tools. The only downside is that you might have to learn a new language (but with a place like Stack Overflow, learning new languages is pretty awesome). It will save you time in the long run.
We are developing an app in our organization where we have to implement charts,maps,GPS, If we Develop in Xamarin.ios/xamrin.android can developers able to share business logic of the app? since both android/ios projects will be in c#.
I'm doing exactly the same thing.
Do not use Xamarin Forms. It is not designed for nor capable of doing heavily customised UIs.
If you are going to require integration with Maps and also producing any kind of non-standard rendering or "User Controls" Xamarin.Forms is not going to work for you.
Go down the route of using a framework like MvvmCross to further abstract away the platforms and keep your core code / logic and user experience flow within the realms of a Core.Pcl type library.
Also I wouldn't try doing this on Windows 7 based bachines if you are doing this on Windows. Most of the components you will find yourself wanting to use will be targetting Profile259 and since Windows 7 doesn't support Windows Phone 8 you'll have all manner of oddities, even if you do the Profile259 hack.
Go with MvvmCross, Windows 8 and ignore Xamarin Forms.
I wrote a bit of it up on my blog.
Read this from Xmarin, they clearly state that Forms is for run of the mill business apps or for prototyping. It's not mature enough yet.
Yes, you can write your core app logic (services, data, domain, etc) in a PCL library that is shared by both your Android and iOS apps.
From my experience, you can build most apps in Xamarin Forms. The main hurdle is that doing anything not included in X.Forms requires that you write Custom Renderers. The thing is, writing custom renderers is much more straightforward if you have a solid grasp of vanilla Xamarin (Xamarin.iOS & Xamarin.Android).
What I think happens is that developers getting into Xamarin go directly to Xamarin.Forms and then become frustrated when they are unable to write custom renderers to accomplish some custom requirements.
So my recommendation is that if you have experience building apps using Xamarin.iOS and Xamarin.Android, Xamarin.Forms is awesome for getting an application developed rapidly for multiple platforms. Being able to use MVVM + XAML + Data Binding is a huge win.
If you are new to Xamarin or even mobile development, build the app using Xamarin.iOS and Xamarin.Android.
As we all know, when developing an Android app in native Java, we use activities. I was wondering that, in developing Android apps in Python(with Kivy), does Kivy implements activities for the apps in itself or not? because I don't see any activity implementation on the sample codes.
If it doesn't implement activities, Do we lose performance or any functionality in the application compared to coding in native Java?
Simply put, you can use Activities (starting them using pyjnius), but not really define them, at least, it's not usually the way one work with kivy.
Kivy doesn't adjust its way of working for targetted platform, it uses its own systems, and make them work there. For what i know the advantages of separating Activities on android is just a way to make your code more neatly organized, and doesn't imply performance changes. It can allow you to start your app in various ways (from a share, for example) but you can do that with p4a/buildozer too, by dispatching messages about the intent, if you need to. With kivy, you'll organise your code like you would do for any python project, using modules.
Kivy is a great tool for developing Android Apps. The best advantage of using Kivy is that it is cross platform and the same project can be used to publish apps on mutti-platforms.
However , it has some performance related disadvantages(as do most cross-platform tools like unity , cocos etc). If you're developing only for Android , I'd suggest taking a look into development tools which use Java. This will help create a smaller APK file which in turn helps in better user retention.
I guess you are real loyal fan of Python, but I have to tell you about its advantage and disadvantage.
Advantages
Pure python and its almightiness is in your hand.
Relatively simple to deploy with buildozer without any need to dive too deep into the details of particular platform.
You can run your app on desktop also, so there is no need to install some extra emulators/VMs to get it work
Disadvantages
Not that much information in Internet, even on stackoverflow
Pretty messy documentation
No obvious way to test the application
Not obvious machanisms of placing widgets, especially in built in layouts, which causes situations like: you want place widget in the center of it's parent, but kivy places it anywhere but not where you want it to be.
Official examples are quite ugly, so you may get false vision of how your application could look like.
I am very very new to Android. I was encouraged to take a closer look at Android when I heard about possbility to write applications on Android in scripting languages like Python. This sounds great and in fact works great.
I did some experiments and everything looks very interesting. I have noticed that I can either write my scripts on Android or create script file on my computer and then copy them to Android ase/scripts folder. This is somehow different (as far as I know) from process of creating application for Android in Java (when you create code, compile it to .apk and install on Android).
To be more specific I want to know:
what are limitations (if any) of script-based applications on Android?
is it possible to ship apps written in scripitng languages to Android Market and let other users install them without requirement to install ASE?
is there some way to create more complicated, multi-file projects in scripting languages on Android?
Thanks for any hints. Also please feel free to correct me if I made any error or wrong assumption in my question - as I wrote, I am very new to Android.
what are limitations (if any) of
script-based applications on Android?
I would flip the question around. Scripts can only execute what is native to their language plus the things exposed by the Android facade. As such, you are not creating full user interfaces and the like -- at most, you have access to some pre-packaged dialogs (e.g., getPassword()). So, for scripting purposes, ASE is very slick, but you are not creating applications, IMHO.
is it possible to ship apps written in
scripitng languages to Android Market
and let other users install them
without requirement to install ASE?
Not presently. It is something that is being worked on.
is there some way to create more
complicated, multi-file projects in
scripting languages on Android?
Ummmm...you could try whatever sort of "include" construct there is in your language of choice.
Although I have not personally done so, it appears possible to compile your python scripts into an .apk. Take a peek at the instructions for sharing scripts on the [Android-Scripting Wiki][1]
[1]: http://code.google.com/p/android-scripting/wiki/SharingScripts"Android Scripting Wiki"