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

(This post was last modified: 07-28-2016, 10:54 PM by skunkbad.)

So this week I have officially been given the task to start making an Android app for the company I work for. If you've never done such a thing, Android seems like a strategy for Java programming. Holy moly, it's so different than PHP. I'm so glad I have a good grasp on PHP OOP, because it has really helped, but Java seems so much harder to get simple things done. 

For instance, in PHP we have file_get_contents(), which is usually a one liner for getting some sort of file contents, maybe even a URL. Try to do a simple HTTP GET request in Android/Java and you're talking about writing like 20 lines of code.

In PHP or HTML we can switch "pages" by simply linking up another file. In Android/Java this is a whole different concept, where you're just showing another "Activity" that you eventually quit to go back to the main "Activity".

Another thing that really takes some getting used to is that Java has checked and unchecked exceptions. In PHP exceptions are not something that you have to use, but can if you want to. In Java you can be forced to implement try-catch blocks. I can see how this is a good thing, but it's much more strict.

So the whole time I'm thinking how blessed we are to have PHP. It's just so so easy. I think I will always love it for being that way. I'm starting to like Java, but it sure is different. You can have classes inside classes in Java. It has no associative array like we are used to though, and that's a big bummer.
Reply
#2

I know java, I tried it before.
Are you using spring as the framework of your java?
Or just plain pure java codes?

Yes php is really awesome because you can write lesser codes than java.
Java is ancient lol, but it has all the features of a matured language.
Reply
#3

Sometimes I'm thinking why they called JAVA a matured language even though it's hard to code using it... lol
Reply
#4

You don't have to use Java to create a native android application.
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
Reply
#5

@albertleao
thanks for letting me know.
I tried java, but did not tried developing native android app.
Reply
#6

(07-28-2016, 11:56 PM)iridion2015 Wrote: Are you using spring as the framework of your java?
Or just plain pure java codes?

I just downloaded and am using Android Studio:
https://developer.android.com/studio/index.html

(07-29-2016, 12:53 AM)albertleao Wrote: You don't have to use Java to create a native android application.

Tell me more. I've seen that one can use C or C++, but I've played around with those in the past and Java is easier for me.

Remember, I've only been doing this for less than a week, so I do appreciate any tips you've got.
Reply
#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
#8

Or build hybrid apps using ionic.
Keep calm.
Reply
#9

(07-29-2016, 09:25 AM)mwhitney Wrote: ...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.

In our situation the app that I'm building is for internal use. Although our normal website is responsive, and authenticates users, the company owner wanted to have the app because it's not web accessible, yet allows employees to be out in the field and do stuff. Sure, we'll still have interactions with the website via an API, but the interface won't be web accessible.

I'm having a bit of fun with it, and yesterday learned about Java generics, which are pretty cool. I sure wish I had a mentor, or somebody that I could actually sit down with who could show me stuff, or explain stuff to me. I'd even be willing to pay for some time with somebody, because I'd like to supercharge my learning experience. This week I easily spent 40 hours just learning, so I think in a week from now I should be making some real progress.

Thanks for the reply. Good stuff.
Reply
#10

I prefer to use C# instead of Java when writing a native android app, C# is close to PHP OOP. hopefully PHP will improve its "General Purpose Programming Languange" not only for the server side but also in Client Side. I'ved tried native client side of PHP in Visual Studio (Phalanger) it is very easy to use and you feel that you are just developing another site Smile with drag and drop textbox, buttons, controls, etc. hopefully PHP will be sooner used by big companies like banks. It really made Programming very simple.
God Bless CI Contributors Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB