Schneller ohne C++

und C, Java, ...

Dr. Stefan Behnel

(Cython Core-Entwickler, Consultant und Schulungsleiter)

http://consulting.behnel.de/

Skoobe - http://skoobe.de/

Schneller? Ohne C/C++ ???

images/shootout_re.png

Quelle: Computer Language Benchmark Game (Shootout), 17.08.2012

Woher kommt der Benchmark-Code?

  1. Aufgabe / Anforderungen
  2. Implementierung
  3. Benchmarking
  4. Optimierung
    • zurück zu 3.
  5. finale Implementierung

... wie schnell ging das?

Entwicklungsaufwand

Anzahl Code-Zeilen bei ähnlichen Projekten:

(Pi x Daumen, aus Beiträgen auf comp.lang.python)

Code, den es nicht gibt, ...

Code, den es nicht gibt,

=> Spitze !

Code-Aufwand

Grobe Abschätzung über Ohloh-Statistiken

Open-Source-Projekte, Stand 29.09.2012

Sprache Projekte #Zeilen #/Projekt 1/Py
Python 49.157 288.210.068 5.863 1,0
Ruby 38.931 224.775.029 5.774 1,0
JavaScript 87.689 1.068.477.617 12.185 2,1
Java 68.184 1.372.759.440 20.133 3,4
C++ 46.440 1.561.464.164 33.623 5,7
C 57.169 3.260.033.266 57.024 9,7

Quelle: https://www.ohloh.net/languages

Vorsicht! Inklusive Linux-Kernel (15M C), Debian (10M C, 6M C++), xBSD (4-8M C), ... oder JavaScript: viele Projekte, wenig Code pro Projekt

C > C++ > Java > Python

Einige Gründe:

Standardbibliothek

Vorteile?

Programmlänge

images/proglen.png
Quelle:

"An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl"

Lutz Prechelt, März 2000

http://page.mi.fu-berlin.de/~prechelt/Biblio/jccpprt_computer2000.pdf

Zeitaufwand

images/progtime.png
Quelle:

"An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl"

Lutz Prechelt, März 2000

http://page.mi.fu-berlin.de/~prechelt/Biblio/jccpprt_computer2000.pdf

Produktivität

images/progproductivity.png
Quelle:

"An empirical comparison of C, C++, Java, Perl, Python, Rexx, and Tcl"

Lutz Prechelt, März 2000

http://page.mi.fu-berlin.de/~prechelt/Biblio/jccpprt_computer2000.pdf

Wirklich schneller?

"premature optimization is the root of all evil"

-- Donald Knuth

Premature optimisation ...

"Programmers waste enormous amounts of time thinking about, or worrying about, the speed of noncritical parts of their programs, and these attempts at efficiency actually have a strong negative impact when debugging and maintenance are considered.

We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil.

Yet we should not pass up our opportunities in that critical 3%."

-- Donald Knuth

(in: Computing Surveys, Dezember 1974, Hervorhebung von mir)

Entwicklung oder Optimierung?

images/shootout_re.png

Quelle: Computer Language Benchmark Game (Shootout), 17.08.2012

Optimale Code-Entwicklung

Beispielrechnung

=> 63% weniger Code -> Entwicklungszeit, Wartung, ...

nach Donald Knuth bei vergleichbarer Performance!

Schnelle Tools für Python

"Wir schreiben euer C!" (oder auch mal Fortran)

... unzählige andere im PyPI, für alle Anwendungsfälle

Anbindung von Python an C/C++/...

Abschließende Worte

Viel Spaß ohne C++ !

Viel

Spaß

ohne

C++

!

BACKUP

... Hilfsfolien ...

Dementi

Woraus besteht Embedded Software?

(Mikrocontroller mal beiseite gelassen - siehe PyMite)

Ausgewählte Projekte

Python #Zeilen Projekt #Zeilen Sprache
Zope 3 240.844 JBoss AS 1.287.320 Java
SQLAlchemy 118.390 Hibernate 1.029.712 Java
Django 147.484 JSF 380.820 Java
..   Wicket 849.862 Java
..   wt 251.146 C++

Quelle: https://www.ohloh.net/