Programming languages
Basics
Programming language
An artificial language used to write instructions that can be translated into machine language (or subroutines) and then executed by a computer.
Syntax
Syntax is the set of rules that defines the combinations of symbols that are considered to be a correctly structured document or fragment in that language.
Syntax is generally distinguished into three levels: words, phrases and context.
Semantics
Semantics is the field concerned with the rigorous mathematical study of the meaning of programming languages. It does so by evaluating the meaning of syntactically legal strings defined by a specific programming language, showing the computation involved.
Programming languages
Assembly
Fortran
program ProjectEuler
implicit none
integer :: i, s = 0
do i=1,1000
if (modulo(i, 3) == 0 .OR. modulo(i, 5) == 0) then
s = s + i
endif
enddo
write (*,'(A, I6)') "Solution: ", s
end program
C
#include<stdio.h>
int solution(int n);
int main(void) {
printf("Solution: %d\n", solution(1000));
return 0;
}
int solution(int n) {
int sum = 0;
for (int i = 1; i <= n; i++) {
if (i % 3 == 0 || i % 5 == 0) {
sum += i;
}
}
return sum;
}
Haskell
multiples = filter (\x -> mod x 3 == 0 || mod x 5 == 0)
solution = sum . multiples
result arr = "Solution: " ++ show arr
main = putStrLn $ result $ solution [0..1000]
Java
import java.util.stream.IntStream;
public class ProjectEuler {
public static void main (String[] args) {
System.out.println("Solution: " + new Solution(1000).run());
}
}
class Solution {
int n;
public Solution(int n) {
this.n = n;
}
int run() {
return IntStream.rangeClosed(0, n)
.filter(x -> x % 3 == 0 || x % 5 == 0)
.sum();
}
}
Ruby
def solution(n)
(1..n)
.to_a
.select{ |x| x % 3 == 0 || x % 5 == 0 }
.reduce(:+)
end
puts "Solution: #{solution 1000}"
Clojure
(ns project_euler)
(defn result [n]
(->>
(str "Solution: " n)
println))
(defn solution [n]
(->>
(range n)
(filter (fn [x] (or (= (mod x 3) 0) (= (mod x 5) 0))))
(reduce +)))
(result (solution 1000))
JavaScript
function solution(n) {
return Array.from(Array(n))
.map((x, i) => i + 1)
.filter(x => x % 3 == 0 | x % 5 == 0)
.reduce((x, akk) => x + akk,0);
}
console.log(`Solution: ${solution(1000)}`);
Programming and Business
Demand
In fact the US Department of Labor estimates that there will be 1.4 million computer specialist job openings by 2020, and enough qualified graduates to fill…
30%
Salary
Java
$115,000
Python
$100,000
R
$100,000
Objective-C/Swift
$100,000 up to 6 figures
C#
$90,000
JavaScript
$90,000
Perl
$80,000
SQL
$80,000
Ruby
$75,000
C
$60,000 - $80,000
PHP
$75,000
Programming languages
By Michał Załęcki
Programming languages
- 1,536