Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #21020 > unrolled thread

Re: "Hello world!" without a public class?

Started by"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
First post2013-01-06 13:09 +0000
Last post2013-01-06 10:42 -0500
Articles 13 — 5 participants

Back to article view | Back to comp.lang.java.programmer

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 13:09 +0000
    Re: "Hello world!" without a public class? "Aryeh M. Friedman" <Aryeh.Friedman@gmail.com> - 2013-01-06 05:19 -0800
      Re: "Hello world!" without a public class? "Aryeh M. Friedman" <Aryeh.Friedman@gmail.com> - 2013-01-06 05:28 -0800
        Re: "Hello world!" without a public class? lipska the kat <lipskathekat@yahoo.co.uk> - 2013-01-06 13:36 +0000
        Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 13:44 +0000
          Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 10:49 -0500
            Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 11:45 -0500
            Re: "Hello world!" without a public class? Martin Gregorie <martin@address-in-sig.invalid> - 2013-01-06 19:44 +0000
              Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 16:09 -0500
                Re: "Hello world!" without a public class? Martin Gregorie <martin@address-in-sig.invalid> - 2013-01-06 21:46 +0000
    Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 14:02 +0000
    Re: "Hello world!" without a public class? "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2013-01-06 14:12 +0000
    Re: "Hello world!" without a public class? Arne Vajhøj <arne@vajhoej.dk> - 2013-01-06 10:42 -0500

#21020 — Re: "Hello world!" without a public class?

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2013-01-06 13:09 +0000
SubjectRe: "Hello world!" without a public class?
Message-ID<-8CdnaTS2P6a5HTNnZ2dnUVZ8vOdnZ2d@bt.com>
Stefan Ram wrote:

>  There is no »public« in front of »class« in Oracles Tutorial!
>
>  What should I teach in my classes?

I don't have a strong opinion on how the class should be declared, but I do 
think -- and very strongly -- that the Java entry-point convention is a massive 
kludge, highly non-representative of how any sane OO code would be written, and 
not at all an example to be followed.  As such, I think it would benefit your 
students if you made that very clear to them from the start (yes, there is a 
risk of confusion, but no student will be confused who wouldn't otherwise 
probably be mislead -- which is worse).

FWIW: the examples in the JLS3 all use an default access class to house the 
(specified to be required) public static void main(String args...) or public 
static void main(String[] args) entry-point.  The spec does not appear to care 
what access the class itself has (and there's no obvious reason -- technical or 
semantic -- why it should).  Does "private" work ?  If so then using that would 
be defensible.

    -- chris 

[toc] | [next] | [standalone]


#21021

From"Aryeh M. Friedman" <Aryeh.Friedman@gmail.com>
Date2013-01-06 05:19 -0800
Message-ID<8f48da51-0eac-42cf-ab1e-f44b3cefac01@googlegroups.com>
In reply to#21020
On Sunday, January 6, 2013 8:09:45 AM UTC-5, Chris Uppal wrote:
> Stefan Ram wrote:
> 
> 
> 
> >  There is no �public� in front of �class� in Oracles Tutorial!
> 
> >
> 
> >  What should I teach in my classes?
> 
> 
> 
> I don't have a strong opinion on how the class should be declared, but I do 
> 
> think -- and very strongly -- that the Java entry-point convention is a massive 
> 
> kludge, 

It makes sense for historical reasons (it was designed to model the Unix/C convention [likely a hold over before the JVM itself was created]).

> 
> 
> FWIW: the examples in the JLS3 all use an default access class to house the 
> 
> (specified to be required) public static void main(String args...) or public 
> 
> static void main(String[] args) entry-point.  The spec does not appear to care 
> 
> what access the class itself has (and there's no obvious reason -- technical or 
> 
> semantic -- why it should).  Does "private" work ?  If so then using that would 
> 
> be defensible.

And no *SANE* person would use the JLS to teach the language from!  That being said private is allowed for inner classes but no where else I think

[toc] | [prev] | [next] | [standalone]


#21022

From"Aryeh M. Friedman" <Aryeh.Friedman@gmail.com>
Date2013-01-06 05:28 -0800
Message-ID<d87371ee-a671-407e-96cf-f506e53fcb89@googlegroups.com>
In reply to#21021
Comments on entery point and teaching Java:
<snip>

> It makes sense for historical reasons (it was designed to model the Unix/C convention [likely a hold over before the JVM itself was created]).

Even though I detest IDE's for actual professional use when I learned Java (to save money I decided to do it through the local community college since I already had a CS background) they used BlueJ and one feature it had really helped in this regard... the feature being that you where allowed in instantiate any class from the IDE directly and needed no wrapping classes/main/etc. this was of great benefit to the students who where in their first programming class, I did some tutoring of the newer students, (it did hinder them slightly when they transferred to Sr. colleges but I think the trade off was worth it)... also note that Micheal Koling [author of BlueJ] has  an companion text "Objects First" [I forget the full title] that is a very good graceful but complete introduction to Java/OO.

[toc] | [prev] | [next] | [standalone]


#21024

Fromlipska the kat <lipskathekat@yahoo.co.uk>
Date2013-01-06 13:36 +0000
Message-ID<B_KdnX5Jr9J84HTNnZ2dnUVZ7t2dnZ2d@bt.com>
In reply to#21022
On 06/01/13 13:28, Aryeh M. Friedman wrote:

> Micheal Koling [author of BlueJ] has  an companion text "Objects First"

http://www.bluej.org/objects-first/

-- 
Lipska the Kat©: Troll hunter, sandbox destroyer
and farscape dreamer of Aeryn Sun

[toc] | [prev] | [next] | [standalone]


#21025

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2013-01-06 13:44 +0000
Message-ID<kOWdnXkvJPMn4nTNnZ2dnUVZ8judnZ2d@bt.com>
In reply to#21022
Aryeh M. Friedman wrote:

> Even though I detest IDE's for actual professional use when I learned
> Java (to save money I decided to do it through the local community
> college since I already had a CS background) they used BlueJ and one
> feature it had really helped in this regard... the feature being that you
> where allowed in instantiate any class from the IDE directly and needed
> no wrapping classes/main/etc. this was of great benefit to the students
> who where in their first programming class, I did some tutoring of the
> newer students, (it did hinder them slightly when they transferred to Sr.
> colleges but I think the trade off was worth it)... also note that
> Micheal Koling [author of BlueJ] has  an companion text "Objects First"
> [I forget the full title] that is a very good graceful but complete
> introduction to Java/OO.

If I were required to teach Java, then I would be very likely to use BlueJ, for 
that and any many other reasons which collectively can be summed up as "you 
can't teach a OO language properly without teaching OO properly".

I doubt if I would even mention public static void main(String args...) until 
very late in the course -- sometime around the point that I started to talk 
about JNI and after we had covered J2EE.

(OK, that's a slight exaggeration ;-)

    -- chris 

[toc] | [prev] | [next] | [standalone]


#21034

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-06 10:49 -0500
Message-ID<50e99d08$0$284$14726298@news.sunsite.dk>
In reply to#21025
On 1/6/2013 8:44 AM, Chris Uppal wrote:
> Aryeh M. Friedman wrote:
>> Even though I detest IDE's for actual professional use when I learned
>> Java (to save money I decided to do it through the local community
>> college since I already had a CS background) they used BlueJ and one
>> feature it had really helped in this regard... the feature being that you
>> where allowed in instantiate any class from the IDE directly and needed
>> no wrapping classes/main/etc. this was of great benefit to the students
>> who where in their first programming class, I did some tutoring of the
>> newer students, (it did hinder them slightly when they transferred to Sr.
>> colleges but I think the trade off was worth it)... also note that
>> Micheal Koling [author of BlueJ] has  an companion text "Objects First"
>> [I forget the full title] that is a very good graceful but complete
>> introduction to Java/OO.
>
> If I were required to teach Java, then I would be very likely to use BlueJ, for
> that and any many other reasons which collectively can be summed up as "you
> can't teach a OO language properly without teaching OO properly".

I am highly skeptical about BlueJ.

I have seen so many new Java programmers learning BlueJ and then
not being able to do anything, because they did not understand
classpath, what is Java vs what is IDE etc..

To make a car analogy (!): they know how the engine and the brakes
works, but they don't know how to turn the ignition key or
actually turn the steering wheel.

Arne

[toc] | [prev] | [next] | [standalone]


#21038

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-06 11:45 -0500
Message-ID<50e9aa12$0$285$14726298@news.sunsite.dk>
In reply to#21034
On 1/6/2013 11:14 AM, Stefan Ram wrote:
> Arne Vajhøj <arne@vajhoej.dk> writes:
>> I have seen so many new Java programmers learning BlueJ and then
>> not being able to do anything, because they did not understand
>> classpath, what is Java vs what is IDE etc..
>
>    The course announcement of my classes announce clearly that
>    the participants do not need to have programming knowledge
>    but need to know how to work with the operating system.
>
>    However, in reality often they do not know what the meaning
>    of the PATH environment variable is. Sometimes, they even do
>    not know how to create a text file, how to edit a text file,
>    how to use the clipboard to transfer text and so on. So I am
>    often forced to give a kind of Windows training, but since
>    the time for the whole beginner's Java course is very small
>    (about 18 hours), I hate to waste any time teaching Windows
>    instead of Java, which is also boring for those participants
>    who already know this.
>
>    So, in the next course I will try to use a Java online
>    compiler for the first steps. No need to setup any software
>    at all. Just paste or type the code into the web page and
>    press »compile«. The participants can do this from home, too.
>    No need for any preparation. One can start with Java
>    immediately, which is very good for a course announced as
>    a Java course, since that's what one is expecting from it.
>
>    Someone who has learned the language Java, but not the
>    meaning of the CLASSPATH environment variable, can learn the
>    meaning of the CLASSPATH environment variable whenever he
>    needs it for the first time. Not learning it right from the
>    start does not impede learning it anytime later.

In theory you are absolutely right.

Getting a good start on OO should be the focus and not the
trivial stuff of getting external jar files added to classpath.

But my practical experience from various help forums is that many
of those BlueJ users never learn the practical stuff and instead
give up on Java.

In that regard it is very similar to those learning PHP and
MySQL by installing one of the popular XAMP packages. They are
up and running in 5 minutes. But when they run into something that
require them to change httpd.conf or php.ini then half of them
give up.

There are obviously caveats:
1) I only know about success rate among those that encounter
    problems - I have no way of knowing about how many that do
    encounter problems
2) Making is difficult should not be taken too far - having
    everybody writing Ada95 code using COPY CON: Foobar.ada
    would certainly not be good

If I were to teach Java for an entire semester, then I would
do the first month with a standard editor and command line
build and run to learn them how things work and then switch them
to a standard Java IDE after that (I like Eclipse, but NetBeans
and IntelliJ would certainly do as well) - sure the options
can be a bit scary, but they are on a path they can continue
on and if they need help, then it is a hell lot easier to
get it for Eclipse/NetBeans than for BlueJ.

Arne

[toc] | [prev] | [next] | [standalone]


#21060

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2013-01-06 19:44 +0000
Message-ID<kcck67$6f4$1@localhost.localdomain>
In reply to#21034
On Sun, 06 Jan 2013 10:49:26 -0500, Arne Vajhøj wrote:

> I have seen so many new Java programmers learning BlueJ and then not
> being able to do anything, because they did not understand classpath,
> what is Java vs what is IDE etc..
> 
I'd probably go further and start students with a decent text editor and 
command line calls for javac/java on the grounds that right from the 
start they'll have a better understanding of the Java compilation and 
runtime environment. 

Once they're starting to write class hierarchies its time to introduce 
packages, ant and jar. Why now? Because I found the later introduction of 
these items to be confusing, requiring, as they did, a certain amount of 
unlearning, particularly in connection with jar files, manifests and 
classpaths.

I don't think students need to see an IDE until they start to find out 
about refactoring. Again, I'd leave this as late ads possible for two 
reasons: (1) IDEs generally have complex GUIs which can be quite 
intimidating to a newbie, (2) they kick entirely too much stuff that a 
programmer needs to know under the carpet: the build process, jarfile 
creation, package management, version control - all things that I think 
are best dealt with explicitly rather than being left to the IDE's magic 
smoke and mirrors.


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

[toc] | [prev] | [next] | [standalone]


#21074

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-06 16:09 -0500
Message-ID<50e9e826$0$290$14726298@news.sunsite.dk>
In reply to#21060
On 1/6/2013 2:44 PM, Martin Gregorie wrote:
> On Sun, 06 Jan 2013 10:49:26 -0500, Arne Vajhøj wrote:
>> I have seen so many new Java programmers learning BlueJ and then not
>> being able to do anything, because they did not understand classpath,
>> what is Java vs what is IDE etc..
>>
> I'd probably go further and start students with a decent text editor and
> command line calls for javac/java on the grounds that right from the
> start they'll have a better understanding of the Java compilation and
> runtime environment.
>
> Once they're starting to write class hierarchies its time to introduce
> packages, ant and jar. Why now? Because I found the later introduction of
> these items to be confusing, requiring, as they did, a certain amount of
> unlearning, particularly in connection with jar files, manifests and
> classpaths.
>
> I don't think students need to see an IDE until they start to find out
> about refactoring. Again, I'd leave this as late ads possible for two
> reasons: (1) IDEs generally have complex GUIs which can be quite
> intimidating to a newbie, (2) they kick entirely too much stuff that a
> programmer needs to know under the carpet: the build process, jarfile
> creation, package management, version control - all things that I think
> are best dealt with explicitly rather than being left to the IDE's magic
> smoke and mirrors.

I agree that text editor and command line tools are important
to (see post I made after the one you replied to).

But when they have learned the basics, then they know what is
under the carpet and should start utilizing the benefits of the
IDE.

And people know sophisticated GUI's from other applications.

Arne

[toc] | [prev] | [next] | [standalone]


#21079

FromMartin Gregorie <martin@address-in-sig.invalid>
Date2013-01-06 21:46 +0000
Message-ID<kccrb0$8mf$1@localhost.localdomain>
In reply to#21074
On Sun, 06 Jan 2013 16:09:58 -0500, Arne Vajhøj wrote:

> I agree that text editor and command line tools are important to (see
> post I made after the one you replied to).
>
Yep, saw it a post or few later.
 
> But when they have learned the basics, then they know what is under the
> carpet and should start utilizing the benefits of the IDE.
>
No argument with this, though I'd add that it should be easier to move 
between IDEs if you know the underlying stuff than if you don't - and its 
unlikely that anybody will use just the one IDE.
 
> And people know sophisticated GUI's from other applications.
>
True. However, if Java is their first programming language (and this is 
the target audience for this thread) its unlikely that they'll have used 
an IDE with a similar complexity or density of displayed information.
  
I'd rate programming IDEs and CAD systems as having the most complex GUIs 
I've used by a fair margin, with graphical apps (e.g. the GIMP, Paintshop 
Pro or Lview) coming next. Everything else, ranging from the Audacity 
mixing desk through SQL tools such as Embarcadero Rapid SQL are much 
simpler: little more complex than a decent graphical text editor or Libre 
Office/Office.


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

[toc] | [prev] | [next] | [standalone]


#21028

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2013-01-06 14:02 +0000
Message-ID<y72dncgdN-_lGXTNnZ2dnUVZ7tGdnZ2d@bt.com>
In reply to#21020
Stefan Ram wrote:
> "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> writes:
> > students if you made that very clear to them from the start (yes, there
> > is a
>
>  I have no idea what you would prefer instead, but I just
>  made up this:
>
>  Rename »java.exe« (the JVM) to »new.exe« and modify the
>  interpretation of its command line arguments so that one can
>  write on the command line:
>
> new Main().start()

Or maybe (simpler, but less Java-like):

    javaNew.exe class-name method-name [arguments...]

Note that there's no need to mess with the JVM for these purposes, it only 
requires a special-purpose launcher program to replace java.exe.  The source to 
java.exe is provided, it's a simple JNI program, and is explicitly open for you 
to copy/modify/reuse without special licencing arrangements (at least that used 
to be true, haven't checked whether Oracle have changed anything).

But that might be overkill (however attractive).  Maybe simpler just to tell 
students always to write their entry-point in the form:

    class Xxx {
        public static void main(String args...)
        {
            new Yyy().doSomething();
        }
    }

(note that the entry-point class always contains main() and nothing else) and 
to treat that pattern as "magic".  Late in the course, after they've got a 
solid grounding in OO and (even later) you've talked about things like static 
methods (and why they are often a bad idea), you can explain what's going on 
with main().  With luck, by that point the students will be able to see that 
it's highly non-typical of Java code, and breaks several "rules", but (by then) 
you'll also be able to explain /why/ it's such a special case.

(All just ideas, of course, I am /not/ an educator, let alone an 
educationalist)

    -- chris 

[toc] | [prev] | [next] | [standalone]


#21029

From"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org>
Date2013-01-06 14:12 +0000
Message-ID<M-Sdnb3BCqH9G3TNnZ2dnUVZ8n-dnZ2d@bt.com>
In reply to#21020
Stefan Ram wrote:
> ram@zedat.fu-berlin.de (Stefan Ram) writes:
> > , where the parameterlist might be empty and might contain
> > literals, instance creation expressions and method invocations
> > (a very small subset of Java, which can be implemented easily).
>
>  Which also might open the world of amazing »Java one-liners«,
>  where JavaSE methods are invoked from the command line without
>  any actual user code to do something useful.

BeanShell ?

(http://www.beanshell.org/intro.html)

    -- chris 

[toc] | [prev] | [next] | [standalone]


#21033

FromArne Vajhøj <arne@vajhoej.dk>
Date2013-01-06 10:42 -0500
Message-ID<50e99b78$0$284$14726298@news.sunsite.dk>
In reply to#21020
On 1/6/2013 8:09 AM, Chris Uppal wrote:
> Stefan Ram wrote:
>
>>   There is no »public« in front of »class« in Oracles Tutorial!
>>
>>   What should I teach in my classes?
>
> I don't have a strong opinion on how the class should be declared, but I do
> think -- and very strongly -- that the Java entry-point convention is a massive
> kludge, highly non-representative of how any sane OO code would be written, and
> not at all an example to be followed.

It is obviously C/C++ inspired.

But I don't see it as being that bad.

Static makes perfectly sense in the context.

Obviously one could prefer the method name to be
specified to the JVM instead of having a magic value
"main".

But to me that is an uninteresting totally insignificant
issue.

Arne

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.programmer


csiph-web