how different is java from javascript?

Started by
9 comments, last by nas1982 18 years, 9 months ago
i know a little of &#106avascript, and while i find it to be a very cool lanugage, anyone can view your code. java however (to the best of my knowledge) is compiled, so other people can not see your code. so i want to learn java. does anyone have some articles on java and know of a free java compiler so i can get started on that? thanks
Charles Reed, CEO of CJWR Software LLC
Advertisement
Java is free in general I belive check sun microsystems website it has a download. Then configure it to work with an IDE like TextPad. After that all you do is open up textpad and start coding.

Java and &#106avascript are quite differen't though in a lot of aspects, they use simliar commands now and then but really they are quite differen't. Check out <a href="http://java.sun.com/docs/books/tutorial/">http://java.sun.com/docs/books/tutorial/</a> for some java tutorials to get you started.
I think all programs can have their source code viewed, regardless of whether it is compiled or not.
A couple of minutes on google will give you all you need to know about how different they are from each other.

Java programs can be decompiled to source-code quite easily and example of some software to do this is the DJ Java Decompiler. So if you really don't want people to get at your source-code you'll still need some sort of obsfucation when using Java.
The similar naming creates a lot of confusion. &#106avascript and Java are not the same thing at all. They aren't even remotely related (well, they do share a C-like syntax). Any language can be decompiled, however, the OP point is that, since &#106avascript is interpreted directly, it is visible to anyone who want to spend 0.5 seconds clicking the view source button in their browser (assuming a owser is used. In that regard, yes, Java will be harder to decompile than &#106avascript, which is not compiled at all.
I teleported home one night; With Ron and Sid and Meg; Ron stole Meggie's heart away; And I got Sydney's leg. <> I'm blogging, emo style
The wikipedia entry on &#106avascript</a> has a good intro to the differences betwenn Java, &#106avascript, and JScript.
the ability/inability for others to view your source code is a strange motivation for learning programming languages, but nonetheless... choice of programming languages is often dictated by the type of program you wish to create. Seeing as you have been working with &#106avascript, you are likely working with web development; if that is in fact the case, look into php or perl for a scripting language where the only source the end user will see is the html generated as the output of the script. otherwise, c++ is a very common, general purpose programming language, and java is an absolute joy to program in (but in my opinion is nothing like &#106avascript)
I can't for the life of me understand why they chose the name "javascript". It's as related to Java as PHP is to Ansi C.

The reason anyone can see your code is that it's designed to be that way. The purpose of &#106avascript is to add scripting capabilities to the browser, not to be a general purpose language. And pretty much everything that goes to the browser is text.

Java was made to be easy to "compile". Compilation, in this case, meaning translation to bytecode. However, the other way around is also easy, and Java decompilers will produce amazing results. The only workaround for that is obfuscation. Same with C# (and all .NET languages).

However, don't let this old textbook stuff confuse you. Nowadays, Java code is most likely compiled. If you've got a properly configured Sun VM, try on the command prompt:

java - version


You'll most likely see:

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)


HotSpot is a compiler. That is, translates bytecodes to ASM instructions. Due to that, and advancements in VM itself, Java code is much faster than it's used to be.


Bottom line: &#106avascript for Web pages. Java for pretty much everything else.<br><br>For a compiler: go to java.sun.com and get the JDK. That's free (the actual compiler is called javac, and is included).<br><br>For a kickass IDE, if you've got a decent amount of memory, try Eclipse (www.eclipse.org).
Gaiomard Dragon-===(UDIC)===-
Quote:Original post by Gink
I think all programs can have their source code viewed, regardless of whether it is compiled or not.


That is true. After all, everything is turned to assembly instructions, and those can be viewed no matter what. In fact, that's how most "cracks" are made.

Now, if you mean the *original* source code, then the answer would be no. A "decompiler" *can* try to guess at what the original code was, but with languages like C there are a lot of ways to accomplish the same result, or even different outputs for the same input, with something as trivial as a compiler version change. Plus variable names are often not kept (unless you've got a debug build). The reason Java (and .NET) are so easy to decompile is that they store a lot of metadata on their assemblies, and that bytecodes/MSIL are easy to translate back and forth.

I like to think that choosing a language based on how easy it is to decompile is often not a wise choice. Not like that will wield a useful build :)
Gaiomard Dragon-===(UDIC)===-
Quote:Original post by Outworlder
I can't for the life of me understand why they chose the name "javascript". It's as related to Java as PHP is to Ansi C.


Marketing. Purely marketing. What *I* can't understand is how they didn't get sued to hell and back.

This topic is closed to new replies.

Advertisement