How to master java and ruby fastest for a PHPer? - java

I've been using PHP all the time.
Any advice to taking on these two languages?

I would say it really depends if you're used to the way OOP (object oriented programming) works. If you're not familiar with this way of thinking I would definately go with the book "Objects First With Java". It might look really, really basic at first, and you might be able to skip the first chapter or two. But if you read it from chapter 2 or 3 or so and finish it, you should have a good amount of knowledge to start building applications.
It's a little hard to help here because I don't know your level of skill when it comes to OOP. :) I've been writing PHP for a long time and didn't know a thing about OOP until I read the above-mentioned book.
All the best,
Bo

The same way you learned PHP - read the documentation, write some code, compile or execute it, debug it. Repeat until you are good. But don't expect to master a language quickly - anyone can learn to write code in a given language, but it takes time and effort to actually write good, high quality, and idiomatic code in that language.

The way I learn new languages is to read the documentation and other people's source code. It really helps to see what is possible in the language, without having it all wrapped up in academic speak.
Books are also helpful, if you have the time/patience to read through them.
A really good idea is to look up programs written in those languages and see if you can write the pseudo code for the programs. Then compare those to the source code and see what the difference is.

The best way to learn Ruby and/or Java is to forget the "PHP way" and to tackle each new language under their own idioms.
Both Ruby and Java have a fair selection of books (dead tree, electronic, free and non-free) as well as numerous free online tutorials. Ruby even has a nifty online interactive tutorial by _why (you did search didn't you?).
Learning the basic operation and syntax of each language is essential to avoid wasting time with random guessing as to why X doesn't work like Y. (Hint: If X doesn't work like Y, it's because X isn't Y.)

Trying to learn two languages at once is probably not the best idea. Ruby is quite similar to PHP, so the transition may be fairly simple, depending on your prior experience with other dynamic languages. You may find this site useful: http://railsforphp.com/

I recommend you try and build basic applications. Have a target, use the documentation and search the blogs or ask somebody if you're stuck. That's how I learned Ruby.
Also, for Ruby and Rails documentation I like APIdock, too bad they don't have Ruby 1.9 (which I recommend you use).

Click this: code-golf
Then solve all the challenges that got at least 10 upvotes in both Java and Ruby. Don't worry about the golf-scoring part, just do the best you can. If you post your efforts you may get some feedback, and you can compare your results with others.

Keep it enjoyable and simple at first. Use the learning style that works for YOU. If you like reading docs - great, otherwise you'll just end up with a nasty aftertaste. I'll say keep it enjoyable again because your initial exposure/experience can be greatly influenced by how you hit it off with a new language. Try to approach it from an angle of familiarity, you will find that there's some overlap between what you know and the new material. It will help if you can introduce the new stuff with as much ease as possible.
Recall what speaks to you or demonstrates most effectively when you learn and plot your course based on that. If you like books, find one that suites your style. Most of the books will give you most of the same information so what will make the most difference in a case like this is style of the book. For me "Java Objects" by J. Baker did the trick, my friend swears by "Thinking in Java". ... or find some screencasts if you like screencasts.
Then of course fire up the debugger and step though some code, but what ever you do first make sure you're enjoying it.

Start with Ruby. There is a wonderful online tutorial that lets you try Ruby right in your browsers. It covers the essentials of flow control and collections.
http://tryruby.sophrinix.com/
Java and PHP have more in common syntactically than Ruby and PHP. Sometimes that makes it harder instead of easier when learning a new language. That's why I think learning Ruby before Java will help. Ruby is also a lot easier to learn than Java, so the emotional return is greater and you'll be more equipped for Java.
As to learning Java, start with a Tutorial using Tapestry. Not so that you learn Tapestry, but so you gain the benefit of rapid development.
"Java developers love it because they can make Java code changes and see them immediately ... no redeploy, no restart!"
The down side to Tapestry is potential mess of setting up Tomcat.

I'd recommend getting yourself familiar an IDE (i.e. Eclipse) and working through some basic HelloWorld-esque problems. This will let you understand the lifecycle of a java program and some basic I/O. Maybe even take parts of a PHP project you've written and port it over to Java to get the basic syntax ideas down.

Related

Is it appropriate to learn and use the ACM package for JAVA?

Right now I'm watching the Stanford's channel in youtube, and to be precise I'm watching the Java lectures by Professor Mehran Sahami. I already have some level of theoretical knowledge of Java but I find these lectures very interesting but there's one thing that confuses me and I want to clarify it before going any further.
In the examples there are a lot of differences from what I've seen so far in the books I've read and even in the original documentation of Sun. In these lectures the main method is as it seems public void run() insted of public static void main(String[] args). For console output he uses only println() instead System.out.println() and I suggest that going more deeply into the Java language there will be even more differencies from what I would call "the standard syntax."
From what I understand all this come from using the ACM package and I really don't know if keep watchng this will help me or just gonna confuse me more. Is this ACM package of some practical use? Does it make the Java syntax a lot more different than usual so I could end up with bunch of useless commands? Do you think it would be better to leave these videos for now and come back later when I can get use of the useful information and be more aware of the outdated stuff or the difference is not that big?
Thanks in advance
Leron
I don't think it's going to get in the way of learning Java. It provides a framework within which your code will run, much as do Java applets, Swing, Android, or some other framework. It will not be the same as vanilla Java, but the ACM package is well documented. Once you master the basic concepts, learning the extra stuff you will need to wean yourself from the ACM package won't be hard at all.
As long as you recognize the differences between the "shortcuts" provided in the ACM code and the standard syntax, I don't think there's any inherent harm in following these lectures. I've heard some decent things about the series, and if your goal is to learn the basics of the language (or fill in gaps in existing knowledge), then I think it's a fine resource.
On the other hand, I have never seen the ACM libraries used outside of an academic setting. Personally I only used them once, on a single project for a single (non-required) class while I was persuing my undergrad degree. If you're already familiar with the language, and know the basic concepts, I'd look for more standard tutorials that don't make use of esoteric or specialized code bases. For the most part, the ACM libraries seem to contain shortcuts and a standardized framework to aid in teaching (and learning) core concepts rather than worrying the exact syntax or any quirks that might be present in the language.
If I want to summarise it, I would say that the ACM Java Libraries main goal is to make you free from the syntax to help you focus on the concept.
The ACM Java Library package is an excellent tool to introduce programming concepts to newbies. As you can see the lecture's title is Programming Methodology and not Programming Java.
Hope it clarifies
I'm in this exact same situation. Rather than learning ACM, which I'm not going to use anywhere else, I decided to do the assignments using current Java technologies, for example doing the graphics portions in JavaFX. Of course this might not be the best approach for absolute beginners, who may find it easiest just to stick with ACM.
In case it helps, I'm putting my coursework in GitHub:
https://github.com/bmaupin/coursework/tree/master/cs106a-stanford
For example, here's the Target assignment: https://github.com/bmaupin/coursework/blob/master/cs106a-stanford/Assignment2/Target.java

Good start for .Net and c++ to Java transition?

I know the .Net framework very well and know where to find things ie: StreamReader, StreamWriter, Graphics, etc, and I know Java has similar things. The syntax is different but quite similar to c++ which I have a lot of native c++ experience. Therefore, what would you recomend as a good starting point for tutorials and such. Thanks
In my new job, I quickly found myself working on a common library in C++, C# and Java. I had no Java knowledge and yet found it pretty intuitive to make simple mods to the Java code - the general C# principle that there is a framework class/namespace for most things you want to do, appear to hold in Java.
The thing that bothers me is that this MO would not teach me tricks and improvements in Java that are specific to that language. That's where I would like to see other answers to this question lead.
In the meantime: http://en.wikipedia.org/wiki/Comparison_of_C_Sharp_and_Java
btw while I found C# and Java pretty congruent, I would not say the same about C++ vs Java.
If you work in eclipse/netbeans/intelliJ it may actually be a no-brainer. Guess at a class name, start typing it and hit ctrl-space (for eclipse, others vary). Regardless of which package it is in, it will find all the classes that match and list them for you faster than you could look them up anywhere else.
The other really nice thing to have on hand is the javadocs for the SDK you are working with--you can code effectively with nothing else. They are online (just search for JDK 6.0 or whatever version) or they can be downloaded from the same place you get the JDK.
The javadocs are your friend - once you figure out some of the main packages in java.*, it's easier to know where to look for specific classes / functionality.
Once you're writing some code, buy Effective Java - it's full of tips for the language, and is just a good programming book.

Approaching Java from a Ruby perspective

There are plenty of resources available to a Java developer for getting a jump-start into Ruby/Rails development. The reverse doesn't appear to be true.
What resources would you suggest for getting up-to-date on the current state of java technologies? How about learning how to approach DRY (don't repeat yourself) without the use of metaprogramming? Or how to approach various scenarios where a ruby developer is used to passing in a function (proc/lambda/block) as an argument (callbacks, etc)?
You might start out by learning Groovy and Grails, which may seem a bit more familiar to you. Then you can start learning more of the Java side of Groovy to get familiar with what Java can do. Eventually (if you need to) you can move into 100% Java.
Groovy is in many ways similar to Ruby (at least from my Ruby-novice view), but you also have full access to Java libraries and coding.
I guess you might also look into JRuby first rather than Groovy since it is a Java-based implementation of Ruby.
The best thing to do is consider what you would want to do with Java and try to dig deeper into that area. Java as a whole has gotten pretty unwieldy over that last few years.
Good luck and I hope this helps a little.
I wouldn't start with the "current state" of Java. Like #chstehno said, Java is huge, and a bit of a mess. Focus on learning the basics, then delve in the the libraries as they become relevant to what you're working on.
I went from Java (and a bunch of other old school languages) to Ruby, so I can't speak to going the other way, except to say that Java is a lot more "by the book" and you can figure out a lot just by reading and searching through code, whereas that can be tough in Ruby with all of the mixins, lambdas, and convention-based magic in frameworks like Rails.

Most effective server side programming language for web development?

This is more a question of pros/cons between PHP and JAVA.
Iv been doing research, and iv narrowed it down to those two.
And in consideration, id like to go into mobile app dev...So thats +1 for Java.
Time taken to learn the language is not an issue...Just would like to know which is the most effective between the two languages mentioned above.
And on a slight note. Can Javascript work with Java? And what is the real advantage of that?
All answers are appreciated, thanks in advance.
I'm sorry, but PHP and Java are not the only choices. Ruby on Rails and Python's Django framework are both excellent tools for web development. While I haven't used it, Groovy's Grails framework is also very highly reviewed (largely by ex Java programmers). In certain (admittedly obscure) circumstances it's even advisable to do something off the wall like write a CGI program in C. It all depends on what you're trying to do.
Mobile app dev shouldn't influence your choice here, because no matter what web framework you're working with a mobile app is a whole new ball of wax.
So, here's the deal: asking people to compare PHP and Java really won't get you any meaningful answers -- you don't have the background necessary to understand what we'll say. You really need to figure out what you're trying to do before you choose your tool. It's like saying "I'm thinking about building a house, should I use a screwdriver or a hammer?" Here is what I would advise:
Go learn to program. Pretty much any language will do, but I'd suggest something nice like Python or Ruby. Spend a few months getting comfortable with programming first.
Pick a project. Make it something simple. When you know what your project is, pick a tool to use to complete your project. This may involve asking another SO question.
Rinse and repeat. Complete many projects. Once you've finished 5 or 10 web projects you'll be in a position to compare different tools. The more tools you use, the better. I'd suggest you do one in Ruby on Rails, one in PHP, one in Django (a python framework), and maybe even one in Java with JSP.
Once you've got that base of experience come back and ask this question again. You'll actually be equipped to understand the answers. Of course, once you've got that experience you won't need to ask the question because you'll already know the answer.
The one you know.
Some feedback:
Mobile app dev is not necessarily just web development.
Javascript is the language of choice on the web browser and works with PHP, Java, etc. on the server.
In general, one language is not more effective than another.
Seriously, judging by your post, I would advise you to start learning PHP and Javascript.
You already have a web browser so you can start writing javascript now.
As for PHP just install XAMPP from http://www.apachefriends.org/en/xampp.html and after a double click you'll be ready for web development.
After learning what its all about you'll be able to then check out Java and see if it is more effective in what you are trying to do.
Your question really indicate you need to learn alot about web development and programming in general, so I could answer your question but.. I'd recomend you go read up a little.
And in consideration, id like to go
into mobile app dev...So thats +1 for
Java.
How is that +1 for Java? We're talking about server-side languages.. you're not running your server off a phone are you? Sure, you can use Java to build apps in addition to running your website, but that's a different story.
Time taken to learn the language is
not an issue...Just would like to know
which is the most profitable at the
end of all the training.
Neither language will make your site more profitable, but you may be in higher demand with different companies depending on what you know.
And on a slight note. Can Javascript
work with Java? And what is the real
advantage of that?
Well... yes, but that's almost a nonsensical question. You use Java or PHP to produce the HTML that gets sent to the client, and then your JavaScript manipulates that. It's completely unrelated to what language you use server-side.
#comment: I can't really say which is more worth learning. I suppose Java is more versatile in that it has more applications outside the web. PHP is supported by more web-servers though (AFAIK), so you won't have trouble if you need to work on a different server.
I can't fairly recommend one over the other though. I've only used PHP for web, and Java for non-web. I like PHP because it's easy to pickup, easy to use, and all sorts of stuff is built into the language without any includes or anything. Has a big community, so there's lots of scripts you can download. One might argue that it's also a mess of a language, but as long as you aren't all uppity about that sort of thing, it's not really a problem. Java OTH... I don't know. I'm not a Java keener, that's all I'll say :)
Most of the answers here should be able to direct you towards your answer though I would just like to say if you are going to learn a programming language to make Web Apps learn Java, not because this will be the best tool for the job, each job is different, but knowing a full fledged language you will be able to quickly adapt to other languages.
You don't learn a language, you learn the concepts behind programming, then apply them to different languages.
I think you need to outline the context of your question. For example, if you are looking to get a job in IT, then the language that is most asked for in job ads is the one you want. If on the other hand, you have an application in mind that you would like to write, then you need to tell people (without giving away the details) what type of application it is so that they can tell you the most suitable languages/APIs to for that area.
But remember this - there is no such thing as a super programming language that is the best for everything. Each language is suitable for a range of tasks in a range of contexts, and is usually awful for everything else. Without the context of where the language will be used, no-one can tell you which is better.
Stop trying to kill two birds with one stone. There are different tools for different tasks. You can write mobile apps with Java but you can't write web apps with it. You'll have to use a server-side programming language such as PHP, Ruby on Rails, Django (Python), etc.

Is Java too complex a programming language for a beginner one man programming team?

I'm trying to learn Java but it just seem like there are too many parts to put together.
You have JSP, Java EE, Java SE, Java ME etc....
I can get Netbeans to do basic but just taking a peek at spring framework it seem like a lot of work to get it to run in the ide from the numerous configuration .
I want to get into web programming and maybe mobile.
Any advice?
Another programming language?
Is java this complex or does it get easier?
Java as a language is certainly not too complicated. J2EE in its entirety is only just about feasible for a one-man team - but you rarely need the whole of J2EE.
It's perfectly reasonable for a one-man team to implement a medium-sized web application. I'm not saying one person could write GMail on their own, but you shouldn't be too scared of the technology stack - find the bits you actually need and concentrate on those. On the other hand, that in itself takes a fair amount of experience - I wouldn't really want to be starting off on an enterprise app (even a small one) on my own as a newcomer to Java.
Start small. Learn the core (the language, IO, collections) - and then start with small projects. Work out whether you want to be in mobile, desktop, server or whatever - don't try all of them simultaneously. Gradually you'll build up your experience.
It's not that Java-the-language is complex, it's that vast libraries and frameworks exist that can help you do your work. This is true for many programming languages. Look at CPAN for Perl, for example. What language to use depends in great part on what your goals are.
You can start simple and work your way up to larger and larger projects.
Java is by no means too complex for a one-man operation, but learning any form of full-formed web programming is a lot to learn when it's all new. If you were looking at .NET for the same purpose, there is a lot there too.
Unless you are doing huge-enterprise applications, ignore all of J2EE except for JSP and JMS and a very few other components. The lion's share of J2EE is only useful in the context of an enterprise application that needs to scale, and in fact can be harmful when used in smaller applications.
The frameworks such as Spring, Hibernate, Apache-*, Web Services, and so on help you do your job, but are yet more things to learn to do your job. There is a lot to learn.
Should you use Java? Well, quite a lot of development is done with LAMP (or WAMP): Linux (or Windows) + Apache-HTTPD + MySQL + PHP. With this, you don't need to worry about Java or .NET or any of those frameworks. LAMP/WAMP works very well for a wide class of applications.
Java and .NET on the server are (sort of) more appropriate for larger services, but once you are familiar with them, they work just fine for smaller services as well.
You have to decide what your exact goals are, then look at how people have implemented the kind of thing that you're looking at doing. This will help you figure out what technologies are the most necessary for the niches you're looking at going into.
Java -- the language -- is one of the simplest strongly typed languages in existence. Vastly simpler than C++ or even its close cousin C#, I would argue.
The standard APIs/libraries really are huge, but nobody learns the whole thing. You're suffering from the intimidation all beginners feel when they look at something that big and new, but this will pass as you just do stuff. First, you need to learn the standard utility stuff -- the collections in java.util, mostly -- and then, for basic web dev, probably next the JDBC library and Java Servlets and JSP. And that's it.
As an alternate tact here...
Another problem you will encounter in Java is Choice. You have a LOT of it in terms of frameworks and technologies etc.
My best advice is search around for about a day if you're so inclined to find what technologies attract you, or who's arguments sway you. Then, pick one. ANY one. Really, it doesn't matter, especially for a first project. They all have learning curves, they all have strengths and weaknesses, they all have fans and foes.
The key though, is once you have chosen, STICK WITH IT. You will inevitably stumble upon some problem, you will pose this problem to someone else, someplace else, and they will say "oh, you should have used QED instead of KnifeForkSpoon". And you will second guess yourself, go off and hear about the wonders of QED, and all of the kittens born under it and hungry children fed by it. If you succumb to that siren song of "greener grass", your project will flail. (Not fail, flail.)
Don't be wooed, don't fall for it. Just fix your problem and move on. At the end, and you're on a new project, THEN go and look for the more bestest greatness silver bullet.
As an aside, if I were just getting in to web programming today in Java, I would humbly offer this simple recipe:
JSP 2.0 with JSTL for markup and presentation
Stripes or Struts 2 for logic (note Struts 2 (TWO), Struts 1 is plain evil)
"raw" JDBC with a database pool for persistence
Tomcat or Glassfish for a container (tomcat more popular, GF easier to use out of the box)
Netbeans or Eclipse (NB is easier to use out of the box)
This uses the most fundamental, yet functional facilities for web apps in Java today, lots of applicability, and solves the major issues of a web app without covering them up with thick, impenetrable layers.
You will learn a lot using these "crude" tools.
You need to learn to pick your battles. Covering the whole J2EE is a massive task and, for most, unnecessary to begin with. I think a common mistake for beginner programmers is that they think they need to learn everything. You'll find your time much more productive if you focus on the core language constructs to begin with, and focus on either web or mobile programming.
You'll be extremely surprised (and pleased) at how much you can carry over from one area to the next. Once you know the language, the different libraries for different platforms are just tools...Stick with Java. It is a good language to learn.
Can I take "get into web programming" to mean that you're just learning web programming in general? If that's true, if you have the time you might consider setting Java aside temporarily and giving LAMP/WAMP a closer look as Eddie suggested. (Though I'd personally use Perl instead of PHP. PHP is sexier resume fodder and lets you do some very cool things on the front end, but in my experience, when it comes to writing server-side code Perl simply blows PHP's doors off. And I've heard that the HTML::Mason extension puts Perl on pretty even footing with PHP's front-end niftiness, but I haven't used it myself.)
I've made a living writing writing web apps in Java and web apps in Perl. I'm fond of both languages, but as a learning tool, I'd put Perl well ahead of Java. As you're finding out, Java's a bulky bastich. Part of that is, as others have mentioned, a function of Java being a mature language with a variety of extensions that are unlikely to apply to your immediate needs. But even stripped down, you'll still need to deal with quite a bit of overhead before you can even get your first "Hello World" web app to run. Comparatively, you'll get rolling much quicker with Perl.
(In fact, Java tends to be pretty verbose in general compared with other languages. That's not necessarily a bad thing; my one big complaint with Perl is you often encounter code that leverages various shortcuts and side effects to do an unholy ton of work in just a few lines. This code is often brilliant, elegant, compact, and utterly bloody unintelligible to a non-expert. Terseness is not a virtue for the poor idiot who has to modify code six months after it was written -- especially when you wind up being the poor idiot in question.)
And as a way of learning web programming, Java's sophistication can actually work against it. As a professional, I'm glad Java's web-based tools automagically take care of a lot of grunt work for me, like session management. But I didn't completely understand what it was doing until I was thrown into a Perl-only environment and had to deal with all that stuff myself.
I guess it depends on why you're doing this and how much time you can devote to it. If time is limited and you're looking for something that will appeal to prospective employers, then yeah, Java's an excellent choice, and you've gotten some solid advice in this thread about how to get started using it.
But if you do have the time, I highly recommend giving old-school Perl/CGI programming a sniff. It ain't a particularly marketable skillset anymore, but you'll learn things worth knowing.
You don't have to learn all of Java and its libraries. Just learn what you need for the job at hand. You will find there are plenty of options, but you don't have to get the best option every time.
If your base programming concepts are clear no
language should be difficult for you. I have switched over from vb 6 to java to c# to objective c now. What really makes a coders life easy is the IDE, debugging tools, documentation and lot of blog posts which google can search :-) regarding one man team my personal view is I am at my best when left to code and research alone with the help of google and stack overflow ofcourse :-) so I do think in programming large sized teams often lead to more screw ups than results
Java is not a complex language, altough it looks frightening at first.
I started learning Java from home, not a school, at 15 years of age (yes, yes, I know that's nothing to brag about) trough a book. It's a norwegian book, so I won't link to amazon;)
After reading/hacking trough half the book I found out I was better off ditching the book and looking for more stuff online. Google really IS awesome!
I would often read about all the fancy features of the JVM, frameworks, third-party libraries, JSRs and so on, and how much better my life would be with them all, but I just ignored them all. Yes I tried, but found it too confusing to learn Java and a framework that wasn't really necessary, at the same time.
Some people gave me hell for not using insertRandomLibraryName() or insertFancyFrameworkName(), and told me all about how much time and effort i would save, but I'm glad I didn't listen.
Now times have changed, and I still learn new things, or easier ways to do old things, every day. And I'm glad I took the time to learn the language itself before all the fancy stuff.
Also, don't use a notepad for writing code, use an IDE from the beginning. The only one I've ever really used is NetBeans, so that's the only thing I can recommend, but I sure am really happy with it!
As to Java SE, ME and EE, start with SE, and you'll propably find that it's enough for now. You don't have to use EE to write for the web, SE is fully capable of webernet stuff;D

Categories

Resources