Programming Languages

speakers_86

Registered User.
Local time
Today, 05:13
Joined
May 17, 2007
Messages
1,919
I am trying to study the different languages so I can expand my abilities a little. There are so many language options, it's hard to figure out what is what. I know there is C, C#,C++,Flash, Flex, Delphi, VB, and I am sure there are many more.

Can you guys tell me what these languages are ideal for? Right now my understanding is that C# is for games, Flash is for the typical stuff you see online like short games and what not.

What if I wanted to build a media player? What would be the best language? I have seen the vb media players, but it seems they are very limited as the results turn out to be the same as if it were done in Access. What if I wanted to build a skin for some other player, like winamp or WMP?
 
C# is actually quite prevalent in conjunction with ASP.NET (web programming) but it is also very active in just Windows Presentation Foundation (WPF) programming.

C++ is a very low level language which many prominent applications are built upon. Access is one example of a C++ (with a little C# programming).
 
What do you mean by low level?

So I guess just about anything could be done with C++?
 
'low-level' refers to the level of abstraction.

On top, you have very high level language, usually scripting languages such as VBA, Python, etc. On the bottom, you have machine code. Nothing good or bad about this- I usually think of an analogy:

You have a chandelier. You want to get the lights to dim. Easy-squeezy. You go to the hardware store, buy a dimmer switch, swap in the old switch with the dimmer switch and you got the dimming effect. Now your lovely spouse would like the chandelier to be able to dim independently for each tier on the chandelier. Hm. Not easy as getting another dimmer switch. You now have to bring down the chandelier, rewire the wiring so there's two separate wires running to the now two separate dimmer switch.

Replacing the dimmer was high level because you bought a off shelf component ready to use. Rewiring the chandelier meant you had to do everything yourself but you could do more. That took more effort, knowledge and time than it did to install a dimmer.

It is not unusual for a complex project to span across different languages - use low level languages such as C or assembly language to do some highly specialized driver-y thing, use general purpose language such as C++ or C# or Java for bulk of application logic, then some scripting language for quick glue jobs.
 
what I dont understand is

does c produce more efficient code than VB?

is

int i = 1; in C more efficient than the nearly equivalent VB

dim i as long
i = 1

---------------
i presume its not vastly different - so other than VB not having a pointer type, what differences are there that make C code faster than any other compiled code.
 
C produces code that is actually closer to machine code than VB. So, basically the answer is yes it is more efficient because it doesn't have to go through extra translation layers. But in today's world of computers it would need to be some really heavy duty computing to really notice a difference.
 
does c produce more efficient code than VB?

One more thing to remember is that C-family language are usually compiled while VBA (as well as many scripting languages such as PHP, Python, Perl) are generally interpreted. Then there's languages that compiles to an intermediate language such as Java, C#, VB.NET.

It's not quite that straightforward because there can be C interpreter and Visual Basic compiler but it's important to keep in mind how we got the output.

With a compiled program, we're very close to the machine code and thus have most optimization available to us. With an interpreted language, it's much slower because the statement has to be executed by an interpreter at runtime. Java and .NET tries to get the best of both world by compiling to an intermediate language and thus getting optimizations while keeping the flexibility that was had in an interpreted language.

Here's a site benchmarking various languages. I've selected C (e.g. compiled) vs. Python (e.g. interpreted) to illustrate the difference. Then compare Java (compiled to bytecode) and see what the difference. Unfortunately, there's no Visual Basic in the list, but hopefully you can get some idea of what difference this means for whether a language is natively compiled, compiled to bytecodes, and interpreted.

int i = 1; in C more efficient than the nearly equivalent VB

dim i as long
i = 1

To be fair, I wouldn't be surprised that both takes two instructions (or more?) to process even though C-family language enables us to declare and assign the default in one line. In other words, just because we can write it on one line does not translate into one instruction at the assembly level. It will depend more on how well designed a given compiler/interpreter is and what optimizations it can do to the source code when it translate the code into the executable.

Here's a fun reading.
 
So are you trying to say that the higher levels are actually written in a lower level language? So Flash and VB and all the others are all based on some version of C?
 
Well, all languages have to compile down into binary. This is the only thing computers actually understand and speak. So yes, someone had to build a compiler from something. C compiler was probably written in an assembly language. Visual Basic compiler may have been written in C++ (but I don't know this for a fact).

Heck, you can even write your own compiler & language if you want. For example: Brainfuck

Hello world code:
++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------.>+.>.

Yes, it will print out a "Hello, world" once compiled. But I bet that if you looked at the binary content of the executable, it wouldn't be that terribly different from a C's Hello, world program, assuming the same steps was done in the C.

However, it's not all languages, really. You need to consider the framework which is what usually give languages real power. In C, that's C standard library. In C++ on Windows, that's MFC, and on Linux, perhaps Qt or something like that. In C#, that's .NET framework. In Java that's Swing. On Mac OS X, there's also Cocoa and Carbon framework. To provide an analogy in VBA, I suppose you could think of Access Object Model as the framework... think of how many times you've used stuff like DoCmd, CurrentDb, and various methods to simplify operations that would have been tedious to replicate by hand. That's what framework does here, enabling us to do a "OpenWindows" rather than "Draw a rectange 100 by 100 pixels, put on a blue rectangle on the top, add three boxes with the icons on right........" Now, though frameworks are usually associated with languages, they are not exclusive. That is, there's nothing stopping you from using Swing with Perl, MFC with Visual Basic, and so forth. It's not always the case, though, as is with .NET which requires COM interop (COM is yet another framework, and is in fact what we use all time to automate Access, Excel, Word among many other things) so while C# can't work with Access objects directly it can do via COM, and if it provides an interface via COM, Access can access it, too.

So in broad sense, frameworks and libraries are language neutral but that's usually where the most of power come from.

I hope this helps a bit.
 
VBA is not interpreted at runtime -- it's precompiled to p-code. This makes it substantially more efficient than pure interpreted languages.
 
I want to try my hand at C++. Is there a good tool for a new guy? I found this. Is that a good way to start? I may go and buy a book too, although I already have 2 that I need to start reading.
 
What if I wanted to build a media player? What would be the best language? I have seen the vb media players, but it seems they are very limited as the results turn out to be the same as if it were done in Access. What if I wanted to build a skin for some other player, like winamp or WMP?
You can use a mixture of languages to build that if you so desire, but for manageability it's best to stick with one. Java Swing is good for that kind of stuff using netbeans IDE. You could also consider C++ and Java, however, C could also handle the back end quite efficiently.

For skins, I believe there are proprietary languages for WINAMP (and the like). It might be Foo, but not sure. Most are compiled using C.
 
Can I just ask why it would be more useful to compile a program at runtime?

From my understanding of VB when you compile it it seems to take less than a second to do any VB I've ever written. (If the compiling is a proper compiler (picture of a running man))

As people have said everything needs to be translated into the instruction set anyway so why not just do it quickly beforehand and then you won't need an interpreter running constantly. Which presumable is
a)taking up memory
b)is an extra set of things going through the processors

My idea was that a compiled language no matter what will have the same instructions as any other - there's only 7 odd gates (depending on combinations) everything has to go through anyway - so the sooner you can get it compiled down into the instructions for those 7 gates the better.
 
Can I just ask why it would be more useful to compile a program at runtime?

Who said that? I couldn't see it in the quick skim and the discussion was about interpreted vs. compiled languages. David Fenton already correctly pointed out that VBA compiles into p-codes which are then interpreted at the runtime.

From my understanding of VB when you compile it it seems to take less than a second to do any VB I've ever written. (If the compiling is a proper compiler (picture of a running man))

But the thing is we're not compiling into machine code - we're compiling into p-codes. To provide an analogy, Java usually compiles into bytecodes which is essentially the same thing and requires a runtime engine to run the bytecodes. Same thing with .NET - you have to have .NET framework/runtime to run .NET code. In Visual Basic 6 there was a option to compile code into p-codes or into native code (whether that means machine code or something, I'm not entirely sure) and I imagine there are Java compiler that does convert Java code into true machine code but once done that, it's only good for that one platform, which goes against Java's premise of "write once, run anywhere" because you have to have compiler for each different platform.

As people have said everything needs to be translated into the instruction set anyway so why not just do it quickly beforehand and then you won't need an interpreter running constantly. Which presumable is
a)taking up memory
b)is an extra set of things going through the processors

Well, one benefit of interpreted language is that you have more control over its execution - it's why one can stop and step, change code during it's running, etc. That wouldn't be easily done in machine code. Again, while VBA and Java are not true interpreted languages, they combined the bests from both worlds.

My idea was that a compiled language no matter what will have the same instructions as any other - there's only 7 odd gates (depending on combinations) everything has to go through anyway - so the sooner you can get it compiled down into the instructions for those 7 gates the better.

That's not correct. Each architecture (indeed, each processor model even from the same family, in fact) has their own distinct instruction set and one instruction set may not be compatible with other. The compiler's job is to convert the source code to something that will work with a given platform's instruction set. Think about various features you've heard of - Intel's MMX, VMX and AMD's Hyperthreading and so forth - those requires special instruction sets and thus need to be compiled specially (or at least use a runtime library that provides a high level access to those functionality) to take advantage of such things.
 
Brilliant B really cleared up some bad misconceptions which had been holding me up and confusing me..

So runtime also allows for platform independence which obviously is a major advantage.!

I've just been reading up on all of this to try and get a good basis understanding of how it all works. I must admit its very interesting and how it all fits together is genius. Despite all of the reading I didn't quite pick up on these points.

The thing is a computer should be a completely knowable thing. Everything has been designed by individuals. But the actual number of people that fully understand the process seems to be very small!
 
Brilliant B really cleared up some bad misconceptions which had been holding me up and confusing me..

So runtime also allows for platform independence which obviously is a major advantage.!

I've just been reading up on all of this to try and get a good basis understanding of how it all works. I must admit its very interesting and how it all fits together is genius. Despite all of the reading I didn't quite pick up on these points.

The thing is a computer should be a completely knowable thing. Everything has been designed by individuals. But the actual number of people that fully understand the process seems to be very small!

au contraire probably.

compilers and the like insulate users from needing to understand anything about the instructions actually being undertaken by the processors, As in anything a little knowledge may help though.

I remember using 40x25 character displays, and learning techniques to push the screen display into a memory stack, thereby giving instantaneous popup windows. All redundant now? I doubt if you can write to dedicated screen memory now.

------------
Anyone familiar with Jeff Minter - unbelievable ability to manage the VIC20 - you would not believe what he could do with 8K memory.
 

Users who are viewing this thread

Back
Top Bottom