📜 ⬆️ ⬇️

How to learn programming languages



I do not in any way assert that the method I have indicated is the best possible. Moreover, I am not at all sure that it is correct at all. Perhaps, if my first language was not C, but any of the functional languages ​​or assemblers, my opinion would be different, and my life would have been very different. So take all the material below with healthy skepticism.

Few personal memories


Since childhood, I dreamed of becoming a biologist, but at the age of thirteen, having familiarized myself with the computer at school for the first time, I decided to become a cool hacker. When I had regular access to a computer at the age of fifteen, my first thought was to study programming. I chose C ++ and bought a book from the “For Dummies” series, but everything was terribly boring, incomprehensible and uninteresting. Even then, I realized that something was wrong with C ++. And the very course of the presentation of the material in the book began with a brief excursion into the function, after which they immediately proceeded to classes, and everything was explained not by living examples, but at the level of global abstractions. The authors enthusiastically talked about the beautiful world of the PLO, in which we are lucky enough to live, about cars with different functions or animals with different behaviors. In general, at that time, the study of C ++ and the concept of OOP itself were abandoned.

A few years later, while studying at the university, I saw in the kiosk a small book , The C Programming Language , by Brian Kernigan and Dennis Ritchie . Having bought it, I immediately began reading. And lo and behold! Everything was clear, easy and terribly interesting. The C language is very small, simple and elegant (I still think so), and the book itself was written in normal human language, but not devoid of rigor. I re-read it many times, did the exercises, and thus I soon learned the language and the standard library of functions.
')
But you can't write a lot on pure C, but I wanted to write serious programs with beautiful graphics. I programmed in Slackware Linux , because in Windows I was completely disappointed in the programming environment. In those days, I generally experimented a lot with different systems, including QNX and NetBSD . But in free Unix systems, the choice of sane graphics libraries was small: GTK + and Qt . And the second one was written in C ++, with which I did not want to get involved, and in the first one it wasn’t clear how to work. And, if I didn’t change my memory, their interface editors generated huge code that still needed to be inserted into its program, not resource files, which seemed to me absolutely terrible.

So I would not have started a career if I had not accidentally met Mac OS X, which I recently ported to Intel processors. Asking a Mac OS X 10.5 Leopard drive from a friend, I installed it on my HackBook and felt myself for the first time in the Promised Land.

Remembering my unfortunate first time, for a long time I was skeptical about object-oriented programming . In the beginning, he even planned to write programs in pure C using the Carbon library. And, as it turned out - in vain. Objective-C I learned from the official leadership of the company NeXT - Object-oriented programming and the Objective-C language . In those days, students of a new language were not yet considered to be idiots or schoolchildren, so the book is written in normal language, and the authors assume C knowledge and a general understanding of programming. It turned out that OOP is easy, interesting and very convenient, and objects are not abstract entities at all, but only structures combined with functions. In my opinion, this is exactly the way to tell the basics of object-oriented programming.

In Xcode and the basics of Mac OS X, I figured out the wonderful lessons of Alexey Boreskov. After that, he immediately dived into the Mac Developer Library , began studying official manuals on Cocoa and other libraries, and at the same time began writing programs.

My first major project was porting OpenGL lessons from Windows to Mac OS X, which stretched for a whole year. Only having finished it, I felt confident enough to get a regular paid job.

Studying Objective-C, it is impossible not to hear about Smalltalk, because it is very often referred to in the materials on Objective-C, apparently apologizing for the unusual syntax. But Smalltalk was like the Elusive Joe - everyone heard about him, but few saw or used him. In the end, I wondered where the Russian land came from.

When I learned that Cincom , the leader in Smalltalk solutions, for advertising purposes, provides my tools for non-commercial use, I immediately ordered them. In less than a few weeks, the courier knocked on my door and handed me a branded box with several CDs and official manuals. Everything was completely free, even for the delivery did not have to pay. VisualWorks , one of the most powerful and fast commercial Smalltalk development environments in the world, was discovered on one of the disks.

After I learned about Squeak - a free implementation of Smalltalk, based on the original version of Smalltalk-80 - and met many of its developers. For training and research, it fits much more than other versions. By the way, the Smalltalk community of programmers is very friendly.

Almost all serious projects are cross-platform, and their kernels are written in C ++, for Objective-C is very rarely distributed outside of the Apple ecosystem. Mainly due to the lack of convenient development tools. (Hopefully, thanks to LLVM, the situation will improve soon.) So I had to learn C ++, despite the obvious dislike for it. Fortunately, by this time I had already learned how to separate the wheat from the chaff.

However, I did not become a hacker.

Language learning order


C - first language


This is a small (only 32 keywords in C89 , 37 words in C99 and 44 words in C11 ) an imperative language, and its initial study will not take you much time. At the same time, C is a very powerful industrial language. Mainly used in system programming, writing hardware independent components of operating systems, compilers and translators of languages, libraries, programming of microcontrollers. According to the TIOBE Programming Community Index, C is still the leader in usage, occasionally politely yielding to the primacy of Java.

/* Hello world in C */

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    printf("Hello World!\n");
    return EXIT_SUCCESS;
}

Objective-C –


. , Objective-C. - : . – Apple.

/* Hello world in Objective C */

#import <Foundation/Foundation.h>

int main (int argc, const char *argv[])
{
    NSAutoreleasePool *pool = [NSAutoreleasePool new];
        NSLog (@"Hello, World!\n");
    [pool drain];
    return 0;
}

Smalltalk –


Objective-C . , Objective-C. - . , , , , . , , . , (Kapital – JPMorgan), (CIM Texas Instruments), (IRIS-2 Orient Overseas Container Lines), (Desjardins General Insurance Group) .

"Hello world in Smalltalk" 

Transcript show: 'Hello World!'; cr.


, , . .

C++


( 100), , . , , . C++ , , - - . , Objective-C Smalltalk , C++ . . , «» C++ , , , , Objective-C Java . : . C++ I/O Kit – Mac OS X.

// Hello world in C++ 

#include <iostream>
 
int main()
{
  std::cout << "Hello World!\n";
  return 0;
}

Assembler


, , , . (, Demo ). , , , .

# Hello World in GNU Assembler on Mac OS X 10.8 using System V AMD64 ABI calling convention

.data
_hello:
    .asciz "Hello world!\n"

.text
.globl _main
_main:
    subq $8, %rsp

    movb $0, %al
    leaq _hello(%rip), %rdi
    call _printf

    movq $0, %rdi
    call _exit

JavaScript


, . – web . . web , JavaScript – . : , -, . JavaScript , C- , . JavaScript , .

// Hello world in JavaScript

document.write("Hello World!");

Ada


, . . , Ada . (, , , ), . , C++.

-- Hello world in Ada

with Ada.Text_IO; use Ada.Text_IO;
procedure Hello is
begin
  Put_Line ("Hello, world!");
end Hello;

Scheme


, . Lisp. . , ( ) . .

;; Hello world in Scheme

(begin (display "Hello, World!")
    (newline))

, .


, , Shell, Perl, JavaScript Scheme. . , , , .

, , , . , , . , , C C++ , , . , , , .

, . .

, , ( ) C, , .

- . . , . . , . , , , , - . , , , «» , .

, C – CoreFoundation Mac OS X.

?


. :

-, . « » « 21 ». , , App Store ( , ). -, ANSI/ISO . , -, , .

, , . , , . , , – . .

– , – , , , , «. », , , , (Introduction to Algorithms by Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest and Clifford Stein). . , .

– . , , , . .

. . , , , , . , . – , .

, – , Fortran ( ) Fortran. , , , , . .

, , . stackexchange.com .

– . , . ( ), screensaver, . , : ( ) .


. . , , , . , , . . , , , , . , . .

Source: https://habr.com/ru/post/304816/


All Articles