How to write Java style classes in C++

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • aardappel

    #1

    How to write Java style classes in C++

    Some of you may enjoy this style of programming:



    I am aware that this post will generate a lot of complaints that this
    is not how one is "supposed" to program C++, but if you do, please
    quantify why you think its bad :)

  • Julián Albo

    #2
    Re: How to write Java style classes in C++

    aardappel wrote:
    [color=blue]
    > is not how one is "supposed" to program C++, but if you do, please
    > quantify why you think its bad :)[/color]

    Is easy: if you want the style of another language, just use that language,
    or design another one with the same ideas.

    --
    Salu2

    Comment

    • Dirk Bruere at Neopax

      #3
      Re: How to write Java style classes in C++

      Julián Albo wrote:
      [color=blue]
      > aardappel wrote:
      >
      >[color=green]
      >>is not how one is "supposed" to program C++, but if you do, please
      >>quantify why you think its bad :)[/color]
      >
      >
      > Is easy: if you want the style of another language, just use that language,
      > or design another one with the same ideas.[/color]

      Perhaps you could point me to some realtime Java compilers for various uP in
      that case...?

      --
      Dirk

      The Consensus:-
      The political party for the new millenium

      Comment

      • Mike Smith

        #4
        Re: How to write Java style classes in C++

        Dirk Bruere at Neopax wrote:[color=blue]
        > Julián Albo wrote:
        >[color=green]
        >> aardappel wrote:
        >>
        >>[color=darkred]
        >>> is not how one is "supposed" to program C++, but if you do, please
        >>> quantify why you think its bad :)[/color]
        >>
        >>
        >>
        >> Is easy: if you want the style of another language, just use that
        >> language,
        >> or design another one with the same ideas.[/color]
        >
        >
        > Perhaps you could point me to some realtime Java compilers for various
        > uP in that case...?[/color]

        Then write in C++, not Java.

        --
        Mike Smith

        Comment

        • KeithSpook

          #5
          Re: How to write Java style classes in C++

          aardappel wrote:[color=blue]
          > Some of you may enjoy this style of programming:
          >
          > http://strlen.com/rants/javaclassesincpp.html
          >
          > I am aware that this post will generate a lot of complaints that this
          > is not how one is "supposed" to program C++, but if you do, please
          > quantify why you think its bad :)[/color]

          It would be really easy to catch "traditiona l" C++ programmers off
          guard with some of these constructs... Especially the

          struct something {
          #include "ALotOfStuf f.h"
          #include "SomeMoreStuff. h"
          };

          If I saw that in production code, I would resign on the spot and become
          a cabby in Tbilisi.

          Also, in Java the idea is that everything is in a class. Sure, one can
          do this in C++:
          #include <iostream>

          class Application {
          void Run() {
          std::cout << "Never mind main()! Use global objects!\n"
          }
          public:
          Application() {
          Run();
          }
          } myGlobalApplica tion;

          int main() { return 0; }

          But the net gain is a loss. Seems silly to me to ignore the ability to
          use free functions in C++...

          ~KS

          Comment

          • Julián Albo

            #6
            Re: How to write Java style classes in C++

            Dirk Bruere at Neopax wrote:
            [color=blue][color=green]
            >> Is easy: if you want the style of another language, just use that
            >> language, or design another one with the same ideas.[/color]
            > Perhaps you could point me to some realtime Java compilers for various uP
            > in that case...?[/color]

            No. Ask in a more adequate group, search the web... or write one.

            --
            Salu2

            Comment

            • Dirk Bruere at Neopax

              #7
              Re: How to write Java style classes in C++

              Julián Albo wrote:
              [color=blue]
              > Dirk Bruere at Neopax wrote:
              >
              >[color=green][color=darkred]
              >>>Is easy: if you want the style of another language, just use that
              >>>language, or design another one with the same ideas.[/color]
              >>
              >>Perhaps you could point me to some realtime Java compilers for various uP
              >>in that case...?[/color]
              >
              >
              > No. Ask in a more adequate group, search the web... or write one.
              >[/color]
              Well, unfortunately I have to get real stuff done for real money to real timescales.

              --
              Dirk

              The Consensus:-
              The political party for the new millenium

              Comment

              • Dirk Bruere at Neopax

                #8
                Re: How to write Java style classes in C++

                Mike Smith wrote:
                [color=blue]
                > Dirk Bruere at Neopax wrote:
                >[color=green]
                >> Julián Albo wrote:
                >>[color=darkred]
                >>> aardappel wrote:
                >>>
                >>>
                >>>> is not how one is "supposed" to program C++, but if you do, please
                >>>> quantify why you think its bad :)
                >>>
                >>>
                >>>
                >>>
                >>> Is easy: if you want the style of another language, just use that
                >>> language,
                >>> or design another one with the same ideas.[/color]
                >>
                >>
                >>
                >> Perhaps you could point me to some realtime Java compilers for various
                >> uP in that case...?[/color]
                >
                >
                > Then write in C++, not Java.[/color]

                So, some reason why I should not take up the suggestion offered by the original
                poster in order to make life easier?

                --
                Dirk

                The Consensus:-
                The political party for the new millenium

                Comment

                • Luke Meyers

                  #9
                  Re: How to write Java style classes in C++

                  Dirk Bruere at Neopax wrote:[color=blue]
                  > Julián Albo wrote:[color=green]
                  > > Dirk Bruere at Neopax wrote:[color=darkred]
                  > >>Perhaps you could point me to some realtime Java compilers for various uP
                  > >>in that case...?[/color]
                  > >
                  > > No. Ask in a more adequate group, search the web... or write one.
                  > >[/color]
                  > Well, unfortunately I have to get real stuff done for real money to real timescales.[/color]

                  So do many of us, but that doesn't mean we get snippy when someone
                  advises us that posting a question in comp.lang.c++ about the
                  availability of Java compilers is a bit misguided. Creates a bit of a
                  signal-to-noise problem for those of us reading this thread to see
                  responses to the OP's idea.

                  Luke

                  Comment

                  • Julián Albo

                    #10
                    Re: How to write Java style classes in C++

                    Dirk Bruere at Neopax wrote:
                    [color=blue][color=green]
                    >> Then write in C++, not Java.[/color]
                    >
                    > So, some reason why I should not take up the suggestion offered by the
                    > original poster in order to make life easier?[/color]

                    Your code will be difficult to read and understand for both Java and C++
                    programmers.

                    --
                    Salu2

                    Comment

                    Working...