Thread: Computer Language question

  1. #1
    Some Guy
    Join Date
    Jul 2004
    Posts
    32

    Computer Language question

    Ok, I understand that assembly language is considerably faster than higher level languages, but I don't understand why? Is it because it just has to pass through the assembler to generate executable code? Thanks.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Posts
    719
    assembler CAN be faster. but thanks to advanced compilers, it would take a lot more effort to optimize assembler code better than most c/c++ compilers.

    the reason it's faster is because you tell the processor, instruction by instruction, what to do while higher level langues kind of put some stuff in that isn't absolutely necessary.
    i seem to have GCC 3.3.4
    But how do i start it?
    I dont have a menu for it or anything.

  3. #3
    Some Guy
    Join Date
    Jul 2004
    Posts
    32
    So, essentially, it's a direct translation?

  4. #4
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Yes. With the exception of assembler-specific things like the ways in which the data section, code section, etc... are designated, assembly code is simply a mnemonic for the binary machine code.

  5. #5
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    Essentially, yes.

    Machine code is essentially the computer's 'native' language. Assemblers assemble code on a 1:1 basis, whereas compilers will compile on a 1:N basis - that is, one instruction in a high level language translates to many machine instructions.

    But as per misplaced's post, C code is often so highly optimised that you wouldn't know the difference.
    I think you can put a signature here.

  6. #6
    Some Guy
    Join Date
    Jul 2004
    Posts
    32
    Would there be a significant difference with Java? Also, so is C considered a low-level language?

  7. #7
    ---
    Join Date
    May 2004
    Posts
    1,379
    C and java are both high level. Java compiles into it's own binary format which is then interpreted by the jvm (am i right?) which is how java becomes portable.

  8. #8
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    Java isn't compiled all the way to machine code. It is compiled into Java byte codes (*.class files) and then interpreted into machine code at run-time (hence Java's corss-platform functionality), so I wouldn't be surprized if you started seeing some major slow-downs there, but again, the process has been almost 'perfected' and it shouldn't make much of a difference. C can be considered both a high-level and low-level language, which is what makes it such a versatile language. C/C++ both can interface directly with memory, which means that can do [almost] anything that assembly can, but they both allow for the re-use of code in an object-oriented way, which makes it possible to create libraries for high-level jobs such as Win32 programming.

  9. #9
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >>Java isn't compiled all the way to machine code.

    in most cases this is correct but its also worthy to note that java can be compiled nativly by using gcj

  10. #10
    The C-er
    Join Date
    Mar 2004
    Posts
    192
    Another reason assembler can be faster is that it allows you to approach the problem space in a different way. You look at all those lovely instructions, and think - hey! I could use *that* to do *this*, whereas in C you're more likely to use an idiomatic form of coding, and let the compiler sort it out. In assembler you're free to do stuff that a compiler would never consider.

    When I'm writing optimised code in C, I tend to have an idea of what the compiler will do with my code, from an assembly point of view. Thus I reckon learning assembler makes you a better C coder.

    Also, so is C considered a low-level language?
    Well, to be controversial, I would say C is pretty low level, with a gloss of some high level features added. You can't really ignore the low level aspects of it, certain features are arranged much for the convenience of the machine, not the programmer.

    For my current project, I'm using C, because it's too complex to be realised in assembler. The last version though (written in 1991) was written in 68k assembler, with a BASIC shell.

    Also I don't really know x86 assembler (yet), and don't like the look of it much.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tabbed Windows with MDI?
    By willc0de4food in forum Windows Programming
    Replies: 25
    Last Post: 05-19-2005, 10:58 PM
  2. General Computer Question
    By maththeorylvr in forum Tech Board
    Replies: 3
    Last Post: 04-29-2005, 03:38 PM
  3. Multithreaded computer language
    By Sang-drax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 09-17-2004, 08:51 PM
  4. Computer will not boot.
    By RealityFusion in forum Tech Board
    Replies: 25
    Last Post: 09-10-2004, 04:05 PM
  5. Enough language discussions.
    By VirtualAce in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 06-13-2004, 09:59 AM