The best VPN 2023

The Best VPS 2023

The Best C# Book

Classifying Programming Languages

.global f f: andcc %o0, 1, %g0 bne .L1 sll %o0, 2, %g2 sll %o0, 1, %g2 add %g2, %o0, %g2 b .L2 add %g2, 1, %o0 .L1: add %g2, -3, %o0 .L2: retl nop

Different languages have different purposes, so it makes sense to talk about different kinds, or types, of languages. Some types are:, that are interpreted directly in hardware, that are thin wrappers over a corresponding machine language, that are anything machine-independent, that are designed for writing low-level tasks, like memory and process management, that are generally extremely high-level and powerful, that are used in highly special-purpose areas only, that are not really intended to be used, but are very interesting, funny, or educational in some way

An assembly language is an encoding of machine code into something more readable. It assigns human-readablelabels(or names) to storage locations, jump targets, and subroutine starting addresses, but doesnt really go too far beyond that. Heres the function from above on the Intel 64 architecture using the GAS assembly language:

Names for almost everything: variables, types, subroutines, constants, modules

These types are not mutually exclusive: Perl is both high-level and scripting; C is considered both high-level and system.

and like this in Julia (yes, 3nisthree times n):

and like this in Haskell (thanks @kaftoot):

Can you tell what it does?Assembly Language

: Which of these languages required that variables or functions be declared with types and which did not?

Other types people have identified: Toy, Educational, Very High-Level, Compiled, Interpreted, Free-Form, Curly Brace, Applicative, Von Neumann, Expression-Oriented, Persistent, Concurrent, Glue, Intermediate, Quantum, Hybrid. SeeWikipedias category page on programming language classification.Machine Code

A high-level language gets away from all the constraints of a particular machine. HLLs have features such as:

2 * (y^5) = 88 && sqrt(4.8) / 2 % 3 == 9

Control structures (conditionals, switches, loops)

Easy, often implicit, ways to manage global, local and heap storage

An esoteric language is one not intended to be taken seriously. They can be jokes, near-minimalistic, or despotic (purposely obfuscated or non-deterministic).

fortran logo32

.globl f .text f: mov %edi, %eax Put first parameter into eax register test $1, %eax Examine least significant bit jnz odd If its not a zero, jump to odd imul $3, %eax Its even, so multiply it by 3 inc %eax and add 1 ret and return it odd: shl $2, %eax Its odd, so multiply by 4 sub $3, %eax and subtract 3 ret and return it

Most computers work by executing stored programs in a fetch-execute cycle. Machine code generally features:Registersto store values and intermediate resultsVery low-level machine instructions (add,sub,div,sqrt)Labels and conditional jumps to express control flowA lack of memory management support programmers do that themselves

And heres the same function, written for the SPARC:

Abstract data types, modules, packages, classes

John Ousterhout once claimed that programming languages roughly fall into two types, which he called scripting and system languages. You can read about this idea atWikipedia. Then read this two-part article (Part 1,Part 2) on the dichotomy and on languages that seem to reject it.

SeeWikipedias article on esoteric languages.Exercise: Implement the function above in False, Brainfuck, Befunge, Malbolge, Kipple, and reMorse.Ousterhouts Dichotomy

System programming languages differ fromapplication programming languagesin that they are more concerned with managing a computer system rather than solving general problems in health care, game playing, or finance. In a system langauge, the programmer, not the runtime system, is generally responsible for:

Machine code is usually written in hex. Heres an example for the Intel 64 architecture:89 F8 A9 01 00 00 00 75 06 6B C0 03 FF C0 C3 C1 E0 02 83 E8 03 C3

The previous example looks like this in Fortran 77 (note how the code begins in column 7 or beyond):

and like this in Fortran 90 (where the column requirements were finally removed):integer function f (n) implicit none integer, intent(in) :: n if (mod(n, 2) == 0) then f = 3 * n + 1 else f = 4 * n – 3 end if end function f

Scripting languages are used for wiring together systems and applications at a very high level. They are almost always extremely expressive (they do a lot with very little code) and usually dynamic (meaning the compiler does very little, while the run-time system does almost everything).Esoteric Languages

: Implement this function in PHP, Objective C, Ceylon, D, and Mercury.

Subroutines with their own private scope

Leave a Comment