Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Coder's Corner Lounge (http://www.programmingforums.org/forum11.html)
-   -   More languages? (http://www.programmingforums.org/showthread.php?t=7447)

UnKnown X Dec 8th, 2005 6:44 AM

More languages?
 
Currently, I'm only learning C++ (after having a brief look on C), and a lot of people say that knowing several languages as well as one "main" language helps in understanding programming more and generally becoming a better programmer. While I can see that this makes sense and is useful, won't it be terribly confusing? I know several regular languages (English, Norwegian/Swedish/Danish, Russian and I'm learning German and Arabic), and I find that a bit confusing, so I wonder if the same happens with programming as well?

And if it really is beneficial, which other languages would you guys recommend? Not Assembly though, I'm not that crazy! ;)

grumpy Dec 8th, 2005 7:09 AM

Yes, knowing multiple languages can result in situations where you confuse between them, or blur the edges between them (eg using techniques suitable for one language when programming in another -- sort of similar to people speaking with accents). The approaches to addressing those issues are the same as for spoken languages: slow down, take more time, think more about how you wish to express something in the language you're using, etc etc.

As to what other languages you might wish to learn: what do you wish to achieve? For example, what types of applications do you wish to develop?

And people who learn assembly may be a little twisted, but that doesn't make them crazy :)

UnKnown X Dec 8th, 2005 7:16 AM

I see!

I'll probably end up doing graphics and game physics and similar.

As for Assembly, it looks pretty crazy to me! :p

darkone916 Dec 8th, 2005 7:31 AM

I am not experienced but i think C++ OpenGL API is good.

Munsta Dec 8th, 2005 7:38 AM

Quote:

Originally Posted by UnKnown X
As for Assembly, it looks pretty crazy to me! :p

try learning assembler for several hardware platforms, that's crazyness ;) .

Arevos Dec 8th, 2005 8:07 AM

Learning programming languages is slightly different from natural languages. Compared to programming languages, natural languages have a hugely complex syntax, and a gigantic dictionary of semantics. In addition, there is much more overlap between programming languages than there is between computer languages.

For instance:
:

if x == 1:
  print "X is 1"
------------------------------------
if (x == 1) {
  System.out.println("X is 1");
}
------------------------------------
if (x == 1) {
  printf("X is 1");
}
------------------------------------
if (x == 1) {
  cout << "X is 1";
}
------------------------------------
if x == 1
  print "X is 1"
end
------------------------------------
print "X is 1" if x == 1;
------------------------------------
IF x = 1 THEN
  PRINT "X is 1"
ENDIF
------------------------------------
(when (= x 1) "X is 1")
------------------------------------
if [ x = 1 ]
then
  echo "X is 1"
fi

All from different languages, but all rather similar. Thus, the confusion that arises is less so than one might initially expect.

There is, however, an awfully large difference between the performance of different computer languages in different situations. A book written in English will not be significantly shorter or longer than the same book written in German. A program written in C will be significantly faster than a program written in, say, Ruby - and likewise, a program written in C will probably take a lot longer to write than one in Ruby!

Some programming languages, such as Perl, appeal to quick scripts and fast results. Others have libraries that make them especially good for certain tasks. Python's Twisted networking library, for instance, makes it an ideal candidate for creating custom network clients and servers in.

grumpy Dec 8th, 2005 4:21 PM

Quote:

Originally Posted by Arevos
All from different languages, but all rather similar. Thus, the confusion that arises is less so than one might initially expect.

Depends on which way you look at it. If you are reading someone elses code, the similarities are more obvious in your examples. If you are writing code, the similarities are not as obvious (eg if you use a syntax from C, you will confuse a Fortran compiler).

And try giving an example, even for your simple case, in assembler!

If you are doing more advanced things than your example, the visual differences between languages become more obvious as well.

Quote:

Originally Posted by Arevos
There is, however, an awfully large difference between the performance of different computer languages in different situations. A book written in English will not be significantly shorter or longer than the same book written in German. A program written in C will be significantly faster than a program written in, say, Ruby - and likewise, a program written in C will probably take a lot longer to write than one in Ruby!

For non-trivial programs (and your examples are reasonably characterised as trivial) it will also be less obvious that the program in C and the one in Ruby actually do the same thing.

Arevos Dec 8th, 2005 6:07 PM

Quote:

Originally Posted by grumpy
Depends on which way you look at it. If you are reading someone elses code, the similarities are more obvious in your examples. If you are writing code, the similarities are not as obvious (eg if you use a syntax from C, you will confuse a Fortran compiler).

Nevertheless, compared to natural languages, the differences between computer languages are not considerable. To be fluent in a natural language, you have to know something like 6000 words. To be fluent in a computer language, I'd be surprised if that number exceeds 50.

Likewise, the syntax of a computer language is consistant and often consists of a relatively few rules. Compare this to the shifting inconsistancies of English!

Further, the similarities between languages run deep. Once you know that an if statement executes a block of code on a condition, you need only learn the way this differs between languages. In Java, blocks are delimited by {}, conditions are surrounded by (), commands are delimited by ;. In Python, blocks are delimited by whitespace, control statments end in :, and commands are delimited by newlines. In just two sentences, a significant proportion of the differences between the languages are revealed.

You make a good point that programs are rarely this simple, but programs are often made up of simple parts. The syntax of computer languages tends to be rather concise and to the point; the complexity comes generally from libraries, and even the most experienced of programmers only bother learning the very most common libraries by heart.

grumpy Dec 8th, 2005 10:20 PM

Quote:

Originally Posted by Arevos
Nevertheless, compared to natural languages, the differences between computer languages are not considerable. To be fluent in a natural language, you have to know something like 6000 words. To be fluent in a computer language, I'd be surprised if that number exceeds 50.

You are focusing only on syntax. Number of words known isn't the only measure of fluency in a natural language. There is also the semantics and grammar. It just happens that the process of learning a natural language happens to result in a student having a working knowledge of semantics and grammar at about the point where s/he has learnt 6000 words or so.

Programming languages are different, in that the basic syntax is often quite simple, but the grammar (what can go with what) and semantics (meanings of different combinations of constructs) are more complex, particularly with modern programming languages.
Quote:

Originally Posted by Arevos
Likewise, the syntax of a computer language is consistant and often consists of a relatively few rules. Compare this to the shifting inconsistancies of English!

You might want to check up on the history of C and C++. Those languages have changed a considerable amount since they were created. As an example, the C++ standard was in draft for ten years or so (during which several drafts were available, with substantial differences between versions) and compilers were implemented along the way. Hence it is possible to find some C++ compilers that won't compile code that is compliant with expectations of the standard.

Again, the issue is that you are focusing on syntax and ignoring fundamentals such as semantics (i.e. meaning of code constructs). I would agree it is quite easy to learn the basic syntax of languages like C++. A lot of the problems that novices (and even some experts) have with C++ (eg in forums like this one) are unrelated to the syntax. The bulk of problems come about because people attach meaning to some code constructs that is invalid.

Quote:

Originally Posted by Arevos
Further, the similarities between languages run deep. Once you know that an if statement executes a block of code on a condition, you need only learn the way this differs between languages. In Java, blocks are delimited by {}, conditions are surrounded by (), commands are delimited by ;. In Python, blocks are delimited by whitespace, control statments end in :, and commands are delimited by newlines. In just two sentences, a significant proportion of the differences between the languages are revealed.

You make a good point that programs are rarely this simple, but programs are often made up of simple parts. The syntax of computer languages tends to be rather concise and to the point; the complexity comes generally from libraries, and even the most experienced of programmers only bother learning the very most common libraries by heart.

The reason that similarities between syntaxes of programming languages appear to run deep is that those syntaxes are actually based on english, and hence readable to the native english speaker. For example, a construct "if (x = 1)" is actually readable (in a "big hands, small maps" kind of way) to someone who has a little knowledge of english. That is a property of the syntax of the language. But the actual meaning of that construct is where the differences between languages come in. For example, "if (x = 1)" has a markedly different effect in C than it does in Basic.

titaniumdecoy Dec 8th, 2005 10:44 PM

Some people go so far as to say it is impossible to learn more than one language when you are starting out. I suggest you get a good understanding of at least one language before moving on and learning others.


All times are GMT -5. The time now is 8:56 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC