# Why is java so slow ?



## sw2wolf (Aug 28, 2011)

I downloaded JRE from http://www.freebsdfoundation.org/cgi-bin/download?download=diablo-jre-freebsd7.i386.1.6.0.07.02.tbz

It is VERY slow so that i feel it is not practical in freebsd.

Sincerely!


----------



## graudeejs (Aug 28, 2011)

It's supposed to be slow by design


----------



## Crivens (Aug 28, 2011)

No, that is not really true. 

But this happens when you let frameworks and toolboxes grow unchecked. Java in itself is fast enough to do a lot of things you need done, but if you layer abstraction over abstraction you end up spending a lot of cycles only pushing bits around instead of doing real work. This happens when you have a language and runtime being developed by a comitee.

I for myself like Java (the idea), but I get into fits of rage when I have to use f.e. eclipse or handle the quagmire the project turned into.


----------



## fonz (Aug 28, 2011)

graudeejs said:
			
		

> It's supposed to be slow by design


Only to some extent. Having the Java VM (JRE) in between the program and the machine as an additional layer is of course always going to make it slower than, say, compiler-optimized Fortran, sure. But having said that, the Diablo JRE isn't supposed to be as slow as the TS complains it is. So I think the main question is: why is Java so slow on the TS' machine?

Fonz


----------



## fonz (Aug 28, 2011)

sw2wolf said:
			
		

> It is VERY slow so that i feel it is not practical in freebsd _[sic]_.


Can you provided some details of your system? Java will by design never be the fastest, but it isn't supposed to be VERY slow.

Fonz


----------



## wblock@ (Aug 28, 2011)

sw2wolf said:
			
		

> It is VERY slow so that i feel it is not practical in freebsd.



Slow in what way?  Slow to download?  Slow to start, to compile, to run an application?  What application?


----------



## UNIXgod (Aug 28, 2011)

They use java vm with jruby to keep twitter up and running. It all depends. The right tool for the right job. If I was going to create a simple filter I would use the shell and shell derived languages as to load the jvm for a filter is ridicules. If I need concurrency using the jvm seems the way to go as launch time isn't relevant in that use case. Of course if that's not good enough your either doing something wrong or need to evaluate other languages in order of speed c++, c, asm etc.


----------



## sw2wolf (Aug 30, 2011)

fonz said:
			
		

> Can you provided some details of your system? Java will by design never be the fastest, but it isn't supposed to be VERY slow.
> 
> Fonz




```
>uname -a
FreeBSD mybsd.zsoft.com 8.2-RELEASE FreeBSD 8.2-RELEASE #2: Sat Feb 26 16:53:57 CST 2011     root@mybsd.zsoft.com:/media/G/usr/obj/media/G/usr/src/sys/MYKERNEL  i386

>dmesg -a|grep -i memory
real memory  = 536870912 (512 MB)
avail memory = 497008640 (473 MB)
```

I know the memory is too little to run Clojure. However, in the same box the "openjdk" under ArchLinux runs smoothly. So i feel the diablo-jre is slower than openjdk.


----------



## graudeejs (Aug 30, 2011)

No wonder. diablo-jdk wasn't updated in years (since FreeBSD 7.0 probably)


----------



## wblock@ (Aug 30, 2011)

Easy enough to try java/openjdk6 or java/openjdk7 on FreeBSD.


----------



## SirDice (Aug 30, 2011)

Java likes to have a lot of memory to play with. With 512MB the system will start swapping quite a lot which accounts for the slowness.


----------



## sw2wolf (Aug 30, 2011)

wblock said:
			
		

> Easy enough to try java/openjdk6 or java/openjdk7 on FreeBSD.


Yes, but it seems that there are no binary packages of openjdk.


----------



## graudeejs (Aug 30, 2011)

There are openjdk{6,7} packages on freebsd-8-stable


----------



## aragon (Aug 30, 2011)

Or just build your own...

`# make package`

ports(7)


----------

