SlideShare a Scribd company logo
Java
vs
C/C++
Cliff Click
www.azulsystems.com/blogs
Java vs C/C++
●

"I declare a Flamewar!!!!"
●

Lots of noise & heat

●

Not many facts

●

Lots of obvious mistakes being made

●

Situation is more subtle than expected

●

This is my attempt to clarify the situation
C/C++ Beats Java
●

Very small footprint – under 300KB
●

●

Very deterministic or fast (re)boot times –
●

●

e.g. engine controllers, pacemakers

Very big problems: Fortran optimizations
●

●

e.g. Embedded controllers, cars, clocks

Array reshaping & tiling for cache

Value types - Complex, Point
●

e.g. Overhead costs of 1b objects

●

vs array-of-doubles
C/C++ Beats Java
●

Direct Machine Access
●

e.g. OS's (special ops, registers), device drivers
–

Hard to do in Java (i.e. JavaOS effort)

●
●

●

AAA Games / First Person Shooter Games
Maxine Java-in-Java might be a counter-example

Direct Code-Generation
●

gnu "asm"

●

Write bits to buffer & exec
–

●

'sort' inner loop key-compare

Interpreters
C++ Beats Java
●

Destructors vs finalizers
●

Destructors are reliable out-of-language cleanup

●

Finalizers will "eventually" run
–
–

●

But maybe after running out of e.g. file handles
So weird force-GC-cycle hooks to force cleanup

Destructors vs & try/finally
●

Destructors are reliable exit-scope action

●

try/finally requires adding explicit exit-scope-action
–
–

For each new enter-scope-action
Maintenance mess
Java Beats C/C++
●

Most Programs - profiling pays off
●
●

All JIT systems profile at least some

●

●

But nobody bothers for C/C++, too hard
More profiling added as systems mature

Very Large Programs >1MLOC
●

Large program tool chain is better

●

A lot more 1MLOC Java apps than C
Java Beats C/C++
●

GC is easier to get right than malloc/free
●
●

●

Faster time-to-market
Why so many variations on Regions, Arenas,
Resource Areas? Basically hand-rolled GC...

GC is efficient
●
●

●

Parallel, concurrent
Good locality, fragmentation

GC allows concurrent algorithms
●

Trivially track shared memory lifetimes

●

Fundamental change, can't "fake it"
Java Beats C/C++
●

Single CPU speed stalled
●

●

Bigger problem => parallel solution

Better multi-threading support
●

Real Memory Model - synchronized, volatile

●

Threads are built-in

●

Large multi-threaded library base
–

●

●

JDK Concurrent Collections

GC vs concurrent malloc/free

Tools for parallel coding, debugging
Libraries
●

Vast Java Library collection
●

●

Can COTS many many problems

Downside: too many 3rd party libraries
●
●

C Mentality: build before download

●

Too many layers of Java crap

●

●

Java Mentality: download from web, don't build

Nobody knows what's going on

Application plagued by failures
no one understands
Claims C-beats-Java
But I Dont Think So
●

Most modest sized programs
●

●

Fast enough is fast enough

16bit chars vs 8bit chars
●
●

●

Lots of noise here (and lots of optimizations)
Rarely makes a difference in practice

Raw small benchmark speed
●

Usually I don't care
–

●

"C gets more BogoMips so it's better!"

OR broken testing methodology
–

"C makes a better WebServer because printf is faster!"
Common Flaws
When Comparing
●

No Warmup
●
●

●

Only interesting for quick-reboot, e.g. Pacemakers
Most apps run for minutes to days

Basic timing errors
●
●

●

API reports in nanos
OS rounds to millis (or 10's of millis)

Caching Effects
●

CPU caches, OS-level, disk & network

●

DB cache, JIT/JVM level

vs
Common Flaws
When Comparing
●

Basic Broken Statistics
●

Run-once-and-report

●

No averages, std-devs

●

Throwing out "outliers"

●

Not accounting for "compile plan"
–
–

●

"Statistically rigorous Java performance evaluation"
"Producing wrong data without doing anything obviously
wrong!"

Flags, version-numbers, env-factors all matter
●

"java" not same as "java -client" or "java -server"

●

Some JDK versions have 30% faster XML parsing
Common Flaws
When Comparing
●

Varying Datasets or Constant-time workloads
●

●

Have seen cycles-per-work-unit vary by 10x

Claiming X but testing Y
●
●

SpecJBB: claims middleware test but is GC test

●

●

209_db: claims DB test but is shell-sort test
Lots more here

Not comparing same program
●

e.g. Debian language shootout
–

http://shootout.alioth.debian.org
Commonly Mentioned
Non-Issues
●

Stack Allocation "Does So" beat GC
●

●

Does Not. You got evidence?
I got evidence of non-issue...

Java has lots of casts
●

But they are basically free
–

●

Virtual & Interface calls are slow
●

●

load/compare/branch, roughly 1 clock

And basically never taken (inline-cache)

C# curious? I dunno, I don't track Microsoft
Java-vs-C Examples
●

Examples limited to what I can fit on slides

●

In-Real-Life never get apples-to-apples

●

Programs either very small

●

Or new re-implementation
●

●

Generally better written 2nd go-round

Or extremely bad (mis)use of language features
Example: String Hash
●

Java tied vs GCC -O2
int h=0;
for( int i=0; i<len; i++ )
h = 31*h+str[i];
return h;
Here I ran it on a new X86 for 100 million loops:
> a.out
100000000
100000000 hashes in 5.636 secs
> java str_hash 100000000
100000000 hashes in 5.745 secs

●

Key is loop unrolling
●

(i.e. JITs do all major compiler optimizations)
Sieve of Erathosthenes
●

Again tied

bool *sieve = new bool[max];
for (int i=0; i<max; i++) sieve[i] = true;
sieve[0] = sieve[1] = false;
int lim = (int)sqrt(max);
for (int n=2; n<lim; n++) {
if (sieve[n]) {
for (int j=2*n; j<max; j+=n)
sieve[j] = false;
}
}

I computed the primes up to 100million:
> a.out
100000000
100000000 primes in 1.568 secs
> java sieve 100000000
100000000 primes in 1.548 secs
Silly Example
●

Silly Example to Make a Point
int sum=0;
for (int i = 0; i < max; i++)
sum += x.val(); // virtual call
return sum;
Here I run it on the same X86:
> a.out
1000000000 0
1000000000 adds in 2.657 secs
> java vcall 1000000000 0
1000000000 adds in 0.0 secs

●

Zounds! Java is "infinitely" faster than C
??? what happened here ???
Silly Example Explained
●

Command-line flag picks 1 of 2 classes for 'x'

●

Type profiling at Runtime
●

Only 1 type loaded for 'x.val()' call
–

●

JIT makes the virtual call static, then inlines
–

●

"for( int i=0; i<max; i++ ) { sum += 7/*x.val*/; }"

Once inlined, JIT optimizes loop away
–

●

"int val() { return 7; }"

"sum += max*7;"

True virtual call at static compile-time
●

No chance for a static compiler to optimize
Why Silly Example Matters
●

Only 1 implementing class for interface

●

Common case for large Java programs
●

Single-implementor interfaces abound

●

Library calls with a zillion options
–

●

But only a single option choosen, etc

Can see 100+ classes collapsed this way
–

10K call-sites optimized, 1M calls/sec optimized

●

Major Optimization not possible without JIT'ing

●

Lots more cool JIT tricks to come...
Other Stuff That Matters
●

Other Things Also Matter
●

Existing infrastructure, libraries, time-to-market

●

Programmer training, mind set
–

Lots of Java programmers Out There

●
●

●

Legal issues – open source or man-rating
Reliability, stability, scalability

JVMs enabling new languages
●

Clojure, Scala, JRuby, Jython, many more

●

Much faster time-to-market
Summary
●

My Language is Faster!!!
●

Except when it's not

●

Ummm.... "fast" is not well-defined...
–

●

Other-things-matter more in many domains
●

●

MOOPS/sec? Faster than thy competitor?
Faster-to-market? Fits in my wrist watch?

If you got 500 X programmers, maybe should use X?

Each language is a clear winner
in some domains, neither going away soon
●

e.g. still room for trains in our auto-dominated world
Summary
●

Internet is a Great Amplifier
●

●

Of both the Good, the Bad AND the Ugly

Real issue: Need Sane Discourse
●

Lots of Screaming & Flames
–
–

●

People with strong opinions, different vested interests,
different experiences & goals
e.g. Do we even agree on what "faster" means?

Lots of Bad Science
–
–

Broken & missing statistical evidence
Misapplied testing, testing unrelated stuff
Summary
●

When the noise exceeds communication levels...
●
●

●

Back up, clarify, acknowlege each side has strengths
Chill out, think it through

Recognize a lack-of-evidence for what it is
●
●

●

yelling louder about what you do know doesn't help
Good testing helps (and bad testing hurts)

Realize "faster" has different meanings
–
–
–

Junior Engineer thinks "faster than the competition"
Manager thinks "faster to market"
Senior Engineer thinks "that brick wall is approaching fast!"
Summary

It Depends.

Cliff Click
http://www.azulsystems.com/blogs

More Related Content

What's hot

002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
Dmitrii Stoian
 
C# in depth
C# in depthC# in depth
C# in depth
Arnon Axelrod
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
Olve Maudal
 
FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)
Dierk König
 
basics of c++
basics of c++basics of c++
basics of c++
gourav kottawar
 
java vs C#
java vs C#java vs C#
C# / Java Language Comparison
C# / Java Language ComparisonC# / Java Language Comparison
C# / Java Language Comparison
Robert Bachmann
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
Michael Stal
 
C# Basics
C# BasicsC# Basics
C# Basics
Sunil OS
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
Amos Wenger
 
Oop2011 actor presentation_stal
Oop2011 actor presentation_stalOop2011 actor presentation_stal
Oop2011 actor presentation_stal
Michael Stal
 
Overview of c language
Overview of c languageOverview of c language
Overview of c languageshalini392
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
hu hans
 
Presentation on C++ programming
Presentation on C++ programming Presentation on C++ programming
Presentation on C++ programming
AditiTibile
 
Objective c runtime
Objective c runtimeObjective c runtime
Objective c runtime
Inferis
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphismFALLEE31188
 
What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?
Kyle Oba
 
Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovy
Iván López Martín
 

What's hot (20)

002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type script
 
C# in depth
C# in depthC# in depth
C# in depth
 
Solid C++ by Example
Solid C++ by ExampleSolid C++ by Example
Solid C++ by Example
 
FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)FregeDay: Design and Implementation of the language (Ingo Wechsung)
FregeDay: Design and Implementation of the language (Ingo Wechsung)
 
basics of c++
basics of c++basics of c++
basics of c++
 
java vs C#
java vs C#java vs C#
java vs C#
 
C# / Java Language Comparison
C# / Java Language ComparisonC# / Java Language Comparison
C# / Java Language Comparison
 
Qcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scalaQcon2011 functions rockpresentation_scala
Qcon2011 functions rockpresentation_scala
 
C# Basics
C# BasicsC# Basics
C# Basics
 
ooc - A hybrid language experiment
ooc - A hybrid language experimentooc - A hybrid language experiment
ooc - A hybrid language experiment
 
Oop2011 actor presentation_stal
Oop2011 actor presentation_stalOop2011 actor presentation_stal
Oop2011 actor presentation_stal
 
Andy On Closures
Andy On ClosuresAndy On Closures
Andy On Closures
 
Overview of c language
Overview of c languageOverview of c language
Overview of c language
 
Boo Manifesto
Boo ManifestoBoo Manifesto
Boo Manifesto
 
Presentation on C++ programming
Presentation on C++ programming Presentation on C++ programming
Presentation on C++ programming
 
Objective c runtime
Objective c runtimeObjective c runtime
Objective c runtime
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
 
What Makes Objective C Dynamic?
What Makes Objective C Dynamic?What Makes Objective C Dynamic?
What Makes Objective C Dynamic?
 
Runtime
RuntimeRuntime
Runtime
 
Greach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovyGreach 2014 - Metaprogramming with groovy
Greach 2014 - Metaprogramming with groovy
 

Viewers also liked

C++vs java
C++vs javaC++vs java
C++vs java
Pradeep wolf king
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
Sagar Pednekar
 
Zulu Embedded Java Introduction
Zulu Embedded Java IntroductionZulu Embedded Java Introduction
Zulu Embedded Java Introduction
Azul Systems Inc.
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and Java
Ajmal Ak
 
Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...
Azul Systems Inc.
 
Towards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleTowards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding Style
Azul Systems Inc.
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market Open
Azul Systems Inc.
 
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
Azul Systems Inc.
 
How NOT to Write a Microbenchmark
How NOT to Write a MicrobenchmarkHow NOT to Write a Microbenchmark
How NOT to Write a Microbenchmark
Azul Systems Inc.
 
Experiences with Debugging Data Races
Experiences with Debugging Data RacesExperiences with Debugging Data Races
Experiences with Debugging Data Races
Azul Systems Inc.
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?
Azul Systems Inc.
 
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Azul Systems Inc.
 
The Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVMThe Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVM
Azul Systems Inc.
 
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Azul Systems Inc.
 
Hoje sou um professor feliz: Python no ensino de programação
Hoje sou um professor feliz: Python no ensino de programaçãoHoje sou um professor feliz: Python no ensino de programação
Hoje sou um professor feliz: Python no ensino de programação
FATEC São José dos Campos
 
Lock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash TableLock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash Table
Azul Systems Inc.
 
DotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie EnvironmentsDotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
Azul Systems Inc.
 
What's Inside a JVM?
What's Inside a JVM?What's Inside a JVM?
What's Inside a JVM?
Azul Systems Inc.
 
Pepe Legal Python e Babalu MongoDB, uma dupla dinâmica
Pepe Legal Python e Babalu MongoDB, uma dupla dinâmicaPepe Legal Python e Babalu MongoDB, uma dupla dinâmica
Pepe Legal Python e Babalu MongoDB, uma dupla dinâmica
FATEC São José dos Campos
 

Viewers also liked (20)

C++vs java
C++vs javaC++vs java
C++vs java
 
Difference between Java and c#
Difference between Java and c#Difference between Java and c#
Difference between Java and c#
 
Zulu Embedded Java Introduction
Zulu Embedded Java IntroductionZulu Embedded Java Introduction
Zulu Embedded Java Introduction
 
Difference between C++ and Java
Difference between C++ and JavaDifference between C++ and Java
Difference between C++ and Java
 
Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...
 
Towards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleTowards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding Style
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market Open
 
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
 
How NOT to Write a Microbenchmark
How NOT to Write a MicrobenchmarkHow NOT to Write a Microbenchmark
How NOT to Write a Microbenchmark
 
Experiences with Debugging Data Races
Experiences with Debugging Data RacesExperiences with Debugging Data Races
Experiences with Debugging Data Races
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?
 
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
 
The Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVMThe Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVM
 
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
 
Hoje sou um professor feliz: Python no ensino de programação
Hoje sou um professor feliz: Python no ensino de programaçãoHoje sou um professor feliz: Python no ensino de programação
Hoje sou um professor feliz: Python no ensino de programação
 
Lock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash TableLock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash Table
 
DotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie EnvironmentsDotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
 
Api facebook
Api facebookApi facebook
Api facebook
 
What's Inside a JVM?
What's Inside a JVM?What's Inside a JVM?
What's Inside a JVM?
 
Pepe Legal Python e Babalu MongoDB, uma dupla dinâmica
Pepe Legal Python e Babalu MongoDB, uma dupla dinâmicaPepe Legal Python e Babalu MongoDB, uma dupla dinâmica
Pepe Legal Python e Babalu MongoDB, uma dupla dinâmica
 

Similar to Java vs. C/C++

Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java code
Attila Balazs
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
Jeremy Leisy
 
strangeloop 2012 apache cassandra anti patterns
strangeloop 2012 apache cassandra anti patternsstrangeloop 2012 apache cassandra anti patterns
strangeloop 2012 apache cassandra anti patterns
Matthew Dennis
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUGslandelle
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadKrivoy Rog IT Community
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
maiktoepfer
 
Benchmarks, performance, scalability, and capacity what s behind the numbers...
Benchmarks, performance, scalability, and capacity  what s behind the numbers...Benchmarks, performance, scalability, and capacity  what s behind the numbers...
Benchmarks, performance, scalability, and capacity what s behind the numbers...
james tong
 
Benchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersBenchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbers
Justin Dorfman
 
Number of Computer Languages = 3
Number of Computer Languages = 3Number of Computer Languages = 3
Number of Computer Languages = 3
Ram Sekhar
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracow
MateuszSzczyrzyca
 
A first look into the Project Loom in Java
A first look into the Project Loom in JavaA first look into the Project Loom in Java
A first look into the Project Loom in Java
Lukas Steinbrecher
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
Dvir Volk
 
On component interface
On component interfaceOn component interface
On component interface
Laurence Chen
 
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
Red Hat Developers
 
Serverless? How (not) to develop, deploy and operate serverless applications.
Serverless? How (not) to develop, deploy and operate serverless applications.Serverless? How (not) to develop, deploy and operate serverless applications.
Serverless? How (not) to develop, deploy and operate serverless applications.
gjdevos
 
Effective cplusplus
Effective cplusplusEffective cplusplus
Effective cplusplusMark Veltzer
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
Alessandro Molina
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Databricks
 
There is something about serverless
There is something about serverlessThere is something about serverless
There is something about serverless
gjdevos
 

Similar to Java vs. C/C++ (20)

Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java code
 
JVM Performance Tuning
JVM Performance TuningJVM Performance Tuning
JVM Performance Tuning
 
strangeloop 2012 apache cassandra anti patterns
strangeloop 2012 apache cassandra anti patternsstrangeloop 2012 apache cassandra anti patterns
strangeloop 2012 apache cassandra anti patterns
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUG
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016Not Your Fathers C - C Application Development In 2016
Not Your Fathers C - C Application Development In 2016
 
Volatile
VolatileVolatile
Volatile
 
Benchmarks, performance, scalability, and capacity what s behind the numbers...
Benchmarks, performance, scalability, and capacity  what s behind the numbers...Benchmarks, performance, scalability, and capacity  what s behind the numbers...
Benchmarks, performance, scalability, and capacity what s behind the numbers...
 
Benchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbersBenchmarks, performance, scalability, and capacity what's behind the numbers
Benchmarks, performance, scalability, and capacity what's behind the numbers
 
Number of Computer Languages = 3
Number of Computer Languages = 3Number of Computer Languages = 3
Number of Computer Languages = 3
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracow
 
A first look into the Project Loom in Java
A first look into the Project Loom in JavaA first look into the Project Loom in Java
A first look into the Project Loom in Java
 
10 reasons to be excited about go
10 reasons to be excited about go10 reasons to be excited about go
10 reasons to be excited about go
 
On component interface
On component interfaceOn component interface
On component interface
 
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
How To Get The Most Out Of Your Hibernate, JBoss EAP 7 Application (Ståle Ped...
 
Serverless? How (not) to develop, deploy and operate serverless applications.
Serverless? How (not) to develop, deploy and operate serverless applications.Serverless? How (not) to develop, deploy and operate serverless applications.
Serverless? How (not) to develop, deploy and operate serverless applications.
 
Effective cplusplus
Effective cplusplusEffective cplusplus
Effective cplusplus
 
PyGrunn2013 High Performance Web Applications with TurboGears
PyGrunn2013  High Performance Web Applications with TurboGearsPyGrunn2013  High Performance Web Applications with TurboGears
PyGrunn2013 High Performance Web Applications with TurboGears
 
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark... Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
Validating Big Data Jobs—Stopping Failures Before Production on Apache Spark...
 
There is something about serverless
There is something about serverlessThere is something about serverless
There is something about serverless
 

More from Azul Systems Inc.

Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017
Azul Systems Inc.
 
Understanding GC, JavaOne 2017
Understanding GC, JavaOne 2017Understanding GC, JavaOne 2017
Understanding GC, JavaOne 2017
Azul Systems Inc.
 
Azul Systems open source guide
Azul Systems open source guideAzul Systems open source guide
Azul Systems open source guide
Azul Systems Inc.
 
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and ToolsIntelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Azul Systems Inc.
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
Azul Systems Inc.
 
The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014
Azul Systems Inc.
 
Push Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and ZingPush Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and ZingAzul Systems Inc.
 
The Art of Java Benchmarking
The Art of Java BenchmarkingThe Art of Java Benchmarking
The Art of Java Benchmarking
Azul Systems Inc.
 
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, PolandAzul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Systems Inc.
 
Understanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About ThemUnderstanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About Them
Azul Systems Inc.
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
Azul Systems Inc.
 
JVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the HoodJVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the Hood
Azul Systems Inc.
 
Enterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchEnterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up Search
Azul Systems Inc.
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About It
Azul Systems Inc.
 
Enabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive ApplicationsEnabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive Applications
Azul Systems Inc.
 
Java at Scale, Dallas JUG, October 2013
Java at Scale, Dallas JUG, October 2013Java at Scale, Dallas JUG, October 2013
Java at Scale, Dallas JUG, October 2013
Azul Systems Inc.
 

More from Azul Systems Inc. (16)

Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017
 
Understanding GC, JavaOne 2017
Understanding GC, JavaOne 2017Understanding GC, JavaOne 2017
Understanding GC, JavaOne 2017
 
Azul Systems open source guide
Azul Systems open source guideAzul Systems open source guide
Azul Systems open source guide
 
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and ToolsIntelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
 
Understanding Java Garbage Collection
Understanding Java Garbage CollectionUnderstanding Java Garbage Collection
Understanding Java Garbage Collection
 
The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014
 
Push Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and ZingPush Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and Zing
 
The Art of Java Benchmarking
The Art of Java BenchmarkingThe Art of Java Benchmarking
The Art of Java Benchmarking
 
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, PolandAzul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
 
Understanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About ThemUnderstanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About Them
 
JVM Memory Management Details
JVM Memory Management DetailsJVM Memory Management Details
JVM Memory Management Details
 
JVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the HoodJVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the Hood
 
Enterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchEnterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up Search
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About It
 
Enabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive ApplicationsEnabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive Applications
 
Java at Scale, Dallas JUG, October 2013
Java at Scale, Dallas JUG, October 2013Java at Scale, Dallas JUG, October 2013
Java at Scale, Dallas JUG, October 2013
 

Recently uploaded

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
mikeeftimakis1
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
UiPathCommunity
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
Alpen-Adria-Universität
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
Vlad Stirbu
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 

Recently uploaded (20)

The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Introduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - CybersecurityIntroduction to CHERI technology - Cybersecurity
Introduction to CHERI technology - Cybersecurity
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
Assure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyesAssure Contact Center Experiences for Your Customers With ThousandEyes
Assure Contact Center Experiences for Your Customers With ThousandEyes
 
UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..UiPath Community Day Dubai: AI at Work..
UiPath Community Day Dubai: AI at Work..
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Video Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the FutureVideo Streaming: Then, Now, and in the Future
Video Streaming: Then, Now, and in the Future
 
Quantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIsQuantum Computing: Current Landscape and the Future Role of APIs
Quantum Computing: Current Landscape and the Future Role of APIs
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 

Java vs. C/C++

  • 2. Java vs C/C++ ● "I declare a Flamewar!!!!" ● Lots of noise & heat ● Not many facts ● Lots of obvious mistakes being made ● Situation is more subtle than expected ● This is my attempt to clarify the situation
  • 3. C/C++ Beats Java ● Very small footprint – under 300KB ● ● Very deterministic or fast (re)boot times – ● ● e.g. engine controllers, pacemakers Very big problems: Fortran optimizations ● ● e.g. Embedded controllers, cars, clocks Array reshaping & tiling for cache Value types - Complex, Point ● e.g. Overhead costs of 1b objects ● vs array-of-doubles
  • 4. C/C++ Beats Java ● Direct Machine Access ● e.g. OS's (special ops, registers), device drivers – Hard to do in Java (i.e. JavaOS effort) ● ● ● AAA Games / First Person Shooter Games Maxine Java-in-Java might be a counter-example Direct Code-Generation ● gnu "asm" ● Write bits to buffer & exec – ● 'sort' inner loop key-compare Interpreters
  • 5. C++ Beats Java ● Destructors vs finalizers ● Destructors are reliable out-of-language cleanup ● Finalizers will "eventually" run – – ● But maybe after running out of e.g. file handles So weird force-GC-cycle hooks to force cleanup Destructors vs & try/finally ● Destructors are reliable exit-scope action ● try/finally requires adding explicit exit-scope-action – – For each new enter-scope-action Maintenance mess
  • 6. Java Beats C/C++ ● Most Programs - profiling pays off ● ● All JIT systems profile at least some ● ● But nobody bothers for C/C++, too hard More profiling added as systems mature Very Large Programs >1MLOC ● Large program tool chain is better ● A lot more 1MLOC Java apps than C
  • 7. Java Beats C/C++ ● GC is easier to get right than malloc/free ● ● ● Faster time-to-market Why so many variations on Regions, Arenas, Resource Areas? Basically hand-rolled GC... GC is efficient ● ● ● Parallel, concurrent Good locality, fragmentation GC allows concurrent algorithms ● Trivially track shared memory lifetimes ● Fundamental change, can't "fake it"
  • 8. Java Beats C/C++ ● Single CPU speed stalled ● ● Bigger problem => parallel solution Better multi-threading support ● Real Memory Model - synchronized, volatile ● Threads are built-in ● Large multi-threaded library base – ● ● JDK Concurrent Collections GC vs concurrent malloc/free Tools for parallel coding, debugging
  • 9. Libraries ● Vast Java Library collection ● ● Can COTS many many problems Downside: too many 3rd party libraries ● ● C Mentality: build before download ● Too many layers of Java crap ● ● Java Mentality: download from web, don't build Nobody knows what's going on Application plagued by failures no one understands
  • 10. Claims C-beats-Java But I Dont Think So ● Most modest sized programs ● ● Fast enough is fast enough 16bit chars vs 8bit chars ● ● ● Lots of noise here (and lots of optimizations) Rarely makes a difference in practice Raw small benchmark speed ● Usually I don't care – ● "C gets more BogoMips so it's better!" OR broken testing methodology – "C makes a better WebServer because printf is faster!"
  • 11. Common Flaws When Comparing ● No Warmup ● ● ● Only interesting for quick-reboot, e.g. Pacemakers Most apps run for minutes to days Basic timing errors ● ● ● API reports in nanos OS rounds to millis (or 10's of millis) Caching Effects ● CPU caches, OS-level, disk & network ● DB cache, JIT/JVM level vs
  • 12. Common Flaws When Comparing ● Basic Broken Statistics ● Run-once-and-report ● No averages, std-devs ● Throwing out "outliers" ● Not accounting for "compile plan" – – ● "Statistically rigorous Java performance evaluation" "Producing wrong data without doing anything obviously wrong!" Flags, version-numbers, env-factors all matter ● "java" not same as "java -client" or "java -server" ● Some JDK versions have 30% faster XML parsing
  • 13. Common Flaws When Comparing ● Varying Datasets or Constant-time workloads ● ● Have seen cycles-per-work-unit vary by 10x Claiming X but testing Y ● ● SpecJBB: claims middleware test but is GC test ● ● 209_db: claims DB test but is shell-sort test Lots more here Not comparing same program ● e.g. Debian language shootout – http://shootout.alioth.debian.org
  • 14. Commonly Mentioned Non-Issues ● Stack Allocation "Does So" beat GC ● ● Does Not. You got evidence? I got evidence of non-issue... Java has lots of casts ● But they are basically free – ● Virtual & Interface calls are slow ● ● load/compare/branch, roughly 1 clock And basically never taken (inline-cache) C# curious? I dunno, I don't track Microsoft
  • 15. Java-vs-C Examples ● Examples limited to what I can fit on slides ● In-Real-Life never get apples-to-apples ● Programs either very small ● Or new re-implementation ● ● Generally better written 2nd go-round Or extremely bad (mis)use of language features
  • 16. Example: String Hash ● Java tied vs GCC -O2 int h=0; for( int i=0; i<len; i++ ) h = 31*h+str[i]; return h; Here I ran it on a new X86 for 100 million loops: > a.out 100000000 100000000 hashes in 5.636 secs > java str_hash 100000000 100000000 hashes in 5.745 secs ● Key is loop unrolling ● (i.e. JITs do all major compiler optimizations)
  • 17. Sieve of Erathosthenes ● Again tied bool *sieve = new bool[max]; for (int i=0; i<max; i++) sieve[i] = true; sieve[0] = sieve[1] = false; int lim = (int)sqrt(max); for (int n=2; n<lim; n++) { if (sieve[n]) { for (int j=2*n; j<max; j+=n) sieve[j] = false; } } I computed the primes up to 100million: > a.out 100000000 100000000 primes in 1.568 secs > java sieve 100000000 100000000 primes in 1.548 secs
  • 18. Silly Example ● Silly Example to Make a Point int sum=0; for (int i = 0; i < max; i++) sum += x.val(); // virtual call return sum; Here I run it on the same X86: > a.out 1000000000 0 1000000000 adds in 2.657 secs > java vcall 1000000000 0 1000000000 adds in 0.0 secs ● Zounds! Java is "infinitely" faster than C ??? what happened here ???
  • 19. Silly Example Explained ● Command-line flag picks 1 of 2 classes for 'x' ● Type profiling at Runtime ● Only 1 type loaded for 'x.val()' call – ● JIT makes the virtual call static, then inlines – ● "for( int i=0; i<max; i++ ) { sum += 7/*x.val*/; }" Once inlined, JIT optimizes loop away – ● "int val() { return 7; }" "sum += max*7;" True virtual call at static compile-time ● No chance for a static compiler to optimize
  • 20. Why Silly Example Matters ● Only 1 implementing class for interface ● Common case for large Java programs ● Single-implementor interfaces abound ● Library calls with a zillion options – ● But only a single option choosen, etc Can see 100+ classes collapsed this way – 10K call-sites optimized, 1M calls/sec optimized ● Major Optimization not possible without JIT'ing ● Lots more cool JIT tricks to come...
  • 21. Other Stuff That Matters ● Other Things Also Matter ● Existing infrastructure, libraries, time-to-market ● Programmer training, mind set – Lots of Java programmers Out There ● ● ● Legal issues – open source or man-rating Reliability, stability, scalability JVMs enabling new languages ● Clojure, Scala, JRuby, Jython, many more ● Much faster time-to-market
  • 22. Summary ● My Language is Faster!!! ● Except when it's not ● Ummm.... "fast" is not well-defined... – ● Other-things-matter more in many domains ● ● MOOPS/sec? Faster than thy competitor? Faster-to-market? Fits in my wrist watch? If you got 500 X programmers, maybe should use X? Each language is a clear winner in some domains, neither going away soon ● e.g. still room for trains in our auto-dominated world
  • 23. Summary ● Internet is a Great Amplifier ● ● Of both the Good, the Bad AND the Ugly Real issue: Need Sane Discourse ● Lots of Screaming & Flames – – ● People with strong opinions, different vested interests, different experiences & goals e.g. Do we even agree on what "faster" means? Lots of Bad Science – – Broken & missing statistical evidence Misapplied testing, testing unrelated stuff
  • 24. Summary ● When the noise exceeds communication levels... ● ● ● Back up, clarify, acknowlege each side has strengths Chill out, think it through Recognize a lack-of-evidence for what it is ● ● ● yelling louder about what you do know doesn't help Good testing helps (and bad testing hurts) Realize "faster" has different meanings – – – Junior Engineer thinks "faster than the competition" Manager thinks "faster to market" Senior Engineer thinks "that brick wall is approaching fast!"