Sign in to follow this  
CJWR

how different is java from javascript?

Recommended Posts

CJWR    180
i know a little of javascript, 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

Share this post


Link to post
Share on other sites
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 javascript 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 http://java.sun.com/docs/books/tutorial/ for some java tutorials to get you started.

Share this post


Link to post
Share on other sites
Easca    163
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.

Share this post


Link to post
Share on other sites
jfclavette    1058
The similar naming creates a lot of confusion. javascript 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 javascript 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 javascript, which is not compiled at all.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
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 javascript, 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 javascript)

Share this post


Link to post
Share on other sites
Outworlder    100
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 javascript 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: javascript for Web pages. Java for pretty much everything else.

For a compiler: go to java.sun.com and get the JDK. That's free (the actual compiler is called javac, and is included).

For a kickass IDE, if you've got a decent amount of memory, try Eclipse (www.eclipse.org).

Share this post


Link to post
Share on other sites
Outworlder    100
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 :)

Share this post


Link to post
Share on other sites
Zahlman    1682
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.

Share this post


Link to post
Share on other sites
nas1982    100
First of all, javascripts resemble Java applets, but without Java's static typing and strong type checking. javascript supports most of Java's expression syntax and basic control flow. In contrast to Java's compile-time system of classes built by declarations, javascript supports a run-time system based on a small number of data types representing numeric, Boolean, and sting values. javascript has a simple instance-based object model that still provides significant capabilities.

javascript also supports functions, again without any special declarative requirements. Functions can be properties of objects, executing as loosely typed methods.

javascript complements Java by exposing useful properties of Java applets to script authors. javascript statements can get and set exposed properties to query the state or alter the performance of an applet or plug-in.

Java is an extension language designed, in particular, for fast execution and type safety. Type safety is reflected by being unable to cast a Java int into an object reference or to get at private memory by corrupting Java bytecodes.

Java programs consist exclusively of classes and their methods. Java's requirements for declaring classes, writing methods, and ensuring type safety make programming more complex than javascript authoring. Java's inheritance and strong typing also tend to require tightly coupled object hierarchies.

In contrast, javascript descends in spirit from a line of smaller, dynamically typed languages like HyperTalk and dBASE. These scripting languages offer programming tools to a much wider audience because of their easier syntax, specialized built-in functionality, and minimal requirements for object creation.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this