开发者

What do I need to know going from Java to JavaScript? [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

Closed 11 years ago.

Improve this question

This isn't as progressive as it sounds. Im not taking the whole "Oh I know Java, that must mean I can write in JavaScript too!" attitude. I have some education on Java under my belt, but now find myself having to do some PHP web development (which I have little experience in) using Java Script to handle some of the logic. But before going out and buying 2 or 3 books on JavaScript and diving right into it, I figure I might ask those that might have gone through the same experience. It appears that JavaScript lives and acts in its own environmnet which makes want to take the ap开发者_运维问答proach taking in JavaScript and PHP as a bundled package in my learning endeavors. JavaScript is similar just enough to Java that I will tend to make some dangerous assumptions. Should I treat JavaScript and PHP as one item, or should I still take this step by step and learn one at a time? What are some pitfalls that I might run Into? What are the main differences between the languages? Is there any litterature that has helped? Thanks Everybody.


You should consider the two languages as completely unrelated. All they have in common is that they use { and } to enclose code blocks and ; to terminate statements. They're both object-oriented, but Java is class-based and JavaScript is prototype-based.

The only reason JavaScript has the word "Java" in it was because Java was "hot." It's nothing but historical marketing reasons.


What do I need to know going from Java to JavaScript?

That they are completely different languages. The Good Parts is a good introduction to the core JS language for existing programmers. You'll also need to learn DOM and other browser APIs if you want to use client side JS for anything practical.

Should I treat JavaScript and PHP as one item

No. They are completely different. Even when you know both of them you should be writing things that work with plain HTML and PHP, then layering JS on top.


I learned Java script coming from Java myself. I had a bit of trouble with it until I worked with NodeJS a little bit. Learning JS by itself when I wasn`t warring with html and css at the same time made the experience much less painful and made it take less then a couple days.

I would really recommend these two books
http://www.amazon.com/JavaScript-MooTools-Experts-Voice-Development/dp/1430230541
http://www.amazon.com/JavaScript-Good-Parts-Douglas-Crockford/dp/0596517742

Don`t be turned off by the fact the first book is related to a frame work. The first 250 pages are a fantastic JS basics crash course.

Of course you are super comfortable with objects and you can find that in Javascript if you really wanted to and never even learn about prototyping and closures. Take the time though to read into these things there are a lot of timing problems that you really can`t solve any other way with respects to asynchronous actions and animation locks.

Research functional programming.
The hardest thing about the transition is javascripts wonky syntax at first you will hate it but it does finally catch a rhythm. Which reminds me use Lint a lot that will help you catch your syntax issues early.


Javascript and PHP are both Java-like languages. Just know that Javascript is client-side and shouldn't be bulky. Javascript is also significantly slower as it's a scripted language.

Javascript is much easier than PHP as it's more similar to Java. Just note that Javascript is not object-oriented at all.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜