Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

O que são, realmente, programas de computador

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    O que são, realmente, programas de computador

    Bom galera, esse artigo eu escrevi pra um fórum gringo, motivo pelo qual ele tá em inglês. Eu sou novo aqui então não sei se a galera fala, mas a dica é que se você quiser ter algum futuro com computadores, precisa saber inglês.

    Qualquer coisa, vocês pedem que eu traduzo. O artigo explica exatamente em que consiste um programa de computador. Escrevi ele porque no fórum onde postei, nem todo mundo sabia rodar códigos perl (acreditem, era um fórum de hacking... rs), mas acabei falando mais do funcionamento de programas em si do que de perl... enfim, aí tá o artigo:



    ::: Programming 101 :::

    A computer program is nothing more than a set of instructions. The program usually receives input data, processes it, and spits back certain results. These instructions are binary words, which can be 32 or 64 bits long. Each individual processor has different ways of interpreting these instructions and executing them, and exactly how they do this is irrelevant to us. We won't be going over any hardware-level implementation here.

    So, in general, a programmer writes a bunch of instructions/commands using a pre-defined syntax and structure. These patterns are individual to each programming language. If the language being used is a high-level language, then the commands and instructions are usually related to english-language words. A few examples are "do", "fopen" ("file open"), "print" (or the C-equivalent "printf"), etc.

    Classifying a language as "high-level" is the same as saying that the level of abstraction of the language is high. In other words, the commands and instructions the language implements are further (or "higher") away from machine-language instructions (which are usually limited to adding, subtracting, multiplying, dividing, "jumping", "storing", "loading", etc).

    Some examples of high-level programming languages are C, C++, C#, Delphi (and its predecessor, Pascal), and a bunch of others. A low level language is Assembly (asm).

    After writing your code in any of these high-level languages, it must be compiled. A compiler program takes your high-level code and generates the equivalent code in Assembly. The assembly code generated is specific to the processor being used (in other words, the same C code would generate different asm codes if compiled in different processors). Then the assembly code is passed through an assembler, who builds the final executable (binary file). The binary generated from it varies according to the operating system (because the functions and instructions are high-level, each of them correspond to different specific and smaller functions and instructions that must interact with the operating system, thus generating different binaries).

    To sketch it up:

    High-level Code --> [ Compiler ] --> Assembly (low level) code --> [assember] --> Binary instructions (executable file).

    Once you have your binary instructions, you can execute them by making a system call to them (in Windows, this is equivalent to the "start" command, or to double clicking the binary file, and in linux, to simply doing "./[binaryname").

    This is how computer programs are built.




    ::: Interpreted Languages :::

    Some programming languages are of even higher level than the ones I listed above. Those languages aren't compiled (turned into binary instructions), but instead, have their instructions passed on to an "interpreter", which will, obviously, "interpret" each command and execute the designated task. The advantage of this approach is the fact that interpreted code can be run under any platform, as long as the correct interpreter is installed on the machine (Perl or Java code will work on any machine that has the correct Java Virtual Machine or Perl interpreter installed). Execution happens WHILE the code is being read by the interpreter.

    The disadvantage of this approach is the loss in performance. As a general rule, the more "layers" there are between user and hardware, the lower the performance. Following this line of thinking, it's easy to conclude that a program written in Assembly will run WAY faster than C code, which will in turn run WAY faster than Java code (the C program will communicate directly with the Operating System, whereas the Java code must first be read by the Virtual Machine, which needs to process it, and only then pass the instructions on to the OS).

    Coding in lower level lets you get rid of "useless" instructions (and useless instructions WILL be created by any "automated" interpreter or compiler), but it is also harder, because you work with simpler instructions. Accessing data on a file in C is a piece of cake, while in Assembly it can be hell. On the same line of thought, Java has a bunch of "classes" (won't be explaining this) that allow you to quickly manipulate different types of files and data, while in C you must do all the handling yourself. Again, this is easier, but slower.

    I would also like to mention that the Java Virtual Machine, while being more "complete" in many ways, is also very (very) heavy and slow. The level of abstraction of the Java Language is incredibly high, thus making it incredibly slow. It is also very restrictive (messing with memory isn't really interesting in this thing).

    Overview:


    Execution Scheme:

    Compiled Languages: Binary File -> Operating System -> Processor
    Interpreted Languages: Source Code File -> Interpreter / Virtual Machine -> Operating System -> Processor



    Speed/Performance: Assembly >> C/C++/C#/Delphi... > Perl/Python... > Java
    Code Specificity: Assembly >> C/C++/C#/Delphi... > Perl/Python... == Java




    Note: do NOT mistake Java for JavaScript. They're completely different things and have completely different applications. To us, it is irrelevant.





    ::: Perl 101 :::

    What you need to know about perl is:


    - It is an interpreted language.

    While any linux distros will come with a perl interpreter, Windows versions will not. This means you need to install a Windows interpreter. I use Activeperl, which you can download for free here:

    Código:
    http://www.activestate.com/activeperl/
    As you install it, it will ask you weather it should associate with .pl files. You should, obviously, tell it to do so. This will allow you to run perl scripts by double clicking them, which might or not be useful (since the window will automatically close at the end of execution if the programmer didn't include a pause at the end, and you won't be able to pass arguments to the program).

    After you get it installed, you can run perl scripts by calling them from the command prompt.



    - It's fast. Very fast, considering it's interpreted.

    - Despite being fast, GUI applications aren't its strong point. That's not the main goal of Perl, anyways, so no biggie.

    - Perl allows for simple ways of implementing complex algorithms. There's no distinction between data types (a variable can hold integers, floats, characters, etc), and working with arrays is pure bliss. Operators in Perl are very [VERY] powerful. The way it handles regular expressions is another advantage of the language. Perl has a bunch of modules to help automatize procedures. It does support multithreading, although some modules aren't thread-safe.


    eof

  • Font Size
    #2
    Muito bom ae!!
    Realmente!! Não tem como galera entrar na área de Informática e ser leigo em Inglês.
    O Inglês ja é o básico, agora além de Ingles temos que saber outra lingua!

    Vlw a contribuição ae!
    Não te engane. De Deus não se zomba, o que o homem plantar, é o que ele vai colher. (Gálatas 6:7)


    sigpic


    Comment

    X
    Working...
    X