Gosling on Computing 74
CowboyRobot writes "ACM Queue has Eric Allman (creator of Sendmail) interviewing James Gosling (creator of Java) and the conversation covers many aspects of computing today, including the state of security, comparisons of languages and OSs, and the future of virtual machines.
'At the lowest level, you have to know that the boundaries around the piece of software are completely known and contained. So, for example, in Java, you can't go outside the bounds of an array. Ever. Period. Turning off array subscripting is not an option.'"
Good idea. (Score:5, Insightful)
Once they do that we'll only have to worry about stuff like SQL injection (which can result in execution of arbitrary code), which can be reduced/near eliminated by making people use prepared statements.
In some cases it'll still be necessary to use the unsafe languages, but nearly 100% of the programmers in the world obviously can't code safely in C or similarly vulnerable languages.
Even Eric Allman couldn't (see Sendmail for evidence).
Re:Good idea. (Score:2, Insightful)
Not that I'd dream of barely-on-topic evangelism or anything...
The problems of code injection (Score:5, Interesting)
Yep, that's a serious problem, and one that gets far less "press" than the sort of buffer over-run vulnerabilities you get in careless C or C++.
The one that always astounds me is that languages with an eval-type statement -- that is, ones which can parse and execute an arbitrary string at run-time -- don't get slated for their security problems way more often. We use Perl to write CGI scripts all the time, and its variable interpolation can be waaaaay more dangerous than any potential pointer nasties in C!
It's notable that Java does not have such a function. It does, however, have the usual problem with allowing arbitrary strings to be interpreted as statements through its SQL API, but given the nature of SQL I'm not sure how realistic it is to address that anyway...
Re:The problems of code injection (Score:3, Interesting)
The first is a "not thinking straight" problem and requires stupidity/ignorance which is common. The second is a "typo class" problem and only requires imperfection which is nearly ubiquitous -even smart and knowlegeable people make such mistak
You haven't heard about "taint mode"? (Score:2)
(If the reason is old Perl code or uneducated programmers, I do think that your complaint is a bit overblown...)
Re:You haven't heard about "taint mode"? (Score:2)
No, taint is a great feature, at least up to a point. It's certainly a good idea, and it (particularly the way you untaint things) fits in pretty well with the general framework of the language. There are a couple of problems with taint mode, though.
Firstly, it's not obligatory. Now, you can reasonably argue that any competent Perl programmer will switch it on where it's needed, as indeed we (my colleagues and I) would, and that making it obligatory would be operate against the convenience of Perl and its
Re:You haven't heard about "taint mode"? (Score:1)
As for SQL injection problems: I'm avoiding them by using a self-built API that is based more closely on the relational model than SQL is. That makes it trivial to write safe code, even without prepared statements. The basic problem of incompetent programmers still remain, of course - it is non-trivial for somebody to learn a relational API instead of SQL, and writing a relational API is even less trivial (and I'm not going to release m
Re:The problems of code injection (Score:1)
This is, in effect, like the scripting problem you mentioned.
The nice thing is that it will be running with the same security system as its parent, so if the app wasn't given access to your HD, that's just not going to happen.
Re:Good idea. (Score:2)
Re:Good idea. (Score:2)
Leave the brick making to the brick makers. Fewer problems that way.
Re:Good idea. (Score:2)
</sarcasm>
Re:Good idea. (Score:2)
But, as my brother says, I've been going downhill. I did like lego and did a fair bit of machine code programming when I was a kid (didn't have access to an assembler).
Now I prefer prefab - I use cpan and perl (in that order
Gosling, Java? Hmmm..... (Score:5, Informative)
The right way to add generics to Java is a radical modification of JVM (Java Virtual Machine), but Sun didn't want to it. So they made an attempt to add generics to Java language without touching JVM. The result of this attempt is a complex scheme of name mangling (just like C++), and some unnecessary overhead. And such implementation _still_ requires some JVM changes and is incompatible with old JVMs. So now we have an ugly generics in Java and Java 5.0 (rebranded J2SE 1.5) incompatible with previous versions.
Re:Gosling, Java? Hmmm..... (Score:2, Insightful)
No Generics until 2006-2007 ?? (Score:4, Informative)
And all that before even 2005.
Re:No Generics until 2006-2007 ?? (Score:1)
Now add 3 years to 2005...
Re:No Generics until 2006-2007 ?? (Score:1)
Re:No Generics until 2006-2007 ?? (Score:1)
I really like
Re:No Generics until 2006-2007 ?? (Score:1)
Re:No Generics until 2006-2007 ?? (Score:2, Informative)
I repeat, Java bytecode is just a subset of IL. So you can do in
Re:No Generics until 2006-2007 ?? (Score:1)
I assume all the default CLR subsystems are defaulted to reject non-safe code?
I wonder how many other OS's MS is supporting with their CLR? If I want to run under Linux, what's the likelihood that an MS produced bytecoded program will run there unmodified and untested. (Not that Java is there yet, but at least that's their goal. MS's goal doesn't seem to be WORA. It seems to be Add More Nons
Re:No Generics until 2006-2007 ?? (Score:3, Insightful)
JBC is completely stack oriented and very close to UCSD pCode. CLR is register oriented
The VMs have completely different abstraction levels as well. Java has no assemblies, they use the more generic approach via class loaders.
angel'o'sphere
Re:No Generics until 2006-2007 ?? (Score:1)
And I'm NOT a Microsoft friend. But
Re:No Generics until 2006-2007 ?? (Score:1)
Look here, if you don't beleive me: IL instruction set [microsoft.com]
Re:No Generics until 2006-2007 ?? (Score:2)
Nevertheless I find the term "subset" inapprobriated. Further: CLI does not have one add instruction, only the notation in text is "add". Like Java it has (and needs to have) an individual instruction for every operand size (i1, i2, i4, i8, u1, u2, u4, u8 etc.)
Thanx for the pointer
angel'o'sphere
Re:Gosling, Java? Hmmm..... (Score:1)
Re:Gosling, Java? Hmmm..... (Score:1)
Re:Gosling, Java? Hmmm..... (Score:2, Interesting)
Because from what I read, java generics look very usable. My only complaint is that they werent in JDK 1.4.
Re:Gosling, Java? Hmmm..... (Score:2, Insightful)
Basicly, Java generic classes are common classes with some compile-time information. Compiler automaticaly inserts type casts when it's neccessary. But resulting byte-code is just the same code with casts from Object. So the only advantage is more typesafeness.
In C# 2.0 generic class are not real classes, they are templates (as in C++) for classes with erased type information. CLR (Common Language Runtime) instantiates parametrized
Re:Gosling, Java? Hmmm..... (Score:2)
Re:Gosling, Java? Hmmm..... (Score:1)
Ok, but C++ templates aren't really generics either. They are basically sophisticated macros that look like generics, which has the side effect of allowing them to do all sorts of weird, powerful things. But it has downsides as well. Some more info [msdn.com]
Re:Gosling, Java? Hmmm..... (Score:2)
Re:Gosling, Java? Hmmm..... (Score:5, Interesting)
I don't think the generics in Java are very ugly at all. The interface - i.e. the syntax itself - is reasonably clean. The implementation ends up being just a fallback to the safe-dynamic-casting functionality of the JVM, but you don't know that when you actually use the generics.
I think the major benefit of generics is that developers can structure their code easier. They can tell the compiler that something is a List of Strings, and not a List of Objects. The performance aspect of it is less important.
Also, you are not considering that there are low-level VM operations that can mollify, to a significant degree, the potential performance hits caused by dynamic casting.
If you read papers related to Self (a Sun research language, based on smalltalk, using prototype-based OO semantics), you'll notice that there was a lot of work done on doing fast dynamic type-inferencing. A lot of that work has been rolled back into Java.
So let's say you have a List of Strings in Java. And there's a location in the code which grabs the first element from a list, and that first element happens to be a String all the time, or most of the time (this occurrs very frequently even in OO code - even though the strict semantics might imply polymorphic behaviour, in practice, a lot of code ends up being monomorphic anyway). The Java VM will actually figure that out at runtime, and compile a special version of the code, which does one pointer check (to see if the object you're pulling out is a string), and if that pointer check succeeds, makes a call to a custom-compiled version of the method based on that type assumption. If that check fails, then it falls back to less efficient code. So that piece of code that ends up dealing with Strings in practice, ends up doing only a single pointer check, instead of the heavyweight operations needed for a blind dynamic cache.
Even when you have limited polymorphic behaviour (code that is polymorphic over a handful of tyes), the java VM optimizes it by using polymorphic inline caches (I think this was added in the 1.5.* VMs).
And the nice thing is, this happens on the dynamic properties of the code, not just the static properties. So if you have some code that, according to the syntax, deals with plain Objects, but in practice, deals with instances of Foo a vast majority of the time.. then most of the time, it WILL execute with the type-assumption, with the added cost of a pointer check.
So yes, it would be nice if the generics system had support at the bytecode level. But it's not as much of a hit on performance as one might think. The jitter and its low-level optimizations compensate for that quite a bit.
I'm pretty sure Sun developers were aware of this when they decided not to mess with the VM bytecode definition when adding generics support to the Java language.
-Laxitive
Re:Gosling, Java? Hmmm..... (Score:2)
So that piece of code that ends up dealing with Strings in practice, ends up doing only a single pointer check, instead of the heavyweight operations needed for a blind dynamic cache.
The bolded section should have been:
blind dynamic cast
-Laxitive
Re:Gosling, Java? Hmmm..... (Score:1)
Besides, it takes about 5000-9000 passes of code to make HotSpot to kick in and optimize a piece of code. It might be OK for long-running server applications, but it can't be tolerated in desktop apps.
Re:Gosling, Java? Hmmm..... (Score:2)
Sun decided that jvm compatibility was more important to them than any performance they could gain from low-level support for parametrized types. To a certain extent, I'm happy even with just the syntax and compiler-level support for it. It'll make my code cleaner and easier to follow, anyway.
-Laxitive
Re:Gosling, Java? Hmmm..... (Score:1)
Re:Gosling, Java? Hmmm..... (Score:2)
If true, that's just plain silly. Can you provide more info? I'd like to read about this.
-Laxitive
Re:Gosling, Java? Hmmm..... (Score:2, Informative)
Re:Gosling, Java? Hmmm..... (Score:2)
Re:Gosling, Java? Hmmm..... (Score:2)
I took a look at the entire site and found no such explanation. Any other suggestions? I'm curious too.
Re:Gosling, Java? Hmmm..... (Score:2)
Ah, OK, so it's not the JVM that's the issue with backwards compatability, but the lack of the appropriate library support. Interesting. I gather then that a 1.4 JVM would actually work just fine provided the 1.5 libraries were in its classpath.
I can't seem to find anything about this mysterious m
Re:Gosling, Java? Hmmm..... (Score:4, Insightful)
As far as how Sun implemented generics, the decision was purely political. Even Sun knows their solution is technically inferior. That doesn't make it wrong. They weighed the pros and cons and arrived at a different solution than you did, not because you know something they don't, but because they weighted the results differently.
Re:Gosling, Java? Hmmm..... (Score:2, Funny)
So you had respect for him, he does something in what you consider to be a clumsy way, and now you have NO respect for him? So if Gosling showed up and offered to help you with some project you'd shoo him away out of disrespect?
Re:Gosling, Java? Hmmm..... (Score:2)
Designerd are loath to make changes that create incompatibilities, lest they inconvenience the existing user base. This ignores the fact that the current user base is already inconvenienced by existing deficiencies in the language, and, moreover, in young languages such as java the existing user base is but a negligible percentage of the total users of the language through its life time
Very good read (Score:1)
Meanwhile... (Score:1)
What about turning off bounds checking? (Score:3, Interesting)
As I recall, it used to be possible to turn off runtime bounds checking. I also think that most people would do this once the code is debugged. Did this feature get disabled recently?
Re:What about turning off bounds checking? (Score:2, Insightful)
The language is defined so that this is impossible. See here. [sun.com] If you were to disable bounds checking, then you would be violating the language spec, and therefore it would not be Java. It would be the same if you wrote a JVM that ran bytecode but never checked array accesses. This sort of stuff may be useful for debugging
Re:What about turning off bounds checking? (Score:2)
angel'o'sphere
JVM and virtual servers (Score:5, Insightful)
In this article he mentions that the idea for the JVM came from the days when he wrote an emulator and found that his emulator actually performed better than the compiled C code. With the most modern JVM's, tests show that their performance is very close to, and often exceeds that of compiled code.
But the problem is that this is done at the expense of the performance of the overall server. UN*X (and other OS's) go to great lengths to make different programs perform and share resources in the most efficient manner. Scheduling, memory management, IO optimization, all that wonderful stuff, that makes a bear like emacs start almost instantaneously even on an old P90.
As is evident from my sig, I've been spending quite a bit of time in the past year tinkering with virtualization (The Linux Vserver in particular). The amazing thing is that all the optimizations of Linux still apply even if you're running two dozen virtual servers on the same machine (the code for emacs is still shared across processes, even in different virtual servers). Except for, sadly, the JVM. This is why you see many VPS hosting providers forbid running Java and sell a separate "Java server" at a much higher price. And we're considering doing the same. In our experience, a typical VPS customer running Apache, sendmail and a few other things uses 200-400MB of virtual memory, much of which is shared, whereas a customer running Tomcat or, even worse, JBoss use 1-3GB of virtual memory, next to none of which is shared. (Note that virtual memory != physical memory, but that's a separate discussion.
Given that virtualization is becoming more and more popular these days (and even Solaris now has "zones", which are same thing as Linux Vserver or FreeBSD jails), I think the folks at Sun need to think about where the JVM fits into a virtual server.
Re:JVM and virtual servers (Score:2, Informative)
Agreed this is indeed a problem, JVMs can be quite memory hungry. However there are several ways to address this. First of all, it's possible to have a single application server instance host multiple web applications. In fact, this is half the point of having an application server in the first place! Sure there's extra effort involved in getting the security and other configuration right, but it will save you gobs and gobs of memory.
Additionally, Sun will be providing new functionality in J2SE 1.6 (6.0?)
Nice comments on GC (Score:2)
Re:Java snake oil (Score:3, Insightful)
Ah, snail oil, it does wonders for the skin
Anyway, yes, it IS bet
Re:Java snake oil (Score:3, Insightful)
My coworker is currently recovering from 3 days' bugfixing session.
In C++, he called a virtual method off uninitialised pointer. The random piece of code that got run somehow managed not to crash the program immediately. Instead, it overran stack in random places. The program would crash in a corrupted STL list, in a completely unrelated spot. And it wasn't compatible with Valgrind.
Frankly, I'd take bugs in Java code instead of this anytime.
--
Re:Java snake oil (Score:3, Insightful)
Calm down, buddy. I never saw anything that said that Java will elim
Re:Java snake oil (Score:2)
HotShot Virtual Machine? (Score:1)
Trolling in the article? (Score:1, Troll)
This is a boneheaded remark. You could say the same thing about Sendmail. Perhaps he's just trolling?
Re:Trolling in the article? (Score:1)