Welcome Guest, Not a member yet? Register   Sign In
How easy PHP is
#7

Using Java in Android is also very different in some ways from using Java for other platforms. Most of my limited Java experience happens to be with Android, but it has been a long time since I've had to use it.

Most of what you're noticing is the difference between web programming and programming for other platforms, or, in other areas, what sometimes is referred to as the difference between scripting (or interpreted) languages and compiled languages (though the lines between the two have become increasingly blurred). An app written for Android in Java is going to run until the user terminates it or the device is restarted and will handle most of the user's interactions itself. A web application is usually more of a partnership between the web server and the script in which the web server determines how the requests are processed and manages many interactions behind the scenes, then calls the script to deal with specific requests, passing data to the script when requested, and passing the script's response back to the user. In most other environments, your application has to play both parts. In some cases, application frameworks or even IDEs can hide some of the details and make the two experiences somewhat more similar, but, in the end, the lifetime of the application and the management of state and data is usually very different.

Files are one of those cases in which you're experiencing a combination of differences at once. First, you have to pre-define all of your variables using the correct types, which can add some code to the process (but prevents you from accidentally creating variables or using variables of the wrong type), which is a common requirement in compiled languages (but not all of them). In Java you can use Files.readAllBytes() or Files.readAllLines() to do essentially the same thing as PHP's file() to access the contents of a small file as an array, but I'm not sure whether there's a built-in method to read the contents of a file as a string (it is very common in most of the programming languages I've used to read files in a loop rather than extracting the contents to a string, most will encourage use of a Stream for efficiency with large files). Android has extra considerations, since your application has to have permission to access the filesystem, you may have access to internal or external storage, and you have a distinction between files which are shared between applications and those which are specific to your app.

In many cases with languages which were designed with OOP in mind, it may be slightly more complicated to perform simple operations, but the abstractions which make the simple operations more complicated also make more complicated operations simpler. There is also the assumption that the developer can create their own classes to simplify those operations when it's appropriate to do so.

I haven't used the Spring framework, but it appears there is a Spring for Android: http://projects.spring.io/spring-android/

I honestly don't think most of the alternatives to using Java or worthwhile unless it fills one of these conditions:
- you can utilize your existing website to handle most of the work,
- you can utilize a language with which you are more familiar, or
- you need to support Android and iOS with very limited resources (you have a very small development team or are the only developer).

In small teams, I usually think it's better to forego mobile apps completely and just focus on good, responsive web applications. There are exceptions, but those are becoming fewer and further apart as HTML5 and various web APIs mature.
Reply


Messages In This Thread
How easy PHP is - by skunkbad - 07-28-2016, 10:44 PM
RE: How easy PHP is - by iridion2015 - 07-28-2016, 11:56 PM
RE: How easy PHP is - by iridion2015 - 07-29-2016, 12:14 AM
RE: How easy PHP is - by albertleao - 07-29-2016, 12:53 AM
RE: How easy PHP is - by iridion2015 - 07-29-2016, 02:47 AM
RE: How easy PHP is - by skunkbad - 07-29-2016, 06:41 AM
RE: How easy PHP is - by mwhitney - 07-29-2016, 09:25 AM
RE: How easy PHP is - by skunkbad - 07-29-2016, 12:50 PM
RE: How easy PHP is - by arma7x - 07-29-2016, 09:42 AM
RE: How easy PHP is - by marksman - 07-29-2016, 06:50 PM
RE: How easy PHP is - by Call-Me-Captain - 07-31-2016, 12:54 PM
RE: How easy PHP is - by albertleao - 07-31-2016, 01:54 PM
RE: How easy PHP is - by johnsmith - 09-16-2016, 08:47 AM
RE: How easy PHP is - by AmarInfotech - 09-21-2016, 01:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB