The Java String object is always immutable, so what do you mean by "mutable String objects"?
Typo. Meant "immutable".
I've parsed files as large as 1 GB, one line at a time (each was a separate immutable string, then split into several substrings). And it was fast enough that the hard drive was the bottleneck.
Using char arrays rather than immutable Strings lead to a 50-75% performance improvement for me. That means the harddrive is not the bottleneck. Regular expression parsing requires complex operations to be performed on each character. Getting each line with a LineNumberReader and then calling charAt() for each character was incredibly inefficient.
Depending on your JVM, you may need to tune the memory parameters. Sun's JVM has a low memory limit by default, I usually increase this to at least 500 MB.
Ha! If they only gave us machines that had so much memory. Yes, I did increase the JVM memory limit. But that was a bandaid. It didn't solve the problem. If a problem would take 30MB in C++, it shouldn't take 90MB in Java. Once it got to 90MB I started rethinking my code, because 90MB was too much for the task I was performing.
i agree... "well, I could make it better and more efficient by doing stuff, but I shouldn't really have to, so that means that it's not right"...what crap.
I know I'm being trolled here, but both of you are the ones full of shit. You could implement your call stack with a static array, and forgo the use of objects altogether. This would make your program fast, but it would make programming Java even worse than programming C++, probably even assembly. This is what I was talking about.
You could also tweak the GC and force it into higher priority when the task demands, which would be a somewhat simpler solution, but still flawed. Why is it flawed? It takes CPU to do reference counting and figure out that an object is eligible for deletion. Boom, performance hit. It takes a separate thread to be able to queue and do GC in lower priority. Another performance hit, though in some cases it distributes the task more efficiently. And another. Not only do you have to check eligible objects for deletion, you also have to check ineligible objects. You wouldn't have to check if you didn't already know. In C++, the runtime knows because you tell it. In Java, it has to be figured out by the runtime itself. This wastes more CPU.
Ok, so it's less efficient. But I shouldn't have to know this. I shouldn't have to worry about all this. The fundamental design of Java is to get rid of the complexity of C++. But it fails, because I have to know all these things to get applications of moderate complexity to work correctly. When performance is an issue, I have to put much more thought and effort into programming Java than I do C++. It wasn't supposed to be that way. So when you propose a solution that requires more effort or complexity than C++, it's automatically wrong, because it means that Java has failed as a language.
Well I wasn't going to reply, since I think I've said everything in my other posts. But since it got moderated up...
I've used Java on embedded applications, on systems that create lots, and lots of objects. And I don't recall ever running out of memory, if there wasn't a bug in the Java program.
There is a difference between using up all your memory and running out of memory. Java maxes out the memory that it's allowed to take in the circumstances I was talking about.
Suppose you have a tight loop that creates a few objects and then disposes of them. Further suppose that loop spikes the CPU, as would be the case for something under constant load or with a lot of data to process. Then you will be creating objects faster than the GC can get rid of them, because the GC is a lower priority than your main thread, which is doing the important stuff. GC is, by its nature, a lower priority task.
But sometimes it just needs to be higher priority. In the above case, the program will take up all the memory it's allowed. As you suggested elsewhere, you could simply not allow it to take up that much memory. But there might be valid cases where it needs that much memory. In these cases, virtual memory is the sad reality, but correct action is better than no action. However, you do not want all your cases to be this degenerate. So you are forced to decide between simple failure when much memory is needed, or maxing out a large portion of memory in all cases. I shouldn't have to make that choice.
As others have suggested, I could tweak the GC to deallocate faster. But this is a flaw. Java should make things simpler, not more difficult. Telling the computer when I'm done with an object is a simpler solution (to me, anyway) than having to tweak runtime parameters.
Personally, I wouldn't trust the average programmer to even collect garbage correctly more than half the time
If I couldn't trust someone to use new and delete correctly, I wouldn't trust them to do much at all for me. Yes, there are many programmers that mess things up with these operators, but they aren't very good programmers. If you can't use new and delete or free and malloc correctly, then there's probably a lot of other things you can't do well either. Memory management is rather fundamental to computer science.
Now, the transparent memory access in C++ is certainly dangerous. But I'm not talking about direct access to memory. I'm talking about garbage collection on demand.
For example, I do not see how things would become much more dangerous in Java if you added a delete operator to complement the new operator. The operator would have the semantics that meant "delete, now". If you tried to access a deleted object, it would throw an exception. The level of danger afforded by such a feature would be vastly outweighed by the advantages wrought.
If it starts to do this, you can usually change the JVM settings to restrict the initial memory the JVM has. That way it will only grow if it really needs to.
This isn't a valid solution because sometimes your program might actually need that much memory. So you have to enable it to grow that large. But you don't want it to always grow that large. You end up with a JVM that always takes up as much memory as it can.
As someone else pointed out, I could possibly tweak the GC settings. But this is all moot, because Java is supposed to make things easier, not harder. I should be able to tell the GC that I am done with an object right here and now, rather than waiting for the low priority GC thread to take too long to pick it up.
Yeah, but that won't cause you to crash on any JVM I've ever used. What happens is it carries on allocating until it hits the limit and then starts GCing...
Maybe I wasn't explicit. But I was talking about using up all the memory, not crashing. So the behavior you described is exactly what happened. But once you hit near 90% of your physical memory, the operating system will start pushing all sorts of things out to virtual memory, causing everything, including your application, to slow down. And when your CPU is spiked by an inner processing loop, the garbage collector which probably runs at a lower thread priority will not be given enough CPU to clear out memory fast enough.
I tried learning Java years ago precisely because of the powerful marketing SUN put behind it, but this is the first I heard about garbage collection being untrustworthy - can you elaborate?
I was talking from anecdotal experience. Which while my experience is significant, it shouldn't be a substitute for actual benchmarks and cold hard analysis of the underlying algorithms.
Question: if a person writes only portable code in C/C++ to begin with, and if Java garbage collection isn't all it's cracked up to be, does that mean Java has no real advantages over C/C++?
Java is much more concise, and that is a huge plus. I mean, you don't program everything in assembly, sheffer strokes, or (godforbid) Turing machines. But each of these is at least as expressive as both C++ and Java. You use Java to make your life easier. A good example of this is the Serialization interface in Java. You can just serialize an object and send it over a socket, then read it on the other side. You can't do this with C++. You could do a shallow copy easy enough, but Java will automate the deep copy for you.
There are many other things, such as Reflection. This is very useful and allows for abstraction at a level that C++ is fundamentally unable to achieve. So yes, there are many reasons to use Java, but portability is near the bottom of the list.
Setting references to null in Java is not what I would expect from a professional programmer.
Well, it shouldn't be necessary. But somewhere I read that it would help the garbage collector realize that the object referenced was no longer needed, so I tried it out. When it made no difference, I changed it back. In my pooling class I ended up having to use freaky things like weak and soft references, however.
If you really think it is a GC bug, try creating a simple test case that demonstrates it. Java has plenty of bugs, but in my experience, trying to construct a simple test case for submission to Bug Parade will often demonstrate that you didn't really understand the problem.
I'm not complaining about the implementation so much as the architecture. My project was a small part of a massive server application port from C++ to Java. C++ did not have any of these problems, but Java did. Someone else may have fubarred the application, but that's a moot point. Java is supposed to make things easier, not harder. The whole point of a garbage collector is that I don't have to understand what's going on under the hood. But the way the language works, I have to understand it in much more detail than I have to understand the relatively simple free() and malloc() of C. I can't tell the JVM when I'm done with an object, so I have to give it hints, or arrange it so my backlog of garbage doesn't get so big, or simply avoid allocation altogether.
Whats wrong with using up all your FREE memory, it isn't doing anything else.
What you lose by taking up free memory is the potential for needed operations. For example, your JVM won't know that your browser needs more memory to allocate that huge PDF. Ideally, it should realize that your waiting for memory and start getting agressive about garbage collecting. But it doesn't know this. Instead, the operating system starts swapping stuff out to disk, making everything slow.
...tune your garbage collection
I really shouldn't have to. I don't have to in C/C++ or (godforbid) VB. But even if I did, there would still be problems. On an inner loop I can't use any value objects since they get allocated on the heap rather than the stack. Stack allocation is O(1), heap allocation is O(N). With an inner loop, this O(N) turns into O(N^2), and so on, while the stack allocation stays at O(1).
I run a *very* complex monte carlo simulation in java, these problems don't exsist for me when acting on THOUSANDS of funds.
I don't doubt that Java can be made to be efficient. But you simple can't go in programming it with the same assumptions that you would with other languages. The garbage collector was supposed to make things easier. It made some things easy, but it made many other things harder.
This is flat out wrong, what is "heavy processing", please describe what causes your machines to run out of memory?
This is simple. Here are some examples I worked on:
A tax adapter that did operations for each order. Setting a load tester against the server caused the machine to max out on memory. So I eventually had to create my own pool of objects to stop them from getting touched by the garbage collector.
Text parsing/processing that operates on each line of many megabyte files. When done with mutable String objects, it kept increasing memory as a function of time, never reducing the memory load. It's not like I kept references to these objects. I had to reprogram it to not keep allocating objects for each line.
I'm sure others have their own examples to contribute.
I've programmed in Java before, and love it as a language. Unfortunately, even in the newer iterations of the JVM, you simply cannot trust the virtual machine to get rid of objects efficiently. If you are doing some heavy processing, you simply will exhaust all memory on your machine, even if you explicitly set references to null.
If there is an "inner loop" of your application that needs performance above all else, and you need to program it in Java for whatever reason, there are two things you should get rid of:
Memory allocations
Function calls
Of course, if you can do this in C/C++, it will also improve performance, but it is not as critical to be so careful in these lower level languages.
I've just found that you can't trust the garbage collector, no matter how good people say it is. People have been saying it's great since the beginning of Java, and now they say, "It wasn't good before, but it is now." And they'll be saying the same thing in 3 more years. No matter what, the opportunistic garbage collection of C/C++ simply leads to better performance than any language that tries to do the garbage collection for you.
umm... what about people that work 10-12 hours a day without even seeing a computer? i used to work 12 hour shifts in a factory... my girlfriends dad is currently in suadi arabia... rhiad.. fixing printing machines... no electricity half the time... up to his ears in suicide bombers... "ohh poor me... i must have acces to my email while at work..." bollocks... you just don't wan't people looking round your work pc cos it's full of kiddie porn.
Nice strawman there. There are laws that make it illegal for companies to tap your phone calls. Why should it be any different for your use of the computer? The days that the data on the computer was the sole province of the company was when it really was all work related. But now the computer is also a communications tool. So what if I have some funny lump on my crotch that I'm not sure is normal or VD? And I browse the web looking for answers. Really, is that anyone's business but my own?
Of course, I could do such browsing at home. But many things don't make sense to always do at home. If I need to schedule a meeting with a doctor, I'd have to call during the doctor's office hours, which are also my work hours. If I emailed information to my doctor rather than calling him up and telling him, why does this information suddenly become less priviledged?
Your company does not own you. Even if you don't use a computer at work, you still have some expectation of privacy. The company cannot go rifling through your wallet or purse, yet much of the stuff on the computer is even more personal than this.
Really, is it that hard to imagine situations where it would be valid to use the computer at work for personal reasons? What if I suffer from panic attacks, and need to schedule an appointment during office hours (again). I obviously don't want to say over the phone at work, "Yeah, I need to schedule an appointment with the psychiatrist." Doing something like having my partner arrange the appointment, and email me the time to show up, is a much better solution.
I could get around this too, but really, the bottom line is that no company owns my sole, even for eight hours a day. When we enter work we do not become property of the company. What could possibly be your justification for thinking otherwise? That someone said, "Anything that happens at work is the business of the company."? Does someone saying it make it true?
Or you might be convinced by the law. But just because companies have successfully lobbied for laws granting sweeping rights into invading our privacy by no means makes it correct. There are many instances throughout history where laws are incorrect, even in our own country. So it has to be something else. So what is it?
Finally, here's a little exercise for you. Tell me who you are. Tell me where you live. Tell me when you masturbate, and how often. Tell me what the stupidest thing you ever said was. Tell me your grades on every assignment you've taken. Tell me your personal medical history, including all the embarrassing ailments you've ever had. Tell me about all the "black sheep" in your family, such as the uncle who cheated on his wife, or worse, someone arrested for doing something stupid.
If you feel in any way hesitant to comply with any of these requests, then you have a sense of privacy. If you feel that the company you work for would be stepping over the line by asking for any of this information, then you believe that we have a right to keep information from companies we work for. And as society demands that we work more and more to maintain sustenance, and as communication tools put us in touch at any moment and any place, you have a fundamental contradiction in your beliefs. Unless, of course, you deny that we should work at any job with these communication tools present.
Yes, I read the acticle. And just because rifling through all the data is easy to do, and might yield useful information, is not a reason to do it. Take a plumber who is rifling through your personal receipts. He wants to see how the person who worked on the toilet before him tried to fix it. Is this useful information? Yes. Does it justify going through personal documents? No.
And just because a company can look at all your personal stuff on a company computer, doesn't mean that they should. I work many hours a day--I'm at work practically all my free time. To ask me to have no personal information on any work computers is basically asking me not to have a personal life. But this is too much to ask.
Other people have dealt within this discussion the justification of actually looking digging deep into his personal folders. Rather than reiterating their points, you can consult them yourselves.
No HR is NOT the proper channel, a FELONY was commited, the only proper channel is the police.
You bring up a good point. But this goes both ways. It's not these people's jobs to execute search warrants--it's the job of the police. But by clicking on random folders that's exactly what they were doing.
Of course, there will always be some small benefit obtained by doing this, but this in no way justifies the action. Say a plumber comes to your house to fix the toilet, and after getting the mail, you come back to find him rifling through your personal papers. He says, "I think whoever tried to fix this before botched the job, I wanted to find the receipt to see exactly what he did." Does he have a valid reason for needing this information? Yes. Does that justify his actions? Not in any way.
The computer stores much personal information, even at work. Asking someone (like me) who works 10-12 hours a day not to have any personal information on a work computer is asking them not to have a personal life. Even eight hours a day is a long time. As such, there should be an expectation of privacy when dealing with people's PCs. Note what the acronym PC stands for: "personal computer". There's a reason it has that name.
That's exactly what the filmmakers who make that sick crap want you to think. They don't want you to ask little Suzzie why she comes into school crying, and they dont' want her to tell you why either.
While it is indeed noble to stop this immoral activity that happens in secret, we have to weigh this against the alternatives. And while you may think that stopping child porn is more important than anything else in the world, it isn't. What's more important? Life, for one. Freedom, for two. Privacy, for three. Now, any of these in their absolute will have negative consequences. Must you perserve the life of someone who is shooting at you? Must you preserve the freedom of one who takes it away from others (i.e., a kidnapper)? Must we protect the privacy of those that we already know to have done many illegal things in secret? The answer to all of these is "No". So there are limits on these things.
But in this case it's different. The way you pose it, there is a dilemma between two choices:
Strong privacy and a clandestine culture of child pornography.
No privacy and the eradication of child pornography.
Maybe in your world (1) is better, but I definitely prefer (2). Total loss of privacy is not something I'd sacrifice to stop child pornography, as noble as its eradication would be.
Maybe I'm attacking a straw man, but I don't think so. You speak as though any invasion of privacy is justified if it discovers something like child porn. But this is only known after the fact. So there are two choices: (a) snooping without discovery of child porn, or (b) snooping with discovery of child porn. The actor who snoops cannot know whether they are facing (a) or (b). And what they cannot know they cannot act on. And what they cannot act on they cannot be held morally responsible for--ought implies can. So by moral theory, these actions are by necessity equivalent. And, if in your mind, (b) is justified, then (a) must also be justified.
But (a) is not justified. No one has a right to invade my privacy without any reason to suspect me of wrong-doing. And if you think about it, you should come to the same conclusion.
Now the story makes it seem like their discovery was innocuous enough. But how many times do computer repair people snoop around where they should not? Yes, the person had vile, disgusting, and illegal content on his computer. But why did the repair person find this material? If I send a computer in for repair, I am not giving access for someone to look through all my personal shit.
It's as if I left my diary in a car that was in the shop, and all the mechanics started reading it. Except for computers, this is the norm rather than the exception. I don't want someone going through all my personal shit.
So the people that fired them made the right decision. The word is now out that giving your computer to these people will hold all your personal data up to scrutiny by complete strangers. So what if your wife picks it up, and they tell her about the (legal) porn hidden in an innocuous sounding directory? Or maybe they'll read about the financial plans of your company, because some important documents were on the PC?
The truth is that people doing repairs should make every attempt not to view even a smidgen of personal data on the PCs they repair. So this article makes their discovery sound like they couldn't help it. But why were they clicking around in random directories? Simply wondering, "Hmm, what's in this directory," is not nearly a good enough reason. A repairperson should know what directories are relevant to fixing the computer and which are not.
Now, of course, all of this is null and void if there was some telling "C:\ChildPorn" directory on the computer. But barring such obvious dumbassedness on the part of the person giving the computer for repair, the repair-persons' actions were clearly unethical, even if, in the end, they discovered another unethical action. Two wrongs don't make a right, remember.
"But there is a logical proof that there is no logical proof of God's existence."
Where? I am genuinely interested.
To say that God follows from logic means that the denial of God's existence is literally a contradiction. It seems implausible that the denial of God's existence can itself be a contradiction, but let's go a little further. Let's take some attribute of God that actually has an impact on our world, such as the parting of the Red Sea. To say that the denial of this miracle is literally a contradiction is to insult both religion and logic. We can repeat the procedure for pretty much any interesting thing that God does.
Now, let's look at the link you provided. In fact, let's just assume that the conclusion has been adequately proved:
Therefore, there exists a unique, non-causal or self-caused, universal cause G, which is the result of P1+P2+P3. Let's call this phenomenon God.
Ok, let's call this thing "God". Does this "God" answer our prayers, love us, punish the wicked, or direct our morality? We can't say. A "unique, non-causal or self-caused, universal cause G" whatever that means is unlikely to do or be anything meaningful. Why can't it be the universe itself?
In any case, I don't have time to go through the whole proof, but most logical proofs of "God" start from the possibility of God's existence and derive the necessity of God's existence. But the real controversy is the possibility of God's existence. Most people would grant that "God is possible". But if you say your notion of possibility means that possibility implies necessity for a necessary being such as God, then they will deny that God is possible, because what they meant by possible was different than what you meant. In any case, the possibility of God's existence is deniable, and thus does not follow from logic itself. For such "proofs" my original assertion remains.
Logical Positivists, with their verificationalist doctrine, deny metaphysics, but not all anti-realists are logical positivists.
Fair enough, but the main point still remains. Denying that philosophy has any importance is itself an interesting and controversial philosophical doctrine.
And proving that there can be no proof of a God that performs meaningful actions is infinitely more difficult than you claim. Especially when you do not define God.
Not only is it difficult, it's impossible. There can be no logical proof of God's existence, and there can be no logical proof of God's non-existence. In addition, there can be no logical proof that there is no proof of God's existence. But there is a logical proof that there is no logical proof of God's existence.
What I mean by "logical" proof is just that that can be derived from logic. God does not follow from logic itself. But as someone else pointed out, God might follow from something else, such as morality, as Kant thought.
The brain-in-a-vat theory is untestable and unfalsifiable and is hence meaningless philisophical masturbation...
The entire point of the brain-in-a-vat scenario is that it is untestable and unfalsifiable. Where you call it "meaningless" you would have a friend with the anti-realists. Anti-realists basically deny metaphysics, which is a pillar of philosophical discussion. When you say that anything unfalsifiable and untestable is "meaningless", you are also denying metaphysics. You are denying that there is an "ultimate reality". And this is not without controversy. So dismissing this discussion is to claim some very interesting and controversial theses.
So try as you might to avoid philosophy, you can't. Philosophy is inherent in our thought, in our actions, in our way of life. Many people never formalize their thought processes enough to even consider things like "the matrix". That's what makes this movie so novel to so many people.
What's depressing is that so many people seem to think the crap that was in The Matrix consisted of Important Questions About Existence(TM).
I don't understand. Isn't something like "the matrix", or "a brain in a vat" exactly the type of idea we want to consider when trying to determine what the ultimate nature of reality is?
Let's consider a simulated environment so good that we could not determine it was simulated. How then could we call it simulated? We would have no evidence of it being simulated, and so all of empiricism would have us call it "real"? But in this hypothetical example what is, by all available evidence, called "real" is not real. And our means of obtaining knowledge cannot allow us to answer this question. So is there even a distinction to be made between the simulation that is experienced "as real" and what "really" is?
The distinction is false, and leads us into the mysterious realm of anti-realism. You should read a few proponents of the subject, such as Hilary Putnam and Michael Dummett, before you disparage it. Not saying these philosophers would enthusiastically embrace the movie "The Matrix", but the type of hypotheticals considered in the movie are critical to, say, Hilary Putnam's anti-realism.
I think the shallowness of the philosophy in the Matrix makes it so that you can safely say "the Matrix has no philosophical content". It can spark a philosophical discussion, but so can my three-year-old.
Does The Matrix make cogent philosophical arguments? No. But I'd say it's ability to "provoke" discussion is a little better than your three-year-old. Things such as The Matrix exist primarily as philosophical ideas, whereas your three-year-old has a lot more going for him/her than being a subject of philosophical discussion.
Decartes' Meditations... read what you're replying to. It's useful.
Logic is destructive, not constructive. It leads us from contradiction, but lends us no positive conclusions. Nothing that is not a tautology follows from logic. Is God a tautology? Not any "God" that does any meaningful actions. So there can be no logical proof of God's existence.
I have a feeling that most people who enjoyed The Matrix won't be able to handle lofty philosophical concepts
That's not exactly fair. I enjoyed the movie quite a bit and have a firm grasp on the fundamentals of most philosophical subjects, which includes a degree in the field. The Matrix is a scenario that is impractical to implement but nevertheless a rich source of discussion in philosophy. Of course, it's been done before. The 'Brothers are by no means the first to think of the idea. Way before them was the idea of a "brain in a vat" that would live a simulated existence. The possibility of such a brain leads us to question what we can call real. Is our entire life just simulated? Would we be able to tell? Does it even matter? These are important questions. You are being too dismissive to just say that the Matrix has no philosophical content. It might not have any new philosophical content, but that does not leave it stripped of anything worthy of discussion.
Using char arrays rather than immutable Strings lead to a 50-75% performance improvement for me. That means the harddrive is not the bottleneck. Regular expression parsing requires complex operations to be performed on each character. Getting each line with a LineNumberReader and then calling charAt() for each character was incredibly inefficient.
Ha! If they only gave us machines that had so much memory. Yes, I did increase the JVM memory limit. But that was a bandaid. It didn't solve the problem. If a problem would take 30MB in C++, it shouldn't take 90MB in Java. Once it got to 90MB I started rethinking my code, because 90MB was too much for the task I was performing.
You could also tweak the GC and force it into higher priority when the task demands, which would be a somewhat simpler solution, but still flawed. Why is it flawed? It takes CPU to do reference counting and figure out that an object is eligible for deletion. Boom, performance hit. It takes a separate thread to be able to queue and do GC in lower priority. Another performance hit, though in some cases it distributes the task more efficiently. And another. Not only do you have to check eligible objects for deletion, you also have to check ineligible objects. You wouldn't have to check if you didn't already know. In C++, the runtime knows because you tell it. In Java, it has to be figured out by the runtime itself. This wastes more CPU.
Ok, so it's less efficient. But I shouldn't have to know this. I shouldn't have to worry about all this. The fundamental design of Java is to get rid of the complexity of C++. But it fails, because I have to know all these things to get applications of moderate complexity to work correctly. When performance is an issue, I have to put much more thought and effort into programming Java than I do C++. It wasn't supposed to be that way. So when you propose a solution that requires more effort or complexity than C++, it's automatically wrong, because it means that Java has failed as a language.
There is a difference between using up all your memory and running out of memory. Java maxes out the memory that it's allowed to take in the circumstances I was talking about.
Suppose you have a tight loop that creates a few objects and then disposes of them. Further suppose that loop spikes the CPU, as would be the case for something under constant load or with a lot of data to process. Then you will be creating objects faster than the GC can get rid of them, because the GC is a lower priority than your main thread, which is doing the important stuff. GC is, by its nature, a lower priority task.
But sometimes it just needs to be higher priority. In the above case, the program will take up all the memory it's allowed. As you suggested elsewhere, you could simply not allow it to take up that much memory. But there might be valid cases where it needs that much memory. In these cases, virtual memory is the sad reality, but correct action is better than no action. However, you do not want all your cases to be this degenerate. So you are forced to decide between simple failure when much memory is needed, or maxing out a large portion of memory in all cases. I shouldn't have to make that choice.
As others have suggested, I could tweak the GC to deallocate faster. But this is a flaw. Java should make things simpler, not more difficult. Telling the computer when I'm done with an object is a simpler solution (to me, anyway) than having to tweak runtime parameters.
If I couldn't trust someone to use new and delete correctly, I wouldn't trust them to do much at all for me. Yes, there are many programmers that mess things up with these operators, but they aren't very good programmers. If you can't use new and delete or free and malloc correctly, then there's probably a lot of other things you can't do well either. Memory management is rather fundamental to computer science.
Now, the transparent memory access in C++ is certainly dangerous. But I'm not talking about direct access to memory. I'm talking about garbage collection on demand.
For example, I do not see how things would become much more dangerous in Java if you added a delete operator to complement the new operator. The operator would have the semantics that meant "delete, now". If you tried to access a deleted object, it would throw an exception. The level of danger afforded by such a feature would be vastly outweighed by the advantages wrought.
As someone else pointed out, I could possibly tweak the GC settings. But this is all moot, because Java is supposed to make things easier, not harder. I should be able to tell the GC that I am done with an object right here and now, rather than waiting for the low priority GC thread to take too long to pick it up.
Java is much more concise, and that is a huge plus. I mean, you don't program everything in assembly, sheffer strokes, or (godforbid) Turing machines. But each of these is at least as expressive as both C++ and Java. You use Java to make your life easier. A good example of this is the Serialization interface in Java. You can just serialize an object and send it over a socket, then read it on the other side. You can't do this with C++. You could do a shallow copy easy enough, but Java will automate the deep copy for you.
There are many other things, such as Reflection. This is very useful and allows for abstraction at a level that C++ is fundamentally unable to achieve. So yes, there are many reasons to use Java, but portability is near the bottom of the list.
Yeah, that's pretty much what I was talking about.
I really shouldn't have to. I don't have to in C/C++ or (godforbid) VB. But even if I did, there would still be problems. On an inner loop I can't use any value objects since they get allocated on the heap rather than the stack. Stack allocation is O(1), heap allocation is O(N). With an inner loop, this O(N) turns into O(N^2), and so on, while the stack allocation stays at O(1).
I don't doubt that Java can be made to be efficient. But you simple can't go in programming it with the same assumptions that you would with other languages. The garbage collector was supposed to make things easier. It made some things easy, but it made many other things harder.
- A tax adapter that did operations for each order. Setting a load tester against the server caused the machine to max out on memory. So I eventually had to create my own pool of objects to stop them from getting touched by the garbage collector.
- Text parsing/processing that operates on each line of many megabyte files. When done with mutable String objects, it kept increasing memory as a function of time, never reducing the memory load. It's not like I kept references to these objects. I had to reprogram it to not keep allocating objects for each line.
I'm sure others have their own examples to contribute.If there is an "inner loop" of your application that needs performance above all else, and you need to program it in Java for whatever reason, there are two things you should get rid of:
- Memory allocations
- Function calls
Of course, if you can do this in C/C++, it will also improve performance, but it is not as critical to be so careful in these lower level languages.I've just found that you can't trust the garbage collector, no matter how good people say it is. People have been saying it's great since the beginning of Java, and now they say, "It wasn't good before, but it is now." And they'll be saying the same thing in 3 more years. No matter what, the opportunistic garbage collection of C/C++ simply leads to better performance than any language that tries to do the garbage collection for you.
Of course, I could do such browsing at home. But many things don't make sense to always do at home. If I need to schedule a meeting with a doctor, I'd have to call during the doctor's office hours, which are also my work hours. If I emailed information to my doctor rather than calling him up and telling him, why does this information suddenly become less priviledged?
Your company does not own you. Even if you don't use a computer at work, you still have some expectation of privacy. The company cannot go rifling through your wallet or purse, yet much of the stuff on the computer is even more personal than this.
Really, is it that hard to imagine situations where it would be valid to use the computer at work for personal reasons? What if I suffer from panic attacks, and need to schedule an appointment during office hours (again). I obviously don't want to say over the phone at work, "Yeah, I need to schedule an appointment with the psychiatrist." Doing something like having my partner arrange the appointment, and email me the time to show up, is a much better solution.
I could get around this too, but really, the bottom line is that no company owns my sole, even for eight hours a day. When we enter work we do not become property of the company. What could possibly be your justification for thinking otherwise? That someone said, "Anything that happens at work is the business of the company."? Does someone saying it make it true?
Or you might be convinced by the law. But just because companies have successfully lobbied for laws granting sweeping rights into invading our privacy by no means makes it correct. There are many instances throughout history where laws are incorrect, even in our own country. So it has to be something else. So what is it?
Finally, here's a little exercise for you. Tell me who you are. Tell me where you live. Tell me when you masturbate, and how often. Tell me what the stupidest thing you ever said was. Tell me your grades on every assignment you've taken. Tell me your personal medical history, including all the embarrassing ailments you've ever had. Tell me about all the "black sheep" in your family, such as the uncle who cheated on his wife, or worse, someone arrested for doing something stupid.
If you feel in any way hesitant to comply with any of these requests, then you have a sense of privacy. If you feel that the company you work for would be stepping over the line by asking for any of this information, then you believe that we have a right to keep information from companies we work for. And as society demands that we work more and more to maintain sustenance, and as communication tools put us in touch at any moment and any place, you have a fundamental contradiction in your beliefs. Unless, of course, you deny that we should work at any job with these communication tools present.
Yes, I read the acticle. And just because rifling through all the data is easy to do, and might yield useful information, is not a reason to do it. Take a plumber who is rifling through your personal receipts. He wants to see how the person who worked on the toilet before him tried to fix it. Is this useful information? Yes. Does it justify going through personal documents? No.
And just because a company can look at all your personal stuff on a company computer, doesn't mean that they should. I work many hours a day--I'm at work practically all my free time. To ask me to have no personal information on any work computers is basically asking me not to have a personal life. But this is too much to ask.
Other people have dealt within this discussion the justification of actually looking digging deep into his personal folders. Rather than reiterating their points, you can consult them yourselves.
Of course, there will always be some small benefit obtained by doing this, but this in no way justifies the action. Say a plumber comes to your house to fix the toilet, and after getting the mail, you come back to find him rifling through your personal papers. He says, "I think whoever tried to fix this before botched the job, I wanted to find the receipt to see exactly what he did." Does he have a valid reason for needing this information? Yes. Does that justify his actions? Not in any way.
The computer stores much personal information, even at work. Asking someone (like me) who works 10-12 hours a day not to have any personal information on a work computer is asking them not to have a personal life. Even eight hours a day is a long time. As such, there should be an expectation of privacy when dealing with people's PCs. Note what the acronym PC stands for: "personal computer". There's a reason it has that name.
But in this case it's different. The way you pose it, there is a dilemma between two choices:
Maybe in your world (1) is better, but I definitely prefer (2). Total loss of privacy is not something I'd sacrifice to stop child pornography, as noble as its eradication would be.
Maybe I'm attacking a straw man, but I don't think so. You speak as though any invasion of privacy is justified if it discovers something like child porn. But this is only known after the fact. So there are two choices: (a) snooping without discovery of child porn, or (b) snooping with discovery of child porn. The actor who snoops cannot know whether they are facing (a) or (b). And what they cannot know they cannot act on. And what they cannot act on they cannot be held morally responsible for--ought implies can. So by moral theory, these actions are by necessity equivalent. And, if in your mind, (b) is justified, then (a) must also be justified.
But (a) is not justified. No one has a right to invade my privacy without any reason to suspect me of wrong-doing. And if you think about it, you should come to the same conclusion.
Now the story makes it seem like their discovery was innocuous enough. But how many times do computer repair people snoop around where they should not? Yes, the person had vile, disgusting, and illegal content on his computer. But why did the repair person find this material? If I send a computer in for repair, I am not giving access for someone to look through all my personal shit.
It's as if I left my diary in a car that was in the shop, and all the mechanics started reading it. Except for computers, this is the norm rather than the exception. I don't want someone going through all my personal shit.
So the people that fired them made the right decision. The word is now out that giving your computer to these people will hold all your personal data up to scrutiny by complete strangers. So what if your wife picks it up, and they tell her about the (legal) porn hidden in an innocuous sounding directory? Or maybe they'll read about the financial plans of your company, because some important documents were on the PC?
The truth is that people doing repairs should make every attempt not to view even a smidgen of personal data on the PCs they repair. So this article makes their discovery sound like they couldn't help it. But why were they clicking around in random directories? Simply wondering, "Hmm, what's in this directory," is not nearly a good enough reason. A repairperson should know what directories are relevant to fixing the computer and which are not.
Now, of course, all of this is null and void if there was some telling "C:\ChildPorn" directory on the computer. But barring such obvious dumbassedness on the part of the person giving the computer for repair, the repair-persons' actions were clearly unethical, even if, in the end, they discovered another unethical action. Two wrongs don't make a right, remember.
Now, let's look at the link you provided. In fact, let's just assume that the conclusion has been adequately proved:Ok, let's call this thing "God". Does this "God" answer our prayers, love us, punish the wicked, or direct our morality? We can't say. A "unique, non-causal or self-caused, universal cause G" whatever that means is unlikely to do or be anything meaningful. Why can't it be the universe itself?
In any case, I don't have time to go through the whole proof, but most logical proofs of "God" start from the possibility of God's existence and derive the necessity of God's existence. But the real controversy is the possibility of God's existence. Most people would grant that "God is possible". But if you say your notion of possibility means that possibility implies necessity for a necessary being such as God, then they will deny that God is possible, because what they meant by possible was different than what you meant. In any case, the possibility of God's existence is deniable, and thus does not follow from logic itself. For such "proofs" my original assertion remains.
What I mean by "logical" proof is just that that can be derived from logic. God does not follow from logic itself. But as someone else pointed out, God might follow from something else, such as morality, as Kant thought.
So try as you might to avoid philosophy, you can't. Philosophy is inherent in our thought, in our actions, in our way of life. Many people never formalize their thought processes enough to even consider things like "the matrix". That's what makes this movie so novel to so many people.
Let's consider a simulated environment so good that we could not determine it was simulated. How then could we call it simulated? We would have no evidence of it being simulated, and so all of empiricism would have us call it "real"? But in this hypothetical example what is, by all available evidence, called "real" is not real. And our means of obtaining knowledge cannot allow us to answer this question. So is there even a distinction to be made between the simulation that is experienced "as real" and what "really" is?
The distinction is false, and leads us into the mysterious realm of anti-realism. You should read a few proponents of the subject, such as Hilary Putnam and Michael Dummett, before you disparage it. Not saying these philosophers would enthusiastically embrace the movie "The Matrix", but the type of hypotheticals considered in the movie are critical to, say, Hilary Putnam's anti-realism.