• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Using Java as opposed to another language where performance counts

 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where performance really counts, it's the architecture that counts, not the language.

Think about how Google makes it happen that no search takes longer than 0.2s. The point is not in using a fast language, but in using a scalable architecture.
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:
Where performance really counts, it's the architecture that counts, not the language.

Think about how Google makes it happen that no search takes longer than 0.2s. The point is not in using a fast language, but in using a scalable architecture.



Define architecture.

Then: The way google makes this happen is that the entire system is distributed. This can be a good thing for original poster to think about in working his question: If anything he wrote had some chance of being scaled, would not having written it in a linguistic which supports scalability have provided time to mature the codebase before getting into a timeline, deploy before ready squeeze ?

If that does not server Doug's contemporary design challenges, then how about the abilty to do rapid-prototyping and concepting ? Java is easy to translate back into C/C++, I would think so. Every time I see some sample code, such as what I found this morning for testing Md5deep, I just rewrite hundreds of lines of code faster than I can loose sleep worring about a runaway pointer, let along obscure ways of implementing try-catch semantics with the pre-processor.

Let's see now:

#ifdefine define
define wine devine
#elseifdef decline
#define dewine declined

it's simpler just to do:

private static final transient long NUMBER = 0x45688L;

Thus, by achieving portability in the prototyping work, a great deal of power has been attained, even if the work is reported to C. One would have to write test loops for isolated, small-scale applications, but this avoids total dependency on other outside libraries. If one's skill is anywhere near what Doug's sounds like, Doug could write libs in Java using attained skills, then employ powerful code-signing techniques using widely-tested code.

In protection of work in compter science, there are no sweeter words than 'widely tested'
 
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ilja & Nick,

Ilja: Where performance really counts, it's the architecture that counts, not the language.



I will agree that the architecture is important as long as it works transparently to the higher layers. An example is an apache load balancer. I disagree that the language is not a factor. Example: How many operating systems support VB or RPG? In my world multiplatform is the norm. My former employer had systems in the field that integrated with mainframes to mini's, all running different os's. We had one site with an IBM 360 hooking up to a Windows box (over time from '95 to 2kPro). There were also other systems at that site concurrently running various versions of Windows and Linux, so everyone involved had the hairs on the back of their necks rise when a system needed to be touched. This probably was not the best overall design of a system, but it evolved over time and as older versions became obsolete and antiquated, we were forced to wedge in new solutions the best we could. The biggest headache as a developer was migrating code to new versions of Windows. Nothing ever worked 100% with a new Windows version .

Nick: If one's skill is anywhere near what Doug's sounds like, Doug could write libs in Java using attained skills, then employ powerful code-signing techniques using widely-tested code.



The standard Java api is way more vast than C. However, there are C libs that do the same thing as the Java language and core api's. I've adopted Java as a relevant language to put effort into learning, but there's still some things that don't sit right with me. Take threads for instance. Actually, threads in a general sense and not how they're implemented in Java. In the good old days before Microsoft(?) coined the term multithreaded (and thread safe), we used to be able to (and still can) get by with a combination of fork(), exec(), select() and shared memory/semaphores. It bugs me in a sense that a programmer has to be thread aware of something the os should handle.

It's good that Java provides more conveniences than C. And in some ways, it's good that the compiler protects us from ourselves. However, experienced programmers (was tempted to say real men, but no flames please ) I've worked with enjoy the freedom of C. A couple of examples:


A Java programmer was blown away when he saw me do something like this (and moreso without a cast).



I've never had a use for the switch example, but it is fun to show to the know-it alls .

Aloha,
Doug

-- Nothing is impossible if I'mPossible

[ October 22, 2007: Message edited by: Doug Slattery ]
[ October 22, 2007: Message edited by: Doug Slattery ]
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Doug Slattery:
I disagree that the language is not a factor. Example: How many operating systems support VB or RPG? In my world multiplatform is the norm.



How is that a *performance* consideration???
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:


How is that a *performance* consideration???



From that comment, I'll admit, probably nothing. I had thought my post about one of the uses of JNI is the claim that where performance counts, a lower level language such as C or assembly discussed here: http://www.coderanch.com/forums/
was in this thread. I was extending that post from the standpoint that programs written in a higher level languages have traditionally ran slower than the equivalent lower level language.

Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I haven't looked at the java switch statement, in a while, but after briefly looking at your example I don't see how it is different from javas implementation. Here is an example from wikipedia. Furthermore in an OO language often polymorphic code can act similarly to a switch statement.

http://en.wikipedia.org/wiki/Switch_statement#Java
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Steve,

Originally posted by steve souza:

I haven't looked at the java switch statement, in a while, but after briefly looking at your example I don't see how it is different from javas implementation. Here is an example from wikipedia.



The syntax of the switch statement is the same, but notice the nested within an if statement. That's where the compiler fails (in Java 5). By failing, it undermines the switch statement of being a glorified goto .

Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

The standard Java api is way more vast than C. However, there are C libs that do the same thing as the Java language and core api's. I've adopted Java as a relevant language to put effort into learning, but there's still some things that don't sit right with me. Take threads for instance. Actually, threads in a general sense and not how they're implemented in Java. In the good old days before Microsoft(?) coined the term multithreaded (and thread safe), we used to be able to (and still can) get by with a combination of fork(), exec(), select() and shared memory/semaphores. It bugs me in a sense that a programmer has to be thread aware of something the os should handle.



I am exhausted right now, I just prototyped two modules and I can see that the issues are being discussed effectively - but your comment about threads is not scalable to larger processor hardware. The scene is likely to normalize, eventually, but CriticalSection (and it's locks) exposes a fundamental camp culture that is only partially aware of such things as Dr. Bulka discusses in his book. I am too exhausted right now make a stable reply, but can you read this book before making further judgments about threading ? Threading is has a lot to do with what hardware it is running on. Fork and select and so on carry clear indicators of pdp-11 and other hdwe that does not map clearly to todays compiler/bus designs at 1:1 .

Threading is very much a compiler/hardware issue, more than it is a linguistic issue - one could thread using the compiler alone - my point here on this one narrow issue is that by supporting threading as a base class directly in the primary namespace, the scalability improves for server apps where business does not want to spend any money anywhere.

My suggestion for the moment is write a simple app that forks a few threads in main() and test synchronized v unsync()'d versions over ten or twenty iterations of a loop and just fiddle with it for awhile to acclimatize to using a namespace style as opposed to an include and a bunch of preprocessing and how nice it is to get away from static/external ambiguities, working where such terms have an easier to get to formalisim.

As for libs, wait till you get a tested implemntation of AES using 2048 bit keylengths just by writing a relatively short body of of code.

[message edit: ... but no flames please ... i've tested the waters, stick with code expertise and good manners, they take any such down in defense of the under 20's ]
[ October 23, 2007: Message edited by: Nicholas Jordan ]
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

By failing, it undermines the switch statement of being a glorified goto .


Kudo's to java for failing to compile such code.
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Nick: your comment about threads is not scalable to larger processor hardware.


Sure it is. Fork() and exec() spawn a new process (technically not really a thread) and you can observe the resource usage using the Linux top utility. Back when SCO Unix was in its heyday, they had multiprocessor support while Windows was fighting tooth and nail to avoid implementing networking. All a developer needed to do was turn on a compile switch and voila, the multiprocessor library was linked in to the executable.

Nick: can you read this book before making further judgments about threading


I'll compromise. I'll lay low on the thread comments for now even though the topic still gives me some "mental indigestion" . I've got other reading to do atm on law. I'm not a lawyer, but am going into a legal battle and it's one of those "if you want a job done right, do it yourself" things.

Steve: Kudo's to java for failing to compile such code.


And kudo's to java for keeping it simple. *not* ! Ok, Ok, I'll give it a break. It is simpler than Win32

Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

[Doug:]Sure it is. Fork() and exec() spawn a new process (technically not really a thread) and you can observe the resource usage using the Linux top utility. Back when SCO Unix was in its heyday, they had multiprocessor support while Windows was fighting tooth and nail to avoid implementing networking. All a developer needed to do was turn on a compile switch and voila, the multiprocessor library was linked in to the executable.


For some reason, I am ate up with doing everything with threads. I earlier attempts at geting my launch loop to run, I made a fool of myself over {System.in.[somefunc() that reads std in ] blocking in Java. Whenever I see the stuff about cgi launching a new process, that gets hammered in and right this moment, I have spent the last week or better prototyping often as much as 500 lines of code a day, depending on who's counting, how they are counting and indentation style. I even wrote a short test stubb to fire off a Thread that actually runs the app and let the main() thread pass on through. It's just the way I am, I comprehend your postion.

What is atm on law ?

Nevertheless, One Comes Over - a convert nearly won.
[ October 26, 2007: Message edited by: Nicholas Jordan ]
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I made a fool of myself over {System.in.[somefunc() that reads std in ] blocking in Java.



We all make those Homer Simpson *doh* or Carlos Mencia Dee-Dee-Dee moves once in a while ...

Like the time I deleted the primary partition off of the wrong drive on a multiuser system when it was up. Luckily nothing was lost, but I saw my life flash before my eyes.

Or, the time I dumped a tray of screws into an open power supply I was working on while it was turned on. No sparks or fires, but the fan was spitting out screws for the few microseconds it took me to yank out the power cord from the wall.

Or, the time a replacement transistor for a Wyse 50 exploded because I put it in backwards.

What is atm on law ?



I've got other reading to do atm (at the moment) on law.

We're starting to get off the beaten path at this point. Some valid points have been made from all the posts. The thing I probably could have added early on was to assume the implementation across languages was the same (meaning the same algorithms), the implementations are written efficiently and they should be equally scalable if the architecture allows.

The main contenders are C/C++ and Java. Until I get more experienced with Java or am thrown to the lions to learn and use it, I'll stick with C. That's only because it's easier for me at this point. 6 months from now, things will probably be different .

Have a nice weekend all...
Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Doug Slattery:
[QB]


I've never had a use for the switch example, but it is fun to show to the know-it alls .

Aloha,
Doug
[QB]



I'm curious about your view on whether or not any language should compile code such as that. I've used "languages" ranging from ARM9 and x86 assembly to Java and I'm finding the latter a breath of fresh air when it comes to not allowing questionable constructs such as the one you illustrated.

Dont get me wrong, I'll be the first to appreciate original and fun solutions. I once got myself involved with creating a graphical demo application of 4096 bytes (x86) and it used things such as self modifying code and other things that sane people (and I reluctantly consider myself part of that group) would now consider out of the question, but thinking about it still makes me all warm and fuzzy inside.

Anyway, just curious about your view on that specific matter. By the way I'm aware this post is well off-topic, but that ship has sailed since post 8 or 9 anyway so indulge me

Oh and to get an on topic comment in here. A while ago I ported some code from a real-time raytracing application i made from C to Java and with the -server JVM flag the performance was comparable. I also think performance comparisons of languages (or perhaps, their VMs and compilers) are utterly useless. Not because performance itself is not an important issue, but because comparing them on performance alone is almost always a matter of apples and pears.
 
Doug Slattery
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi R van Vliet,


I'm curious about your view on whether or not any language should compile code such as that. I've used "languages" ranging from ARM9 and x86 assembly to Java and I'm finding the latter a breath of fresh air when it comes to not allowing questionable constructs such as the one you illustrated.


I would say that depends. Since assembly doesn't have a switch statement, it's definitely out of the question . Actually, I see it making the most sense that C and maybe C++ be the only candidates. They're in a category close to low level and abstract while being considered structured languages. This observation is based on my experience with other languages: Java, Basic, VB, Assembly, Pascal and Fortran.
I would definitely put comments around the code for the next guy though.


Dont get me wrong, I'll be the first to appreciate original and fun solutions. I once got myself involved with creating a graphical demo application of 4096 bytes (x86) and it used things such as self modifying code and other things that sane people (and I reluctantly consider myself part of that group) would now consider out of the question, but thinking about it still makes me all warm and fuzzy inside.


I did something similar to that in a game program I wrote back in the early 80's. I was in high school at the time. Back then, I also developed a recursive routine in assembly before I knew what recursion was. Recently, I wrote an XHTML generator with strict compliance in C using only #define's. I had to do it that way because the function couldn't be prototyped. So yeah, pretty cool stuff.


Anyway, just curious about your view on that specific matter. By the way I'm aware this post is well off-topic, but that ship has sailed since post 8 or 9 anyway so indulge me


No problem chiming in this late in the game, I notice you recently joined the ranch, so it's in bounds, and welcome to the group too .


Oh and to get an on topic comment in here. A while ago I ported some code from a real-time raytracing application i made from C to Java and with the -server JVM flag the performance was comparable. I also think performance comparisons of languages (or perhaps, their VMs and compilers) are utterly useless. Not because performance itself is not an important issue, but because comparing them on performance alone is almost always a matter of apples and pears.


Are you doing some game development? Dr. Dobbs had an interesting article back in the early 90's on game engines using ray casting.
I originally started the thread because I was trying to justify why my former employer was switching from C to Java for CGI development. My opinion at that time was that Java was slow. From the replies, I can see that it is now a manini (pronounced Mah-Nee-Nee, Hawaiian for very minor) topic.

Aloha,
Doug

-- Nothing is impossible if I'mPossible
 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Doug Slattery:
I did something similar to that in a game program I wrote back in the early 80's. I was in high school at the time. Back then, I also developed a recursive routine in assembly before I knew what recursion was. Recently, I wrote an XHTML generator with strict compliance in C using only #define's. I had to do it that way because the function couldn't be prototyped. So yeah, pretty cool stuff.



Early 80's? Damn, I was still actively objecting to my first school day back then

Originally posted by Doug Slattery:
No problem chiming in this late in the game, I notice you recently joined the ranch, so it's in bounds, and welcome to the group too .



Why thank you

Originally posted by Doug Slattery:
Hi R van Vliet,

Are you doing some game development? Dr. Dobbs had an interesting article back in the early 90's on game engines using ray casting.
I originally started the thread because I was trying to justify why my former employer was switching from C to Java for CGI development. My opinion at that time was that Java was slow. From the replies, I can see that it is now a manini (pronounced Mah-Nee-Nee, Hawaiian for very minor) topic.



Funnily enough I have that very issue of Dr. Dobbs somewhere, it was about simple grid raytracing (Wolfenstein 3D style) if memory serves. It's actually only one of 3 issues I have, I was an early teen then and couldn't afford a subscription

I wouldn't consider myself active in game development directly at the moment. I'm dutch and the game dev industry here isn't what I'd call booming. I'm currently tech lead for a project realising a high-concurrency game server for online multiplayer games (based on Java NIO, actually). I also do some mobile game development work.

Other than that I'm just a development masochist with a strange fixation of doing the wrong things in Java. In the past I've implemented a full GameBoy Advance emulator in Java, real-time raytracers and got halfway through a Quake 1 software renderer before I forced myself to do a sanity check. I also have a healthy interest in performance and optimalisation.

Currently I'm looking for a new hobby project, one of the reasons I'm actively browsing some java dev forums and ran into your post
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[R van Vliet:]   I was an early teen then and couldn't afford a subscription

Were you on a 10k dialup, looking for clues from people who will only cite Kenneth C. Louden ?
 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
28.8k actually, but rarely online. Here in holland local calls arent free so a dialup internet connection was quite costly, and with my developing internet addiction I regularly managed to increase my father's blood pressure significantly with rather high phone bills.

I managed to find a single Dr. Dobbs issue just now, it's not the raycasting one but the one where a isometric tile game engine was described. Most likely the reason I bought it.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[R van Vliet:]   28.8k actually, but rarely online. Here in holland local calls arent free so a dialup internet connection was quite costly, and with my developing internet addiction I regularly managed to increase my father's blood pressure significantly with rather high phone bills.

I just got a broadband uplink and have had a commercial server hired for over a year now, much greater read-aheads in a day of terabyte drives not far away and hot-links as up-links. I can remember the day when an OC-1 to the mainland was considered spectacular. Do they wear spectacles in your country when looking at computer screens ?

[R van Vliet:]   I managed to find a single Dr. Dobbs issue just now, it's not the raycasting one but the one where a isometric tile game engine was described. Most likely the reason I bought it.

Huh, explain. DDJ is online and mostly free except for the bloated client-side scripting that is an inevitable consequence of wesite success.
 
R van Vliet
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hehe, consider I am talking about roughly 15 years ago. I bought some random DDJ issues well before I actually had an internet capable PC. In fact, I distinctly remember the first URL I ever entered on my home computer was one to a company selling a debugger, and I got the URL from a DDJ issue

Anyway, we're going well off topic with this I think
 
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Doug Slattery:

The main contenders are C/C++ and Java. Until I get more experienced with Java or am thrown to the lions to learn and use it, I'll stick with C.



This gets to the heart of any serious discussion of performance: what are you trying to optimize?

In practice, its the developers who are the scarce resource, not the cpu cycles. So for 99.44% of the time, you need to focus on getting productive development done. Not focus on the time it takes to execute. This has been true for at least 40 years.

When Java first came out, execution was much slower than well crafted C. Since then, the JVMs have gotten much better at runtime optimizations, and the number of developers who can produce well crafted C has gone down.

Even the old distinction between compiled and interpreted languages has become fuzzy and less important. Java is technically interpreted, but JIT compilers make it more like a compiled language.

Fifteen years ago, Very Long Instruction Word CPUs were the future, with them, you could not write optimized C or assembly, you needed a smart compiler. The main commercial implementation of VLIW is the Itanium, which has not set the world on fire.

I believe (IMHO, YMMV, etc.) that you should write code to get the job done, and then look at the real execution bottlenecks. Fix the slow ones, remeasure, repeat until done.
 
Pat Farrell
Rancher
Posts: 4686
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by S.C Sekar:
Comparing Table Saw and Hand Saw is very different from comparing JEdit and Kate.



Right, if you carry the hand saw up a ladder and saw there, rather than carrying the board down to the table saw, there is no comparison in performance.

I'm not sure that current professional carpenters even use hand saws or hammers, but 20 years ago, a pro with a hand saw was impressively fast.
 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Pat Farrell:
I'm not sure that current professional carpenters even use hand saws or hammers, but 20 years ago, a pro with a hand saw was impressively fast.



That was until virtually all of them was forced to follow the lead of Klien Tools founder as a consequence of social enginerring.

 
Why does your bag say "bombs"? The reason I ask is that my bag says "tiny ads" and it has stuff like this:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!