File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Subjective Questions? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Subjective Questions?" Watch "Subjective Questions?" New topic
Author

Subjective Questions?

Gowher Naik
Ranch Hand

Joined: Feb 07, 2005
Posts: 643
1.Garbage collection is platform independent
true or false
2.Thread scheduling algorithms are platform dependent
true or false
Please give me any url which explains examples for Regx
Thanks.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Because these questions are about Java In General I'm moving this topic to our Java In General forum. By the way, we have a Threads forum too.

It would have been better to ask specific questions in relevant forums.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36514
    
  16
Don't know about Regx, nor a lot about regex. But there is a link on the java website here about the memory management and garbage collection mechanism.
Don't know about threads.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

1. Garbage collection is platform independent

The garbage collector is a typical Java feature, it's something that's built-in into the JVM, not something in the native OS that the JVM uses.

2. Thread scheduling algorithms are platform dependent

I'd say that is definitely true, thread scheduling is implented using different algorithms on different operating systems, and Java (normally) just uses the thread scheduling of the underlying operating system.

Please give me any url which explains examples for Regx

If you're asking about regular expressions, look at this part of The Java Tutorial: Lesson: Regular Expressions


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Adam Nace
Ranch Hand

Joined: Jul 17, 2006
Posts: 117
Originally posted by Jesper Young:
1. Garbage collection is platform independent

The garbage collector is a typical Java feature, it's something that's built-in into the JVM, not something in the native OS that the JVM uses.

2. Thread scheduling algorithms are platform dependent

I'd say that is definitely true, thread scheduling is implented using different algorithms on different operating systems, and Java (normally) just uses the thread scheduling of the underlying operating system.

Please give me any url which explains examples for Regx

If you're asking about regular expressions, look at this part of The Java Tutorial: Lesson: Regular Expressions


  • Garbage Collection and Platform Dependency


  • While it is certainly true that garbage collection is a function of the JVM, not the operating system, I do not think one can reasonably say that garbage collection happens the same way on all platforms without evidence to support that it does. One needs to remember that there are more than one implementation of the JVM, and that much of the JVM code is native code. Without supporting evidence, I would not attempt to claim that the garbage collection code DOES not use native code in ANY JVM. Furthermore, while the garbage collection algorithm of the Sun JVM's for each operating system may be essentially the same, we should not forget that Apple controls the JVM for macs, and hence, they could have a slightly (or completely) different garbage collection algorithm.

    In my personal opinion, since I have seen no evidence to indicate that garbage collection is the same on ALL JVM's, it is safer to assume that garbage collection IS platform dependent.
  • About Threads


  • I agree with you on this point. Thread scheduling is platform dependent.
  • About Regular Expressions


  • While the sun tutorial for regular expressions is a good resource, regular expressions are almost a language of their own, which exist well outside of the context of java programming. I would suggest that anybody interested in learning to use regular expressions, even if only in java, should look to a resource that places regular expressions as the domain, rather than as a sub-domain of a given programming language.

    Might I suggest Regular-Expressins.Info as an appropriate authority?
    Also, Wikipedia has some good general info on regular expressions, as well as a number of links to pages on regular expressions.
    Another site, The Regular Expression Library has a neat application that will test Regular Expressions for you, which is handy.

    Also, although PERL is not the originating language of regular expressions, most programmers do regard PERL as the undisputed standard for regular expressions, perhaps because regex's are such an integral part of how PERL works. Consulting any reference on Perl should give you an excellent introduction to regular expressions.



    Anyway, that's how I see things. Hope this helps.

    - Adam
    Steve L. Williams
    Greenhorn

    Joined: May 20, 2006
    Posts: 13
    Garbage collection may and probably does behave differently on different JVM implementations. That does not mean that it is platform dependent. Regardless of what language is used to write it(likely C, which is a platform independant language), GC is not dependant on the underlying OS.

    You can have two different GC implementations on the same OS. It is dependant on the specific JVM not OS.
    Adam Nace
    Ranch Hand

    Joined: Jul 17, 2006
    Posts: 117
    Originally posted by Steve L. Williams:
    Garbage collection may and probably does behave differently on different JVM implementations. That does not mean that it is platform dependent. Regardless of what language is used to write it(likely C, which is a platform independant language), GC is not dependant on the underlying OS.

    You can have two different GC implementations on the same OS. It is dependant on the specific JVM not OS.



    Again, I have to dissagree, and here's why. Since garbage collection is JVM dependent, and the JVM implementation is platform dependent, therefore, garbage collection may also be platform dependent.

    More specifically, since a client of a jvm typically has no knowledge of how the garbage collection is implemented, he/she cannot safely assume that native libraries are not used in the garbage collection process. Since native libraries ARE platform dependent, it is not safe to assume that the garbage collector is platform indepedent.

    If you cannot be certain that there is no platform dependent code in the garbage collector, one should always assume that there could be, and hence should NEVER rely on platform independence of the Garbage Collector in their code.

    Furthermore, since the garbage collector has evolved throughout the many versions of the jvm, one should never assume the same characteristics from the garbage collector EVER. It is generally a bad idea to attempt to manipulate the garbage collection in the first place. Simply attempt to ensure that all element references get nulled or go out of scope when they are no longer needed, and the let the garbage collector do it's job itself.

    Additionally, I think whether garbage collection is Platform dependent or JVM dependent is really a moot point. The point I'm attempting to make applies in BOTH coditions, and that point is, one should not rely on the garbage collector to function the same way on all machines. If one assumes that it always will, and writes code that depends on this, eventually, that code will end up on a machine that will fail.

    - Adam
    Adam Nace
    Ranch Hand

    Joined: Jul 17, 2006
    Posts: 117
    Additionally, I think whether garbage collection is Platform dependent or JVM dependent is really a moot point. The point I'm attempting to make applies in BOTH coditions, and that point is, one should not rely on the garbage collector to function the same way on all machines. If one assumes that it always will, and writes code that depends on this, eventually, that code will end up on a machine that will fail.


    I guess, more to the point, I would say that for all intents and purposes, when writing a java application, I would consider the JVM as part of the host platform, in as far as the JVM has the freedom of defining certainl algorithms, including garbage collection.

    One should typically rely only on what is specified by the Java Language Specification and the Java Virtual Machine Specification. If there is anything that is left open-ended by either, then it should be assumed that this will vary from jvm implementation to jvm implementation, and to my mind, that makes it platform dependent. Perhaps I'm "humpty-dumpty-ing" the term, but I don't think it's that much of a stretch.

    - Adam
    Steve L. Williams
    Greenhorn

    Joined: May 20, 2006
    Posts: 13
    Whether the code itself is native has nothing to do with platform independance. That is just marketing hype from Sun.

    The GC is not dependant on the OS, but the particular JVM. If you want to say each JVM is a platform(reasonable) then yes it is. But it is not dependant on the underlying OS.

    "It is generally a bad idea to attempt to manipulate the garbage collection in the first place."

    Then what does it matter if it is platform dependant. Why would the app running in the JVM care anyway?
    Paul Clapham
    Bartender

    Joined: Oct 14, 2005
    Posts: 18140
        
        8

    Originally posted by Steve L. Williams:
    Then what does it matter if it is platform dependant.
    Yes. The correct answer to the question "Garbage collection is platform independent -- true or false?" is "Who cares?" Such questions just lead to pointless debates about the possible meanings of the term "platform independent".
    Tony Morris
    Ranch Hand

    Joined: Sep 24, 2003
    Posts: 1608
    Originally posted by Paul Clapham:
    Yes. The correct answer to the question "Garbage collection is platform independent -- true or false?" is "Who cares?" Such questions just lead to pointless debates about the possible meanings of the term "platform independent".


    And once you've defined that, enjoy defining "Garbage Collection"


    Tony Morris
    Java Q&A (FAQ, Trivia)
    Steve L. Williams
    Greenhorn

    Joined: May 20, 2006
    Posts: 13
    GC is easy to define in just about any non-ethereal context since it is well implemented, and thus defined, in many languages. The job of the GC is its definition.

    If you subscribe to the notion that things we do and use everyday have no definition, so doesn't exist, then I suppose it would be difficult.
    [ July 20, 2006: Message edited by: Steve L. Williams ]
    Tony Morris
    Ranch Hand

    Joined: Sep 24, 2003
    Posts: 1608
    I've heard more fallacy about garbage collection than not from the Java community. I'm just pre-empting the usual remarks that are far from correct. Still, a topic as broad as "garbage collection" followed by a remark such as "yes it is (or no it isn't) platform dependent" is quite ambitious and bound to carry many holes in it.
    Adam Nace
    Ranch Hand

    Joined: Jul 17, 2006
    Posts: 117
    Originally posted by Steve L. Williams:
    Whether the code itself is native has nothing to do with platform independance. That is just marketing hype from Sun.

    The GC is not dependant on the OS, but the particular JVM. If you want to say each JVM is a platform(reasonable) then yes it is. But it is not dependant on the underlying OS.


    I have to disagree with your first statement, by again stating that the absence of a guarantee of platform independence should be taken as an indication of platform dependence. And I will also indicate why I agree with the "reasonable" qualification in your second statement. I support my case with the following quite from Wikipedia:

    Platform (computing). (2006, June 28). In Wikipedia, The Free Encyclopedia. Retrieved 22:34, July 23, 2006, from http://en.wikipedia.org/w/index.php?title=Platform_%28computing%29&oldid=61080709.
    In computing, a platform describes some sort of framework, either in hardware or software, which allows software to run. Typical platforms include a computer's architecture, operating system, or programming languages and their runtime libraries.


    Although wikipedia articles are generally written by community members, and not necessarily qualified members, they do undergo editing and review processes, and I believe this article should make my point clear. The original poster DID ask about "platform dependence." "Platform", while similar, is not necessarily synonymous with "Operating System." The Platform is the entire set of libraries used to perform a process (see "runtime libraries in the definition provided"), and hence, where different libraries may be used by different jvms, this implies difference of platform, regardless of the similarity of the operating system. When it comes down to it, when we ask if something is platform dependent, what we are really interested in is, "Will the class perform the same on ALL (conforming) jvms?" At least, I cannot think of any time when it would matter to me if a process was different on a mac as it is on Windows, but that I really wouldn't care if it was different on two different jvms on windows. Can any of you? Clearly, in this case, platform dependence is essentially synonymous with jvm dependence.

    Originally posted by Steve L. Williams:
    "It is generally a bad idea to attempt to manipulate the garbage collection in the first place."

    Then what does it matter if it is platform dependant. Why would the app running in the JVM care anyway?


    Point taken. But then, I never really missed that point in the first place. Either the original poster is going to take my advice about not messing with the garbage collector or he's not. If he chooses to continue, then I think it's important that he realizes that the garbage collector will not necessarily work the same way in all jvms.

    - Adam
     
    Don't get me started about those stupid light bulbs.
     
    subject: Subjective Questions?
     
    Similar Threads
    only static methods can access static members
    Double doubt
    Short Circuit AND
    You can directly run the GC whenever you want to ?????
    Garbage collection