Jump to content

Progamming Java or C+


Greenlight

Recommended Posts

Uhm, I assume you meant C++ rather than C+ (or perhaps C#?). C++ is an extension of C to include more modern features (such as objects). C# is more recent still. I don't know much about it, but I gather it is somewhat like java.

 

It's less that java and C++ are new/old and more that they have different goals. There is still active development of C/C++ compilers (don't know about the language standard itself, but this is less important. I think the languages may have everything they should need already).

Java is based on a virtual machine, and has a lot of high level features like garbage collection (it cleans up memory for you when you're done with it).

A full explanation quite involved, but if you don't want to go into detail: Basically it does a lot of stuff for the programmer, often making his life easier. The down-side of this is there is more overhead (the minimum amount of stuff you need running to make your program work), and for some tasks it is slower than C or C++ (probably not in any way you or I would notice, your program also has to be written to take advantage of the extra speed of a compiled language).

C was invented first, because when computers had very limited resources and the overhead of a virtual machine wasn't often worth the advantages.

Link to comment
Share on other sites

I understand there are older programs and java is the most recent but what is the difference between java and other programs is it just the methods that change or the objects?

 

Pascal is extremely strict with data types, i.e. declaring an integer variable and trying to assign a real number to it will generate a syntax error if my memory serves correctly

 

C++ and C are less strict with data types and you can do implicit conversions by assigning a real number to an integer variable.

 

Java script, which I assume I have been using to program my website, has the syntax of C but data declarations more like basic, where you do not specify the data type of variables and can assign any data type to it at any time.

 

Not sure if java and java script are one and the same or slight different.

Edited by Greg Boyles
Link to comment
Share on other sites

@Greg Boyles: No, they're not. JS is based on Java, but it's a completely different language. You have specific variable types in Java, and you can't assign one to the other (unless they can be implicitly converted). This can however be easily achieved using generic programming.

 

Comparisons of Java and C++ are easily available using a simple Google search; try "C++ vs. Java". The Wikipedia article on this topic should give you all the necessary information: http://en.wikipedia.org/wiki/Comparison_of_Java_and_C%2B%2B

Link to comment
Share on other sites

@Greg Boyles: No, they're not. JS is based on Java, but it's a completely different language. You have specific variable types in Java, and you can't assign one to the other (unless they can be implicitly converted). This can however be easily achieved using generic programming.

 

Comparisons of Java and C++ are easily available using a simple Google search; try "C++ vs. Java". The Wikipedia article on this topic should give you all the necessary information: http://en.wikipedia....ava_and_C%2B%2B

 

Is Java more like Pascal with stricter typing than C++?

 

Can you use either Java or Javascript to program websites?

In which case I assume that the html tags used to delineate java would be different to those for java script. Or is it programed seperately in a compiler and then the executables plugged into the website via appropriate html tags.

Edited by Greg Boyles
Link to comment
Share on other sites

Java is executed in the web browser through "applets," which are precompiled files plugged in with appropriate HTML tags. They're rather uncommon these days.

 

When I was programming my website and teaching myself javascript web programming I was using client side javascript. But it was recommened to me that I should change it to server side programming.

 

Hence I taught myself ASP javascript and converted my website. Getting my head around the client/server system was the hardest part, but I picked it up fairly quickly.

 

Then I wanted to host my site on a unix webserver, so I taught myself php script and converted it all again. php is rather javascript like despite the differences in syntax. I converted my website with relative ease. I wrote myself a little C++ windows application that I ran each asp file through. It did 90% of the conversion and then I just had to tidy up a few loose ends that my utility didn't handle properly.

 

It seems to be all server side programing these days, except for a few odd task that have to be done on the client side such as changing and disabling controls etc.

 

Java is executed in the web browser through "applets," which are precompiled files plugged in with appropriate HTML tags. They're rather uncommon these days.

 

What are applets precisely?

I assume they are some sort of binary script, that is faster to read and process than text, that is still interpreted by the web browser in the same way as regular script.

Edited by Greg Boyles
Link to comment
Share on other sites

Basically. Applets consist of Java programs which are compiled into "bytecode," which is is sort of halfway between a programming language and machine code. A Java "virtual machine" processes the bytecode like it's machine instructions. Web browsers can embed Java applets -- essentially, the web browser fires up the Java system, gives it the bytecode, and says "display the result right here in this web page." It's similar to how Flash video works.

Link to comment
Share on other sites

I'd tell you to learn Java since it's simple, easy, and platform-independent ...

 

But, I'd like to be honest, and tell you that the best way is to learn C++ first, then Java is in your pocket .. since learning C++ will give you more info about

dealing with low-level and system programming, which is not possible from languages such as Java which doesn't interact much with the machine ...

 

.. good luck

Link to comment
Share on other sites

What khaled said is true; im learning java and python but may have to do c++ for games. Depends what you want from the program but most higher end stuff is achievable on most modern languages and generally what you learn is directly portable although syntax and certain rules may differ. In other words for most basic tasks it doesnt matter which language you learn, infact it may be beneficial to learn both simultaneously so that you can learn yourself why a particular language is better at a particular thing (im relatively new to programming but i know both c++(#) and java give you huge library's at your disposal), i imagine familiarity will sway which language you prefer, if you learn java you will get used to doing certain tasks often.

Link to comment
Share on other sites

Basically. Applets consist of Java programs which are compiled into "bytecode," which is is sort of halfway between a programming language and machine code. A Java "virtual machine" processes the bytecode like it's machine instructions. Web browsers can embed Java applets -- essentially, the web browser fires up the Java system, gives it the bytecode, and says "display the result right here in this web page." It's similar to how Flash video works.

 

The benefit is, if you have a JVM, the bytecode will work universally on any machine. For languages without a interpreter (like C++), you have to compile the source code into a machine language, which aren't generally aren't compatible between different types of machines. Especially back in the old days, if you wanted to run a C++ script on a PC or a Mac, you'd have to recompile the source code on the new machine. With Java, once you compile the source into bytecode, it'll work on any machine (with a JVM).

Link to comment
Share on other sites

  • 2 weeks later...

A java code is compiled into classes, that are run by the JVM .. Applet is the port of java to websites ...

 

in HTML you can use this:

<applet width="600" height="500" style="background:#0C0; color:#FFF;" src="example.class"> You need JRE 1.5 or later ... </applet>

 

where example.class is compiled from example.java which has the code of the form:

 

import java.applet.*;
import java.awt.*;

public class Example extends Applet
{

  public void init()
 {
     setBackground ( Color.black );
  }

  public void paint( Graphics g )
 {
     g.setColor( Color.white );
     g.drawString( "The applet works ...",  50,50 );
  }
}

Edited by khaled
Link to comment
Share on other sites

can u plzz tell me in computer science where we apply group theoryunsure.gif

 

Group theory is about groups (a mathematical structure), it includes permutation groups, abstract groups, matrices, transformation groups, ..etc

 

They're used widely, from the applications of linear algebra, to abstract algebra .. to discrete mathematics where general and transformation groups

are used to build models to solve problems, and permutation groups are used in cryptography and integrity checks ...

Link to comment
Share on other sites

can u plzz tell me in computer science where we apply group theoryunsure.gif

 

Also many of the concepts you use in group theory (thinking about things in terms of applying an operation on a thing and getting a different thing, and examining the rules of those operations) are useful for solving problems efficiently.

There's the entire field of linear programming where you are restricted to a (non turing-complete) set of operations. Algorithms that are writtens as a series of these operations can be condensed into a single matrix and as a result are obscenely fast at solving problems to which they are applicable.

Without some grounding in the study of algebras (note: This kind of algebra, not the elementary algebra you'll know from algebra class) the restrictions in place on such programming will not make sense.

 

On top of this, understanding things like invariants of the code, or whether the vector space of the data you're working on is closed under some operation can be essential for proving that your code does what you think it does, or even just chasing down some bugs in less formal settings.

Link to comment
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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.