curs 03 handout
DESCRIPTION
fsfsTRANSCRIPT
![Page 1: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/1.jpg)
Cursul 3Dezvoltarea programelor
Utilizarea Sistemelor de Operare (USO)19 octombrie 2015
Departamentul de Calculatoare
CSE Dep Cursul 3, Dezvoltarea programelor 1/61
![Page 2: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/2.jpg)
Moto
There are only two kinds of programming languages: those peoplealways bitch about and those nobody uses.
Bjarne Stroustrup
One of the main causes of the fall of the Roman Empire was that –lacking zero – they had no way to indicate successful termination
of their C programs.
Robert Firth
CSE Dep Cursul 3, Dezvoltarea programelor 2/61
![Page 3: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/3.jpg)
Utilizarea sistemului de fis, iere
separator director ierarhie
ier dimensiune
cale
nume
director
r d cin
creare tergere
listarea are
opera ii
recursive
trunchiere
redirectare
concepte
opera ii
nume
binar/text
ASCII
editare
arhivarecomprimare
copiere
mutare
schimbare
director
CSE Dep Cursul 3, Dezvoltarea programelor 3/61
![Page 4: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/4.jpg)
Utilizarea sistemului de fis, iere
http://www.geekarmy.com/geeks/2906/file-transferring/
CSE Dep Cursul 3, Dezvoltarea programelor 4/61
![Page 5: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/5.jpg)
Suport curs
I Suport (Introducere ın sisteme de operare)I Capitolul 11 – Compilare s, i linkingI Capitolul 14 – Utilitare pentru dezvoltare
CSE Dep Cursul 3, Dezvoltarea programelor 5/61
![Page 6: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/6.jpg)
Bogdan dores, te un orthodox file manager
I orthodox file manager : manager de fis, iere cu doua coloane(tip Norton Commander sau Total Commander)
I Ce poate face Bogdan?I poate cauta pe Internet software existentI poate gasi o varianta pe care o cumpara, o varianta freemium
sau o varianta open source
I Daca nu este mult, umit de ce gases, te? Is, i dores, te o integrarebuna cu un terminal s, i inclus un client de BitTorrent.
I discuta cu dezvoltatorii pentru aceste funct, ionalitat, iI plates, te pe cineva sa le dezvolteI le dezvolta el (de indicat nu de le zero, ci pornind de la ceva
existent)
I presupunem ca Bogdan dezvolta el
CSE Dep Cursul 3, Dezvoltarea programelor 7/61
![Page 7: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/7.jpg)
Ce va face Bogdan pentru a dezvolta aplicat, ia?
I investigheaza proiecte existente, biblioteci existente,framework-uri existente de la care sa porneasca
I cere pareri de la alt, i utilizatori/dezvoltatori legat defunct, ionalitat, i
I ia decizii legate de dezvoltarea aplicat, ieiI ce limbaj/limbaje sa foloseascaI ce resurse existente sa foloseasca (biblioteci, framework-uri)I ce mediu de dezvoltare sa foloseasca: IDE, editor, compilatorI ce platforma va folosi: sistem de operare, hardware,
mobile/desktop/webI cum va arata interfat, a cu utilizatorulI ce suita de build va folosiI cum va colabora cu alt, i dezvoltatori s, i utilizatoriI cum va livra pachetul final
CSE Dep Cursul 3, Dezvoltarea programelor 8/61
![Page 8: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/8.jpg)
Ce face Bogdan dupa ce dezvolta aplicat, ia?
I o utilizeaza
I o monetizeaza
I o publica (open source) pentru a fi dezvoltata ın continuarede persoane interesate (contribuitori)
Cele de mai sus nu se exclud.
CSE Dep Cursul 3, Dezvoltarea programelor 9/61
![Page 9: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/9.jpg)
Ce pas, i urmeaza Bogdan?
I trasare specificat, ii: interfat, a, funct, ionalitat, i, performant, a,securitate
I proiectare: trasarea arhitecturii file manager-ului, cum seleaga modulele ıntre ele, este extensibil
I implementare: dezvoltarea efectiva
I testare: valideaza implementarea
I integrare: diversele componente sunt lipite pentru a forma untot unitar
I instalare (deployment): crearea unui pachet software
I mentenant, a: rezolvat bug-uri, t, inut cont de feedback, cizelat
CSE Dep Cursul 3, Dezvoltarea programelor 10/61
![Page 10: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/10.jpg)
Folosirea limbajelor de programare pentru implementare
I se aleg limbajele adecvate proiectului
I depind de opt, iunile dezvoltatorilor, ale proiectului s, i alepachetelor care vor fi folosite
I performant, a s, i legaturi cu sistemul de operare: C
I dezvoltare rapida: Python, Ruby
I scripting s, i automatizare: Perl, Python, Bash
I web: PHP, Perl, Python, Java
I enterprise: Java, C++, JavaScript
CSE Dep Cursul 3, Dezvoltarea programelor 11/61
![Page 11: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/11.jpg)
Biblioteci
Program calls library.Library is functionality. Program uses functionality.
http://stackoverflow.com/questions/148747/what-is-the-difference-between-a-framework-and-a-library
program library
CSE Dep Cursul 3, Dezvoltarea programelor 12/61
![Page 12: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/12.jpg)
Framework-uri
Framework calls program.Framework is skeleton. Program is “meat”.
http://stackoverflow.com/questions/148747/what-is-the-difference-between-a-framework-and-a-library
framework
program
CSE Dep Cursul 3, Dezvoltarea programelor 13/61
![Page 13: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/13.jpg)
Perspectiva despre dezvoltarea unei aplicat, ii
fișcod sursă
fișier
cod sursă
fișier
obiect
fișier
obiect
fișier
executabilpachet
software
fișier
de datefișier de
configurare
bibliotecă
compilare
compilare
linking
dezvoltator
utilizator
CSE Dep Cursul 3, Dezvoltarea programelor 14/61
![Page 14: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/14.jpg)
Operat, iile utilizatorului cu aplicat, iile
I instalare
I dezinstalare
I parcurgere documentat, ie
I configurare s, i personalizare
I rulare (cu diverse opt, iuni)
I dezvoltatorul trebuie sa-i faca viat, a cat mai us, oarautilizatorului
CSE Dep Cursul 3, Dezvoltarea programelor 16/61
![Page 15: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/15.jpg)
Pachete software
I arhive cu fis, ierele necesare pentru instarea aplicat, iei
I fis, iere de date, fis, iere de configurare, fis, iere executabile
I fis, ierele executabile sunt folosite pentru a rula aplicat, ia
I utilizatorul instaleaza pachetele software s, i apoi foloses, tefis, ierele din acestea
Cont, inutul pachetului tcpdump
user@host:~$ dpkg -L tcpdump
[...]
/usr/share/man/man8/tcpdump.8.gz # pagina de manual
[...]
/usr/sbin/tcpdump # executabilul din pachet
CSE Dep Cursul 3, Dezvoltarea programelor 17/61
![Page 16: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/16.jpg)
Fis, iere executabile
I folosite pentru rularea aplicat, iei
I dublu click ın GUI, rulare de comanda ın linia de comanda
I obt, inute din codul sursa
I ın Unix se gasesc, ın general ın /bin, /sbin, /usr/bin s, i/usr/sbin
I pot fi binare sau text (ASCII)I binare pentru cod sursa compilat (C, C++, Java)
I /bin/ls, /usr/bin/vim
I text pentru cod sursa interpretate (Perl, Python, Ruby)I ls /bin/* | grep ASCIII ls /usr/bin/* | grep ASCII
CSE Dep Cursul 3, Dezvoltarea programelor 18/61
![Page 17: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/17.jpg)
Ce urmares, te un dezvoltator?
I sa faca activitat, i provocatoare
I sa creeze aplicat, ii interesante
I sa creeze aplicat, ii utile; adica apreciate de utilizator
Un dezvoltator va scrie cod sursa s, i apoi va folosi utilitare care saconduca la executabile s, i pachete software pentru utilizator.
CSE Dep Cursul 3, Dezvoltarea programelor 19/61
![Page 18: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/18.jpg)
Cod sursa pentru un limbaj
I un fis, ier al unui program este denumit fis, ier cod sursa
I codul sursa este codul citibil al unui limbaj de programare:format text
I cod sursa: instruct, iuni ıntr-un limbaj
I codul sursa respecta sintaxa acelui limbaj
I pentru a ınt, elege un program este necesara cunoas, tereasintaxei limbajului
I codul sursa este scris de programator
CSE Dep Cursul 3, Dezvoltarea programelor 21/61
![Page 19: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/19.jpg)
Editoare s, i IDE-uri
I folosite pentru scrierea codului sursaI editoare
I scriu ın general text, printre care s, i cod sursaI Vim, Emacs, Notepad++, Sublime Text
I IDE: Integrated Development EnvironmentI integreaza editor, compilator, debugger, biblioteciI Eclipse, Visual Studio, Code::Blocks, NetBeans
I facilitat, iI syntax higlighting, auto indentation, utilitare pentru debugging
integrateI code folding, code completion (autocompletion)
CSE Dep Cursul 3, Dezvoltarea programelor 22/61
![Page 20: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/20.jpg)
Coding Style
I convent, ii s, i recomandari pentru scrierea codului sursa
I us, urint, a ın a ınt, elege codul sursa
I consecvent, a
I ın general cu suport din partea editoarelor s, i IDE-urilorI aspecte acoperite
I indentareI nume de funct, ii, variabile, constante, macro-uriI spat, iereI comentarii de cod
I Steve Oualline: C Elements of Style
I Python PEP 8
CSE Dep Cursul 3, Dezvoltarea programelor 23/61
![Page 21: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/21.jpg)
Best Practices
I nume sugestive
I cod neıngramadit, bine spat, iat
I cod comentat relevant
I cod indentat
I funct, ii de dimensiune rezonabila
I funct, ionalitat, i diferite ın fis, iere/module diferite
I evitarea hard coding-ului: folosit, i macro-uri sau variabile ınloc de valori hard codate
I limitata dimensiunea maxima a liniilor
I evitarea duplicarii codului
I consecvent, a
CSE Dep Cursul 3, Dezvoltarea programelor 24/61
![Page 22: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/22.jpg)
Bad Code
#include<stdio.h>#include <string.h>
int prime(int n)
{int i;
for(i=2;i<n/2;i++)
if(n%i==0)return 0;
return 1;
}
int get sum(int n)
{ int i, sum;
for (i=1; i <=n; i++)
sum=sum+i;
return sum;
}
main(){int extra; char *len="prime";
int num;
int is prime,i;
for(i=0;i<10;i++){printf("Introduceti numar:");
scanf("%d", &num);
is prime=prime(num);
if(is prime)
printf("is %s\n",len); else printf("is not %s\n",len);extra=get sum(num);
printf("sum (1..%d) is %d\n",num,extra);}}
CSE Dep Cursul 3, Dezvoltarea programelor 25/61
![Page 23: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/23.jpg)
Good Code
#include <stdio.h>#include <string.h>
#define NUM ROUNDS 10
static int check if prime(size t n)
{size t i;
for (i = 2; i < n/2; i++)
if (n%i == 0)
return 0;
return 1;
}
static size t compute sum until(size t n)
{size t i, sum;
sum = 0;
for (i = 1; i <= n; i++)
sum = sum+i;
return sum;
}
int main(void)
{size t i, num;
for (i = 0; i < NUM ROUNDS; i++) {printf("Introduceti numar: ");
scanf("%zu", &num);
if(check if prime(num))
printf("%zu e numar
prim.\n", num);
elseprintf("%zu nu e numar
prim.\n", num);
printf("Suma (1..%zu) este
%zu\n", num, compute sum until(num));
}
return 0;
}
CSE Dep Cursul 3, Dezvoltarea programelor 26/61
![Page 24: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/24.jpg)
Good Code / Bad Code
http://blog.codinghorror.com/whos-your-coding-buddy/
CSE Dep Cursul 3, Dezvoltarea programelor 27/61
![Page 25: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/25.jpg)
Controlul versiunii
I VCS (Version Control System), SCM (Source CodeManagement)
I folosit ın orice proiect software ,,pe bune”I De ce controlul versiunii?
I asigura lucru colaborativI istorie de modificari (legea lui Murphy spune ca vei gres, i ceva
la un moment dat; sau ıt, i vei s, terge sursele)
I codul este t, inut ıntr-un repositoryI modificarile din program au o istorie
I un element din istorie este o versiuneI permite revenirea la o stare anteriora ın caz de probleme
I Git, Subversion, Darcs, Mercurial, Bazaar
CSE Dep Cursul 3, Dezvoltarea programelor 28/61
![Page 26: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/26.jpg)
GitHub
I serviciu de hosting pentru repository-uri Git
I Git, issue tracking, wiki
I us, or de creat repository-uri, de lucrat ın echipa
I contribut, ii la alte proiecte
I ın general folosit pentru proiecte open source, dar nu numai
I pentru cod ınchis (teme de casa), putet, i cere repository-urigratis pentru student, i
I alternative: BitBucket, GitLabI instant, a GitLab ın facultate
I https://gitlab.cs.pub.ro/I autentificare folosind LDAP (contul de pe cs.curs.pub.ro)
CSE Dep Cursul 3, Dezvoltarea programelor 29/61
![Page 27: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/27.jpg)
Compilare s, i interpretare
I un fis, ier cod sursa poate fi compilat sau interpretatI deosebirea ıntre compilare s, i interpretare
I compilare: codul sursa este translatat de un program denumitcompilator ın cod mas, ina, dupa care poate fi executat
I interpretare: un program este executat direct din cod sursaprin intermediul unui interpretor
I compilatoare s, i interpetoareI GCC (GNU Compiler Collection) – compilator de C, C++,
Ada, FortranI MSVC (Microsoft Visual C) – compilator de C, C++I GCL (GNU Common Lisp) – interpretor de Common LispI Python: interpretor de PythonI Perl: interpretor de Perl
CSE Dep Cursul 3, Dezvoltarea programelor 30/61
![Page 28: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/28.jpg)
Linking
I ın urma procesului de compilare, din modulul cod sursarezulta un modul obiect
I modulul obiect este fis, ier binar (.o, .obj)
I mai multe fis, iere obiect (+biblioteci) sunt legate (linked)ıntr-un fis, ier executabil
I cod sursa compilat → modul obiect
I module obiect s, i biblioteci linkate → executabil
CSE Dep Cursul 3, Dezvoltarea programelor 31/61
![Page 29: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/29.jpg)
De la dezvoltator la utilizator
fișcod sursă
fișier
cod sursă
fișier
obiect
fișier
obiect
fișier
executabilpachet
software
fișier
de datefișier de
configurare
bibliotecă
compilare
compilare
linking
dezvoltator
utilizator
CSE Dep Cursul 3, Dezvoltarea programelor 32/61
![Page 30: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/30.jpg)
Documentat, ie
I pentru a ınt, elege funct, ionarea aplicat, iei
I de utilizator, user manual : configurare, opt, iuni de rulare,indicat, ii de instalare
I de dezvoltator, technical manual : arhitectura, coding style,module, indicat, ii de compilare s, i testare
I pot fi documente, fis, iere PDF, wiki-uri, pagini de manual
CSE Dep Cursul 3, Dezvoltarea programelor 33/61
![Page 31: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/31.jpg)
De ce programare ın limbajul C?
I limbaj foarte cunoscut
I limbaj foarte puternic
I limbaj aproape de hardware s, i sistemul de operare, eficient,rapid
I documentat, ie, tutoriale, cart, i
CSE Dep Cursul 3, Dezvoltarea programelor 35/61
![Page 32: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/32.jpg)
De ce nu programare ın limbajul C?
I limbaj relativ de ınvat, at
I limbaj periculos, necesita experient, a
I limbaj mai put, in expresiv
I dureaza mult timp sa dezvolt, i o aplicat, ie
I posibile probleme de portabilitate (Linux, Windows, Mac OSX, Android etc.)
CSE Dep Cursul 3, Dezvoltarea programelor 36/61
![Page 33: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/33.jpg)
Procesul de dezvoltare pentru programe C
I scriere de fis, iere cod sursa: surse (.c) s, i headere (.h)
I urmarirea unui coding style
I compilarea fis, ierelor cod sursa ın fis, iere obiect
I linkarea fis, ierelor cod obiect s, i a bibliotecilor ın fis, ier executabil
I pe Unix/Linux, pentru compilare s, i linking folosim gcc (GNUC Compiler)
CSE Dep Cursul 3, Dezvoltarea programelor 37/61
![Page 34: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/34.jpg)
Compilare de program simplu ın C
Compilare cu gcc
user@host$ ls -F
hello-world.c
user@host$ gcc hello-world.c
user@host$ ls -F
a.out* hello-world.c
user@host$ ./a.out
Hello, World!
user@host$ rm a.out
user@host$ ls -F
hello-world.c
user@host$ gcc -Wall hello-world.c -o hello-world
user@host$ ls -F
hello-world* hello-world.c
user@host$ ./hello-world
Hello, World!
CSE Dep Cursul 3, Dezvoltarea programelor 38/61
![Page 35: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/35.jpg)
Compilare s, i linking de program simplu ın C
Compilare cu gcc
user@host$ ls -F
hello-world.c
user@host$ gcc -Wall -c hello-world.c
user@host$ ls -F
hello-world.c hello-world.o
user@host$ gcc hello-world.o -o hello-world
user@host$ ls -F
hello-world* hello-world.c hello-world.o
user@host$ ./hello-world
Hello, World!
CSE Dep Cursul 3, Dezvoltarea programelor 39/61
![Page 36: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/36.jpg)
Modularizare s, i module
I Do one thing, do one thing well!
I funct, ionalitat, ile diferite intra ın fis, iere sursa diferite
I evitam ıngramadirea funct, ionalitat, ilor ıntr-un singur fis, ier
I fiecare fis, ier poarta numele de modul
CSE Dep Cursul 3, Dezvoltarea programelor 40/61
![Page 37: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/37.jpg)
Compilare s, i linking din surse multiple
Compilare cu gcc din mai multe surse
user@host$ ls -F
debug.h http_reply_once.c sock_util.c sock_util.h util.h
user@host$ gcc -Wall -c sock_util.c
user@host$ gcc -Wall -c http_reply_once.c
user@host$ ls -F
debug.h http_reply_once.o sock_util.h util.h
http_reply_once.c sock_util.c sock_util.o
user@host$ gcc http_reply_once.o sock_util.o -o http_reply_once
user@host$ ls -F
debug.h http_reply_once.c sock_util.c sock_util.o
http_reply_once* http_reply_once.o sock_util.h util.h
CSE Dep Cursul 3, Dezvoltarea programelor 41/61
![Page 38: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/38.jpg)
Procesul de build
I building : obt, inerea unui executabil, a unui set de executabilesau a unui pachet software din fis, iere cod sursa
I o versiune de pachet construita se mai cheama s, i un build
I pentru programe scrise ın C ınseamna compilare, linking,ımpachetare
CSE Dep Cursul 3, Dezvoltarea programelor 43/61
![Page 39: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/39.jpg)
Sisteme de build
I cele care permit automatizarea procesului de build
I make: folosit foarte mult ın lumea Unix/Linux
I Ant, Maven: folosite pentru Java
I Scons: scris ın Python
I Rake: folosit pentru Ruby
I altele
CSE Dep Cursul 3, Dezvoltarea programelor 44/61
![Page 40: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/40.jpg)
Make
I sistem de build s, i automatizare
I folosit ındeosebi pentru automatizare procesului de compilare(dar nu numai)
I se scriu reguli ıntr-un fis, ier denumit ın general Makefile
I se ruleaza comenzile aferente regulilor, ın mod automat,folosind comanda make
I se obt, in target-uri (ın general fis, iere executabile) care depindde dependent,e (ın general fis, ire cod sursa)
CSE Dep Cursul 3, Dezvoltarea programelor 45/61
![Page 41: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/41.jpg)
Folosire simpla a Make
1 hello-world: hello-world.c
2 gcc -Wall hello-world.c -o hello-world
Compilare folosind make pentru fis, ierul Makefile de mai sus
user@host$ ls -F
hello-world.c
user@host$ make
gcc -Wall hello-world.c -o hello-world
user@host$ ls -F
hello-world* hello-world.c
CSE Dep Cursul 3, Dezvoltarea programelor 46/61
![Page 42: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/42.jpg)
Folosire mai avansata a Make
1 all: hello-world
2
3 hello-world: hello-world.c
4 gcc -Wall hello-world.c -o hello-world
5
6 clean:7 rm -f hello-world hello-world.o
Compilare folosind make pentru fis, ierul Makefile de mai sus
user@host$ ls -F
hello-world.c
user@host$ make
gcc -Wall hello-world.c -o hello-world
user@host$ ls -F
hello-world* hello-world.c
CSE Dep Cursul 3, Dezvoltarea programelor 47/61
![Page 43: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/43.jpg)
Folosire eleganta a Make
1 .PHONY: all clean2
3 all: hello-world
4
5 hello-world: hello-world.o
6 gcc hello-world.o -o hello-world
7
8 hello-world.o: hello-world.c
9 gcc -Wall -c hello-world.c
10
11 clean:12 -rm -f hello-world hello-world.o
13 -rm -f *∼
Compilare folosind make pentru fis, ierul Makefile de mai sus
user@host$ ls -F
hello-world.c
user@host$ make -f Makefile.elegant
gcc -Wall -c hello-world.c
gcc hello-world.o -o hello-world
user@host$ ls -F
hello-world* hello-world.c hello-world.o
CSE Dep Cursul 3, Dezvoltarea programelor 48/61
![Page 44: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/44.jpg)
Folosire eleganta a Make pentru surse multiple
1 .PHONY: all clean2
3 all: http reply once
4
5 http reply once: http reply once.o sock util.o
6 gcc http reply once.o sock util.o -o http reply once
7
8 http reply once.o: http reply once.c util.h debug.h sock util.h
9 gcc -Wall -c http reply once.c
10
11 sock util.o: sock util.c util.h debug.h sock util.h
12 gcc -Wall -c sock util.c
13
14 clean:15 -rm -f http reply once http reply once.o sock util.o
16 -rm -f *∼
Compilare folosind make pentru fis, ierul Makefile de mai sus
user@host$ ls -F
Makefile debug.h http_reply_once.c sock_util.c sock_util.h util.h
user@host$ make
gcc -Wall -c http_reply_once.c
gcc -Wall -c sock_util.c
gcc http_reply_once.o sock_util.o -o http_reply_once
user@host$ ls -F
Makefile http_reply_once* http_reply_once.o sock_util.h util.h
debug.h http_reply_once.c sock_util.c sock_util.o
CSE Dep Cursul 3, Dezvoltarea programelor 49/61
![Page 45: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/45.jpg)
Nice to know: Obt, inerea automata a regulilor ın Makefile
Folosire gcc -MM pentru obt, inerea automata a regulilor
user@host$ gcc -MM sock_util.c
sock_util.o: sock_util.c util.h debug.h sock_util.h
user@host$ gcc -MM http_reply_once.c
http_reply_once.o: http_reply_once.c util.h debug.h sock_util.h
CSE Dep Cursul 3, Dezvoltarea programelor 50/61
![Page 46: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/46.jpg)
De ce dezvoltam software?
I creativitate
I us, urint, a ın distribuire
I reutilizare
I provocare
I dezvoltare continua
CSE Dep Cursul 3, Dezvoltarea programelor 52/61
![Page 47: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/47.jpg)
Ce ne ofera software-ul?
I automatizare
I eficientizare
I divertisment
I extensibilitate
I us, urint, a ın distribuire/copiere
CSE Dep Cursul 3, Dezvoltarea programelor 53/61
![Page 48: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/48.jpg)
De la dezvoltator la utilizator
fișcod sursă
fișier
cod sursă
fișier
obiect
fișier
obiect
fișier
executabilpachet
software
fișier
de datefișier de
configurare
bibliotecă
compilare
compilare
linking
dezvoltator
utilizator
CSE Dep Cursul 3, Dezvoltarea programelor 54/61
![Page 49: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/49.jpg)
GCC s, i Make
GCC GNU C Compiler
I compilatorul implicit pe distribut, iile Linux
I compileaza s, i linkeaza cod sursa ın C
Make
I utilitar pentru automatizarea procesului de build
I reguli, target-uri, dependent, e
CSE Dep Cursul 3, Dezvoltarea programelor 55/61
![Page 50: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/50.jpg)
Compilers: Principles, Techniques and Tools
I The Dragon Book
I Aho, Sethi, Ullman
I 2nd Edition, 2006
I cartea de baza pentru toate cursurile de compilatoare dinuniversitat, i
I expunere exhaustiva a analizei sintactice, semnatice s, iparserelor
CSE Dep Cursul 3, Dezvoltarea programelor 56/61
![Page 51: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/51.jpg)
Guido van Rossum
I inventatorul limbajului de programare Python
I Benevolent Dictator for Life (BDFL) pentru Python
I a activat la Google ın perioada 2005-2012
I din 2013 lucreaza la Dropbox
CSE Dep Cursul 3, Dezvoltarea programelor 57/61
![Page 52: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/52.jpg)
I google.com – cel mai folosit site din lume
I fondata de Larry Page s, i Sergey Brin
I lansata ın 1998
I init, ial: search engine + advertising
I aplicat, ii web
I Android
I Chrome
I YouTube
CSE Dep Cursul 3, Dezvoltarea programelor 58/61
![Page 53: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/53.jpg)
Valgrind
I http://valgrind.org
I detectarea de probleme la rulare (runtime)
I ın principal folosit pentru probleme de lucru cu memoria
I Linux s, i Darwin (Mac OS X)
I un engine peste care ruleaza componente dedicate: memcheck(implicit), cachegrind, callgrind, helgrind
CSE Dep Cursul 3, Dezvoltarea programelor 59/61
![Page 54: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/54.jpg)
Resurse utile
I http://www.oualline.com/style/index.html
I http://www.gnu.org/software/make/
I http://www.gnu.org/software/libc/manual/
I http://git-scm.com/
I http://gitimmersion.com/
I http://www.moolenaar.net/habits.html
CSE Dep Cursul 3, Dezvoltarea programelor 60/61
![Page 55: Curs 03 Handout](https://reader034.vdocuments.site/reader034/viewer/2022050809/5695d1cb1a28ab9b0297edc9/html5/thumbnails/55.jpg)
Cuvinte cheie
I software
I implementare
I programare
I limbaj de programare
I biblioteci
I framework-uri
I cod sursa
I coding style
I editor
I IDE
I controlul versiunii
I Git
I GitHub
I GitLab
I pachet software
I fis, ier executabil
I fis, ier obiect
I compilare
I linking
I limbajul C
I gcc
I modularizare
I sistem de build
I make
I Makefile
CSE Dep Cursul 3, Dezvoltarea programelor 61/61