Different languages?

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Different languages?

Post by doubleman on Thu Jul 10, 2008 2:38 pm
([msg=7100]see Different languages?[/msg])

I think this is the quote that started me on what I thought was the thought I was thinking.... yeah.

Nathandelane said

"Going back to Python, if you want to learn another language, then I would take on Java - it's built at a higher level than C or C++, so there's less you need to worry about, but it teaches about the same constructs that exist in C++ more or less. Knowing Java can help you learn C and C++ better."

If Java is built at a higher language (though I'm not sure what that means, I could just read the wikipedia article on programming languages), then why learn C or C++? What's the use in saying "hello world", in Javascript, when we can say it in C? Does C have more functions? Why do we use Javascript? I know this might anger some people who love their languages, but why wouldn't we just have a language that "does it all"? Is this impossible?
doubleman
New User
New User
 
Posts: 30
Joined: Thu Jun 26, 2008 4:15 pm
Blog: View Blog (0)


Re: Different languages?

Post by nathandelane on Thu Jul 10, 2008 3:11 pm
([msg=7104]see Re: Different languages?[/msg])

Haha - that's a good laugh. You shouldn't anger anybody by writing stuff like

doubleman wrote:If Java is built at a higher language (though I'm not sure what that means, I could just read the wikipedia article on programming languages), then why learn C or C++? What's the use in saying "hello world", in Javascript, when we can say it in C? Does C have more functions? Why do we use Javascript? ...why wouldn't we just have a language that "does it all"? Is this impossible?


Anyway, the reason that I think we have different programming languages is because there are specific needs based on the system (I don't mean the computer, I mean the software). For example, using C to write a program that moves a whole tree of files on your hard drive up a whole directory might be overkill - that's what scripting and shell languages are far - one time simple tasks (don't get me wrong, they are also useful for full-out applications). By saying that Java is built at a higher level than C or C++, I am talking about the level at which you must understand what the computer is doing in order to program. Higher-level languages, like C#, Java, or even Python abstract most of the low-level stuff or stuff closest to the machine. That makes it simpler to write a program that does more in less time. Writing a program at the lowest level, machine code, that would do the same thing might take hours, whereas the Java version might take minutes. The reason we have C and C++ is to write applications that have full control over the computer that they run on, like operating systems such as Windows or Linux, but we don't necessarily need to have full control when we write a simple text editor, so it might be quicker and in many cases more useful to write the text editor in C#.

Basically for the most part choosing a programming language to use comes down to a few things, 1) What is implemented on the system? 2) What does the language need to do? 3) How well do you know which language? and 4) Can you do what you want to do in which language? Javascript is suitable for scripting web pages and shell scripts, but not very good for writing a word processor. Java is better for writing a word processor, but you'd have to go about it in a convoluted way to use it for scripting a web page, granted there are servlets, but they are server-side, whereas JavaScript would be client-side -- different experiences completely.

I hope that gives you a better understanding somewhat of why so many languages exist in the realm of programming.
Me, Nathandelane, Highly influential to Hackerdom, Premature Optimization=http://c2.com/cgi/wiki?PrematureOptimization
User avatar
nathandelane
Poster
Poster
 
Posts: 204
Joined: Thu Jun 26, 2008 11:26 am
Location: Utah
Blog: View Blog (0)


Re: Different languages?

Post by doubleman on Thu Jul 10, 2008 4:52 pm
([msg=7114]see Re: Different languages?[/msg])

Wow. That was a good post, I'll re read that one.

Do high level languages have less functions than lower level languages like C++?

If I used C++ for something like a program (like an .exe), would it run slower because it has more text in it, and is more complex? Would it compile slower?
doubleman
New User
New User
 
Posts: 30
Joined: Thu Jun 26, 2008 4:15 pm
Blog: View Blog (0)


Re: Different languages?

Post by nathandelane on Thu Jul 10, 2008 5:38 pm
([msg=7125]see Re: Different languages?[/msg])

doubleman wrote:Do high level languages have less functions than lower level languages like C++?


Yes and no. High level languages offer larger APIs or frameworks for programming - usually more is implemented for you so that you're not spending your time reinventing the wheel. For example the Java 6 Development Kit (JDK) has 3,778 classes comprising hundreds of thousands of functions in 202 libraries (called packages), while ANSI/ISO Standard C has only about 100 functions in 15 libraries (called header files). But you can't write an operating system in Java (at least not effectively and not at the machine level), and you can in C.

doubleman wrote:If I used C++ for something like a program (like an .exe), would it run slower because it has more text in it, and is more complex? Would it compile slower?


Generally speaking, the less complex the language is, the smaller it is, and yes the smaller it is the less time it takes to load, but in a day when Pentium 4 processors are faster than 1980's supercomputers, speed is not as much of a concern in most cases. Still writing your programs as concise as possible weighs heavily on the performance of your program. You can write a simple program in about four lines of code or you could extend it to 20. That DOES affect how big your program will be. Programming languages are just like computers - they do exactly what you tell them to do and in the way you tell them to do it. So if you write your code in a sloppy manner, then it may become clunky, large, and overbearing. Practice is the key here. The more you practice, the better your programs will be. But there is little to no indication that, for example, writing a program that is compiled into machine code (lowest level) will perform faster than one written in an interpreted or intermediate compiled program (like those written in Python or Java) -- it mostly relies on how good the programmer is and how well he or she understands the language they are using to program.
Me, Nathandelane, Highly influential to Hackerdom, Premature Optimization=http://c2.com/cgi/wiki?PrematureOptimization
User avatar
nathandelane
Poster
Poster
 
Posts: 204
Joined: Thu Jun 26, 2008 11:26 am
Location: Utah
Blog: View Blog (0)


Re: Different languages?

Post by doubleman on Sat Jul 12, 2008 12:38 pm
([msg=7282]see Re: Different languages?[/msg])

Thank you for such expert insight. I hate to get nit picky with one more question, but, why can't you write an operating system with Java?

I appreciate your responses, they are very informative.
doubleman
New User
New User
 
Posts: 30
Joined: Thu Jun 26, 2008 4:15 pm
Blog: View Blog (0)


Re: Different languages?

Post by BhaaL on Sun Jul 13, 2008 5:28 am
([msg=7321]see Re: Different languages?[/msg])

Java runs on top of the JVM (Java Virtual Machine), which interprets Java bytecode - a step prior to real machine code as Assembler is. For that reason, Java is pretty much portable, as it works on every platform that has a JVM.
The Idea itself isnt that far off tho. Microsoft presented Singularity as Managed Operating System (based on the .Net Framework), and others also got that Idea (such as SharpOS and Cosmos) - they use an ahead-of-time compiler to make Assembler instructions of the target platform before running, similar like the .Net Runtime does with the CIL Code prior to execution. The Difference to the Java VM is that CIL is actually compiled just-in-time, while Java bytecode is not.
BhaaL
Poster
Poster
 
Posts: 270
Joined: Sun Apr 13, 2008 11:16 am
Blog: View Blog (0)



Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests