Java is a stupid language

  • Thread starter Jussi Jumppanen
  • Start date
J

Jussi Jumppanen

An example of why Java is a stupid overly complicated
programming language:

import java.io.*;

public class SimpleJavaQuestion
{
public static void main(String[] args)
{
try
{
String line = "";

// surely the first character of the line is not a '#' character
if (line.charAt(0) != '#')
{
System.out.println("Never expect the obvious....");
}
}
catch (Exception e)
{
// stupid me. there is no first character, how obvious!!!!!
System.out.println("When the unexpected is far more interesting.");
}
}
}
 
M

Mike Schilling

Jussi Jumppanen said:
An example of why Java is a stupid overly complicated
programming language:

import java.io.*;

public class SimpleJavaQuestion
{
public static void main(String[] args)
{
try
{
String line = "";

// surely the first character of the line is not a '#' character
if (line.charAt(0) != '#')
{
System.out.println("Never expect the obvious....");
}
}
catch (Exception e)
{
// stupid me. there is no first character, how obvious!!!!!
System.out.println("When the unexpected is far more interesting.");
}
}
}

if (!line.startsWith("#"))

works much better. java.util.regex will work for more complex
pattern-matching.
 
R

Roedy Green

An example of why Java is a stupid overly complicated
programming language:

and if you were designing the language how would that work? What could
charAt return when there was no character? 0?

If it did that, how would be able to test for an embedded 0 char?
 
J

jan V

An example of why Java is a stupid overly complicated
programming language:

import java.io.*;

Adding unnecessary imports will definitely undermine the validity of your
already-suspect argument.

Why don't you deal with your negative opinion of Java elsewhere? The vast
majority of people in this newsgroup are Java fans, and you knew that
perfectly well given your deliberately inflammatory subject line.
 
F

Filip Larsen

Jussi Jumppanen wrote
An example of why Java is a stupid overly complicated
programming language

Whenever you get that feeling (using any general purpose programming
language) it is a fairly safe bet that you need improve your knowledge
of the language and its API. Complaining about how stupid shoes are
because you have to use half a roll of duct tape to secure them to your
feet tells more about you not knowing about shoe laces than about shoes
being badly designed.


Regards,
 
E

ErikFK

Hi,
An example of why Java is a stupid overly complicated
programming language

English is a stupid language - compared to German (for example):
.... here missing example of something that is easier to say in German
than in English ...

French is far better than German (for example):
.... here missing example of something that is easier to say in French
than in German...

Java is easier to understand than APL
....here missing example of something that is easier to understand in
Java than in APL...

This leads absolutely nowhere. If you are frustrated, have a walk,
change your job, your girlfriend or whatever - who cares.

Lots of ;-).

Erik
 
R

Roland

An example of why Java is a stupid overly complicated
programming language:

import java.io.*;

public class SimpleJavaQuestion
{
public static void main(String[] args)
{
try
{
String line = "";

// surely the first character of the line is not a '#' character
if (line.charAt(0) != '#')
{
System.out.println("Never expect the obvious....");
}
}
catch (Exception e)
{
// stupid me. there is no first character, how obvious!!!!!
System.out.println("When the unexpected is far more interesting.");
}
}
}

You give an example but yet you fail to explain what you think is
"stupid" and/or "overly complicated" in this example.
Maybe "stupidity" is in the eye of the beholder :) .
--
Regards,

Roland de Ruiter
` ___ ___
`/__/ w_/ /__/
/ \ /_/ / \
 
W

Wibble

Roland said:
An example of why Java is a stupid overly complicated
programming language:

import java.io.*;

public class SimpleJavaQuestion
{
public static void main(String[] args)
{
try
{
String line = "";

// surely the first character of the line is not a '#' character
if (line.charAt(0) != '#')
{
System.out.println("Never expect the obvious....");
}
}
catch (Exception e)
{
// stupid me. there is no first character, how obvious!!!!!
System.out.println("When the unexpected is far more interesting.");
}
}
}


You give an example but yet you fail to explain what you think is
"stupid" and/or "overly complicated" in this example.
Maybe "stupidity" is in the eye of the beholder :) .
Its not that the language is stupid. You're just saying something
stupid in the language. By that definition, any language in which
you can say something stupid is stupid. That leaves...
 
J

jussij

Roedy said:
and if you were designing the language how would
that work? What could charAt return when there was
no character? 0?

It could return a nil value.

The nil could be an object, a value, anything you like,
but the point is, provided the function returned somthing
then you always have something to compared.

Thus code like this would even work:

if (line.charAt(0) == nil)
else if (line.charAt(0) == 'a')
else if (line.charAt(0) == 'b')
else if (line.charAt(0) == 'c')
....

It is just seems stupid to have to write two lines of
code when at a progrmming logic level only one exists.

If a string is empty string then obviously the
first character of the string is not going to
be a '#' character.

These types of coding construct are so common it seems
stupid that the best the language can offer is the use
of a string object, a regular expression and the starts
with function.

It aint pretty but at least it does achieve the desired
result of having a one line of code solution.
 
T

Thomas Fritsch

Roedy Green wrote:




It could return a nil value.

The nil could be an object, a value, anything you like,
but the point is, provided the function returned somthing
then you always have something to compared.

Thus code like this would even work:

if (line.charAt(0) == nil)
else if (line.charAt(0) == 'a')
else if (line.charAt(0) == 'b')
else if (line.charAt(0) == 'c')
....
Again, exactly what value should your 'nil' be? It cannot be any of the
char range ['\u0000' to '\uFFFF'], and it cannot be of another type,
both because the charAt method is declared to return a char.
May be your mind is pre-conditioned by C-language, where '\0' char
serves as that kind of 'nil' (which by convention means no char).
Have you ever tried to handle strings with '\0's (I mean as *part* of
the string, not denoting the *end* of the string) with the C-library?
When you think deeper about this, you will find C is a lot more stupid
than Java.
 
D

Daniel P. Kionka

Wibble said:
Its not that the language is stupid. You're just saying something
stupid in the language. By that definition, any language in which
you can say something stupid is stupid. That leaves...


"Stupid is as stupid does." --Forrest Gump
 
C

Chris Uppal

Thomas said:
Again, exactly what value should your 'nil' be? It cannot be any of the
char range ['\u0000' to '\uFFFF'], and it cannot be of another type,
both because the charAt method is declared to return a char.

and the primitive types are not objects so nil is never acceptable as a value.
But note that this can be seen as rather strong evidence /for/ Jussi's overall
thesis...

(BTW, I think there are some values in that range that are illegal, in the
sense than any Unicode implementation is required to detect and disallow them,
so -- being particularly pedantic -- I suppose there are values available for
use as 'nil' values ;-)

-- chris
 
D

Dimitri Maziuk

(e-mail address removed) sez:
It could return a nil value.

Google for "two's complement" and think of nil char. Or integer.
Or boolean. It gets better when you do JDBC and fetch a NULL of
any of the above types.

The
if( (str == null) || (str.length() < 1) )
construct is fun, too, esp. if str is declared but not initialized
(thankfully, Java compiler catches that. Other languages, OTOH...)

HTH
Dima
 
R

Raymond Martineau

May be your mind is pre-conditioned by C-language, where '\0' char
serves as that kind of 'nil' (which by convention means no char).
Have you ever tried to handle strings with '\0's (I mean as *part* of
the string, not denoting the *end* of the string) with the C-library?

That's where C++ comes in - it creates a string class which should not
phased by nulls. Even if it is, it's minimal problem to change that by
creating your own string class.
When you think deeper about this, you will find C is a lot more stupid
than Java.

Not really - if you want to have strings containing '\0', you just need to
ensure that there's a consistant method of accessing those strings without.
For example, havinc a counter that has the number of characters. Other
methods are possible (and work well enough.)
 
J

John Currier

Raymond said:
That's where C++ comes in - it creates a string class which should not
phased by nulls. Even if it is, it's minimal problem to change that by
creating your own string class.

If that's your solution then the OP can simply write their own string
class with a charAt() method that acts the way he wants. (ducking as
the discussion moves to operating overloading...)
Not really - if you want to have strings containing '\0', you just need to
ensure that there's a consistant method of accessing those strings without.
For example, havinc a counter that has the number of characters. Other
methods are possible (and work well enough.)

True, but the standard C libraries don't provide that functionality. I
think the OP was talking about the behavior of built-in libraries.

John
http://schemaspy.sourceforge.net
 
W

Wibble

Raymond said:
That's where C++ comes in - it creates a string class which should not
phased by nulls. Even if it is, it's minimal problem to change that by
creating your own string class.




Not really - if you want to have strings containing '\0', you just need to
ensure that there's a consistant method of accessing those strings without.
For example, havinc a counter that has the number of characters. Other
methods are possible (and work well enough.)
At least C never throws NullPointerExceptions. ;^)
 
W

Wil Hadden

It could return a nil value.

The nil could be an object, a value, anything you like,
but the point is, provided the function returned somthing
then you always have something to compared.

Thus code like this would even work:

if (line.charAt(0) == nil)
else if (line.charAt(0) == 'a')
else if (line.charAt(0) == 'b')
else if (line.charAt(0) == 'c')
....

It is just seems stupid to have to write two lines of
code when at a progrmming logic level only one exists.

In this case sloppy programmers would then write code that uses that nil as
a valid character, it would be a very easy mistake to make, much like error
return codes in C, ala read.

I see what you're getting at, in that the string should take care of itself
and not put the burden of checking for the case of an empty string on the
programmer, but 99% of the time, if a program finds itself working with an
empty object when one is not explicitly expected then the programmer didn't
really know what is happening in their program, usually through a lack of
design.
 
T

Tor Iver Wilhelmsen

Wibble said:
At least C never throws NullPointerExceptions. ;^)

I don't see how a crash resulting from EACCESVIOLATION or SEGFAULT is
any better.

C++ "fixed" null pointer problems by introducing non-null references -
but these can be cast away to nullable pointers AFAIK...
 
M

Mike Schilling

Tor Iver Wilhelmsen said:
I don't see how a crash resulting from EACCESVIOLATION or SEGFAULT is
any better.

C++ "fixed" null pointer problems by introducing non-null references -
but these can be cast away to nullable pointers AFAIK..

Well, no. C++ references and pointers are quite different things, used for
different purposes, and fixing null pointers isn't why references were
introduced.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,259
Messages
2,571,035
Members
48,768
Latest member
first4landlord

Latest Threads

Top