Changes

Jump to navigation Jump to search
549 bytes added ,  06:33, March 25, 2021
Added comparison source code
Line 24: Line 24:  
==Low-level vs High-level==
 
==Low-level vs High-level==
 
Programming languages can be categorized by whether they are low-level or high-level.  They can also be referred to by "generation".  1st-generation languages are the machine code of the [[CPU]].  2nd-generation languages are the assembly languages.  3rd-generation languages are what most programmers use in the modern world and include such things as BASIC, C++, Pascal, and PHP.  4th-generation languages are domain-specific and offer productivity gains for programmers in those domains, but their narrow focus makes them unsuitable for solving problems outside of their specific domain.  1st- and 2nd-generation languages are categorized as low-level, while 3rd- and 4th-generation are categorized as high-level.  Each generation abstracts the programming concepts further away from the hardware that runs the program.  However, concepts and capabilities often cross these generational boundaries over time.
 
Programming languages can be categorized by whether they are low-level or high-level.  They can also be referred to by "generation".  1st-generation languages are the machine code of the [[CPU]].  2nd-generation languages are the assembly languages.  3rd-generation languages are what most programmers use in the modern world and include such things as BASIC, C++, Pascal, and PHP.  4th-generation languages are domain-specific and offer productivity gains for programmers in those domains, but their narrow focus makes them unsuitable for solving problems outside of their specific domain.  1st- and 2nd-generation languages are categorized as low-level, while 3rd- and 4th-generation are categorized as high-level.  Each generation abstracts the programming concepts further away from the hardware that runs the program.  However, concepts and capabilities often cross these generational boundaries over time.
 +
 +
Here's an example of some 3rd-generation (Pascal) code and what the equivalent code looks like in 2nd-generation (assembly):
 +
 +
In Pascal:
 +
<pre>
 +
    P := pos( HT, S ) + 1 ;
 +
    while( S[ P ] <> HT ) do inc( P ) ;
 +
</pre>
 +
 +
In assembly:
 +
<pre>
 +
    lea eax,[ebp-$918]
 +
    mov edx,[ebp-$10]
 +
    call @UStrFromLStr
 +
    mov edx,[ebp-$918]
 +
    mov ecx,1
 +
    mov eax,$62f890
 +
    call Pos
 +
    inc eax
 +
    mov [ebp-$8],eax
 +
    jmp A
 +
loop:
 +
    inc dword ptr [ebp-8]
 +
A:
 +
    mov eax,[ebp-$10]
 +
    mov edx,[ebp-8]
 +
    cmp byte ptr [eax+edx-1],9
 +
    jnz loop:
 +
</pre>
    
===Low-level languages===
 
===Low-level languages===
SkipCaptcha
292

edits

Navigation menu