why is Java the way it is?

This is a discussion on why is Java the way it is? within the Java forums in Programming Languages category; Tom Anderson wrote: > This: > > int place ; > while ((place = s.indexOf(x)) >= 0 ) ... > > Can be written: > > for (int place; (place = s.indexOf(x)) >= 0 ... Or for (int place = s.indexOf(x); place >= 0; place = s.indexOf(x)) Which isn't bad except for the redunancy in the first and third clauses....

Go Back   Application Development Forum > Programming Languages > Java

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #21  
Old 08-27-2008, 07:27 PM
Mike Schilling
Guest
 
Default Re: why is Java the way it is?

Tom Anderson wrote:
> This:
>
> int place ;
> while ((place = s.indexOf(x)) >= 0 ) ...
>
> Can be written:
>
> for (int place; (place = s.indexOf(x)) >= 0 ...


Or

for (int place = s.indexOf(x); place >= 0; place = s.indexOf(x))

Which isn't bad except for the redunancy in the first and third clauses.


Reply With Quote
  #22  
Old 08-27-2008, 10:48 PM
Roedy Green
Guest
 
Default Re: why is Java the way it is?

On Wed, 27 Aug 2008 07:48:26 -0700, Daniel Pitts
<newsgroup.spamfilter@virtualinfinity.net> wrote, quoted or indirectly
quoted someone who said :

>void myMethod() {
> doSomething();
> {
> int foo = 10;
> while (foo < 100) {
> foo = nextFoo(foo);
> }
> // foo is not in scope here.
> doSomethingElse();
>}

The problem you need an ugly extra pair of {}, which even in your case
failed to balance. Figuring out nesting and fixing broken nesting is
by far the syntax feature of Java what wastes the most of my time and
the one that I find hardest just to eyeball.
I suggest some ways out in my Scid project. See
http://mindprod.com/project/scid.html
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Reply With Quote
  #23  
Old 08-27-2008, 10:50 PM
Roedy Green
Guest
 
Default Re: why is Java the way it is?

On Wed, 27 Aug 2008 12:39:23 +0100, Tom Anderson
<twic@urchin.earth.li> wrote, quoted or indirectly quoted someone who
said :

>int x = (int y = 1) + 1;
>
>Isn't legal. This:


Why not? I am not asking about the language as defined now, but what
the language designers might have been thinking when they concocted
the syntax.
--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Reply With Quote
  #24  
Old 08-28-2008, 02:34 AM
Ian Semmel
Guest
 
Default Re: why is Java the way it is?



Roedy Green wrote:
> On Wed, 27 Aug 2008 12:39:23 +0100, Tom Anderson
> <twic@urchin.earth.li> wrote, quoted or indirectly quoted someone who
> said :
>
>> int x = (int y = 1) + 1;
>>
>> Isn't legal. This:

>
> Why not? I am not asking about the language as defined now, but what
> the language designers might have been thinking when they concocted
> the syntax.


They might have considered it and asked "Why on earth would anyone want to write something like that?"
Reply With Quote
  #25  
Old 08-28-2008, 04:00 AM
Andreas Leitgeb
Guest
 
Default Re: why is Java the way it is?

Roedy Green <see_website@mindprod.com.invalid> wrote:
> Figuring out nesting and fixing broken nesting is
> by far the syntax feature of Java what wastes the
> most of my time and the one that I find hardest
> just to eyeball.


What editor do you use? Most editors designed
for coding should have a feature "find matching
paranthese/brace/bracket/...".
In vi, it's "%". I've seen it in ultraedit as well
(but don't remember the keyboard shortcut) and
I'd be surprised, if eclipse and netbeans didn't
have such a feature.

> I suggest some ways out in my Scid project. See
> http://mindprod.com/project/scid.html


&%$/&%$&/Webwasher seems to have decided that your page
belongs to categories: (Politics, Extreme).
(Just for your information. I've got my ways
to still view it, though less convenient)
Reply With Quote
  #26  
Old 08-28-2008, 11:10 AM
Mike Schilling
Guest
 
Default Re: why is Java the way it is?

Andreas Leitgeb wrote:
> Roedy Green <see_website@mindprod.com.invalid> wrote:
>> Figuring out nesting and fixing broken nesting is
>> by far the syntax feature of Java what wastes the
>> most of my time and the one that I find hardest
>> just to eyeball.

>
> What editor do you use? Most editors designed
> for coding should have a feature "find matching
> paranthese/brace/bracket/...".
> In vi, it's "%". I've seen it in ultraedit as well
> (but don't remember the keyboard shortcut) and
> I'd be surprised, if eclipse and netbeans didn't
> have such a feature.


IntelliJ, at least, has the ability to indent the code according to
the nesting level. This makes missing or superfluous braces obvious.


Reply With Quote
  #27  
Old 08-28-2008, 12:13 PM
Tom Anderson
Guest
 
Default Re: why is Java the way it is?

On Wed, 27 Aug 2008, Mike Schilling wrote:

> Tom Anderson wrote:
>> This:
>>
>> int place ;
>> while ((place = s.indexOf(x)) >= 0 ) ...
>>
>> Can be written:
>>
>> for (int place; (place = s.indexOf(x)) >= 0 ...

>
> Or
>
> for (int place = s.indexOf(x); place >= 0; place = s.indexOf(x))
>
> Which isn't bad except for the redunancy in the first and third clauses.


Even worse! More characters duplicated, and a duplication where
differences between the two won't be caught by the compiler - with the
duplicated variable name, they probably will.

tom

--
I have been trying to find a way of framing this but yes, a light meal is
probably preferable to a heavy one under the circumstances. -- ninebelow
Reply With Quote
  #28  
Old 08-28-2008, 12:14 PM
Tom Anderson
Guest
 
Default Re: why is Java the way it is?

On Thu, 28 Aug 2008, Roedy Green wrote:

> On Wed, 27 Aug 2008 12:39:23 +0100, Tom Anderson
> <twic@urchin.earth.li> wrote, quoted or indirectly quoted someone who
> said :
>
>> int x = (int y = 1) + 1;
>>
>> Isn't legal. This:

>
> Why not? I am not asking about the language as defined now, but what
> the language designers might have been thinking when they concocted the
> syntax.


I would guess it just never occurred to them. The model of statements and
expressions, with the former containing the latter but not vice versa, is
a very ancient one, that has generally served us pretty well.

tom

--
I have been trying to find a way of framing this but yes, a light meal is
probably preferable to a heavy one under the circumstances. -- ninebelow
Reply With Quote
  #29  
Old 08-28-2008, 12:37 PM
Stefan Ram
Guest
 
Default Re: why is Java the way it is?

Tom Anderson <twic@urchin.earth.li> writes:
>I would guess it just never occurred to them. The model of
>statements and expressions, with the former containing the
>latter but not vice versa, is a very ancient one, that has
>generally served us pretty well.


In Java, an expression /can/ contain a statement.

In C, »( printf( "a" ), printf( "b" ))« is an expression for
a sequence of evaluations at run time. Something statements
are used for in many other languages.

In LISP languages, there really is no such distinction,
there only are nested lists in the source code (S-expressions).
But some lists are more like statements, other more like expressions.

In Assembler, there only are simple operations, which are more
like statements.

In pure functional languages, there are no statements nor
sequences of evaluations.

In natural language (English), there are noun phrases and
verb phrases, which approximately correspond to expressions
and statements, respectively.

Reply With Quote
  #30  
Old 08-28-2008, 03:07 PM
Martin Gregorie
Guest
 
Default Re: why is Java the way it is?

On Thu, 28 Aug 2008 08:10:48 -0700, Mike Schilling wrote:

> Andreas Leitgeb wrote:
>> Roedy Green <see_website@mindprod.com.invalid> wrote:
>>> Figuring out nesting and fixing broken nesting is by far the syntax
>>> feature of Java what wastes the most of my time and the one that I
>>> find hardest just to eyeball.

>>
>> What editor do you use? Most editors designed for coding should have
>> a feature "find matching paranthese/brace/bracket/...".
>> In vi, it's "%". I've seen it in ultraedit as well (but don't remember
>> the keyboard shortcut) and I'd be surprised, if eclipse and netbeans
>> didn't have such a feature.

>
> IntelliJ, at least, has the ability to indent the code according to the
> nesting level. This makes missing or superfluous braces obvious.


It also indicates the matching brace by momentarily highlighting it.
I like that, the syntax colouring, on-the-fly syntactic and semantic
checks and its refactoring facilities, but I find its straight forward
editing features and cursor movement capabilities disappointing. ymmv,
but IMO its clunky editing really detract from its usability, so much so
that its only marginally better than a non-language-aware editor.


--
martin@ | Martin Gregorie
gregorie. | Essex, UK
org |
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 06:58 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.