[Q] C Kernel vs Java Applications - Asus Eee Pad Transformer Prime

Kind of off topic, but does anyone know why applications are written in java when the Kernel is written in C? It seems to me that if the applications were directly written in C, it would save the machine some effort in translating java code into bytecode as well as increase program speeds?

For a developer writing something in C is a lot harder and takes a lot longer than writing the equivalent in in Java, plus afaik a lot of the Google APIs are not available in C.
For an analogy do you think the average writer would you rather hand write a 500 page book or use a computer to accomplish the same task.

Ah gotcha... that makes sense. Thanks

It is possible to program for Android using native code (C/C++):
http://developer.android.com/sdk/ndk/index.html

foboi1122 said:
Kind of off topic, but does anyone know why applications are written in java when the Kernel is written in C? It seems to me that if the applications were directly written in C, it would save the machine some effort in translating java code into bytecode as well as increase program speeds?
Click to expand...
Click to collapse
Also Java comes with lots of protection for the end user. Since its running in a jvm it gives good system protection from an application bringing down the entire system(think of BSOD in windows). It also does a great bit of memory management with its built in garbage collecting. With c you have to do all this memory management yourself and can be quite difficult to do 100% correctly, especially with complex applications, causing memory leaks. Yes it does add some overhead with the jvm running but with the power of today's devices it is negligable.
Sent from my Transformer Prime TF201 using xda premium

Related

[Q] learning how to develop apps

i want to start making apps for android but dont know where to stat i have the sdk on my desktop but thats about it. If someone could please help me or push me in the next step please do so.
Just go to the dev guide on the Android website to start making your first Hello World app. As for language, Android (I could be wrong) uses Java. Again, I could be wrong.
Sent from my GT-I9000M using XDA App
Indeed, Android uses Java. I'd suggest learning it before attempting to program for Android or else you'll feel like it's gonna be too difficult. There's plenty of books on Java, and some powerful Google searching will lead you to step-by-step guides to learning Java.
Also, go through the Android Dev Center for a lot of information. There's plenty of guides there on things like 'how to design your app to flow with the overall android feel' and 'designing icons to fit general android homescreen look'.
You're gonna want to download Eclipse for Java Programming. It's a free Java development environment much like Dreamweaver and Visual Studio are for web development.
Oh, and PLAN! Like any good development project, your project will not get anywhere if you don't know where to start and when to end it.
Plan first. Then plan the planned elements. Java is object-based programming, and just like building a house each object needs to be solid or else it'll crumble to pieces.
Same here. Thx for the advice.
elindemann said:
Indeed, Android uses Java. I'd suggest learning it before attempting to program for Android or else you'll feel like it's gonna be too difficult. There's plenty of books on Java, and some powerful Google searching will lead you to step-by-step guides to learning Java.
Also, go through the Android Dev Center for a lot of information. There's plenty of guides there on things like 'how to design your app to flow with the overall android feel' and 'designing icons to fit general android homescreen look'.
You're gonna want to download Eclipse for Java Programming. It's a free Java development environment much like Dreamweaver and Visual Studio are for web development.
Oh, and PLAN! Like any good development project, your project will not get anywhere if you don't know where to start and when to end it.
Plan first. Then plan the planned elements. Java is object-based programming, and just like building a house each object needs to be solid or else it'll crumble to pieces.
Click to expand...
Click to collapse
Actually, you're doing things the hard HARD ...HARD way....
if you want to develop apps for android, Titanium Mobile (appcelerator.com) is the best way to go. It takes far less time to learn JavaScript , CSS and HTML then it does to learn pure JAVA, and then learn to implement Android's API.
There are a few things that Titanium Mobile can't do, but they are always working on it to make it better. And of course - it's free
I've made a few apps using it. Including an HTML eBook reader, Chinese Flashcard App, and a Simple Chat Client.
Their JavaScript API takes a bit to get used to, but after that, you can easily spit out a simple app in about a day or so.
I have a web-app Template that lets me dump a Web-app (html/css/js) into a project, and spits out a nice new shiny Android app ready for the market.... I also wrote code that lets you access the Menu Button on android too. So it's not like using PhoneGap where it's just a Browser session with an icon on your phone.
PM me if you're interested, and i'll show you everything i learned about Titanium Mobile so far (i'm still learning actually). Or if you want an app done, i can do it for you... free if it's easy enough
DaoMingJin said:
Actually, you're doing things the hard HARD ...HARD way....
if you want to develop apps for android, Titanium Mobile (appcelerator.com) is the best way to go. It takes far less time to learn JavaScript , CSS and HTML then it does to learn pure JAVA, and then learn to implement Android's API.
There are a few things that Titanium Mobile can't do, but they are always working on it to make it better. And of course - it's free
I've made a few apps using it. Including an HTML eBook reader, Chinese Flashcard App, and a Simple Chat Client.
Their JavaScript API takes a bit to get used to, but after that, you can easily spit out a simple app in about a day or so.
I have a web-app Template that lets me dump a Web-app (html/css/js) into a project, and spits out a nice new shiny Android app ready for the market.... I also wrote code that lets you access the Menu Button on android too. So it's not like using PhoneGap where it's just a Browser session with an icon on your phone.
PM me if you're interested, and i'll show you everything i learned about Titanium Mobile so far (i'm still learning actually). Or if you want an app done, i can do it for you... free if it's easy enough
Click to expand...
Click to collapse
Wow, I'm very interested. I might check it out.
sent from my pimp hero running Froyo CM6 and the XDA app
If you know the C or C++ language you could try out MoSync, depends what you like, some programmers like the level of control and speed you get from C++. If your content with simpler apps then maybe phonegap or appcellerator for you.
I guess that when mobile apps get more sophisticated javascript programs will be just as complex as C++ programs.
Thats my view, but then I like C++ better.
/Tony
MoSyncTony said:
If you know the C or C++ language you could try out MoSync, depends what you like, some programmers like the level of control and speed you get from C++. If your content with simpler apps then maybe phonegap or appcellerator for you.
I guess that when mobile apps get more sophisticated javascript programs will be just as complex as C++ programs.
Thats my view, but then I like C++ better.
/Tony
Click to expand...
Click to collapse
It really depends on how much control and you really need. If you're going to write games, then you do need speed that C++ and the Native Application Development API on android can give you. If you're writing a social networking app, the speed of C++ would really be an overkill.
As far as i've read, PhoneGap still has a lot of issues. And the build process is a bit more complicated than on Titanium Mobile.
If you're just using the regular Android API to write apps, i don't notice a lot of difference in speed execution between writing it in pure Java, or using Titanium mobile (using native code and UI elements - i don't mean putting everything into a WebView).
The current app that i'm writing now i don't think can be written using Titanium Mobile or PhoneGap (unless i added some native functions and did my own fork of PhoneGap).
More or less, i'm writing an App for Android and JRE/Linux systems that will allow me to enumerate, and access USB status bits, and USB data frames of a given USB device, and then allowing that USB device to be accessed through a TCP or UDP connection.
I might be able to do this with Titanium Mobile, but i don't think i can. As the only files you're allowed to access are on the SD card, application data directory, and temp directory.... i think there's one other place you're allowed to access too, but i never used it. However later today i might just try to see if i can access the /Dev/DSP01 (aka sound card) on an android device. If i can, i think i could write it using titanium mobile. I'm already halfway done with this app in pure java, so i wouldn't actually rewrite it in Titanium Mobile now.
DaoMingJin said:
if you want to develop apps for android, Titanium Mobile (appcelerator.com) is the best way to go.
Click to expand...
Click to collapse
Thanx mate!
If you looking a book or something to teach you the basics Beginning Java Programming for Dummies and Android Application Development in 24 Hours are good reads.
I'd rather not fill the forum with more threads so I'm just going to ask my question here. What is the best way to read the android dev guide on the device itself? Just going to the site directly? Ideally I'd like a pdf or something designed to be read on a small screen. The site can have formatting issues when read on a small screen.
Sent from my SPH-D700 using XDA App
I've been developing for a long time (nearly 30 years), and whenever I need to learn a new language I start with the Sams range, "Teach yourself whatever language in X days/hours". They're pretty good and this is available for Kindle, which is great if you use the Amazon Kindle app...
http://www.amazon.co.uk/Teach-Yours...1_fkmr2_2?ie=UTF8&qid=1287485537&sr=8-2-fkmr2
It obviously costs, but I really do rate those books as brilliant starting points. The rest is google and friends on here.
Hope this helps - good luck mate.
Personally, I've been coding in Java for what... four years now? I'm feeling dwarfed here by johncmolyneux but honestly, the best way to learn is to not use an IDE like Eclipse, but to use something that you have to hand-code everything yourself, such as Geany! You learn fairly quickly after writing a few applications.
If you are thinking "titanium", "mosync" or "phone gap" it is worth doing a bit of background research. There are several extremely powerful tools out there that can help you build cross platform apps - these are among the top ones.
bit more discussion about this here: http://forum.xda-developers.com/showthread.php?p=16703287#post16703287
There are a few useful reports comparing them - check out ours by googling "triballabs cross platform"
The Google App Inventor makes it pretty easy to create your own Android apps. Best part is you don't need to learn any programming languages. You won't be creating anything too complicated like a video game for example, but it's a good start nonetheless.
http://appinventor.googlelabs.com/about/
If you want to learn the basics of Java, then please check out a book called as "Head First Java". They really explain the basics with the help of real life examples to make things much simpler so that people understand.
Beginner app projects
I'm also just getting started with app development. Something I've been looking for is a beginner app project. Wish I could find a walkthrough of a simple app like a game of Hangman or something like that. I've been through the android developer training web site and got some good info but some things I'm still a little stuck on. Id Love to see an actual app (rather than just a mock up of some fields and buttons) and then a slightly dumbed down explanation of the code. Might be a lot to ask but man it would be great!

[Q] Full Java Virtual Machine - Is it a possibility?

So if this is a stupid question - please be kind.
It seems the Prime has the power to run the full Java instead of the phone based version.
I noticed this the other day when I was trying to run a java video app from within BlackBoard for one of my assignments. I just get a bunch of symbols at the top of the frame and it extends the screen endlessly to the right.
So is adding the full java something that can be done in a new firmware update or be a part of a rooting package of the future? It sure would be nice to take advantage of the power of this tablet by adding the upgraded java.
Thoughts? Suggestions? Am I crazy?
Dalvik is a full JVM, it's just that Android doesn't implement a lot of the Java libraries dedicated to writing desktop apps. It might not be too much work to get, e.g., hidden Java applets running. It would be a lot of work to get Java applications with graphical interfaces working.
I think it'd be cool to run a Minecraft server off my tablet... but that's just me.
Noxious Ninja said:
Dalvik is a full JVM, it's just that Android doesn't implement a lot of the Java libraries dedicated to writing desktop apps. It might not be too much work to get, e.g., hidden Java applets running. It would be a lot of work to get Java applications with graphical interfaces working.
Click to expand...
Click to collapse
But this tablet has the horsepower to run it if it were done, correct? I'm just thinking quad core tablet- a GB of ram. Seems like a ripe apple for the developers to add something a little more tricked out in the software now that there is hardware that would support it.
Of course I am not a developer, but my understanding is java is scaled back due to hardware limitations. The Prime is a beast of a tablet. What would it take for this to happen?
redraider II said:
What would it take for this to happen?
Click to expand...
Click to collapse
A lot of time and money? Months of work at an absolute minimum. I don't know all the missing APIs, but at least pretty much all the graphics stuff from desktop Java is missing on Android.
Noxious Ninja said:
A lot of time and money? Months of work at an absolute minimum. I don't know all the missing APIs, but at least pretty much all the graphics stuff from desktop Java is missing on Android.
Click to expand...
Click to collapse
Oh crap. Well..... I suppose that hope just went out the window.
I am happy with the Prime as it is. I was just curious about the possibilities of taking it to the next level java wise now that there are devices capable of running it.
I see you are in SA, Noxious. I'm just up the road in Austin. Have to come down there every other month or so to Methodist Transplant hospital. Had a liver transplant almost 5 years ago now. Graduated from Judson.
Thanks for your replies.
RedRaider II
You can run Java SE and even a JDK but you lose Android integration. Example: I have JRE/JDK and most of the Android SDK running on mine, in a Debian chroot. All I am missing seems to be a couple x86 C/C++ programs that I don't know where to find the source for, otherwise I could get them ported to ARM and do Android development on my tablet with the usual build system (not what terminal ide does).
But note that if you want to do GUI crap in Java, like AWT/Swing/JWT, then you need the x11/vnc stuff or to push the built code to another machine you can remote into. Running headless Java code is also possible via dalvik (just like the Android SDK does for what goes into .apk files) in some cases but I would not want to test complicated parts of core libs and classpath dancing.
Sent from my Transformer Prime TF201 using Tapatalk
Run Linux (ARMel or ARMhf) OS ontop of Android and run "ARM_Linux_Moder" from the following link after cloning it to the Linux file system
https://github.com/S0AndS0/Debian-Kit-Mods
Full directions are in readme file and I've a guide on xda and google docs to set up Linux on Android using Debian Kit.
Currently you can run JDK hard or soft float on Android and run almost any .jar file or java program that runs on PC Linux OS's using the scripts provided and install Java dependent software I've tested and scripted installers for.
I'll be working on Android SDK and NDK soon.
Sent from my SPH-D700 using xda app-developers app
Khyrdantai said:
I think it'd be cool to run a Minecraft server off my tablet... but that's just me.
Click to expand...
Click to collapse
I think it would be great too

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.

C++ For Android?

Hey all,
I'm pretty new to android development and I was curious if anyone could tell me the benefits of learning C++ alongside Java (specifically while working with Android).
My first project that I'd like to accomplish seems a little arduous, though I do have help. I'm attempting to create an app that is used to catalog clothes, but also parses image data to detect the colors. In this way, it will be (hopefully, by some means) possible to have the app help match the clothes for the user. The inspiration for this is my extreme colorblindness.
Anyone who potentially has feedback regarding interpreting data from the camera on Android, feel free to pitch your two cents.
Read this. May help you. http://forum.xda-developers.com/showthread.php?t=2225668
Sent from my SonyX8 using Tapatalk 2
ScatteredHell said:
Read this. May help you. http://forum.xda-developers.com/showthread.php?t=2225668
Sent from my SonyX8 using Tapatalk 2
Click to expand...
Click to collapse
Thanks so much!
Sent from my HTC One using xda app-developers app
not sure you need c++ for your project
My experience with C++ (using Marmalade) is that if you need a lot of UI, than you are better off with the Java framework. Designing UI with Marmalade is a real pain. It's great for power hungry games and apps, but not for UI.
If you absolutely need to use C++, my advise it to start with the native Java and NDK, and only if you're not satisfied, look elsewhere. Even in Marmalade, which is supposed to be cross-platform, you will reach the point, too quickly in my opinion, in which the SDK doesn't give a cross platform solution to what you want (say use a downloaded third-party sdk, or request some OS function that the SDK does not offer), and you will have to implement specific OS "EDKs", so will have to know your native coding anyway.
Hi,
you should try Qt, though you need the android sdk/ndk, Jdk and Ant as well, but it works.
jrdemasi said:
Hey all,
I'm pretty new to android development and I was curious if anyone could tell me the benefits of learning C++ alongside Java (specifically while working with Android).
My first project that I'd like to accomplish seems a little arduous, though I do have help. I'm attempting to create an app that is used to catalog clothes, but also parses image data to detect the colors. In this way, it will be (hopefully, by some means) possible to have the app help match the clothes for the user. The inspiration for this is my extreme colorblindness.
Anyone who potentially has feedback regarding interpreting data from the camera on Android, feel free to pitch your two cents.
Click to expand...
Click to collapse
Get a book from fipkart to lear this. "Android Devlopment"
jrdemasi said:
Hey all,
I'm pretty new to android development and I was curious if anyone could tell me the benefits of learning C++ alongside Java (specifically while working with Android).
My first project that I'd like to accomplish seems a little arduous, though I do have help. I'm attempting to create an app that is used to catalog clothes, but also parses image data to detect the colors. In this way, it will be (hopefully, by some means) possible to have the app help match the clothes for the user. The inspiration for this is my extreme colorblindness.
Anyone who potentially has feedback regarding interpreting data from the camera on Android, feel free to pitch your two cents.
Click to expand...
Click to collapse
I would choose for this between two options: develop entirely in Java except for the portions that are computationally heavy, which can be implemented in C/C++ using JNI glue code. Or you may implement everything using a C++ based framework, like Qt, both for the creation of the UI and of the rest of your application. With Qt of course, the specific UI portion can be written using QML, which might be faster.
const_char said:
I would choose for this between two options: develop entirely in Java except for the portions that are computationally heavy, which can be implemented in C/C++ using JNI glue code.
Click to expand...
Click to collapse
I second this, with the sidenote that you should only use C/C++ if the computationally heavy code is actually time-critical.
I mean, at first glance, your project sounds like it won't be very taxing on the CPU anyway. So having a full Java version may still be fast enough, and the user wouldn't even know the difference. In that case C/C++ is not worth the trouble (JNI is very ugly, and you shouldn't use it unless you really have to).
C++
I think C++ is not for suitable for this application. Although i did not use it. But you may first take some tutorial then you can start. When face problem then discus this forum. I am sure somebody may help you.
Sorry for my English.
Thank you
you can get pixel color use this sample code.
jrdemasi said:
Hey all,
I'm pretty new to android development and I was curious if anyone could tell me the benefits of learning C++ alongside Java (specifically while working with Android).
My first project that I'd like to accomplish seems a little arduous, though I do have help. I'm attempting to create an app that is used to catalog clothes, but also parses image data to detect the colors. In this way, it will be (hopefully, by some means) possible to have the app help match the clothes for the user. The inspiration for this is my extreme colorblindness.
Anyone who potentially has feedback regarding interpreting data from the camera on Android, feel free to pitch your two cents.
Click to expand...
Click to collapse
you can get pixel color use this sample code.
String imageUrl = SOME_IMG_URL;
InputStream in = new java.net.URL(imageUrl).openStream();
Bitmap bitmap = BitmapFactory.decodeStream(in);
int pixel = bitmap.getPixel(x,y);
and.
int red = Color.red(pixel);
int blue = Color.blue(pixel);
int green = Color.green(pixel);
you can get average color value of SOME_IMG and you can catalog this.
it seems easy!

Coding languages

Hi guys, can anyone explain to me why you can have different coding languages? I am going to try and explain it the best way possible. Pretty much I want to know why some people use other coding languages instead of others? Are some better for particular activities? Like I know cross compatibility like you can't use html to code a game online you need to use Flash or Javascript etc.
tl;d why use one language over another?
Every programming language has advantages and disadvantages. For example Java is portable but slower then, let's say, C++. C++ is less portable and needs to be compiled seperately for every OS but it's faster. Python is very easy and very portable but it's slower then Java. Html, Javascript and Go are for websites. PHP is designed for the use with databases. Prolog uses a completely different approach and is good for logical stuff.
You see, (almost) every language has its own field of application. Additionally, everyone has a favorite language for whatever reasons (e.g. because he thinks the code is pretty). So it's a matter of taste as well.
nikwen said:
Every programming language has advantages and disadvantages. For example Java is portable but slower then, let's say, C++. C++ is less portable and needs to be compiled seperately for every OS but it's faster. Python is very easy and very portable but it's slower then Java. Html, Javascript and Go are for websites. PHP is designed for the use with databases. Prolog uses a completely different approach and is good for logical stuff.
You see, (almost) every language has its own field of application. Additionally, everyone has a favorite language for whatever reasons (e.g. because he thinks the code is pretty). So it's a matter of taste as well.
Click to expand...
Click to collapse
Thanks for the high quality response.
As a beginner, someone who wants to start developing android applications..What coding language do you think I should start with? I understand android is basically Java?
Blakebn2012 said:
Thanks for the high quality response.
As a beginner, someone who wants to start developing android applications..What coding language do you think I should start with? I understand android is basically Java?
Click to expand...
Click to collapse
Well, it's Java with some extra stuff. That's why I would recommend starting with Java. It's portable, object oriented and you'll need it for Android later anyway.
When I learned Java, I used the Head First Java book which I can highly recommend.
Ok thank you very much you have been a great help.
Blakebn2012 said:
Ok thank you very much you have been a great help.
Click to expand...
Click to collapse
You're welcome.
There's different languages for different things, like Java vs. C++ (Java is portable/cross-platform, pure object-oriented, has automatic garbage collection, etc; C++ is platform dependent and needs to be compiled on each environment, wasn't built from the ground up as OO, you need to allocate and manage memory yourself, etc. Java isn't quite as fast/efficient as C++ but it's come a long way from it's beginnings and is pretty close now, for desktop apps IMO anyway.
Then, for web development, there's Python and PHP. Both accomplish the same thing (doing back-end logic for websites, like querying databases so the data can be displayed on the page) but have different syntax. People like either one for different reasons and it's mainly just personal preference when it comes down to those.
So to answer your question, the difference between some languages is pretty great (like assembly and C#) and they're used for different purposes. And the difference between others, like PHP and Python, is for the most part superficial and it's just personal preference between the two.
The main reason we do have programming languages is that working directly on the bare hardware is pretty difficult. Working directly with machine code is difficult in many ways: it is hard to be kept bugfree, even harder to be read and understood, and there is also the problem that it's only working on a specific machine. Programming languages cope with those problems by introducing programming paradigms, which make several things easier, but it turned out that there is no paradigm which covers all needs. C/C++ for instance makes it possible to work pretty close to the machine while producing quite readable code, which can be ported easily from one plattform to another (compared to using assembly language). In contrast Java introduces a Virtual Machine on top of the actual system such that it's even a lot easier run code across several systems (compile it on one machine, run it everywhere ... as long as a JVM is available), and it brings the object oriented paradigm with it. Furthermore there are declarative languages for database programming, functional programming languages or logical programming languages for mathematical problems around, and so on ... . Sometimes you might not be interested in writing understandable portable code, such that assembly language is your best pet, but that's most probably not true in most situations.
123123132
Really good compact responses. I also want to recommend learning some shell programming, i.e. linux terminal programming for file/process management and low-level hardware manipulation in the kernel. Shells are usually mksh, zsh, bash, busybox ash, or symbolically linked to sh. This is known as a scripting language because you can run your programs/scripts on-the-fly without any compiling. Adding some shell scripts to your java app can make it very powerful such as with apps like trickster, synapse, performance control, etc., .. basically any kernel/hardware control apps.
Also you can try Ruby language. Its great for some everyday tasks, very simple and powerful(especially string processing). Also Ruby On Rails is very simple framework for web-developing. A week and you can try to code your own github. And the IRB console is good enough. But i duuno, is there any mobile-app-dev modifications of Ruby. Anyway, its still great enough.
Blakebn2012 said:
Hi guys, can anyone explain to me why you can have different coding languages? I am going to try and explain it the best way possible. Pretty much I want to know why some people use other coding languages instead of others? Are some better for particular activities? Like I know cross compatibility like you can't use html to code a game online you need to use Flash or Javascript etc.
tl;d why use one language over another?
Click to expand...
Click to collapse
That would be perfect, if we lived in a place where only one language is enough for all works XD
However, the really life isn't perfect.
Some works need complicated language to achieve and some don't.

Categories

Resources