Welcome to the Wiki of the seminar '''Java vs. C++''' in the winter semester 2010 / 2011

This seminar is given by Prof. Dr. Hannah Bast, assisted by Björn Buchhold(buchholb@informatik.....). The seminar takes place every Wednesday, 2:15 pm - 3:45 pm, in the seminar room 01-018 in building 101. Our first session is on Wednesday, October 20, 2010. The last session is on Wednesday, February 9, 2011. On Wednesday December 29, 2010 and on Wednesday January 5, 2011 there is no session due to the christmas break. That's 15 sessions altogether. All sessions are recorded (video + audio).

The seminar is about the performance differences between Java and C++, in particular, running time and space consumption. It's NOT about the differences in syntax, language features, ease of programming, etc. The sessions will be recorded, and the slides as well the recordings will be put online after each presentation: see the links below.

Hier ist der Evaluationsbogen für die Veranstaltung. Sie können den ausgefüllten Bogen entweder hier auf diese Wikiseite hochladen (vorher ausloggen, sonst nicht anonym!), oder persönlich bei Hannah Bast oder Björn Buchhold abgeben.

Information and materials for each session

  1. Wednesday October 20, 2010: Introduction and Overview, Hannah Bast, slides, recording as AVI (not cut).

  2. Wednesday October 27, 2010: Machine code generation in C++, Hannah Bast,slides, recording as AVI (not cut).

    • Topics: x86 Assembler (history, registers, instructions, stack, function calls, some simple programs, MXX 128-bit streaming registers).

    • Remember 1: Write an array of 256 million ints = 1 GB. C++ unoptimized (gcc -O 0): 1.1s, Java: 0.8s, Hand-written assembler code: 0.6s, C++ optimized (gcc -O 3): 0.4s.

    • Remember 2: C++ unoptimized (gcc -O 0) translates the code line by line to machine code (just like Java without JIT).

    • Remember 3: Almost all PCs / notebooks / servers today use x86. Mobile phones etc. use RISC.

  3. Wednesday November 3, 2010: The Java Virtual Machine (Robin Schirrmeister),slides as pdf, slides as odprecording as WMV,faculty function written in jasmin.

    • Topics: Introduction to the Java Virtual Machine and Problems with benchmarking Java.

    • The JVM is a virtual machine that can be used to run programs from any language that has a compiler to Java Bytecode.
    • The JVM was designed with a focus on portability and security of the programs running on it.
    • Due to the complex features of modern JVM implementations and their optimization techniques, correctly benchmarking a long-running Java program is difficult.

    • When Benchmarking you need to run the benchmarked program many times to avoid measuring JVM startup time, JIT compile time, etc. One Benchmark Framework taking care of this can be found at http://www.ibm.com/developerworks/library/j-benchmark2/index.html

  4. Wednesday November 10, 2010: Compiler optimization in C++ (Jens Hoffmann), slides as pdf recording as WMV.

  5. Wednesday November 17, 2010: NO SESSION.
  6. Wednesday November 24, 2010: Java Just-in-Time Compilation (Jan Kelch), slides as pdf recording as WMV.

  7. Wednesday December 1, 2010: Memory management in C++ (Simon Rettberg), slides as pdfrecording as WMV.

  8. Wednesday December 8, 2010: Memory management in Java (Arda Akcay), recording as WMV.

  9. Wednesday December 15, 2010: GCJ (Thomas Liebetraut), slides as pdf recording as WMV.

    • Topics: Building blocks of a Java runtime environment, history if different Java implementations, GCJ's mode of operation, comparison Hotspot/GIJ/GCJ

    • GCJ (GNU Compiler for Java) bytecode and Oracle's javac bytecode are very similar, so no performance differenz when using the same VM
    • GIJ (GNU Interpreter for Java) is a LOT slower than Hotspot, especially when it comes to memory de-allocation
    • GCJ to native code is somewhat faster than JITting (even with Hotspot), but has the same major problems with de-allocation as GIJ
    • C++ with all optimizations still faster
  10. Wednesday December 22, 2010: RTL optimization (Alexander Nutz) slides as pdf recording as WMV code examples.

    • Topics: RTL in GCC: compiler internal representations: AST, CFG ; RTL as GCC's intermediate representation ; optimizations done in RTL

    • AST (abstract syntax tree) is the representation a compiler works on, CFG (control flow graph) is used for many analyses
    • For hardware-independent optimizations RTL is gradually replaced by Tree-SSA but it is still necessary for hardware-dependent optimizations like register allocation and still many optimizations are done in it
    • When trying to read RTL (all passes can be output by -fdump-rtl-all) the sixth argument of each (insn ...) is the interesting one (LISP-like syntax)
  11. Wednesday January 12, 2011: Arrays Java vs. C++ (Simon Skilevis, Ammar Qaseem) c++ slides as powerpoint c++ slides as pdf java slides as powerpoint .

    • Topics ( C++ ): 1D Array Representation and Space Overhead of 1D Array .

    • 2D Array Representation ( Row-mapping representation,Column-mapping representation,and Array-of-array representation) and Space Overhead of each way.
    • Buffer Overflow ( no Bounds Checking ): C and C++ provide no built-in protection against accessing or overwriting data in any part of memory and solution for this problem.
    • Dynamic memory allocation( new and delete operator).
    • STL-Vector as dynamic array and advantages of Vectors.
    • Topics ( Java ):

  12. Wednesday January 19, 2011: Strings Java vs. C++ (Michael Pereira, Christoph Hofmann) c++ slides as pdf Java slides as pdf recording as WMV.

    • Topics ( C++ ): String Implementations (STL, CString), Sting Optimizations (Small String, Reserve, Copy-On-Write, Call-By-Reference), String Functions (find, Multibyte)

    • Remember 1: The STL brings many optimizations and functions to String and should be prefered over the old cstring

    • Remember 2: String Optimizations really can increase performance. Some are already implemented by Libraries (small string opt. by boost, copy on write by qt) or can be implemented by yourself.

    • Remember 3: Use reserve when working with large strings or concatenation and call-by-reference when passing strings to functions to really improve performance.

    • Topics ( Java ):

  13. Wednesday January 26, 2011: NO SESSION.
  14. Wednesday February 2, 2011: Threads Java vs. C++ (Niklas Meinzer). slides live demo sources

    • Topics: Basics of Multithreading: Properties of Processes and Threads

    • Threads in Java: Thread creation, Mutual exclusion and wait-notify thread coordination
    • pthreads: C-style thread library: properties and usage
    • boost::threads: C++ style thread library: properties and usage
    • Performance tests: Thread creation and Locking
    • Note: During the live demo of my talk there was a discrepancy between the results of the single locking test for java and the locking test series. This was due to the fact that the single locking test created 10 threads and not only one as intended. I have corrected this mistake in the source code and the results are now identical. The data on the slides however uses the data from the locking test series program and is thus accurate.

  15. Wednesday February 9, 2011: Graphical User Interfaces Java cs. C++ (Daniel Brand, Franz Dietrich). slides

    • Performance completely depends on hardware acceleration
    • Native look and feel vs. emulation ( AWT, SWT, Gtk <-> Swing)

    • Complex vs. simple layouting (SWT, Gtk <-> Swing)

    • Avoid Swing under Linux when performance matters (might get better in future with accelerated backend)
    • Layers on Linux: Gtk -> Cairo -> xlib -> Driver

    • You can't tell for sure which of them is better (depends on the needs and system you want to run it on)

Interesting additional topics: smart pointers / auto pointers / scoped pointers in C++.

AD Teaching Wiki: JavaVsCplusplusWS1011 (last edited 2013-09-09 20:33:39 by Axel Lehmann)