# which language



## spazman5656 (Nov 28, 2005)

Hey I am thinking about learning a new programming language and I was wondering which one I should learn. Tell me what you guys think. I already know the basics of Java. Thanks


----------



## asbo (Sep 21, 2001)

It depends on what sort of platform you're aiming for, how old you/your career is, how seious a coder you plan to be, what you plan to do, etc.


----------



## spazman5656 (Nov 28, 2005)

im not that serious of a coder but I just want to learn a good base of languages because I am thinking about going to college for something in the computer field and just want to learn a new language


----------



## asbo (Sep 21, 2001)

C++ is always a good option, and if you don't want that big of a challenge yet, try something like VB.


----------



## aewarnick (Sep 3, 2002)

I hate VB with a passion. Avoid it if you can. I use C++ and love it!


----------



## blaqDeaph (Nov 22, 2005)

aewarnick said:


> I hate VB with a passion. Avoid it if you can. I use C++ and love it!


Well, personally, I've gotten over the *hate* stage of VB. I'll avoid it at all costs, and I'll recommend to people that they don't start with it as it teaches poor programming practices.

C++ is the way to go, or you can try Python for an easier start, as C++ has a reasonably steep learning curve.


----------



## asbo (Sep 21, 2001)

How do you mean, "poor programming practices"?


----------



## RGregory (Jul 27, 2005)

Personally, I prefer C# and use it almost exclusively. Unfortunately, my employer won't spring for a copy of C# at work, so I'm stuck programming in VBA (and COBOL) there.


----------



## lotuseclat79 (Sep 12, 2003)

spazman5656 said:


> Hey I am thinking about learning a new programming language and I was wondering which one I should learn. Tell me what you guys think. I already know the basics of Java. Thanks


Hi spazman5656,

Knowing the basics of Java is just getting started.

Learn C/C++ and an assembly language (for Intel's instruction set) along the way to get the feel of controlling hardware/architecture features, pointer manipulation, and advanced programming techniques including multi-threading (try programming the canonical concurrent problem of the Dining Philosophers in Java, and a rules based AI language, or a known concurrent language such as Ada or Parallel C++ just for fun - I did!). Java does not manipulate pointers as they do not exist in the language, but C/C++ can. I haven't tried C#, but you should try to learn whatever useful languages can help you achieve whatever goals you choose in the programming/software engineering field.

In addition to learning to program in different languages, if you can learn about how computer architecture, compiler implementation, and languages are designed with denotational semantics then you will come to know that there are three very different kinds of language specificaton semantics:

1) Axiomatic semantics - what programmers need to understand to design a program
2) Operational semantics - what compiler implementers need to understand to design a compiler [Action Semantics (IMHO the best approach to operational semanitcs) which perhaps best abstracts the intent of the language designer into its primitives to allow the clearest exposition of a specification of a language that is most useful to the compiler implementer.]
3) Denotational semantics - what language designers need to understand to design a language (abstract mathematical topic)

-- Tom

P.S. We may be able to write a program syntactically, but the real understanding is in the semantics of a language in which the program is written. Understanding the semantics <=> Understanding the language.

P.P.S. Dining Philosophers problem goes something like this:
There are 5 philosphers, 5 forks, and a bowl of spaghetti (always filled when empty). The philosphers eat, sleep, and think. Devise a way such that the forks are shared, and no philosopher starves to death. Forks are placed between the philosophers on a round table with the bowl of spaghetti in the middle of the table - i.e. each philosopher can use either the fork to the left, or the fork to the right, but only if it is free to use.

This is a resource problem where there are issues of contention, sharing, and starvation of resources - often found at the operating sytem level for which good design can prevent from happening to allow progress of all processes.

Note: All programs are theories!


----------



## techshar31 (Nov 10, 2005)

Why not continue with Java? I made a 5+ year career out of Java development. I'm not sure how it is today ... but C/C++/C# might be better for job security. Java and C have a lot of similarities. Also, Java is a LOT more popular today than it was 5+ years ago.


----------



## lotuseclat79 (Sep 12, 2003)

techshar31 said:


> Why not continue with Java? I made a 5+ year career out of Java development. I'm not sure how it is today ... but C/C++/C# might be better for job security. Java and C have a lot of similarities. Also, Java is a LOT more popular today than it was 5+ years ago.


Hi techshar31,

C and Java have more disimilarities than Java and C++:

C is not object-oriented whereas both C++ and Java are, but with significant differences, for instance Java does garbage collection of memory by definition of its design/implementation. Neither C nor C++ guarantee this. C/C++ can do pointer arithmetic, Java has no pointer construct. Running off the end of an array is common in C/C++ code, whereas not in Java code. Java is inherently safer than C/C++.

In both C/C++, the programmer is responsible for:

memory management
thread synchronization
platform specifics
error-handling protocols

whereas all of the above are the responsibility of the Java language/implementation rather than the programmer.

-- Tom


----------



## techshar31 (Nov 10, 2005)

lotuseclat79 said:


> Java does not manipulate pointers as they do not exist in the language, but C/C++ can.


Not exactly true. Pointers exist in Java, but are just not explicit. They are in the form of a reference which IMO (and the opinion of others) is a better way to go. Modern optimizing compilers solve most performance issues that used to exist when using references in Java vs. pointers/pointer arithmetic in C.


----------



## techshar31 (Nov 10, 2005)

lotuseclat79 said:


> Hi techshar31,
> 
> C and Java have more disimilarities than Java and C++:
> In both C/C++, the programmer is responsible for:
> ...


Good points. I was getting at a guy who knows the "basics of Java" might want to continue with that or C++/C# as he could eventually go in either direction. All of the points you mention go beyond the language barriers. All "good" developers should be at least familiar with these concepts regardless of the language. Some of the VB crowd will always disagree with me on that. Oh well.


----------



## lotuseclat79 (Sep 12, 2003)

techshar31 said:


> Not exactly true. Pointers exist in Java, but are just not explicit. They are in the form of a reference which IMO (and the opinion of others) is a better way to go. Modern optimizing compilers solve most performance issues that used to exist when using references in Java vs. pointers/pointer arithmetic in C.


Hi techshar31,

Pointers DO NOT exist in Java and are not defined in the language specification. Saying they are not explicit does not imply that they even exist in the language definition - which they do not!

A reference is a name to an object. For example, in C/C++, argc contains the number of arguments passed to main(). argv[] is a pointer to an array that contains one character string per command line argument. The first parameter contains the name of the program that was invoked.

Java handles command line parameters differently. First, there is only one paramter, String args[]. Unlike argv in C, i.e.

main (int argc, char *argv[]) {

args in the Java program is not a pointer to anything - it is instead, an array of objects, and in Java, an array is also an object.

Accessing data in a Java object is identical to how you do it in C++.

In Java, the number of command line parameters is not guaranteed to be at least 1, as in C/C++. In Java, you are not executing a program per se - you are executing a class. You can ask an object what its class attribute is, so there is no need to pass this info in the command line parameter.

In Java, you cannot fall off the end of an array and start accessing or modifying memory that's not part of the object you are dealing with, as you can do with the pointer argv in the C code snippet above. If you try, you will generate an ArrayIndexOutOfBoundsException at runtime.

A name resolves to a memory address allocated for the type of the container to which the name refers which contains its current value. The memory address is a reference to the value applied to the name container type. These memory addresses are commonly called pointers. The value contained at the memory address is a bit-mapping of the value of the type container (i.e. type interprets value of bits) at that memory address (for the length allocated to the type according to the language implementation) - e.g. integer on a 32-bit machine is 32 bits wide, on a 64-bit machine, 64 bits wide, so the length of an integer is implementation dependent based on the target machine characteristics.

Such memory addresses do not exist and are not defined in the Java language, and are an explicit (hidden) property of the implementation of the language in accordance with the name-value mapping specified in the Java language specification.

In effect, there are two mappings:
1) name-address mapping, and
2) address-value mapping

The actual address mapping is invisible/transparent to the Java programmer. Therefore, it is impossible to manipulate pointers directly in Java, because it is not defined for the Java language which is separate from the language implementation of Java on any one target machine (interpreter or compiler).

-- Tom


----------



## techshar31 (Nov 10, 2005)

lotuseclat79 said:


> Hi techshar31,
> 
> Pointers DO NOT exist in Java and are not defined in the language specification. Saying they are not explicit does not imply that they even exist in the language definition - which they do not!
> 
> -- Tom


Whoah. Take it easy. I said "not exactly true". Take a look at this simple example. I didn't write it myself, but it sums up pointers in Java in a very simple fashion:

It's a common misconception that Java has no pointers. It's not exactly true. Java has pointers, they're just not explicit. Every object is a reference to a location making it a pointer... you just can't manipulate the pointers directly.

Which approach is better.. explicit or not? Well, that very much depends on the context and scope of the application. I'm sure everyone who ever went through learning C will however agree that non-explicit pointers are sure as hell easier to comprehend for someone who is just learning programming.

Here's why it's a pointer.. say you have two Strings s and t

String s = "hi"; String t = "hello";
These are two separate objects in two different locations.

t = s;
Now t and s both reference the same location hence referencing the same object. That is a behavior of a pointer. Now for the purists (hi Lotus) that will argue that this is still not a pointer.. oh well.. it's all based on how you define it.

XXXX

I'd also like to add that I've worked with these reference-type pointers in Java and (to a much lesser extent) "real" pointers in C. You'll find when you get "nullpointerexceptions" in Java that you need to become aware of these "non-existent" pointers if you aren't already


----------



## lotuseclat79 (Sep 12, 2003)

techshar31 said:


> Whoah. Take it easy. I said "not exactly true". Take a look at this simple example. I didn't write it myself, but it sums up pointers in Java in a very simple fashion:
> 
> It's a common misconception that Java has no pointers. It's not exactly true. Java has pointers, they're just not explicit. Every object is a reference to a location making it a pointer... you just can't manipulate the pointers directly.
> 
> ...


Hi techshar31,

Apparently, you are talking about the implementation of Java, whilst I am talking about the language - two different things mate!

Have you taken a debug tour and verified that t and s reference the same location? If they do, that's because its an implementation detail, not a Java language characteristic. Also, is the code unoptimized or post-optimized - i.e. it could be a property of the optimization pass to define it like you have described it? Is it different or the same for interpreters and compilers on the same machine?

-- Tom


----------



## techshar31 (Nov 10, 2005)

lotuseclat79 said:


> Hi techshar31,
> 
> Apparently, you are talking about the implementation of Java, whilst I am talking about the language - two different things mate!
> 
> ...


No, not an implementation detail. They both point to the same OBJECT. I'm not really sure what you are getting at. References (or pointers) are the only way of accessing objects in Java (as far as I know or have done). The primary difference from a programming standpoint is that a reference is "safer" and more "natural" way of accessing an object. Not sure if I can post a link here but take a look at this :

http://www.relisoft.com/book/lang/pointer/ptr.html


----------



## techshar31 (Nov 10, 2005)

techshar31 said:


> No, not an implementation detail. They both point to the same OBJECT. I'm not really sure what you are getting at. References (or pointers) are the only way of accessing objects in Java (as far as I know or have done). The primary difference from a programming standpoint is that a reference is "safer" and more "natural" way of accessing an object. Not sure if I can post a link here but take a look at this :
> 
> http://www.relisoft.com/book/lang/pointer/ptr.html


In other words, Java controls what you can do with pointers more than C/C++. I'd imagine there may be *some* very specialized applications where this is not desired. However, I've not personally run into any. Perhaps you have? If so, it would be interesting to see an example of where a pointer is preferred over a reference and why.


----------



## lotuseclat79 (Sep 12, 2003)

techshar31 said:


> No, not an implementation detail. They both point to the same OBJECT. I'm not really sure what you are getting at. References (or pointers) are the only way of accessing objects in Java (as far as I know or have done). The primary difference from a programming standpoint is that a reference is "safer" and more "natural" way of accessing an object. Not sure if I can post a link here but take a look at this :
> 
> http://www.relisoft.com/book/lang/pointer/ptr.html


Hi techshar31,

Read your reference article very carefully and you will discover that the author agrees that references are different than pointers.

All I am saying [is give pease a chance - huh? Lennon reference, not a Java pointer  ] - i.e. pointers (in the classic sense) are a machine memory mapped characteristic and are not designed into the Java language whilst references in Java have a different set of characteristics than pointers. Yes they refer to the memory address locating the value, but different declared objects have their own memory mapping despite whether their container's have the same reference value - which may just be an optimization by the compiler implementation rather than a language defined characteristic.

-- Tom


----------



## techshar31 (Nov 10, 2005)

lotuseclat79 said:


> Hi techshar31,
> 
> Read your reference article very carefully and you will discover that the author agrees that references are different than pointers.
> 
> ...


Ha! Now YOU are talking about implementation. Look a pointer IS MOST DEFINITELY a reference! In fact, Wikipedia defines a pointer as a type of a reference. Actually, I didn't think of it quite like that until now ... but it does make perfect sense!

I think you are getting at the fact that you can't generally manipulate a "reference" in Java where you can manipulate a pointer in C/C++. However, this has historically been a weakness of C/C++ which is why I asked why/what/where one might need to have this "capability".

So, again, from a language standpoint both C/C++, Java, and a bunch of other languages have the concept of a reference. A pointer is a type of a reference. Back the the original point, the developer should understand the concept of a reference - especially if they are programming in Java.

Ya?


----------



## aewarnick (Sep 3, 2002)

"However, this has historically been a weakness of C/C++ which is why I asked why/what/where one might need to have this "capability"."

How is this a weakness?

```
char* p= &var;
while(g < 20)
{
   *p= g; ++p;
   g*=5;
}
```
That is fast code.


----------



## lotuseclat79 (Sep 12, 2003)

Here are a couple of references (no pun intended) on the computer science meaning of the difference between a pointer and a reference - enjoy! And be sure to follow the URLs (hyperlinks) in the webpages for clarification.

-- Tom

Pointer: http://en.wikipedia.org/wiki/Pointers

In computer science, a pointer is a programming language datatype whose value refers directly to ("points to") another value stored elsewhere in the computer memory using its address. Obtaining the value that a pointer refers to is called dereferencing the pointer. A pointer is a simple implementation of the general reference datatype (although it is quite different from the facility referred to as a reference in C++).

Pointers are so commonly used as references that sometimes people use the word "pointer" to refer to references in general; however, if you are seeking general information on a small piece of data used to find an object, see reference (computer science).

Reference (computer science): http://en.wikipedia.org/wiki/Reference_(computer_science)

In computer science, a reference is a small object containing information which refers to data elsewhere, as opposed to containing the data itself. Accessing the value that a reference refers to is called dereferencing it. References are fundamental in constructing many data structures and in exchanging information between different parts of a program.

...

A number of popular mainstream languages today such as Java, C#, and Visual Basic have adopted a much more opaque type of reference, usually referred to as simply a reference. These references have types like C pointers indicating how to interpret the data they reference, but they are typesafe in that they cannot be interpreted as a raw address and unsafe conversions are not permitted. In those managed languages, the references are actually pointers of pointers of the referred data. In C/C++, the reference concept of managed languages means two-step pointing. The Garbage Collector is the sole actor that can directly access the mid-step pointers, which cause the opacity. Typically pointer arithmetic is also not supported.


----------



## f1_champ (Nov 6, 2005)

Go with VB thats what they teach us in school, it is very easy and help you in learning the basics of programming (thats what my computer teacher says)


----------



## aewarnick (Sep 3, 2002)

I'd say that C# is just as easy as vb and is much better because it's like Java and c++.


----------



## techshar31 (Nov 10, 2005)

f1_champ said:


> Go with VB thats what they teach us in school, it is very easy and help you in learning the basics of programming (thats what my computer teacher says)


They teach VB for Comp Sci nowadays?!


----------



## aewarnick (Sep 3, 2002)

I have a friend in college here that is taking C# (not his major either).


----------



## InterKnight (Oct 19, 2004)

I am personally a big fan of c++. I program with wxWidgets (or I am learning to) which is a cross-platform set of libraries and such for programming GUI interfaces. From what I have read it is similar to Microsoft's MFC (which I believe was used to program Windows applications).

If you decide to program with C++, I've stumbled across a pretty good free Integrated Development Environment (IDE) for doing so called Code::Blocks Studio. There are a lot of others out there that I've used, but it seems (to me, anyhow) that Code::Blocks is a worthy IDE to look into.

I hope that I've been of even a little help to you. Please take care.


----------



## f1_champ (Nov 6, 2005)

techshar31 said:


> They teach VB for Comp Sci nowadays?!


Yep VB in grade 10 and Java next year in grd 11.


----------



## blaqDeaph (Nov 22, 2005)

Woah, so much heat over pointers in C++/Java. What pointers are: They hold a memory address. Yes, it's that simple. All pointers hold a memory address. The only reason why you have a type infront of the pointer, is to let C++ know what the memory address contains. so, both:


```
int *
float *
char *
```
all contain memory addresses. The difference lies in what is contained in the memory address. Without going into a lesson on pointers, and what they do, suffice to say that the type before the pointer tells C++ what to do with the memory location.

There are many flaws with pointers however, and so many mis-uses and misconceptions that when Sun developed Java, they decided to improve on it. First of all, it's called a "reference", and secondly, the actual memory address is hidden from the user. In C++, to view the address of pointer p, you can use the '&' infront of the pointer. However, you can't do this in Java, which means that pointers are limited in Java. Pointers, however, more built into Java than C++ (in C++, you can statically create objects, whereas in Java, you have to dynamically allocate them using refrences).

Hope this cleared some things up.


----------



## Shadow2531 (Apr 30, 2001)

techshar31 said:


> String s = "hi"; String t = "hello";
> These are two separate objects in two different locations.
> 
> t = s;
> Now t and s both reference the same location hence referencing the same object.


Just curious. Coming from c++, that doesn't make sense. Java really does that?

The way you make it sound, if you assign s to t, t changes to a pointer to s, which in that case, if you change the value of s after that, the value at the address t references would also change because t is now just a pointer to s.

If that's true, then from what you say, in this case:

String s = "hi";
String t = "Hello";
t = s;
s = "bob";
System.out.println(t);

t would print out "bob".

However, that doesn't make sense and I can't see that happening.

Now if I do:
String s = "hi";
String t = "Hello";
t = s;

and the code doesn't modify t and s anywhere after ' t = s', I can see it being *compiled* the way you say as an optimization.

Anyway, in c++, I like to pass by reference to a function, where in java, I have to create a class for that, which works out fine, but seems pretty annoying sometimes.

I like c++ better, but I've been doing quite a few things with unicode and the methods for unicode support could be much better. I've read that unicode support is great and simple in java.


----------

