diff --git a/c++-ss22/beamercolorthemehd.sty b/c++-ss22/beamercolorthemehd.sty index 563eb79..a1cf47c 100644 --- a/c++-ss22/beamercolorthemehd.sty +++ b/c++-ss22/beamercolorthemehd.sty @@ -13,7 +13,7 @@ \definecolor{beamer@hdgrey}{rgb}{.2118,.2118,.2118} \definecolor{beamer@hddarkred}{rgb}{0.3490,0.0510,0.0314} \definecolor{beamer@hdlightred}{rgb}{0.7765,0.0941,0.1490} -\definecolor{beamer@hdsand}{rgb}{0.9569,0.9451,0.9176} +\definecolor{beamer@hdsand}{rgb}{0.8,0.7901,0.7694} \definecolor{beamer@hdblue}{rgb}{0.1412,0.1843,0.2510} % % diff --git a/c++-ss22/c64.png b/c++-ss22/c64.png new file mode 100644 index 0000000..670bc30 Binary files /dev/null and b/c++-ss22/c64.png differ diff --git a/c++-ss22/turing_maschine.png b/c++-ss22/turing_maschine.png new file mode 100644 index 0000000..1ff270c Binary files /dev/null and b/c++-ss22/turing_maschine.png differ diff --git a/c++-ss22/vortrag.tex b/c++-ss22/vortrag.tex index 29fa1c7..7f21fcc 100644 --- a/c++-ss22/vortrag.tex +++ b/c++-ss22/vortrag.tex @@ -14,17 +14,6 @@ \usepackage{calc} \usepackage{natbib} \usepackage[absolute,overlay]{textpos} -\usepackage{listings} % Programm Listings -\usepackage{siunitx} -\lstset{language=C} -\lstset{breaklines=true} -\lstset{frame=shadowbox} -\lstset{rulesepcolor=\color{gray}} -\lstset{basicstyle=\fontsize{9}{9}\selectfont \ttfamily} - - - - \usepackage{booktabs}%für horizontale Linien %Figures @@ -158,6 +147,20 @@ grow to left by=\leftmargin, } +\NewTCBListing{python}{O{}}{% + listing only, + minted language=python, + minted options={autogobble,#1}, + colframe=black!10!white, + arc=.5mm, + boxsep=1mm, + top=0mm, + bottom=0mm, + flush left, + grow to left by=\leftmargin, +} + + \newmintinline{bash}{} \newmintinline{cpp}{} @@ -322,7 +325,7 @@ \begin{frame} \begin{center} - \pgfimage[width=0.8\textwidth]{6231ab70a521ca66} + \pgfimage[width=0.7\textwidth]{6231ab70a521ca66} \end{center} \end{frame} @@ -369,6 +372,323 @@ \section{C++-Hintergrund}\label{sec:c++-hintergrund} +\subsection{Programmiersprachen} + +\begin{frame}{Turing-Vollständigkeit} + +\only<1>{ + \begin{itemize} + \item Eine Turing-Maschine ist eine einfache Maschine. + \item Sie besteht aus: + \begin{itemize} + \item einem potentiell unendlichen Band, welches in Felder eingeteilt ist +und pro Feld genau ein Zeichen aufnehmen kann, + \item einem Schreib-Lesekopf sowie + \item einem internen Zustand. + \end{itemize} + \item Je nach Zustand und Inhalt des Bandes kann die Turing-Maschine +folgende Aktionen ausführen: + \begin{itemize} + \item ein neues Zeichen Schreiben, + \item den Schreib-Lesekopf um eine Position nach rechts oder links bewegen und + \item den internen Zustand verändern. + \end{itemize} + \end{itemize} +} + +\only<2>{ +%Bild Turing Maschine + + \begin{center} + \pgfimage[width=0.8\textwidth]{turing_maschine} + \end{center} +} + +\only<3>{ + \begin{itemize} + \item Alles, was berechenbar ist, kann durch Turing-Maschinen berechnet werden + \item Eine Programmiersprache, in der man eine Turingmaschine schreiben kann, ist genauso mächtig wie die Turing-Maschine + \item Da Turing-Maschinen aber bereits das charakterisieren, was berechenbar +ist, handelt es sich bei der Sprache um eine berechnungs-universelle +Sprache, d.h. wir können damit genau die berechenbaren Funktionen +programmieren. + \end{itemize} +} + +\end{frame} + +\begin{frame}{Programmierparadigma} + +\only<1>{ + +\textbf{\glqq Ein Programmierparadigma ist ein fundamentaler Programmierstil.\grqq} + +\begin{itemize} + \item Darstellung von statischen und dynamischen Elementen + \item Struktureller Aufbau eines Programms + \item Wichtig: Imperativ vs. deklarativ +\end{itemize} + +} + +\only<2>{ +{\large {\textbf Imperativ}} + +\begin{itemize} + \item Programme sind Folge von Befehlen + \item Untermenge: Strukturierte Progrmmierung (\textit{\glqq Go To Statement Considered Harmful\grqq}) + \item Ebenfalls Untermenge: Prozedurale Programmierung (Unterteilung von Programmen in Unterprogramme/Prozeduren) + \item Noch eine Untermenge: Modulare Programmierung (Module, z.B. Bibliotheken, gliedern große Softwareprojekte) +\end{itemize} +} + +\only<3>{ +{\large {\textbf Deklarativ}} + +\begin{itemize} + \item Problem wird beschrieben, Lösungsweg wird \glqq automatisch\grqq ~ ermittelt + \item Beispiel: Funktionale Programmierung (alles ist eine Funktion) + \item Beispiel: Logische Programmierung (Axiome definieren Regeln) + \item Fun fact: Mit dem \emph{make} Tool lernen wir hier eine deklarative Sprache kennen +\end{itemize} +} + +\only<4>{ +{\large {\textbf Generisch}} + +\begin{itemize} + \item Allgemeiner Entwurf von Funktionen + \item Verwendbar für verschiedene Datentypen +\end{itemize} +} + +\only<5>{ +{\large {\textbf Objekt-Orientiert}} + +\begin{enumerate} + \item Alles ist ein Objekt + \item Objekte kommunizieren durch das Senden und Empfangen von Nachrichten (welche aus Objekten bestehen) + \item Objekte haben ihren eigenen Speicher (strukturiert als Objekte) + \item Jedes Objekt ist die Instanz einer Klasse (welche ein Objekt sein muss) + \item Die Klasse beinhaltet das Verhalten aller ihrer Instanzen (in der Form von Objekten in einer Programmliste) + \item Um eine Programmliste auszuführen, wird die Ausführungskontrolle dem ersten Objekt gegeben und das Verbleibende als dessen Nachricht behandelt“ +\end{enumerate} +{\hspace{10cm} \textit{Alan Kay}} +} + +\end{frame} + +\begin{frame}[fragile]{Wieso nicht\dots} + +\only<1>{ +{\large {\textbf Ook!}}\\ +\emph{Esoterische} Sprache für Orang-Utans, die Turing-vollständig ist + +\begin{tabular}{|lp{10cm}|} +\hline \textbf{Befehl} & Beschreibung\\\hline +Ook. Ook. & den Wert der aktuellen Zelle um 1 erhöhen\\ +Ook! Ook! & den Wert der aktuellen Zelle um 1 verringern\\ +Ook. Ook? & eine Zelle nach rechts gehen\\ +Ook? Ook. & eine Zelle nach links gehen\\ +Ook! Ook? & Schleifenanfang – die Schleife durchlaufen solange der Wert der aktuellen Zelle ungleich 0 ist\\ +Ook? Ook! & Schleifenende – beendet die Schleife, wenn der Wert der aktuellen Zelle gleich 0 ist\\ +Ook! Ook. & den Wert der aktuellen Zelle ausdrucken\\ +Ook. Ook! & einen Wert von der Tastatur in die aktuelle Zelle einlesen \\\hline +\end{tabular} + +} + +\only<2>{ +Hello World in Ook! + +%\begin{plaincode}[fontsize=\tiny] +%\begin{verbatim} +\texttt{\tiny +Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. +Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. +Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. +Ook! Ook. Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. +Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? +Ook! Ook! Ook? Ook! Ook? Ook. Ook. Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. +Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook. Ook! Ook. Ook. Ook. Ook. Ook. +Ook. Ook. Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. +Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. +Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook. +Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. +Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook! Ook? Ook? Ook. Ook. Ook. +Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. Ook. +Ook. Ook? Ook! Ook! Ook? Ook! Ook? Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook. +Ook? Ook. Ook? Ook. Ook? Ook. Ook? Ook. Ook! Ook. Ook. Ook. Ook. Ook. Ook. Ook. +Ook! Ook. Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook. +Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! Ook! +Ook! Ook. Ook. Ook? Ook. Ook? Ook. Ook. Ook! Ook.} +%\end{verbatim} +%\end{plaincode} + +} + +\only<3>{ +{\large {\textbf C64-Basic}} + + \begin{center} + \pgfimage[width=.8\textwidth]{c64} + \end{center} +} + +\only<4>{ +{\large {\textbf C64-Basic}} + \begin{itemize} + \item Triviale Syntax + \item Nicht strukturiert, nicht funktional (Spaghetti-Code!) + \item Nicht standardisiert! + \item Interpreter: Langsam + \end{itemize} + + (Und in Bezug auf den C64: Mit Basic alleine kann eigentlich nichts machen) +} + +%C64 Basic +%Assembler +\end{frame} + +\begin{frame}[fragile] +\frametitle{Wieso nicht Assembler?} + + +\begin{minted}[fontsize=\footnotesize]{as} +global _start + +section .text + +_start: + mov rax, 1 ; write( + mov rdi, 1 ; STDOUT_FILENO, + mov rsi, msg ; "Hello, world!\n", + mov rdx, msglen ; sizeof("Hello, world!\n") + syscall ; ); + + mov rax, 60 ; exit( + mov rdi, 0 ; EXIT_SUCCESS + syscall ; ); + +section .rodata + msg: db "Hello, world!", 10 + msglen: equ - msg +\end{minted} + +\end{frame} + + +\begin{frame}[fragile]{Wieso nicht Assembler?} + + \begin{itemize} + \item Nicht strukturiert, nicht objekt-orientiert + \item Maschinen-spezifisch $\rightarrow$ nicht portabel + \item Quasi undurchsichtig\dots + \end{itemize} + +\end{frame} + + +\begin{frame}[fragile]{Wieso nicht Pascal?} + + \begin{itemize} + \item Enthält wichtige Paradigmen: Objekt-Orientierung, Struktur, Module\dots + \item Nicht überall verfügbar + \item Nicht vollständig standardisiert + \end{itemize} + +\end{frame} + +\begin{frame}[fragile]{Wieso nicht Fortran?} + + \begin{itemize} + \item Enthält wichtige Paradigmen: Objekt-Orientierung, Struktur, Module\dots + \item Überall verfügbar + \item Gut standardisiert + \item Bis ins 21. Jahrhundert wichtige Sprache für naturwissenschaftliche Anwendungen + \item Objekt-Orientierung wesentlich schlechter als in C++ + \end{itemize} + +\end{frame} + +\begin{frame}[fragile]{Wieso nicht Python?} + + \begin{python}[fontsize=\footnotesize] +class Parrot: + + # class attribute + species = "bird" + + # instance attribute + def __init__(self, name, age): + self.name = name + self.age = age + +# instantiate the Parrot class +blu = Parrot("Blu", 10) +woo = Parrot("Woo", 15) + +# access the class attributes +print("Blu is a {}".format(blu.__class__.species)) +print("Woo is also a {}".format(woo.__class__.species)) + +# access the instance attributes +print("{} is {} years old".format( blu.name, blu.age)) +print("{} is {} years old".format( woo.name, woo.age)) + \end{python} + +\end{frame} + +\begin{frame}[fragile]{Wieso nicht Python?} + + \begin{itemize} + \item Enthält wichtige Paradigmen: Objekt-Orientierung, Struktur, Module\dots + \item Überall verfügbar + \item Gut standardisiert + \item Meistens langsam\dots + \item \dots außer man verwendet in C++ geschriebene Bibliotheken + \end{itemize} + +\end{frame} + + + + +%Lisp +\begin{frame}[fragile]{Wieso nicht C\#?} + +\begin{cpp} +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ConsoleApp1 +{ + class Program + { + static void Main(string[] args) + { + } + } +} +\end{cpp} +\end{frame} + +\begin{frame}[fragile]{Wieso nicht C\#?} + + \begin{itemize} + \item Weiterentwicklung von C++ + \item Nicht überall verfügbar + \item Genauso fürchterlich wie Java + \end{itemize} + +\end{frame} + + + \begin{frame} \frametitle{Was ist C++?} C++ ist eine Programmiersprache, die sowohl für systemnahe als auch für Anwendungsprogrammierung @@ -414,13 +734,6 @@ - - - - - - - %%%% Lecture 1