LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-23-2012, 06:24 PM   #16
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454

Quote:
Originally Posted by ejspeiro View Post
...
I remember in my Java coding times, having the sensation that, even though you couldn't control how pointers behave, it does not mean that Java DOES NOT use them. In fact, to me Java HAS NOTHING ELSE but pointers. Since I recall being able to perform certain assignation and thinking how could I be capable of performing an analog operation in C++? I usually ended up answering something with a lot of dereferencing and castings involved.

Any thoughts? This topic actually reminded me of the Java and pointers topic, which I consider really interesting.
...
I think you are missing the point(er).

When you are doing bare metal programming, you sometimes need to load/store data from/to certain address of computer memory (let's forget for a time being about physical <-> logical memory mapping, and in simple HW there is no mapping). Java can not do it.

I.e. in Java in you can not write the equivalent of this:

Code:
char *ptr = (char *)0x100;
*ptr = (char)0xa5;

"C" code.


Similarly, think how you'd write in Java a device driver.
 
Old 05-23-2012, 06:29 PM   #17
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ejspeiro View Post
... portable devices computing aka limited resources computing. Before, Java was extremely useful for this ...
Even though Java is widely used in portable devices, it's more nonsense than not.

Portable devices have limited energy source; JVM is more often than not less efficient than native code; less efficient means more HW cycles are needed to do the same job, and this means shorter time from battery charge to batter charge.
 
Old 05-23-2012, 09:59 PM   #18
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Originally Posted by Sergei Steshenko View Post
Even though Java is widely used in portable devices, it's more nonsense than not.

Portable devices have limited energy source; JVM is more often than not less efficient than native code; less efficient means more HW cycles are needed to do the same job, and this means shorter time from battery charge to batter charge.
Java still has a big place in enterprise computing. It may not be used as common for small one off developer jobs or for doing certain tasks on your Linux box. But as I said before use the right tool for the job. I currently manage around 60 RedHat servers and more than half of them I manage apps servers such as Tomcat, JBoss, Weblogic, and Jetty. As a servlet container and for business logic Java has many uses.

In fact when you're talking about hosting enterprise apps you're more likely going to be using Java. Oh and never PHP. I work for an educational institution and it's used to process admissions applications, Turbotax during tax season, Term Master Schedule (where students look up their courses for registering), Blackboard/Learn9, and much more that I could go on. When I worked for PJM Interconnection they used it in several places such as their market where power companies buy and sell power from each other. I was programming in C at the time but I had to set up a JMS system for them at some point (Java Messaging Service).

Just because Java may be useless for what you want to accomplish does not mean it is useless as a language or a technology. The fact that it is a JVM (Virtual Machine) means that it's secure and contained from the host OS. That means if the app get's compromised then they only have the database backend and the JVM with which the malicious attacker could do harm (and that's only if the setup is poorly designed). A smarter setup wouldn't even affect the database. If your network service written in C is compromised then you don't have the security of a virtual machine unless you're running it in a VM or the process is chroot jailed. Not sure if it's a misunderstanding of the technology and its uses or what but you seem to have personal a bias against it. I could also have mistaken your statements as you may have just been trying to get certain points across rather than actually having a bias.

As always I like to say use the best tool for the job. If Java is a better choice then I use it. If C is a better choice then I use it. Truly good programmers have a variety of languages at their fingertips in which they can solve their pragmatic problems. It's not uncommon for good a programmer to know 20 or more languages. Once you understand programming concepts and the math it's only a matter of syntax and a few other core concepts unique to the language. So my suggestion to the OP is to learn both if they wish to be versatile.

A note to the OP of this thread.
If the OP doesn't want to learn both and just wants to tackle one language then the OP should take a hard look at where they want their career to go. If they want to develop enterprise apps then I would say Java is more useful. If they want to develop iPhone apps (Objective C and not C per se), do network programming, or the many other genres dominated by C then you wouldn't want to waste your time on Java for that. So it really comes down to your goals and what you wish to get out of the experience.

Also check out SweetHome 3D. That's a real cool application I use to organize the interior of my house which was written in Java (shameless plug for a good open source app).

Last edited by sag47; 05-23-2012 at 10:05 PM.
 
Old 05-24-2012, 04:40 AM   #19
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
When one considers languages to learn, he/she may look at different aspects. For example, at number of available jobs or at what a languages teaches conceptually.

My main point is that C++ is much closer to computing reality than Java. That is, people with in-depth C++ knowledge understand much better real cost (in terms of computing) of things.
 
Old 05-24-2012, 07:55 AM   #20
sag47
Senior Member
 
Registered: Sep 2009
Location: Raleigh, NC
Distribution: Ubuntu, PopOS, Raspbian
Posts: 1,899
Blog Entries: 36

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
I'm not sure what you mean by computing reality and you may have to elaborate on "real cost" in terms of computing. Any Java programmer I've talked to understands how the JVM works and is able to utilize its potential. It usually comes down to getting out pen and paper and solving the problem before writing a line of code. All programmers should do that. I'm not really sure what you're trying to imply. Java programmers are in high demand just like many other programming languages so I don't think any of the points you've made are valid for not considering Java to learn as a language.

The skills of a Java developer are just as marketable as the skills of a C++ developer. Don't get me wrong, I love C and C++ but I'm just trying to say that there's nothing wrong with learning Java either as a first programming language or for professional interest.

Parallel computing is the future of programming (PThreads, OpenMP, MPI in C or java.lang.thread in Java) and will be in much higher demand as microprocessors come out with more cores. Though the OP needs to learn basic programming concepts before they venture into that arena. Single threaded applications aren't able to get as much performance gain with new processors because processing performance is scaling out rather than scaling up (i.e. more cores instead of higher frequency/more pipeline stages).

Last edited by sag47; 05-24-2012 at 08:20 AM.
 
Old 05-24-2012, 01:15 PM   #21
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by sag47 View Post
I'm not sure what you mean by computing reality and you may have to elaborate on "real cost" in terms of computing.
...
Does a Java programmer understand the cost of function call ? Does a Java programmer understand the cost of function return statement ? Does a Java programmer understand benefits and drawbacks of inlined functions ? Does a Java programmer understand how much memory a data structure can occupy ? Which implies understanding what pointer and its size is. Does a Java programmer understand cache-friendliness ? Does Java guarantee continuity of RAM allocated for an array ?
 
Old 05-24-2012, 03:02 PM   #22
aspire1
Member
 
Registered: Dec 2008
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 23
Does every Java programmer? .- probably not.

Does every c/c++ programmer? probably not.

Being part of a specific group does not imply virtue.
 
Old 05-24-2012, 03:08 PM   #23
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by aspire1 View Post
Does every Java programmer? .- probably not.

Does every c/c++ programmer? probably not.

Being part of a specific group does not imply virtue.
And from my experience of talking to C/C++ programmers on one hand and to Java programmers on the other the latter typically have much less clear idea what in reality is happening and how much computationally it costs.

Or, as somebody has already said, they soar in their object-oriented clouds.

Though "Being part of a specific group does not imply virtue" is correct, in practice there is some correlation.
 
Old 05-24-2012, 08:03 PM   #24
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Sergei Steshenko View Post
Does a Java programmer understand the cost of function call ? Does a Java programmer understand the cost of function return statement ? Does a Java programmer understand benefits and drawbacks of inlined functions ?
I don't remember if the Java compiler can inline functions or not (perhaps only if a method is declared final), but certainly the JIT compiler can. JIT will make the cost of all those things much harder to understand.

Quote:
Does a Java programmer understand how much memory a data structure can occupy ? Which implies understanding what pointer and its size is.
On the one hand, data structures can only contain references and primitive types in Java. References are always 32 bits. On the other hand:
Quote:
2.7. Representation of Objects
The Java virtual machine does not mandate any particular internal structure for objects.

http://docs.oracle.com/javase/specs/....html#jvms-2.7
Quote:
Does Java guarantee continuity of RAM allocated for an array ?
I'm fairly certain the answer to this is yes (though I'm unable to find the official answer).
 
Old 05-24-2012, 10:03 PM   #25
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
The word, versus, has almost no practical application in any discussion of computer programming languages. Each one ... every one ... is "a tool for a job." The designers of each system carefully selected among a system of inter-related technical compromises (so to speak...) in order to devise a pragmatic and practical tool. Each tool stands alongside all of its peers ... not against them.
 
Old 05-25-2012, 11:39 AM   #26
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ntubski View Post
...
I'm fairly certain the answer to this is yes (though I'm unable to find the official answer).
AFAIK, the answer is no. And this is funny in the light of the fact that I see, say, FFT implementations in Java.

Among various mathematically equivalent FFT implementations the cache-friendly ones work faster, but how can we speak about cache-friendliness if arrays are not necessarily contiguous in memory ?
 
Old 05-25-2012, 06:51 PM   #27
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Sergei Steshenko View Post
AFAIK, the answer is no. [i.e. arrays need not be contiguous]
Hmm, you might be right about this. I may have been confusing between constant time access and contiguous layout, although I can't even find a statement saying plain array access is constant time! ArrayList.get() is specified to be constant time.

Quote:
Among various mathematically equivalent FFT implementations the cache-friendly ones work faster, but how can we speak about cache-friendliness if arrays are not necessarily contiguous in memory ?
If you are talking about a specific implementation, you can decide to only consider jvms that have contiguous arrays. Are there any that don't have contiguous arrays?
 
Old 05-25-2012, 07:16 PM   #28
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 454Reputation: 454Reputation: 454Reputation: 454Reputation: 454
Quote:
Originally Posted by ntubski View Post
...
If you are talking about a specific implementation, you can decide to only consider jvms that have contiguous arrays. Are there any that don't have contiguous arrays?
My point is that C99/C++ standard prescribes contiguous arrays.

And, if you think about it, without this requirement you won't be able to write, for example, a program loader. I.e. in terms of an OS there are code/data/stack/etc memory areas, so the language you write in absolutely must have a notion of memory the way the OS and the CPU see it.

Likewise, the notion of memory at least allows to think about cache friendliness - not the case with Java.

...

Hopefully, you folks remember that I was talking about real computational cost of things and about computational reality. And, as I said, in this respect C++ beats Java hands down.

...

About dummies/smarties. Of course, generalizations often go wrong. Alas, it's quite often among "Java-only folks" (i.e. among folks who never studied HW/assembly/S/C++) to have great misconceptions about computing reality.

That's why I think if Java is studied after exposure to computing reality/low level/HW, it's OK. But if it is studied before, it is a "disaster". The same applies to other interpreted/"high level" languages, e.g. Perl/PHP/Python/Ruby and the like.

...

ntubski, I learned a lot of interesting things from you in C/C++ area, so are not at all a part of my generalizations .
 
Old 05-25-2012, 11:35 PM   #29
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by Sergei Steshenko View Post
Likewise, the notion of memory at least allows to think about cache friendliness - not the case with Java.
I think you are overestimating the impact of the standard. It's true that if you restrict yourself to pure standard abstract Java language, you can't make any conclusions about cache friendliness. But if you are writing real code, you can think about real implementations.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Java Woes: A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available ... chytraeus Slackware 10 11-27-2010 10:04 AM
Java plugin installed correctly for Firefox but not able to view any java applet tvn Linux - Software 10 04-15-2010 02:13 AM
IN JAVA, how to do a multi chat client in java with the option of private message ? nicolasd Programming 5 09-16-2009 08:53 PM
LXer: Java news met with cautious optimism in free Java community LXer Syndicated Linux News 0 11-14-2006 10:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration