9

Having been programming in PHP for a year, I now want to start learning Java. I am in a Windows environment.

I want to develop a GUI with Java that would query a MySQL database. I know I would use JFC to accomplish this, but my questions are:

  • Will it be difficult to adapt to Java?
  • Do I benefit for learning Java because I know PHP?
2
  • 1
    If you're developing GUIs for windows, you're better off with C#, its syntax is very similar to this of Java, but it does more than Java ever could on windows. Commented Jun 2, 2011 at 23:48
  • 1
    Also check out this question: programmers.stackexchange.com/questions/81875/… Commented Jun 6, 2011 at 18:14

3 Answers 3

9

Learning programming is much harder than learning any particular programming language. So, it will not likely take you nearly as long to become productive in Java as it did to become productive in PHP (if that was your first language). One piece of advice: You need to try and learn "the way" of Java - not just its unique syntax and libraries but also the conventions of the Java development community.

I think what you may find more challenging than the difference between Java and PHP is the difference between web and desktop programming.

2
  • 3
    "Learning programming is much harder than learning any particular programming language. " -- agree totally, but, consider also that Java and PHP have very different models -- PHP is a scripting language strongly tilted toward web development, while Java is a general-purpose OO language. Commented Jun 3, 2011 at 0:17
  • 1
    Do you have good pointers on learning "the way" of Java? Commented Sep 5, 2012 at 7:11
2

I hope this is a coherent response...

You should not encounter too much difficulty learning Java if you already a solid foundation in the fundamental aspects of programming. There are some idiosyncrasies of PHP, however, that you need to be sure to look past when moving to another language.

Java is deeply object-oriented, and the Java development "culture" subscribes deeply to OO methodologies. PHP's OO was an afterthought added on, and is only beginning to fully mature. The PHP "culture" sometimes tends to care less about deep OO hierarchies because the language doesn't encourage it. PHP code tends to be an inconsistent mix of procedural and OO code, wherever the two are best suited. (This is not a criticism; PHP is my primary language these days too)

My suggestion would be this: Approach Java as though you are learning programming anew, though you already understand the important and fundamental flow control structures and atoms. Do not attempt to write Java code like it is a PHP web application, where the language sort of encourages a linear and procedural program flow. Use the time you spend learning Java to develop a strong sense of OO hierarchy and application architecture that you can spend years coding PHP without having to worry too much about.

1
  • while your answer certainly holds true for legacy code, most of the really good, modern frameworks and packages are entirely OOP. PHP7 is very OO based and includes many java-like features. PHP is rapidly becoming very much like Java. We have classes, interfaces, abstract classes, traits, inheritance (though not multiple..) and even strong typing if you want it now.. Commented Oct 10, 2016 at 15:07
1

It certainly depends on what kind of app you are talking about. To get a basic "hello world" CRUD app with Java and MySQL up and running, you really should not have much trouble at all.

PHP might help a bit, but for the type of starter app you would be building at first, you should be able to do it just fine and learn a bit along the way.

2
  • More specifically, the features of the app would be: Search, and display data in the GUI. All the data would come from a Mysql database. I want to use this Java app to manage a website of mine. Commented Jun 2, 2011 at 20:47
  • @Ryan So why not to create a private web-based panels that only you can use? since you already know PHP. Why to spend too much time learning Java and Swing? Commented Jun 2, 2011 at 22:36

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.