First, and foremost, last thing wanted is to re-start another C/C++ vs. Java conversation.But, I was hopeful that this forum might pep, rally, and re-motivate my belief that mechanical sympathy from the Java platform view is indeed a worth-while and righteous pursuit.Reason I mention this is that at an (admittedly vodka fueled) holiday party last night I was overwhelmed by a pack of seasoned "C/C++ forever, just say no to Java" programmers that unanimously preached (and without any compromise) that those seeking mechanical sympathy from the Java view are fundamentally mis-directed (if not outright delusional).They prosecuted as follows:1. mechanical sympathy is the pursuit of OS level/hardware/et. al. native resources to gain access to performance advantages otherwise un-available from the default development platform.
2. The Java platform purposefully denies access to OS level/hardware/et. al. native resources
3. The OS (kernel, I/O, process subsystem, system call API, hardware device drivers,etc.) are all written in C/C++ ... interfacing with these resources via C/C++ is natural and intended
4. Java platform's highest priority is WORA portability ... a necessarily OS-agnostic approach ... which, by definition, compromises its capability to fully access OS-specific mechanical resources.
5. Java platform's non-direct access to these mechanical resources must cross a JNI bridge to C/C++ ... So, no matter how you look at it your going to wind up in C/C++ anyway.
CONCLUSION: If you have both the capability and choice to use C/C++, why in the world wouldn't you just write your app in C/C++ in the first place?
DERIVED CONCLUSION: pursuit of mechanical sympathy from the Java view is at conflict with itself. Frankly, the Java platform, at its core, wants to deny you mechanical sympathy.
Though the vodka has worn off, and the prosecution has rested, I still remain a bit sympathetic to their lack of sympathy.But I want re-engage this crowd. Any advice for a defense re-buttal?Happy holidays everybody,Ben
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
5. Java platform's non-direct access to these mechanical resources must cross a JNI bridge to C/C++ ... So, no matter how you look at it your going to wind up in C/C++ anyway.
There are cases where the control of the hardware is so important and
so central that would make no sense to choose Java.
There are other cases where what is provided by Java is compelling
over C++, yet you want to be able to have some degree of control on
the hardware.
--
How does C++ handle false sharing much better? In java you just use padding. Not elegant but it works.
If you want full control you can just use Unsafe to layout native memory.
There are other cases where what is provided by Java is compelling
over C++, yet you want to be able to have some degree of control on
the hardware.But , in the strictly mechanical sympathy sense, and with all due respect, what provided by Java is more compelling over C++?
Why not use C++ for everything?
A: Due to the price you pay by longer time to market, higher maintenance costs, less reuse of embedded open source software. Are you willing to turn a two month Java project into a six month C++ project just to avoid manual padding?
I think we need to define/agree what it is meant here by "mechanical sympathy".
My interpretation sticks with the "redefinition" given by Martin
Thompson, which took the definition of Jackie Stewart: know your
hardware because you'll become a better programmer (hey, I hope Martin
agrees here :)
In this light, I think that pursuing mechanical sympathy is something
you really want to look at in general, like you want to be interested
in functional programming if you have an imperative programming
background (or viceversa), or object-oriented if you have a procedural
background, etc.
Way too much of the C++ code I've seen looks like it has been written by someone who looks like me driving the F3000. Learning the fundamentals and constantly improving are way way more important than the machinery. Unless you are racing to be the absolute fastest, and a few actually are doing this, then we need to go as fast as necessary in an efficient and safe manner - and be enjoying it while doing it.
Way too much of the C++ code I've seen looks like it has been written by someone who looks like me driving the F3000. Learning the fundamentals and constantly improving are way way more important than the machinery. Unless you are racing to be the absolute fastest, and a few actually are doing this, then we need to go as fast as necessary in an efficient and safe manner - and be enjoying it while doing it.
Fabulous! Thank you. :-)
C++ Martin can in general get a few percentage points more performance than Java Martin. However Java Martin can often complete the development a few times faster than C++ Martin.
On Friday, December 20, 2013 10:46:39 AM UTC-8, Martin Thompson wrote:C++ Martin can in general get a few percentage points more performance than Java Martin. However Java Martin can often complete the development a few times faster than C++ Martin.
Still I think the comparison is lacking. There will be performance targets you can never hit in Java, no matter how long you spend in development.
2) C++ lacks libraries. Some say it's because of the lack of GC. There are no established conventions on who allocates and who frees and getting libraries to work with each other is painful. Anecdotal evidence: I see questions on who is responsible for freeing all the freaking time [..]
You lose some performance but it's easier to finish your project while business driven performance goals are still met.
The response is that time and money and flexibility IS a factor --
If you subsitute c for any lower level primitive, and jvm for kernel or any other layer, you could equally argue that there's no point bothering with mech sympathy in such bloated environments.
Argument would go:Why would anyone waste time on writing with c++, libc, or using the write once run anywhere kernel abstractions when you can write your own loader, machine code and device drivers for the specific hardware you own? Much more efficient!By extension, if you write c++ you are wasting time thinking about memory layout and algorithms because if you really cared you would use machine code.
Hey just think about how much chip space is wasted on processor instructions you don't use very often! Build your own processor :)
Well, I must disagree:2) C++ lacks libraries. Some say it's because of the lack of GC. There are no established conventions on who allocates and who frees and getting libraries to work with each other is painful. Anecdotal evidence: I see questions on who is responsible for freeing all the freaking time [..]
This is a thing every C++ developer must take responsibility for: when some library gives you some (dynamically allocated) object: who is responsible for it? Usually the context gives you a hint, and otherwise the documentation will tell you. In any case, you MUST regard it, it is essential for C++. (And in many cases objects can be stack-allocated, then it is easy...).
However, a C++ developer MUST take care of this issue, in contrast to a developer on some GC VM environment.
And the good thing about it is: there is a very clear and visible knowledge about WHO owns something at which time in processing. And this leads to a very clear and visible sense of "lifetimes of objects". Something that is unknown in (current) GC environments. Or at least it is a blurry, doubtful thing, leading to many bugs in GC environments.
Remember me, the next time you open a file, and write a try/catch clause with an additional final clause (just to close any dangling file handles) in Java ;-)
You lose some performance but it's easier to finish your project while business driven performance goals are still met.
Maybe. But if you trade performance against correctness, then you (or your customer) will lose some day.
It is easy to write toy-code in Java, but extremely hard to make it correct.
C++ demands much more from you, up-front, but your code will be much more correct.
On Friday, December 20, 2013 2:53:36 PM UTC-8, Robert Frunzke wrote:Well, I must disagree:2) C++ lacks libraries. Some say it's because of the lack of GC. There are no established conventions on who allocates and who frees and getting libraries to work with each other is painful. Anecdotal evidence: I see questions on who is responsible for freeing all the freaking time [..]
This is a thing every C++ developer must take responsibility for: when some library gives you some (dynamically allocated) object: who is responsible for it? Usually the context gives you a hint, and otherwise the documentation will tell you. In any case, you MUST regard it, it is essential for C++. (And in many cases objects can be stack-allocated, then it is easy...).
However, a C++ developer MUST take care of this issue, in contrast to a developer on some GC VM environment.
And the good thing about it is: there is a very clear and visible knowledge about WHO owns something at which time in processing. And this leads to a very clear and visible sense of "lifetimes of objects". Something that is unknown in (current) GC environments. Or at least it is a blurry, doubtful thing, leading to many bugs in GC environments.
Remember me, the next time you open a file, and write a try/catch clause with an additional final clause (just to close any dangling file handles) in Java ;-)I typically use C++ a lot more than Java and I appreciate RAII. I am not labeling GC as a silver bullet - just observing that it helped Java to develop a rich ecosystem of high performance libraries. Rust I think again looks great in this regard. Ownership of objects is statically verified. There are no dangling pointers, no double frees, no returning a pointer to a stack allocated structure. This bugs are eliminated not with GC but with static analysis.
On Friday, December 20, 2013 2:53:36 PM UTC-8, Robert Frunzke wrote:Well, I must disagree:2) C++ lacks libraries. Some say it's because of the lack of GC. There are no established conventions on who allocates and who frees and getting libraries to work with each other is painful. Anecdotal evidence: I see questions on who is responsible for freeing all the freaking time [..]
This is a thing every C++ developer must take responsibility for: when some library gives you some (dynamically allocated) object: who is responsible for it? Usually the context gives you a hint, and otherwise the documentation will tell you. In any case, you MUST regard it, it is essential for C++. (And in many cases objects can be stack-allocated, then it is easy...).
However, a C++ developer MUST take care of this issue, in contrast to a developer on some GC VM environment.
And the good thing about it is: there is a very clear and visible knowledge about WHO owns something at which time in processing. And this leads to a very clear and visible sense of "lifetimes of objects". Something that is unknown in (current) GC environments. Or at least it is a blurry, doubtful thing, leading to many bugs in GC environments.
Remember me, the next time you open a file, and write a try/catch clause with an additional final clause (just to close any dangling file handles) in Java ;-)I typically use C++ a lot more than Java and I appreciate RAII. I am not labeling GC as a silver bullet - just observing that it helped Java to develop a rich ecosystem of high performance libraries. Rust I think again looks great in this regard. Ownership of objects is statically verified. There are no dangling pointers, no double frees, no returning a pointer to a stack allocated structure. This bugs are eliminated not with GC but with static analysis.
You lose some performance but it's easier to finish your project while business driven performance goals are still met.
Maybe. But if you trade performance against correctness, then you (or your customer) will lose some day.
It is easy to write toy-code in Java, but extremely hard to make it correct.
C++ demands much more from you, up-front, but your code will be much more correct.Where did I talk about trading correctness? Could you elaborate why it is difficult to write correct code in Java or any more tougher than it is in C++?
There are no dangling pointers, no double frees, no returning a pointer to a stack allocated structure.
Am Samstag, 21. Dezember 2013 00:29:40 UTC+1 schrieb Rajiv Kurian:
On Friday, December 20, 2013 2:53:36 PM UTC-8, Robert Frunzke wrote:Well, I must disagree:2) C++ lacks libraries. Some say it's because of the lack of GC. There are no established conventions on who allocates and who frees and getting libraries to work with each other is painful. Anecdotal evidence: I see questions on who is responsible for freeing all the freaking time [..]
This is a thing every C++ developer must take responsibility for: when some library gives you some (dynamically allocated) object: who is responsible for it? Usually the context gives you a hint, and otherwise the documentation will tell you. In any case, you MUST regard it, it is essential for C++. (And in many cases objects can be stack-allocated, then it is easy...).
However, a C++ developer MUST take care of this issue, in contrast to a developer on some GC VM environment.
And the good thing about it is: there is a very clear and visible knowledge about WHO owns something at which time in processing. And this leads to a very clear and visible sense of "lifetimes of objects". Something that is unknown in (current) GC environments. Or at least it is a blurry, doubtful thing, leading to many bugs in GC environments.
Remember me, the next time you open a file, and write a try/catch clause with an additional final clause (just to close any dangling file handles) in Java ;-)I typically use C++ a lot more than Java and I appreciate RAII. I am not labeling GC as a silver bullet - just observing that it helped Java to develop a rich ecosystem of high performance libraries. Rust I think again looks great in this regard. Ownership of objects is statically verified. There are no dangling pointers, no double frees, no returning a pointer to a stack allocated structure. This bugs are eliminated not with GC but with static analysis.
Okay, I can not yet imagine how static analysis could solve the problem, but I will definitely have a look at Rust!!
You lose some performance but it's easier to finish your project while business driven performance goals are still met.
Maybe. But if you trade performance against correctness, then you (or your customer) will lose some day.
It is easy to write toy-code in Java, but extremely hard to make it correct.
C++ demands much more from you, up-front, but your code will be much more correct.Where did I talk about trading correctness? Could you elaborate why it is difficult to write correct code in Java or any more tougher than it is in C++?
My statement was just a statement against the common statement that "c++ is just for performance".... while correctness, idioms, language features and so on are silently ignored. And the first issue seen in production java code is a lax understanding of correctness: dangling file handles, exceptions (in common error cases) that nobody can still understand (instead of plain, simple error messages to the user for common error cases), and so on.
You can write correct code in Java, but - IMHO - many people trade correctness for easy, fast-written, code.
But that is just my impression.
There are no dangling pointers, no double frees, no returning a pointer to a stack allocated structure.
By the way: "double frees" and similar things are the issues, that Java mentors tell their pupils to make them amenable!
But, Java is not so much different. In Java, you may call on or read something from a NULL object, and get an exception.
In C++, this can happen too. But in C++ you would use stack objects and object references in situations, where an instance would actually be expected, and a plain pointer (which can be NULL) only in situations where the object actually could be NULL.
So, you would have the choice, and you would have agreements.
In Java you will not have that choice. To write correct Java, you would have to check any stupid object "ref" for being null at many stupid code points.
You lose some performance but it's easier to finish your project while business driven performance goals are still met.
Maybe. But if you trade performance against correctness, then you (or your customer) will lose some day.
It is easy to write toy-code in Java, but extremely hard to make it correct.
C++ demands much more from you, up-front, but your code will be much more correct.Where did I talk about trading correctness? Could you elaborate why it is difficult to write correct code in Java or any more tougher than it is in C++?
My statement was just a statement against the common statement that "c++ is just for performance".... while correctness, idioms, language features and so on are silently ignored. And the first issue seen in production java code is a lax understanding of correctness: dangling file handles, exceptions (in common error cases) that nobody can still understand (instead of plain, simple error messages to the user for common error cases), and so on.
You can write correct code in Java, but - IMHO - many people trade correctness for easy, fast-written, code.
But that is just my impression.Once again like I said RAII is a good pattern but the rest of what you are saying is FUD. I have very seldom heard the argument for C++ language features (besides RAII) being any good. There are too many things in the C++ language that range from minor annoyance to absolute nightmare to deal with. The list is endless. Entire tomes have been written about the misfeatures of C++. One good one is http://yosefk.com/c++fqa/fqa.html. The only reason I am writing against C++ (a language I use almost daily) is your insistence (without any proof) that C++ lets you write more correct code and that Java users trade correctness for easy code.
--
Maybe, but...:
Am Samstag, 21. Dezember 2013 00:05:44 UTC+1 schrieb Jason Koch:The response is that time and money and flexibility IS a factor --
Okey-dokey! No resistance from me.If you subsitute c for any lower level primitive, and jvm for kernel or any other layer, you could equally argue that there's no point bothering with mech sympathy in such bloated environments.
No, C is not any lower level primitive and JVM is not the kernel! That kind of substitution is stupid, and not our topic.
Argument would go:Why would anyone waste time on writing with c++, libc, or using the write once run anywhere kernel abstractions when you can write your own loader, machine code and device drivers for the specific hardware you own? Much more efficient!By extension, if you write c++ you are wasting time thinking about memory layout and algorithms because if you really cared you would use machine code.
Read some lines below here... your assumed substitutions are rather surreal.
And your imaginary "wasted time" - is not so wasted at all, but most of the time it is essential for correct code. As I showed in my text about object lifetimes. Give "thinking about it" a try.
And comparison to "machine code" is unfair, stupid. Adding the values of two values in Java, in encapsulated integer objects, does not feel like machine code? It feels like a missing abstraction in java. But well, another topic...
Hey just think about how much chip space is wasted on processor instructions you don't use very often! Build your own processor :)
No.. whats your point here?
I am not an offender of GC VM environments at all. But I just do not like how people dismiss C++ when they have absolutely no idea of the underlying concepts, and thus in such discussions often also present how little they know about their actual GC VM environment (Java) at all. Java is not perfect, get it.
My point (and that one is religional) is, that Java Developers constantly argue about idioms and features they use, while never even trying to dilate their "feature space". It feels like "some" Java guys feel superior ... while not even knowing what exactly they are arguing about and against.
While, with C++, you can definitely shoot yourself in your foot, you can do so too in Java.
C++ has advantages, Java has advantages. Both have disadvantages.
Micro proofs are like micro benchmarks - ultimately overly contrived and often ignore larger issues.To address the issue, yes, references are better than potentially null pointers. The other thing you left out is the consequence of a null deref. In c and c++ a binary abort - I have not seen a segv recovery in production C/C++ code. In Java however, you can capture and recover from a NPE, even report errors to an RPC, etc.
Finally, I agree that Java isn't safe enough. The solution for most developers is to move to languages like Clojure and Scala, not switch back to C++.
I think it's pretty commonly believed now that application programming in C++ - avoid at all costs.
That is not a conclusive proof especially of how Java programmers trade easy code for correctness. There are instances of C++ royally screwing up everywhere on the internet. Some examples:i) Returning pointer to a stack allocated object (C is also guilty).
ii) Throwing exceptions everywhere - you cannot throw in the destructor in C++ because your destructor might be called on a previous exception. Guess what happens on two exceptions - terminate :). Destructors don't let you return an error code either. From yosefk.com - " If you want your destructor to detect problems, make it a close function."
iii) No type safety for exceptions. Java forces you to declare exceptions and to handle them. C++ does not.
iv) Throws of polymorphic objects is weird - a throw looks at the static type of its argument expression but catch respects inheritance :)
v) You can throw any object but catch won't let you find out what was thrown and from where. You also don't know how many times an object that is thrown is copied.
IMHO C error handling is much better. C++ is a complete disaster.
Again I'd like to point out that modern languages like Rust will allow you to pass a stack allocated object and ensure that you cannot dereference a null pointer.My point (and that one is religional) is, that Java Developers constantly argue about idioms and features they use, while never even trying to dilate their "feature space". It feels like "some" Java guys feel superior ... while not even knowing what exactly they are arguing about and against.I don't think such people are on this list. Most people on this list have used C/C++.
While, with C++, you can definitely shoot yourself in your foot, you can do so too in Java.
C++ has advantages, Java has advantages. Both have disadvantages.I think most posts here acknowledge that. I'd still argue that error handling in C++ is definitely not one of it's advantages in spite of RAII.
Okay, the gory details...That is not a conclusive proof especially of how Java programmers trade easy code for correctness. There are instances of C++ royally screwing up everywhere on the internet. Some examples:i) Returning pointer to a stack allocated object (C is also guilty).Yes.
ii) Throwing exceptions everywhere - you cannot throw in the destructor in C++ because your destructor might be called on a previous exception. Guess what happens on two exceptions - terminate :). Destructors don't let you return an error code either. From yosefk.com - " If you want your destructor to detect problems, make it a close function."Yes.. in practice you are right. You still could throw from a destructor, but it is one of those situations where you could shoot yourself in your feet. Or you could start re-thinking your design (in trust to the god of C++, in trust to the thought, that all of this may not be without any reason at all).
So, in a practical hot-or-not comparison between C++ and Java: What would you do in Java, if (e.g.) a file handle object inhibits its close (and though its automatic destruction) ??? What would you do, if you even just could do anything here?
iii) No type safety for exceptions. Java forces you to declare exceptions and to handle them. C++ does not.
Agreed, that one is strange.
iv) Throws of polymorphic objects is weird - a throw looks at the static type of its argument expression but catch respects inheritance :)
Maybe that design was made up of the idea, that sometime someone may find a use case. But there is none (at least "there does not seem to be one"), agreed.
v) You can throw any object but catch won't let you find out what was thrown and from where. You also don't know how many times an object that is thrown is copied.
Same...
IMHO C error handling is much better. C++ is a complete disaster.
Well, maybe. But with anything C++, YOU have the choice...
I was in doubt. And some guys at stackoverflow helped me to get "sympathy" for complete-style kind of exception handling:
http://stackoverflow.com/questions/1853243/c-do-you-really-write-exception-safe-code
The first and "accepted" answer enlightened me. And its also applicable to Java and other languages. This is how it really should be.
Again I'd like to point out that modern languages like Rust will allow you to pass a stack allocated object and ensure that you cannot dereference a null pointer.My point (and that one is religional) is, that Java Developers constantly argue about idioms and features they use, while never even trying to dilate their "feature space". It feels like "some" Java guys feel superior ... while not even knowing what exactly they are arguing about and against.I don't think such people are on this list. Most people on this list have used C/C++.
Then I am sorry!While, with C++, you can definitely shoot yourself in your foot, you can do so too in Java.
C++ has advantages, Java has advantages. Both have disadvantages.I think most posts here acknowledge that. I'd still argue that error handling in C++ is definitely not one of it's advantages in spite of RAII.
Okay.
But even then its not automatically an advantage of Java. From a users perspective: Whenever I have some Java program that crashes, I am totally lost. With a bit of luck I get a stacktrace (depends: on console, on gui, on log file), but usually this contains totally useless information. E.g. the trace was created some dozen lines of code after the actual error line (yeah, that is very common!!!) --- come one, you all know that stuff... you do not really want to defend that gross mess of bad code out there? Do you?
[...] I'll use whatever language best fits the things I'm trying to fit this super efficient code into, whether it's C (with goto statements) in kernel code, C++ in JVM code, or Java in libraries that lots of other people can actually use. [...]
In all cases, I try to code these fast-path things with the machine in mind, and I consider the machine to be the thing my code will be running on, in it's entirety.
[...] doesn't really matter, but if you write to something with no ecosystem, you are taking on a lot of unneeded work. In 2013, writing app server libraries in C++ is just as silly as writing Java code for running Facebook games. [...]
To put this Java vs. C++ discussion in perspective, lets rip on some other "too abstract to know the machine" levels before we ease up and come back to reality:- C++ programmers that think they program to the metal are kidding themselves. From a kernel programmer's point of view, C++ programs are for little children that live in little sand boxes and can't be trusted with actual access to the hardware they run on. I haven't seen much [real-world] kernel code written in C++, and user mode code is inherently separated form the hardware by an abstraction layer that takes away your code's control over whether or not it's even running, and when. Anyone that tries to make a user-mode spin loops actually work (without isolcpus or some such) runs into this one pretty fast.
- [SMP, scheduled] Kernels are way to abstract to control hardware well with. A tight loop (with interrupts disabled) is the only way to directly control what a CPU is doing.
- Do I really need to continue? We can go into x86 instructions vs. microcode and keep going down to ECC, power management, hypervisors, and all the other things that stand between you and you actual execution.
Now that I've hopefully demonstrated the fallacy of "the machine is the user-mode interface to the Linux kernel", and given a reason to think in more generic terms like "the machine is the thing we run on, and we should understand it", Saying that virtual calls or automatic memory management create abstractions that separate you too much from the metal is no different than saying that a scheduler, virtual memory and user-mode/kernel-mode separation do the same. I'd say that Java just has a couple of more layers to the machine than user mode C/C++ have, and that being 14 steps removed or 12 steps removed from content performance transistor behavior is not a big difference.
Okay, you got my attention...
[...] I'll use whatever language best fits the things I'm trying to fit this super efficient code into, whether it's C (with goto statements) in kernel code, C++ in JVM code, or Java in libraries that lots of other people can actually use. [...]
So, in your stereotyped world, C must have goto statements, C must be in kernel code and C++ in JVM code. Nice prerequisites!
In all cases, I try to code these fast-path things with the machine in mind, and I consider the machine to be the thing my code will be running on, in it's entirety.
Of course, you do.
[...] doesn't really matter, but if you write to something with no ecosystem, you are taking on a lot of unneeded work. In 2013, writing app server libraries in C++ is just as silly as writing Java code for running Facebook games. [...]
You forgot to mention, that any goal in the arts of application server framework technology was already reached, exploited and technologically exhausted.
And building up on that situation, it does not matter if you build up on concrete, silicon, paper or air - because ... ehm, well, yes, why?
To put this Java vs. C++ discussion in perspective, lets rip on some other "too abstract to know the machine" levels before we ease up and come back to reality:
- C++ programmers that think they program to the metal are kidding themselves. From a kernel programmer's point of view, C++ programs are for little children that live in little sand boxes and can't be trusted with actual access to the hardware they run on. I haven't seen much [real-world] kernel code written in C++, and user mode code is inherently separated form the hardware by an abstraction layer that takes away your code's control over whether or not it's even running, and when. Anyone that tries to make a user-mode spin loops actually work (without isolcpus or some such) runs into this one pretty fast.
Please elaborate on this one!
- [SMP, scheduled] Kernels are way to abstract to control hardware well with. A tight loop (with interrupts disabled) is the only way to directly control what a CPU is doing.
Well, if you say it!
- Do I really need to continue? We can go into x86 instructions vs. microcode and keep going down to ECC, power management, hypervisors, and all the other things that stand between you and you actual execution.
Okay, but what is your point then???
Now that I've hopefully demonstrated the fallacy of "the machine is the user-mode interface to the Linux kernel", and given a reason to think in more generic terms like "the machine is the thing we run on, and we should understand it", Saying that virtual calls or automatic memory management create abstractions that separate you too much from the metal is no different than saying that a scheduler, virtual memory and user-mode/kernel-mode separation do the same. I'd say that Java just has a couple of more layers to the machine than user mode C/C++ have, and that being 14 steps removed or 12 steps removed from content performance transistor behavior is not a big difference.
Okay, I am not sure, but I think I understood. But what is your point here???
--
You received this message because you are subscribed to a topic in the Google Groups "mechanical-sympathy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mechanical-sympathy/6xt1URgjnZY/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to mechanical-symp...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
I'm a pragmatist, and I have work to do. I'm not a language evangelist, and I certainly don't try to bring Java to the kernel heathens. I don't try to use Java for kernel programming, or C for app servers. Either would be silly in this decade. [...]
- C++ programmers that think they program to the metal are kidding themselves. From a kernel programmer's point of view, C++ programs are for little children [...]
<MyDisclaimerHereBecauseEverybodyHereAddedItToo>
Yeah, I work in many different environments, in different languages on a day-to-day basis. I gathered some experience with them. I am not a newbie.
</MyDisclaimerHereBecauseEverybodyHereAddedItToo>
With all that luggage on my bag, I still think that Java is a very bad, a very, very bad compromise. I just do not understand that spontaneous defense response, whenever comparing Java to another language - beware, I will write it now, e.g.: C++! OMG!!! I wrote it down. Oh no. C++! Yeah, C++!
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
<MyDisclaimerHereBecauseEverybodyHereAddedItToo>
Yeah, I work in many different environments, in different languages on a day-to-day basis. I gathered some experience with them. I am not a newbie.
</MyDisclaimerHereBecauseEverybodyHereAddedItToo>
With all that luggage on my bag, I still think that Java is a very bad, a very, very bad compromise. I just do not understand that spontaneous defense response, whenever comparing Java to another language - beware, I will write it now, e.g.: C++! OMG!!! I wrote it down. Oh no. C++! Yeah, C++!I've written code in a lot of languages and found them all to have a certain utility with the exception of Javascript.
I like both C++ and Java for very different reasons and each have their sweet spot. I'd never say one is better than the other without context. You have made the statement that both Java is generically bad and a very bad compromise. Can you provide context and some rational argument? Looking at the tone of your written response, it looks like spewing emotion so it is hard to see what concrete point you are making :-)
I like both C++ and Java for very different reasons and each have their sweet spot. I'd never say one is better than the other without context. You have made the statement that both Java is generically bad and a very bad compromise. Can you provide context and some rational argument? Looking at the tone of your written response, it looks like spewing emotion so it is hard to see what concrete point you are making :-)
That was not my intent. Java has its pros and cons, as C++ has its pros and cons.
I just tried to be some kind of antipole to all this Java Love here ;-) You may not have noticed it, but that Java Love often seems to come in company with a rather unconscious and subjectively inspired hate to C++ and all what it is and represents.
I presented some rational arguments some posts ago.
I just tried to be some kind of antipole to all this Java Love here ;-) You may not have noticed it, but that Java Love often seems to come in company with a rather unconscious and subjectively inspired hate to C++ and all what it is and represents.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
I like both C++ and Java for very different reasons and each have their sweet spot. I'd never say one is better than the other without context. You have made the statement that both Java is generically bad and a very bad compromise. Can you provide context and some rational argument? Looking at the tone of your written response, it looks like spewing emotion so it is hard to see what concrete point you are making :-)
That was not my intent. Java has its pros and cons, as C++ has its pros and cons.
I just tried to be some kind of antipole to all this Java Love here ;-) You may not have noticed it, but that Java Love often seems to come in company with a rather unconscious and subjectively inspired hate to C++ and all what it is and represents.
I presented some rational arguments some posts ago.I certainly do not subscribe to a blind love of Java. I come face to face with its many flaws every day. Can be simple things like lack of unsigned types or the butt ugliness of clone() and serialization through to the horrendous compromise in not reifying generics.However the one major issue Java has from a mechanical sympathy perspective, which I'm surprised no one brought up, and that is control over memory layout. Cache missing and contention are the biggest issues in performance.Without more control over memory layout we can never have great collections classes in Java. We need to have what is effectively arrays of structs/objects plus the ability to inline one object into another, such as an AtomicLong into a Queue implementation with appropriate padding to prevent false sharing. This is why the likes of Gil and I are pushing hard on things like the ObjectLayout initiative. In a similar vein if escape analysis does not get the love it needs it would be great to have the ability to allocate on the stack and pass by ref or value stack allocated types. The true value of stack based allocation is not avoidance of GC, it is the fact is it totally free of any concurrent interaction with another thread and thus Amdahl is not hunting it down like all other contended approaches on the heap.
I could have similar rants on C or C++ but every language has its shortcomings.I just tried to be some kind of antipole to all this Java Love here ;-) You may not have noticed it, but that Java Love often seems to come in company with a rather unconscious and subjectively inspired hate to C++ and all what it is and represents.The "C++ Love" can equally come in company and in my experience with greater zealotry. ;-)
First, and foremost, last thing wanted is to re-start another C/C++ vs. Java conversation.But, I was hopeful that this forum might pep, rally, and re-motivate my belief that mechanical sympathy from the Java platform view is indeed a worth-while and righteous pursuit.Reason I mention this is that at an (admittedly vodka fueled) holiday party last night I was overwhelmed by a pack of seasoned "C/C++ forever, just say no to Java" programmers that unanimously preached (and without any compromise) that those seeking mechanical sympathy from the Java view are fundamentally mis-directed (if not outright delusional).They prosecuted as follows:1. mechanical sympathy is the pursuit of OS level/hardware/et. al. native resources to gain access to performance advantages otherwise un-available from the default development platform.2. The Java platform purposefully denies access to OS level/hardware/et. al. native resources3. The OS (kernel, I/O, process subsystem, system call API, hardware device drivers,etc.) are all written in C/C++ ... interfacing with these resources via C/C++ is natural and intended4. Java platform's highest priority is WORA portability ... a necessarily OS-agnostic approach ... which, by definition, compromises its capability to fully access OS-specific mechanical resources.5. Java platform's non-direct access to these mechanical resources must cross a JNI bridge to C/C++ ... So, no matter how you look at it your going to wind up in C/C++ anyway.CONCLUSION: If you have both the capability and choice to use C/C++, why in the world wouldn't you just write your app in C/C++ in the first place?DERIVED CONCLUSION: pursuit of mechanical sympathy from the Java view is at conflict with itself. Frankly, the Java platform, at its core, wants to deny you mechanical sympathy.Though the vodka has worn off, and the prosecution has rested, I still remain a bit sympathetic to their lack of sympathy.But I want re-engage this crowd. Any advice for a defense re-buttal?Happy holidays everybody,Ben
I could agree about 90% to you, except on one thing:
I'm a pragmatist, and I have work to do. I'm not a language evangelist, and I certainly don't try to bring Java to the kernel heathens. I don't try to use Java for kernel programming, or C for app servers. Either would be silly in this decade. [...]
Okay, lets ignore that "kernel programming" topic at all! That one is rather religious, and doesn't fit into this discussion, after all!
But for app servers, why not C, nor C++? Why do you think Java is so much more suited for these purposes? This is a real question! Why?
<MyDisclaimerHereBecauseEverybodyHereAddedItToo>
Yeah, I work in many different environments, in different languages on a day-to-day basis. I gathered some experience with them. I am not a newbie.
</MyDisclaimerHereBecauseEverybodyHereAddedItToo>
With all that luggage on my bag, I still think that Java is a very bad, a very, very bad compromise. I just do not understand that spontaneous defense response, whenever comparing Java to another language - beware, I will write it now, e.g.: C++! OMG!!! I wrote it down. Oh no. C++! Yeah, C++!
> I predict that you'll see a lot more of the likes of Spring and Ruby on Rails and Django and Node.js come (and go?) than you would new COBOL based app server frameworks in the future.
A safe guess. Of course, and WHO started talking about COBOL here? That one is history.
But you tried to stash a very important thing: Node.js is implemented in C++, Ruby probably in C (I do not know exactly), and Django was AFAIK based on the JVM. I know, that is not your point.
But your point is to state, that anything but C/C++ may be used for base of app server code. You state that Java is much more well-suited to application code than C/C++. Or what?
So, why not C/C++? You know about the enormous bunch of 3rd-party code (usually packaged in libraries), that is written in C/C++ and directly accessible.
BUT you still refuse to accept that fact, even while you work with it daily.
That sounds silly! That even sounds a bit schizophrenic.
- C++ programmers that think they program to the metal are kidding themselves. From a kernel programmer's point of view, C++ programs are for little children [...]
Did we talk about selfish C++ kernel hackers? Really? Who throwed that topic into our discussion? Stupid guy.
This is fun.
Sent from my iPadI could agree about 90% to you, except on one thing:
I'm a pragmatist, and I have work to do. I'm not a language evangelist, and I certainly don't try to bring Java to the kernel heathens. I don't try to use Java for kernel programming, or C for app servers. Either would be silly in this decade. [...]
Okay, lets ignore that "kernel programming" topic at all! That one is rather religious, and doesn't fit into this discussion, after all!
<sarcasm>Right, because kernels don't aim for mechanical sympathy, and are much farther away from the metal than useful C++ programs are.
Ok, but while we are at it, and just as not to offend, we should probably limit this discussion to the type of apps that people actually (still) use C++ in, I guess. Kernels are too religious. And so are a few other narrow and useless application domains that nobody uses C++ for any more. Like web facing applications. And phone applications. And custom business applications. Since all those have been taken over by C++ hating religions, let's keep them out of the conversation.</sarcasm>
Evolution is alive and well in our profession.
But for app servers, why not C, nor C++? Why do you think Java is so much more suited for these purposes? This is a real question! Why?
<sarcasm>Maybe we should ask one of the many successful people who built (new) app servers in C++ in the last 15 years and actually got people to write software on top of it. Oh, wait...</sarcasm>
The reality is that nobody (in their right mind) wants to run other people's custom written C/C++ code in their process, and since that's pretty much what app servers do, non of them want the apps that run on them to be written in C/C++. From an application platform point of view, other people's C/C++ code belongs in a separate process, with its own address space and its own SEGV signals.
Java app servers quickly relegated all C++ based app servers to their proper place in the computer history museum, and in the process, killed most of the C++ business application writing future.
Web browsers and phones completed the job on the GUI side throughout the past decade, leaving no major application area (that is interacted with by a human) where C++ is a language of choice for a new app. Other things (most of which are built on top of C++ infrastructure pieces) are just too much better and more productive than C++ is for application writers, and they've all voted with their feet.
I do think that C++ is still alive and well in many parts of the infrastructure software world. E.g. Many compilers, Runtimes, and remotely-accessed data containers like databases and key value stores are still dominated by C++. So C++ clearly doesn't have debilitating downsides there.
But your point is to state, that anything but C/C++ may be used for base of app server code. You state that Java is much more well-suited to application code than C/C++. Or what?
Hard to find better empirical proof for this than the state of reality in 2013.
Am Samstag, 21. Dezember 2013 19:18:10 UTC+1 schrieb Gil Tene:This is fun.
Sent from my iPadI could agree about 90% to you, except on one thing:
I'm a pragmatist, and I have work to do. I'm not a language evangelist, and I certainly don't try to bring Java to the kernel heathens. I don't try to use Java for kernel programming, or C for app servers. Either would be silly in this decade. [...]
Okay, lets ignore that "kernel programming" topic at all! That one is rather religious, and doesn't fit into this discussion, after all!
<sarcasm>Right, because kernels don't aim for mechanical sympathy, and are much farther away from the metal than useful C++ programs are.
Ok, but while we are at it, and just as not to offend, we should probably limit this discussion to the type of apps that people actually (still) use C++ in, I guess. Kernels are too religious. And so are a few other narrow and useless application domains that nobody uses C++ for any more. Like web facing applications. And phone applications. And custom business applications. Since all those have been taken over by C++ hating religions, let's keep them out of the conversation.</sarcasm>
Come on. YOU threw in that "kernel" topic. And exactly that style of argueing is one of my bigger problems with you! Read on....
But for app servers, why not C, nor C++? Why do you think Java is so much more suited for these purposes? This is a real question! Why?
<sarcasm>Maybe we should ask one of the many successful people who built (new) app servers in C++ in the last 15 years and actually got people to write software on top of it. Oh, wait...</sarcasm>
The reality is that nobody (in their right mind) wants to run other people's custom written C/C++ code in their process, and since that's pretty much what app servers do, non of them want the apps that run on them to be written in C/C++. From an application platform point of view, other people's C/C++ code belongs in a separate process, with its own address space and its own SEGV signals.
Cool. You think application servers are just skeleton. And the "apps" running on it are made up of code, doing something to some data, and responsing to requests, while integrating itself somehow into a hosting app server. Yeah!
You know what? You have re-invented the "process" thing of a core of an operating system. Well done!!!
Java app servers quickly relegated all C++ based app servers to their proper place in the computer history museum, and in the process, killed most of the C++ business application writing future.
I really love the way you ignore me. First you thought that C++ would be for kernel stuff, now you assume it should be used for business stuff, then GUI stuff. Whoah. You push that C++ baby through all registers of your mind, through anything you come up with. Yeah!
And you know what? C++ fits into many of your obscure fantasies. Not into all, and most of the times not perfectly. But it often just fits. Even though you really did not meant it like that!
Web browsers and phones completed the job on the GUI side throughout the past decade, leaving no major application area (that is interacted with by a human) where C++ is a language of choice for a new app. Other things (most of which are built on top of C++ infrastructure pieces) are just too much better and more productive than C++ is for application writers, and they've all voted with their feet.
Much better and more productive? A statement, ok. But please eloberate on that! ;-)
I do think that C++ is still alive and well in many parts of the infrastructure software world. E.g. Many compilers, Runtimes, and remotely-accessed data containers like databases and key value stores are still dominated by C++. So C++ clearly doesn't have debilitating downsides there.
Ah, NOW you are pushing your C++ baby into the backend space. I seee.
But your point is to state, that anything but C/C++ may be used for base of app server code. You state that Java is much more well-suited to application code than C/C++. Or what?
Hard to find better empirical proof for this than the state of reality in 2013.
So, you say that "north" is the correct direction, because all your cattles are aimed at and walking to north?
> For the record, I'm stupid and I own it.
Maybe? But I am not in a position to judge on that. But if you are not stupid, you maybe could at least give up some of the more stupid prejudices. E.g.: C/C++ is not for kernel, C/C++ is not for low-level, .. etc., either you got it now or not.
I'm sorry that this encroaching view and my refusal to acknowledge C++'s obvious superiority, birthright, and monopolistic ownership of that space offends you. I *like* C++.
We need to have what is effectively arrays of structs/objects plus the ability to inline one object into another, such as an AtomicLong into a Queue implementation with appropriate padding to prevent false sharing. This is why the likes of Gil and I are pushing hard on things like the ObjectLayout initiative. In a similar vein if escape analysis does not get the love it needs it would be great to have the ability to allocate on the stack and pass by ref or value stack allocated types.
I'm sorry that this encroaching view and my refusal to acknowledge C++'s obvious superiority, birthright, and monopolistic ownership of that space offends you. I *like* C++.
A first GOOD point in your texts ;-) Gil, that is a problem: You spontaneously unconciously feel offended, whenever the term "C++" is thrown at you.
And your reaction is similar to the reaction of other people. As if "Java guys" were trained to respond like this. Scary! Really scary!
However, have a nice christmas time! I am off now ;-)
From an implementation point of view, we are certainly working on adding intrinsic ObjectLayout stuff into Zing, starting with StructuredArray. We also hope to demonstrate it on a vanilla OpenJDK offshoot to make the case for how all JVMs can handle this stuff well, and show that it's not hard to do with any collector and it's just getting the semantics right.
Wow. I count 16 posts by you in about 24 hours. That's 16 to to my 6, the first of which did not involve you, and 5 that were simply answers to your rapid fire questions (or just your rude statements) following my 1st post. I guess I just misread this as a technical discussion, where you were somehow posting twice as many messages as I was because you cared so much.
That's not it. You are just rude. Or just a troll. Nothing to do with C++, Java, the subject of this thread, or mechanical sympathy. That makes it easier to understand. Now I can relax (but I bet a response is coming, since nothing drives trolls crazy more than not getting the the last word in).
-- Gil.
On Dec 21, 2013, at 7:04 PM, Robert Frunzke <robert....@gmail.com> wrote:
Oh Gil, please relax! RELAX BOY!
Maybe you did not notice, but in the last hours, you have responded to any clichee of any C++ topic that I would have thrown into the discussion. Even if I actually did not throw it.
You catched all the balls, that I did not throw.
You proved my point.
However... get a large glass of your egg nog and relax now.
Am Sonntag, 22. Dezember 2013 03:17:06 UTC+1 schrieb Gil Tene:On Dec 21, 2013, at 5:28 PM, Robert Frunzke <robert....@gmail.com> wrote:
I'm sorry that this encroaching view and my refusal to acknowledge C++'s obvious superiority, birthright, and monopolistic ownership of that space offends you. I *like* C++.
A first GOOD point in your texts ;-) Gil, that is a problem: You spontaneously unconciously feel offended, whenever the term "C++" is thrown at you.
And your reaction is similar to the reaction of other people. As if "Java guys" were trained to respond like this. Scary! Really scary!
Yup. We all went to the same brainwashing classes, and we are all terrified of this new fangled thing with two plusses that kids these days are talking about. We worry that it is creeping up on us and taking our jobs away, I guess. But since you don't like prejudices and stereotypes, I probably I read that wrong.
It's hard to offend me. Not even by calling me stupid in public posts. But you're right that it's easy to get me to react when the term "C++" is thrown at me.
Well, not quite.
It only gets these reactions when it comes along in an envelope that carries the obligatory: "C++, and only C++. Maybe a bit of C, but definitely not Java. Never Java. People who even dabble in Java clearly can't appreciate the singular perfection that is C++. Admit that C++ is better than Java or I won't go to sleep."
I'd probably react the same way to someone who tries the same zealot defense of Java. Maybe even point out COBOL's (or C++'s) history to teach them a lesson about language bigotry. Or maybe I'd just show them the disassembled x86 code of their own comparative code examples.
You see, I *like* C++, and I *also* like Java. And (oh no!) I think that they are *just as good* for low level user mode development. Especially when the machine code that comes out is no different. Heresy. Again.
However, have a nice christmas time! I am off now ;-)
You too. Try some egg nog. I hear it helps.
--
You received this message because you are subscribed to a topic in the Google Groups "mechanical-sympathy" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mechanical-sympathy/6xt1URgjnZY/unsubscribe.
To unsubscribe from this group and all of its topics, send an email to mechanical-sympathy+unsub...@googlegroups.com.
Good point.
If C is so great why do low latency Java programs avoid the kernel written in C for network, scheduling and memory mapped files? Just using one language or another is not the solution to all problems.
--
You received this message because you are subscribed to the Google Groups "mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mechanical-symp...@googlegroups.com.
We need to have what is effectively arrays of structs/objects plus the ability to inline one object into another, such as an AtomicLong into a Queue implementation with appropriate padding to prevent false sharing. This is why the likes of Gil and I are pushing hard on things like the ObjectLayout initiative. In a similar vein if escape analysis does not get the love it needs it would be great to have the ability to allocate on the stack and pass by ref or value stack allocated types.+1 .... Hoping that your's and Gil's efforts are not running into any "Not a top priority .... only affects the tiniest of Java community use cases" type reactions. Real problems can be remedied with these capabilities. Any specific public forum (a/o reference) detailing this initiative's exact ambitions/status?
>
> For all the crap that has been talked about lambdas if we take a
> mechanical sympathy perspective, and a cleaner implementation
> perspective, why do we need closures when all we needed are functions?
> Closing over all that possible scope is something I feel has not been
> that wisely considered. I want to apply a transform to large datasets
> but I don't give a damn about closing over a pile of scope when doing
> that.
One of the guy behind the 'lambda in Java' here.
Lambdas are not closure in Java, hence the name lambda BTW, a lambda can
capture the value of a variable, neither the variable itself nor its scope.
Now, there is a strong argument to have closures not lambdas in a language,
it makes the language syntax less bloated because you can express things
like if, loop or try inside the API like SmallTalk, Clojure or Scala does.
>
> I'd like the future of Java and the JVM brought more back to
> fundamentals rather than the latest fluff. Though this is not a Java
> community issue per se and more just a common affliction of our modern
> world.
The real fundamental concepts are neither lambda nor closure, but
function type and eta abstraction that you can find in Java 8 under the
name functional interface and method reference.
Lambda is just syntax sugar.
How do you see method references and functional interfaces making a fundamental difference to real world applications? Ones written by people who never run a *compiler* and struggle to use a debugger. Please don't just say parallel collections and fork-join ;-)
How do you see method references and functional interfaces making a fundamental difference to real world applications? Ones written by people who never run a compiler and struggle to use a debugger. Please don't just say parallel collections and fork-join ;-)I ask this in the spirit of having a good debate. I really do not have fixed views. I'm basing my views on personal experience and what I see in my client base.
Hi Remi and thanks for contributing to the debate!
On Sunday, 22 December 2013 18:48:14 UTC, Rémi Forax wrote:>
> For all the crap that has been talked about lambdas if we take a
> mechanical sympathy perspective, and a cleaner implementation
> perspective, why do we need closures when all we needed are functions?
> Closing over all that possible scope is something I feel has not been
> that wisely considered. I want to apply a transform to large datasets
> but I don't give a damn about closing over a pile of scope when doing
> that.
One of the guy behind the 'lambda in Java' here.
Lambdas are not closure in Java, hence the name lambda BTW, a lambda can
capture the value of a variable, neither the variable itself nor its scope.
Just to clarify so I don't get my functional terminology wrong :-) By lambdas you are referring to lambda expressions?
So if the reference to a local object is captured by the expression do you need see this as closing over scope?
Now, there is a strong argument to have closures not lambdas in a language,
it makes the language syntax less bloated because you can express things
like if, loop or try inside the API like SmallTalk, Clojure or Scala does.
>
> I'd like the future of Java and the JVM brought more back to
> fundamentals rather than the latest fluff. Though this is not a Java
> community issue per se and more just a common affliction of our modern
> world.
The real fundamental concepts are neither lambda nor closure, but
function type and eta abstraction that you can find in Java 8 under the
name functional interface and method reference.
Lambda is just syntax sugar.
Let me clarify my quote with regard to fundamentals. We all have a limited view of the world but from what I see, lambdas are not going to do much to help with delivering faster software or software faster. I'm not at all knocking the good work to bring such features to Java. My question is very simple in that is it worth the opportunity cost of what else could have been addressed? I've seen the pain of watching people try to debug such applications as they try to cope with crazy stack traces and what is really the order of execution they are facing. It gets much worse as non-trivial applications are tackled.
I get to measure a lot of real world applications and can see the real issues that slow down our applications. Often simple things like loggers, parsers, boxed types, and poor collection performance. All of which could be so much better for a fraction of the opportunity cost expended on jigsaw and lambdas. For me this is the fundamentals. One of the biggest issue being the quality of our garbage collectors. The skill required to tune them is just insane - C4 excluded.
How do you see method references and functional interfaces making a fundamental difference to real world applications. Ones written by people who never run a compiler and struggle to use a debugger. Please don't just say parallel collections and fork-join ;-)
I ask this in the spirit of having a good debate. I really do not have fixed views. I'm basing my views on personal experience and what I see in my client base.
Martin...
On 12/22/2013 10:19 PM, R�diger M�ller wrote:
>
> Agree on JDK8 Lambdas being basically syntactic sugar for anonymous
> classes (so I don't get the hype ).
No it's not.
Lambda are classless.
> However I have observed frequently how the messy syntax of anonymous
> classes lets programmers use blocking patterns just to get a cleaner
> syntax.
>
> So its fundamental in the way that it encourages and supports styles
> which look 'unnatural' and messy today.
>
> remote.getStuff( (stuff) => { remote.getOtherStuff( stuff,
> (OtherStuff) => { setState(INITIALIZED); } ) }
java.util.stream API [1] comes with strong word to explain why it's messy,
read the sections non-Interference, stateless behaviors, side-effects.
The hope is that because lambdas is a new syntax, people will not use
them to do side effect,
it's the "don't cross the stream" of Java if you prefer.
>
> is better than
>
> remote.getStuff(
> new FutureResult() {
> public void resultReceived( Stuff stuff ) {
> remote.getOtherStuff( stuff, new FutureResult() {
> public void resultReceived( Stuff otherStuff ) {
> setState(INITIALIZED);
> }
> }
> }
> });
>
> (if one adds generics it gets even worse).
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "mechanical-sympathy" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to mechanical-sympathy+unsub...@googlegroups.com.
So if the reference to a local object is captured by the expression do you need see this as closing over scope?
you close over the value and not over the scope if you prefer.
Java is fundamentally a pass by value language, so you can not close over the scope.
>
> I'd like the future of Java and the JVM brought more back to
> fundamentals rather than the latest fluff. Though this is not a
Java
> community issue per se and more just a common affliction of our
modern
> world.
The real fundamental concepts are neither lambda nor closure, but
function type and eta abstraction that you can find in Java 8
under the
name functional interface and method reference.
Lambda is just syntax sugar.
Let me clarify my quote with regard to fundamentals. We all have a limited view of the world but from what I see, lambdas are not going to do much to help with delivering faster software or software faster. I'm not at all knocking the good work to bring such features to Java. My question is very simple in that is it worth the opportunity cost of what else could have been addressed? I've seen the pain of watching people try to debug such applications as they try to cope with crazy stack traces and what is really the order of execution they are facing. It gets much worse as non-trivial applications are tackled.
Delivery software faster:
Lambdas will clearly help here because you can create declarative API (see below).
Crazy stack traces is a problem on it's own.
In my opinion, the problem comes from the fact that most applications use frameworks and not libraries,
and framework use proxies
[shameless plug, see http://www.parleys.com/play/529bb792e4b0e619540cc3ac]
About the order of execution, yes, lambdas allow you to delay the execution of a piece of code and like any abstraction, it has a cost when you want to debug. IMO, a way to reduce that cost is to have developers used to the concept. And the best way for that is to teach that concept at Uni. so having lambdas in Java goes in the right direction.
For boxed type, escape analysis, value type, array of value type, type specialization,
there will be something in Java 9 that will cover I hope most of theses subjects.
For the GC, I'm not an expert, I know a guy that is able to do the magic for me and I call it two or three times a year. But most of the time, I've found that it's better to spend time with a profiler, take a look to the number of objects created and ask why.
How do you see method references and functional interfaces making a fundamental difference to real world applications. Ones written by people who never run a compiler and struggle to use a debugger. Please don't just say parallel collections and fork-join ;-)
Functional interface allows you to create declarative APsI. That's the fundamental behind the stream API.
The Stream API is not important per se but you can apply the same design principle on a lot of APIs in order to simplify them because you can gather at a same place, something that describe what you want and the code that specify how to react to.
Caller: 'All roads lead to Rome. And. ... When in Rome do as the Romans.'
The caller just happened to be the 'lead prosecutor' from last night's party.
So I just awoke from a deep slumber to answer my phone (it is. 3.40am in NYC) .The caller just happened to be the 'lead prosecutor' from last night's party.Me: 'hello'Caller: 'All roads lead to Rome. And. ... When in Rome do as the Romans.'Me: 'u r still drunk, what the F r u talking about?'Caller: 'Go read Gil Tene's response to your mechanical-sympathy post'(I hang-up and start reading)Wow. Rings clear. An epiphany. Thank u so much Gil.Indeed, thank you *all* for these incredibly thoughtful responses.Defense rests. Happy holidays.Ben
Sent from my iPhoneThe language of your source code matters to mechanical sympathy in computers about as much as the language a race car driver speaks does to how fast he can get around a race course.And theology arguments between people who are only good in C/C++ and people who are only get in Java are about as sensible as theology arguments between Hindus and Christians.To me, it's all machine instructions at the end. It's silly to talk about which language you write it in when the instructions that the CPU runs at the end are exactly the same. When I look at critical path code that I want to be super efficient, all care about is the generated code that actually executes, and could care less if it's generated by gcc, LLVM, or C2. I'll use whatever language best fits the things I'm trying to fit this super efficient code into, whether it's C (with goto statements) in kernel code, C++ in JVM code, or Java in libraries that lots of other people can actually use. In all cases, I try to code these fast-path things with the machine in mind, and I consider the machine to be the thing my code will be running on, in it's entirety.The machine you need mechanical sympathy for is the one you run on, with all it's layers.And a key thing to keep in mind is that most of your code (by volume)n should be non-critical-path code, and for that code maintain-ability, undeerstand-ability, debug-ability, and stability are dramatically more important that straight-line speed. That means that the most natural language to use is the one that your your applications and ecosystem will tend towards, and the one that provides you with the most leverage. Whether it's Python, Java, C, Scala, C++, or PHP doesn't really matter, but if you write to something with no ecosystem, you are taking on a lot of unneeded work. In 2013, writing app server libraries in C++ is just as silly as writing Java code for running Facebook games. And writing kernel modules in Scala is just as silly as writing Hadoop code in C.To put this Java vs. C++ discussion in perspective, lets rip on some other "too abstract to know the machine" levels before we ease up and come back to reality:- C++ programmers that think they program to the metal are kidding themselves. From a kernel programmer's point of view, C++ programs are for little children that live in little sand boxes and can't be trusted with actual access to the hardware they run on. I haven't seen much [real-world] kernel code written in C++, and user mode code is inherently separated form the hardware by an abstraction layer that takes away your code's control over whether or not it's even running, and when. Anyone that tries to make a user-mode spin loops actually work (without isolcpus or some such) runs into this one pretty fast.- [SMP, scheduled] Kernels are way to abstract to control hardware well with. A tight loop (with interrupts disabled) is the only way to directly control what a CPU is doing.- Do I really need to continue? We can go into x86 instructions vs. microcode and keep going down to ECC, power management, hypervisors, and all the other things that stand between you and you actual execution.Now that I've hopefully demonstrated the fallacy of "the machine is the user-mode interface to the Linux kernel", and given a reason to think in more generic terms like "the machine is the thing we run on, and we should understand it", Saying that virtual calls or automatic memory management create abstractions that separate you too much from the metal is no different than saying that a scheduler, virtual memory and user-mode/kernel-mode separation do the same. I'd say that Java just has a couple of more layers to the machine than user mode C/C++ have, and that being 14 steps removed or 12 steps removed from content performance transistor behavior is not a big difference.On Friday, December 20, 2013 8:42:00 AM UTC-8, Ben Cotton wrote:First, and foremost, last thing wanted is to re-start another C/C++ vs. Java conversation.But, I was hopeful that this forum might pep, rally, and re-motivate my belief that mechanical sympathy from the Java platform view is indeed a worth-while and righteous pursuit.Reason I mention this is that at an (admittedly vodka fueled) holiday party last night I was overwhelmed by a pack of seasoned "C/C++ forever, just say no to Java" programmers that unanimously preached (and without any compromise) that those seeking mechanical sympathy from the Java view are fundamentally mis-directed (if not outright delusional).They prosecuted as follows:1. mechanical sympathy is the pursuit of OS level/hardware/et. al. native resources to gain access to performance advantages otherwise un-available from the default development platform.2. The Java platform purposefully denies access to OS level/hardware/et. al. native resources3. The OS (kernel, I/O, process subsystem, system call API, hardware device drivers,etc.) are all written in C/C++ ... interfacing with these resources via C/C++ is natural and intended4. Java platform's highest priority is WORA portability ... a necessarily OS-agnostic approach ... which, by definition, compromises its capability to fully access OS-specific mechanical resources.5. Java platform's non-direct access to these mechanical resources must cross a JNI bridge to C/C++ ... So, no matter how you look at it your going to wind up in C/C++ anyway.CONCLUSION: If you have both the capability and choice to use C/C++, why in the world wouldn't you just write your app in C/C++ in the first place?DERIVED CONCLUSION: pursuit of mechanical sympathy from the Java view is at conflict with itself. Frankly, the Java platform, at its core, wants to deny you mechanical sympathy.Though the vodka has worn off, and the prosecution has rested, I still remain a bit sympathetic to their lack of sympathy.But I want re-engage this crowd. Any advice for a defense re-buttal?Happy holidays everybody,Ben
So ... Charges dropped? Case dismissed? (right, Ben?)
Great thread. Learned a lot.
"something in Java 9" Are you referring to Value Types as proposed by John Rose? If so I think this only a very partial solution. Just how can one develop better implementations of Maps or Trees with what is being proposed? This seriously dissappoints me.
Can you point to links that cover more than Value Types on this subject?
Sure, you can take a look to the presentation of lasts JVM Summit
Packed Objects in Java,
http://www.oracle.com/technetwork/java/javase/community/jvmls2013-2013900.html
Arrays 2.0
http://www.oracle.com/technetwork/java/javase/community/jvmls2012-1840099.html
On 12/23/2013 10:49 AM, Martin Thompson wrote:
For boxed type, escape analysis, value type, array of value type,
type specialization,
there will be something in Java 9 that will cover I hope most of
theses subjects.
"something in Java 9" Are you referring to Value Types as proposed by John Rose? If so I think this only a very partial solution. Just how can one develop better implementations of Maps or Trees with what is being proposed? This seriously dissappoints me.
Can you point to links that cover more than Value Types on this subject?
Sure, you can take a look to the presentation of lasts JVM Summit
Packed Objects in Java,
http://www.oracle.com/technetwork/java/javase/community/jvmls2013-2013900.html
Arrays 2.0
http://www.oracle.com/technetwork/java/javase/community/jvmls2012-1840099.html