[NTLUG:Discuss] Java/Linux versus school teacher.

steve sjbaker1 at airmail.net
Tue Mar 20 01:50:17 CDT 2007


Leroy Tennison wrote:

> Am I missing something here?  I thought the promise of Java was "write 
> once, run anywhere".  Yea, I know - marketing.  But still, this stuff is 
> supposed to work in the real world and it's beginning to sound like 
> running Java has a lot in common with visiting Las Vegas.  What's also 
> disturbing is to see comments indicating that similar things may exist 
> in C++.  Have we made programming languages so complex that we have 
> almost guaranteed ourselves of "shooting ourself in the foot"?

But these are not-recommended-coding-practices.

I've never had the problem in either C++ or Java because you just
don't *DO* that - it's a 'known-stupid' thing to do.

The only reason we're discussing it at all is because my kid's teacher
asked the question on his programming test (probably without any
understanding of the underlying mechanisms).

> I have to admit, I haven't been a big object-oriented fan, mainly 
> because I've seen it implemented in scripting languages such as VB and 
> OpenOffice macros.

This is nothing to do with object-orientedness - you can see this in
good old fashioned vanilla 1970's K&R C.  But don't take my word for
it:

#include <stdio.h>
int main ()
{
   char *x = "Hello" ;
   char *y = "Hello" ;
   if ( x == y )
     printf ( "true" ) ;
   else
     printf ( "false" ) ;
}

...what it prints depends on whether the compiler chooses to optimise
for storage space and use the same set of memory locations to store
each of the two "Hello" strings.  It's not specified in the language
whether the compiler is guaranteed to do that - and we know that many
of them do - so it's implementation-dependent. Even within on
implementation (gcc for example), the result depends on what
compilation options you set on the command line when you compile the
sucker and perhaps even which CPU type you are compiling for.  On
my PC with default compilation options, the result is 'true' but if
I compile with "--writable-strings" (which some ancient C programs
still need) then the result is 'false'.

It seems that Java does the same kind of thing for the same reasons.

> In my opinion we've lost sight of the purpose: 
> scripting and macro "languages" were intended to be relatively easy 
> allowing someone with lesser training to do useful automation and, in 
> the process, get a "big bang for the buck".  It seems that the "high 
> priests of object oriented programming" have succeeded in depriving most 
> people of that possibility any more.

Well, very few of these languages REQUIRE you to do things in an object-
oriented fashion.  Java does - but it's the exception.  But I'll have
to disagree with you on the efficacy of OOPS. The encapsulation you get
is what allows less experienced people to use these big class libraries
safely. But that's another debate!




More information about the Discuss mailing list