Just Curios - C++ or Other Android Development Languages

What are the advantages of developing android apps in C++ rather than in JAVA?

The biggest advantage for me is that you can have a shared codebase between the platforms.
The best example is creating cross-platform games. If you write the game code in C++ you only need to write a small amount of code specific for current platform (e.g. Android) that just runs your C++ code right after the start.
Just take a look at Cocos2D-x game engine project (its open-source) and how many platforms it supports because its written in C++.

What are the advantages of developing android apps in C++ rather than in JAVA
OkieKokie said:
What are the advantages of developing android apps in C++ rather than in JAVA?
Click to expand...
Click to collapse
Mainly for game. Most of the mainstream 3D engine are written in C/C++, so for game developer, they can make use of the current c/c++ 3D engine directly without rewriting from scratch.

Related

Native C# Android?

Has anyone seen this?
http://blog.xamarin.com/2012/05/01/android-in-c-sharp/
This could be the bomb... coding in C# for Android natively!! Even maybe some of the good developers here at XDA could make a C# native Android ROM with a Dalvik machine for compatibility with non-C# market apps??
They have made tests and it seems that C# ROMs run like 5-8 times faster and leech much less power ...
Cheers!!!
Java and C# is brother actually. Both have virtual machines, both came from C++. But creating a new variation of one of these is so unreliable. Dalvik is Basically Java's clone but not very succesful clone. Mono is C#'s VM's clone and very reliable. Linux, Mac and Windows has Mono Ports (actually windows has .net framework) Mono is great but you know microsoft doesn't like UNIX like systems especially linux based ones. Thus C# programming could be harder for people. Also C# for phones could be awesome. Since 2000's We already have javaVMs on phones. Why Not C#. (python is good too but google wants a new language called GO)
Repeal said:
...Mono is great but you know microsoft doesn't like UNIX like systems especially linux based ones...
Click to expand...
Click to collapse
I think the problem is much greater with Google since they won't want a M$ programming language in their OS ... and that's a reason for which I'm sure they won't never support C# Android, but another thing are community ROMs.
Let time judge it.. but I think its good stuff...
Not only they do not 'want', they probably are not allowed as c# has patents. Look what is happening to google with java now owned by oracle..

[Q] i will like to know about this

https://www.apportable.com/ they are porting ios apps/games to android os?
Copy&Paste from the site:
Code:
Welcome to Apportable: the ultimate iOS-to-Android porting platform for games.
With Apportable, your game will run natively on Android without major changes to the Objective-C/C++/C codebase.
You’ll never have to write a line of Java, HTML5, or JavaScript - forget about hiring contractors or in-house porting engineers..
RoberGalarga said:
Copy&Paste from the site:
Code:
Welcome to Apportable: the ultimate iOS-to-Android porting platform for games.
With Apportable, your game will run natively on Android without major changes to the Objective-C/C++/C codebase.
You’ll never have to write a line of Java, HTML5, or JavaScript - forget about hiring contractors or in-house porting engineers..
Click to expand...
Click to collapse
so it's a good news for us android users (?)

Questions about going from JAVA to C++

Hi everyone
I've been coding games in OpenGL ES 2, 100% in JAVA. My question : Will I have a performance boost (in FPS) if I coded some parts of my games in C++ ? Like the rendering part ect. Can I have an estimation ? (2x, ect.)
Also, C++ is compiled, so I suppose I will need to make 2 APKs, one for ARM and an other for x86 ?
kamuikun said:
Hi everyone
I've been coding games in OpenGL ES 2, 100% in JAVA. My question : Will I have a performance boost (in FPS) if I coded some parts of my games in C++ ? Like the rendering part ect. Can I have an estimation ? (2x, ect.)
Also, C++ is compiled, so I suppose I will need to make 2 APKs, one for ARM and an other for x86 ?
Click to expand...
Click to collapse
You will have performance boost, c++ runs natively while java runs on vm
How much boost i don't know, i have never used c/c++. On today's modern hardware i presume not too much
You can make 2 apks, google play store allows adding separate apks for each supported architecture (mips, arm, x86)
But you dont have to if you dont want.
You can compile native libraries for both arm and x86. Then in java you determine which one to use
Thanks for your answer
Can someone that actually did the jump (from JAVA to C++) share about his experience ? Hom much FPS boost should I expect ?
I have a simple scene right now in 100% JAVA that is rendered at 17 FPS on an old mono 1 GHZ device, which is quite low. I was wondering if I optimized the rendering in C++ I would have 60 FPS on that device...
I can't talk from an OpenGL point of view but I made an Equation Solver a while back using the NDK and C++ as the engine for it. I can say the performance increase is quite dramatic.
http://www.youtube.com/watch?v=pHS4aXqPo-A
Go to 7:30, it shows an application that executes the same algorithm via Java and Native. You can see a large difference in performance.
It depends on what you're doing. If you have some heavy physics engine or massive calculation of whatever else you gain a lot by using the NDK in addition to the SDK. Small calculations and simple games aren't worth the overhead because each call to native code via JNI has a huge impact.
C++ performance gain
Hi,
Indeed you should expect performance gain, as a rule of thumb, C si between 3x and 50x faster than Java and C++ is roughly 3% slower than C. These were the figures of 2000, Java might have been improving since. Definetly, you will have a performance boost. For all serious animated games, it should be C++, no doubt.
There might be a trick to compile C++ code at runtime saving you the burden to compile for all platforms. For instance, for RenderScript, which allows computation on GPU, the C code (C99) is compiled at runtime.
Hope this will help.
DP
It could be faster. Remember Java & C++ have quite a few differences: no garbage collection in C++, pointers, no reflection for example. Not trying to put you off but it could mean altering your design to compensate. Having said that I have used JNI in a project years ago to talk to some hardware (not for performance) & that was no problem.
it is not easy from java to c++. c++ has some concept very different with java. for example pointer, free, delete memory. i think how to manage the memory space is very hard to java engineer.
kamuikun said:
I've been coding games in OpenGL ES 2, 100% in JAVA. My question : Will I have a performance boost (in FPS) if I coded some parts of my games in C++ ? Like the rendering part ect. Can I have an estimation ? (2x, ect.)
Click to expand...
Click to collapse
Nice stone age writing (for/about loopers) with some metrics
The first think I recommend you is to profile your code and get a clear idea of where is most of the time spent, if your time is mostly spent on gpu / draw calls then I don't think language is your problem.
my experience
I initially implemented my PlotimFree plotting app with Java and was not satisfied with the results. For the move to C++ I gave the Marmalade sdk a shot, and while I;m not sure I'd use it again if I started from scratch (due to pretty awful support), the performance boost was amazing. I expect pure NDK to be at least as good.
About two versions: Indeed, you need to compile for each target separately, which Marmalade limits, depending on the license you acquire. And there are a few more targets besides Arm and x86. I can testify, though, that converting my Android app to BB10 (which is also Arm based but still a different target) was no more than a two hour process.
Lyonsbane said:
The first think I recommend you is to profile your code and get a clear idea of where is most of the time spent, if your time is mostly spent on gpu / draw calls then I don't think language is your problem.
Click to expand...
Click to collapse
This is exactly right, profile first and find out what is consuming the most processing time. Then from there you can determine if that component is something you can write natively in C and invoke from your Java code.
kamuikun said:
Hi everyone
I've been coding games in OpenGL ES 2, 100% in JAVA. My question : Will I have a performance boost (in FPS) if I coded some parts of my games in C++ ? Like the rendering part ect. Can I have an estimation ? (2x, ect.)
Also, C++ is compiled, so I suppose I will need to make 2 APKs, one for ARM and an other for x86 ?
Click to expand...
Click to collapse
It depends on your skills, I would consider to include shades rather than migrating to different language.
As others have mentioned.. maybe look at the way you are rendering or the shaders. On most Android devices now we have a JIT, this basically compiles sections of the Java code at runtime to the platforms native format.
Many times I consider switching to C++ but really cannot convince myself yet! The main benefits I see to it are:
- No garbage collector, so hopefully you can control your allocations more easily
- Platform independence, you can write most of your code in modules and keep non-platform specific parts away to make it easier to port later.
A lot depends on the quality of your Java code as well.
A big problem with doing graphics in Java is getting things smooth. If you create a lot of objects each frame, you will overload the garbage collector, and every few seconds, you will see a slowdown.
C++ won't suffer from this issue.
I have done a Java software rendering demo years ago (search for 'Croissant 9' on pouet.net), and spent a lot of time on minimizing the load on the garbage collector by re-using objects with a simple pool system, so that the demo ran smoothly throughout.
I recently tried to port it to Android, and found that Dalvik is worse at memory management than the JVMs I used 10 years ago when developing the original demo. Dalvik is also a lot slower. The original ran fine even on simple 1.6 GHz Northwood Celeron, easily 30-50 fps... A modern high-end Android phone should be faster, but the code runs with single-digit framerates.
So there's a lot to gain with C++ there.
But with hardware rendering, the bottleneck is not so much on the CPU, but on the GPU, if your code is designed properly.
As for APKs, I believe if you just add multiple platforms to your makefile, it will pack the multiple platforms into a single APK, and the proper code will get deployed on the device automatically.
I can confirm what many of the pro-C++ posts are saying, but I can also correct a few assumptions about Java development for OpenGL ES 2 targets.
I have decades of experience in C/C++, with targets ranging from 3D engines to robotics control systems.
Most of the high performance work you see on Android devices was written in C++, not Java.
There is very little if any benefit, contrary to the Android documentation, in mixing Java and C++ together. The JNI interface is a considerble bottleneck. If you're going to work in C++ for OpenGL ES 2 targets, you should work entirely in C++ - viewing the Java nature of Android applications as a necessary evil for getting I/O from touch.
There are a number of free C++ engines targeting Android. I can't heartily recommend them for you, but they exist as examples from which to base judgement. One that you can EASILY unpack and compare right now is GamePlay3D - from Blackberry (I know, it's a surprise source). With that, and the NDK, you can build 3D example games from the package and see for yourself what an all C++ development target does on your device.
Contrary to Google's claims, Java is slow by the standards expected from engineers familiary with C++ development. Little to zero can be done to change that. However, C++ is a complicated language to use effectively. The learning curve is steep, the potential perils are high and for Android it was an unwelcome, highly resisted addition to the platform (when the NDK was introduced). Since NDK 7 C++ has become a relatively first class member of Android development work, and virtually all high performance games use it for both portability and performance.
A lot of people seem to expect all kinds of magic performance improvements from going to C++, without realizing that their graphics coding might be sub-optimal. Too many state changes, too many draw calls, textures that are too big or shaders that are too complex, those are all quite common causes of slow graphics that are not going to be fixed by moving to C++.
Sure, if you really need every last bit of performance (and you know how to get it), go with C++. But given the power of todays hardware, most people should be able to get by just fine with Java.
It would be a different story if you're planning to port your stuff to IOS: then coding in C++ actually makes sense. I also do a lot of OpenGL stuff in C++; simply because it allows me to plug the renderer into a Qt application on the desktop, avoiding the upload to the device, and making debugging a lot easier.
BTW: the pain of writing JNI code can be eased a lot by using SWIG, which generates all the required wrapper code based on interface definitions.

Android Game C++ SFML or Android Studios Or C# Monogame ?

Hello all ^^
Am a rookie programmer, and i want to make an MMORTS game like OGame but for Android. I am good at Oracle, SQL, Java and about average at C++ (with little over 6 months training in my college)
so i got a question please forgive me if i said something wrong or ignorant, cause am still a rookie just starting into the world if programming
the game will be pretty much like Ogame but with little animations (u know like blinking lights on buildings and some very basic and simple ship battle animation). Other than that most of the game will be text based just like Ogame
build buildings
research tech
build ships
farm others
harvest resources
should i use C++ with SFML(Simple and Fast Media Library) or should i start with Android Studio ? Or C# And Monogame ?
the thing is i want to implement in app purchases and ads and premier memberships.
can i do that in a game written in C++ using SFML and ported to android platform? or am i better off using Android Studio cause it will be easier to incorporate them into my game using Android Studio.
my concern about using Android Studio is i dont see it having a good 2D library, or atleast a capable one like SFML and one of my seniors said 2D libraries in android studio are primitive and a pain to use
please suggest me which one to pick ?
we are a team of 2 members
am the programer and one of my friend who is a rookie designer

C++ Ide

Hey,
I use visual studio for programming in C++ and am interested in learning to develop for android. I have previously done so in eclipse but it has been 2 years or so and that was in Java. I am interested in programming in C++ and was curious what IDE y'all used.
Thanks,
Fish.
MrFish. said:
Hey,
I use visual studio for programming in C++ and am interested in learning to develop for android. I have previously done so in eclipse but it has been 2 years or so and that was in Java. I am interested in programming in C++ and was curious what IDE y'all used.
Thanks,
Fish.
Click to expand...
Click to collapse
I suggest you to use Qt
You can programing in c++ for android
If you're on Windows, Visual C++ isn't a bad choice (esp. the latest editions which include Android support!). But if you're on Linux and/or programming on both Windows and Linux, Qt Creator is my favourite by all means.
Personally, I prefer CLion by JetBrains (the company that creates IntelliJ and Android Studio). Although it is a commercial IDE, you can have free license for student or open source project.
THGDev said:
Personally, I prefer CLion by JetBrains (the company that creates IntelliJ and Android Studio). Although it is a commercial IDE, you can have free license for student or open source project.
Click to expand...
Click to collapse
CLion is amazing! It works really well with Rust plugin too.

Categories

Resources