Re: C++ vs Java


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Re: C++ vs Java

  1. #1
    Michael Guest

    Re: C++ vs Java


    Hi Tricia,

    I've been a programmer for 35 years, and I'm competent in C, C++, COBOL,
    BASIC, JAVA, PL/1 and others. Here are some things the other people haven't
    mentioned.

    As was mentioned, in C and C++ the programmer is responsible for allocating
    and freeing memory. That memory is usually accessed with a "pointer," a variable
    with a memory address in it. I've heard it said more than once that the vast
    majority of bugs in C and C++ have to do with memory allocation and reference
    errors. My own experience seems to bear that out. One of your respondents
    mentioned that JAVA and C# use garbage collection. That means that the programmer
    never allocates or frees memory, and never deals with pointers. I've found
    that with JAVA, I no longer produce some of the horrific bugs that I did
    with C/C++.

    Programming languages have evolved over time, trying (IMHO) to do two things.
    1. - create a language that mimics the way the programmer thinks, and 2.
    - guide the programmer’s style of design and coding.

    #1 was the idea behind the first modern (“third generation”) programming
    language, FORTRAN (“FORmula TRANslation). Statements in FORTRAN are algebraic
    equations, which mimics the way an engineer thinks. The next major one was
    COBOL, which attempted to mimic the way business accountants think: Statements
    look like English.

    #2 is actually a significant driving force in the evolution of languages,
    and often changes the way that programmers think (thus affecting what happens
    in #1). Researchers have discovered that style of programming has a significant
    impact on the quality of software. There’ve been at least three revolutions
    in programming style.

    The first happened in the 50s, I think (it was before my time), and was called
    “top-down” programming. It meant that you started with the most general concept
    (like a payroll system) and you coded functions at that general level (functions
    like “produce payroll check”) even before you’ve created the lower level
    routines (like “calculate deductions” and “print”). This meant you had to
    write dummy programs (called “stubs”) for the lower level routines. This
    is sometimes called “functional” programming because it sees the parts of
    the software as a set of functions: “do this function, then do that one.”


    The second revolution, called “Structured Programming,” hit the software
    business pretty hard in the early 70s, and we’ve never been the same. It
    was controversial for a while (because people don’t like to give up old habits),
    but now it’s so common that the name is not even used anymore. Everyone practices
    structured programming, but doesn’t know it. To write an unstructured program,
    you need a “goto” statement, which doesn’t even exist in JAVA. I would love
    to show you what a “spaghetti” program looks like. If you follow the thread
    of execution, it actually looks like a bowl of spaghetti. When the term "spaghetti"
    was first used, everyone laughed long and loud. Nobody had to explain it
    to us. We all knew that it referred to our own code.

    So when we combined Top-Down with Structured, it was like a regime change.
    It literally was a new way of looking at the world. The “case” statement
    was invented to facilitate structured programming. “Goto,” which once had
    been an essential concept, was now an obscene word. Modula-2 was designed
    without it, partially out of arrogance of the inventor (“I won’t have any
    gotos on my record,” or something like that). We all thought that we had
    learned the ultimate programming style, one that would free us from buggy
    code and long development schedules. Today, it’s not the ultimate style.
    It’s just good programming practice.

    The next revolution was Object Oriented. It began with a language called
    “Simscript,” which was for writing simulations. Objects are natural in simulation.
    If you want to simulate traffic, for example, you want to have objects called
    “cars.” Again, we had to completely change the way we viewed the world. Object
    orientation, by nature, is contrary to the functional view. In fact, it made
    top-down obsolete. With objects, the best way to design is bottom-up: Start
    with the detailed stuff, and work your way up to the more general. So it
    literally turned the old way of thinking on its head.

    (C++ is the object-oriented version of C)

    At least two languages were inspired directly by Simscript. The ones I know
    are SmallTalk and Eiffel. SmallTalk is the most famous, but Eiffel is still
    going strong and has a loyal following. A new version of Eiffel even works
    with the .NET framework.

    One of your respondents pointed out that you can still write non-object code
    in JAVA. That's true, but it misses the point. When you learn to code in
    JAVA, you learn to think in terms of objects. And that makes you a product
    of the revolution, whether you know it or not.

    Well, I’d love to talk all night about this, but it’s time for me to meet
    my girlfriend and go to a movie (two important functions). If you have any
    questions you can write me at Jma26@Bigfoot.com.

    - Michael



  2. #2
    Markn Guest

    Re: C++ vs Java


    <Q>
    One of your respondents pointed out that you can still write non-object code
    in JAVA. That's true, but it misses the point.
    </Q>

    No it doesn't miss the point. If you read the previous post you would understand
    why I said this.

    <Q>
    When you learn to code in
    JAVA, you learn to think in terms of objects. And that makes you a product
    of the revolution, whether you know it or not.
    </Q>

    Do people really? I wish that were true. Unfortunately, many examples provided
    for learning Java are not OO (check out MQ Series documentation). Having
    a "main" method, seems to cause most of the problem. The other is that most
    still must think GUI ("Web App") and relational database ("database driven").

    It seems most Java code produced is not OO. Using Java doesn't produce
    OO code. Neither does putting code in objects. People actually have to
    think.

    "Michael" <jma26@bigfoot.com> wrote:
    >
    >Hi Tricia,
    >
    >I've been a programmer for 35 years, and I'm competent in C, C++, COBOL,
    >BASIC, JAVA, PL/1 and others. Here are some things the other people haven't
    >mentioned.
    >
    >As was mentioned, in C and C++ the programmer is responsible for allocating
    >and freeing memory. That memory is usually accessed with a "pointer," a

    variable
    >with a memory address in it. I've heard it said more than once that the

    vast
    >majority of bugs in C and C++ have to do with memory allocation and reference
    >errors. My own experience seems to bear that out. One of your respondents
    >mentioned that JAVA and C# use garbage collection. That means that the programmer
    >never allocates or frees memory, and never deals with pointers. I've found
    >that with JAVA, I no longer produce some of the horrific bugs that I did
    >with C/C++.
    >
    >Programming languages have evolved over time, trying (IMHO) to do two things.
    >1. - create a language that mimics the way the programmer thinks, and 2.
    >- guide the programmer’s style of design and coding.
    >
    >#1 was the idea behind the first modern (“third generation”) programming
    >language, FORTRAN (“FORmula TRANslation). Statements in FORTRAN are algebraic
    >equations, which mimics the way an engineer thinks. The next major one was
    >COBOL, which attempted to mimic the way business accountants think: Statements
    >look like English.
    >
    >#2 is actually a significant driving force in the evolution of languages,
    >and often changes the way that programmers think (thus affecting what happens
    >in #1). Researchers have discovered that style of programming has a significant
    >impact on the quality of software. There’ve been at least three revolutions
    >in programming style.
    >
    >The first happened in the 50s, I think (it was before my time), and was

    called
    >“top-down” programming. It meant that you started with the most general

    concept
    >(like a payroll system) and you coded functions at that general level (functions
    >like “produce payroll check”) even before you’ve created the lower level
    >routines (like “calculate deductions” and “print”). This meant you had to
    >write dummy programs (called “stubs”) for the lower level routines. This
    >is sometimes called “functional” programming because it sees the parts of
    >the software as a set of functions: “do this function, then do that one.”
    >
    >
    >The second revolution, called “Structured Programming,” hit the software
    >business pretty hard in the early 70s, and we’ve never been the same. It
    >was controversial for a while (because people don’t like to give up old

    habits),
    >but now it’s so common that the name is not even used anymore. Everyone

    practices
    >structured programming, but doesn’t know it. To write an unstructured program,
    >you need a “goto” statement, which doesn’t even exist in JAVA. I would

    love
    >to show you what a “spaghetti” program looks like. If you follow the thread
    >of execution, it actually looks like a bowl of spaghetti. When the term

    "spaghetti"
    >was first used, everyone laughed long and loud. Nobody had to explain it
    >to us. We all knew that it referred to our own code.
    >
    >So when we combined Top-Down with Structured, it was like a regime change.
    >It literally was a new way of looking at the world. The “case” statement
    >was invented to facilitate structured programming. “Goto,” which once had
    >been an essential concept, was now an obscene word. Modula-2 was designed
    >without it, partially out of arrogance of the inventor (“I won’t have any
    >gotos on my record,” or something like that). We all thought that we had
    >learned the ultimate programming style, one that would free us from buggy
    >code and long development schedules. Today, it’s not the ultimate style.
    >It’s just good programming practice.
    >
    >The next revolution was Object Oriented. It began with a language called
    >“Simscript,” which was for writing simulations. Objects are natural in simulation.
    >If you want to simulate traffic, for example, you want to have objects called
    >“cars.” Again, we had to completely change the way we viewed the world.

    Object
    >orientation, by nature, is contrary to the functional view. In fact, it

    made
    >top-down obsolete. With objects, the best way to design is bottom-up: Start
    >with the detailed stuff, and work your way up to the more general. So it
    >literally turned the old way of thinking on its head.
    >
    >(C++ is the object-oriented version of C)
    >
    >At least two languages were inspired directly by Simscript. The ones I know
    >are SmallTalk and Eiffel. SmallTalk is the most famous, but Eiffel is still
    >going strong and has a loyal following. A new version of Eiffel even works
    >with the .NET framework.
    >
    >One of your respondents pointed out that you can still write non-object

    code
    >in JAVA. That's true, but it misses the point. When you learn to code in
    >JAVA, you learn to think in terms of objects. And that makes you a product
    >of the revolution, whether you know it or not.
    >
    >Well, I’d love to talk all night about this, but it’s time for me to meet
    >my girlfriend and go to a movie (two important functions). If you have any
    >questions you can write me at Jma26@Bigfoot.com.
    >
    >- Michael
    >
    >



  3. #3
    Michael Guest

    Re: C++ vs Java




    Hi Mark -

    You're absolutely right. I did read the previous message, and I understand
    that you were correcting a clumsily stated idea. But it's not the important
    point <I>as far as Tricia's question is concerned</I>. My post was intended
    to help Tricia, not to criticize you. I apologize for not noticing that your
    post was indented under Kent's post, not Tricia's (the indents are pretty
    small).

    What I was trying to say is that with languages like JAVA, we are given the
    <U>opportunity</U> to <B>think</B> in OO terms. Anyone who has witnessed
    the development of computer languages will understand how revolutionary that
    is.

    My point was that a particular language will help to mold the way we think,
    and that in turn will help mold how we design computer languages. Languages
    are about more than just programming techniques and styles--they're very
    much about world-view, and they express our values about programming.

    The struggle in programming has always been to find a methodology that maximizes
    productivity, quality, and maintainability. When a concept like OO does that
    by completely changing what the world looks like, then it doesn't matter
    if some people refuse to operate in the new world. They're welcome to their
    own view of reality, but others can explore and progress and eventually produce
    an even newer world.

    You can't learn JAVA without getting at least a glimpse of the OO world.
    Such a glimpse was nearly impossible 25 years ago, because few programmers
    could even think that way. Simula (not Simscript, as I said earlier) was
    around, but its value as a general programming paradigm was understood by
    maybe 4 or 5 people.

    When we want to understand and compare the nature of computer languages (as
    Tricia does), it's important to realize that every programming language was
    invented to solve some kind of problem. The nature of that problem and the
    paradigm of its solution are the keys to the bigger picture.

    Your comments are definitely correct. Please don't take it personally that
    I said they miss the point of Tricia's question.

    "Markn" <java.@127.0.0.1> wrote:
    >
    ><Q>
    >One of your respondents pointed out that you can still write non-object

    code
    >in JAVA. That's true, but it misses the point.
    ></Q>
    >
    >No it doesn't miss the point. If you read the previous post you would understand
    >why I said this.
    >
    ><Q>
    >When you learn to code in
    >JAVA, you learn to think in terms of objects. And that makes you a product
    >of the revolution, whether you know it or not.
    ></Q>
    >
    >Do people really? I wish that were true. Unfortunately, many examples

    provided
    >for learning Java are not OO (check out MQ Series documentation). Having
    >a "main" method, seems to cause most of the problem. The other is that

    most
    >still must think GUI ("Web App") and relational database ("database driven").
    >
    >It seems most Java code produced is not OO. Using Java doesn't produce
    >OO code. Neither does putting code in objects. People actually have to
    >think.
    >
    >"Michael" <jma26@bigfoot.com> wrote:
    >>
    >>Hi Tricia,
    >>
    >>I've been a programmer for 35 years, and I'm competent in C, C++, COBOL,
    >>BASIC, JAVA, PL/1 and others. Here are some things the other people haven't
    >>mentioned.
    >>
    >>As was mentioned, in C and C++ the programmer is responsible for allocating
    >>and freeing memory. That memory is usually accessed with a "pointer," a

    >variable
    >>with a memory address in it. I've heard it said more than once that the

    >vast
    >>majority of bugs in C and C++ have to do with memory allocation and reference
    >>errors. My own experience seems to bear that out. One of your respondents
    >>mentioned that JAVA and C# use garbage collection. That means that the

    programmer
    >>never allocates or frees memory, and never deals with pointers. I've found
    >>that with JAVA, I no longer produce some of the horrific bugs that I did
    >>with C/C++.
    >>
    >>Programming languages have evolved over time, trying (IMHO) to do two things.
    >>1. - create a language that mimics the way the programmer thinks, and 2.
    >>- guide the programmer’s style of design and coding.
    >>
    >>#1 was the idea behind the first modern (“third generation”) programming
    >>language, FORTRAN (“FORmula TRANslation). Statements in FORTRAN are algebraic
    >>equations, which mimics the way an engineer thinks. The next major one

    was
    >>COBOL, which attempted to mimic the way business accountants think: Statements
    >>look like English.
    >>
    >>#2 is actually a significant driving force in the evolution of languages,
    >>and often changes the way that programmers think (thus affecting what happens
    >>in #1). Researchers have discovered that style of programming has a significant
    >>impact on the quality of software. There’ve been at least three revolutions
    >>in programming style.
    >>
    >>The first happened in the 50s, I think (it was before my time), and was

    >called
    >>“top-down” programming. It meant that you started with the most general

    >concept
    >>(like a payroll system) and you coded functions at that general level (functions
    >>like “produce payroll check”) even before you’ve created the lower level
    >>routines (like “calculate deductions” and “print”). This meant you had

    to
    >>write dummy programs (called “stubs”) for the lower level routines. This
    >>is sometimes called “functional” programming because it sees the parts

    of
    >>the software as a set of functions: “do this function, then do that one.”
    >>
    >>
    >>The second revolution, called “Structured Programming,” hit the software
    >>business pretty hard in the early 70s, and we’ve never been the same. It
    >>was controversial for a while (because people don’t like to give up old

    >habits),
    >>but now it’s so common that the name is not even used anymore. Everyone

    >practices
    >>structured programming, but doesn’t know it. To write an unstructured program,
    >>you need a “goto” statement, which doesn’t even exist in JAVA. I would

    >love
    >>to show you what a “spaghetti” program looks like. If you follow the thread
    >>of execution, it actually looks like a bowl of spaghetti. When the term

    >"spaghetti"
    >>was first used, everyone laughed long and loud. Nobody had to explain it
    >>to us. We all knew that it referred to our own code.
    >>
    >>So when we combined Top-Down with Structured, it was like a regime change.
    >>It literally was a new way of looking at the world. The “case” statement
    >>was invented to facilitate structured programming. “Goto,” which once had
    >>been an essential concept, was now an obscene word. Modula-2 was designed
    >>without it, partially out of arrogance of the inventor (“I won’t have any
    >>gotos on my record,” or something like that). We all thought that we had
    >>learned the ultimate programming style, one that would free us from buggy
    >>code and long development schedules. Today, it’s not the ultimate style.
    >>It’s just good programming practice.
    >>
    >>The next revolution was Object Oriented. It began with a language called
    >>“Simscript,” which was for writing simulations. Objects are natural in

    simulation.
    >>If you want to simulate traffic, for example, you want to have objects

    called
    >>“cars.” Again, we had to completely change the way we viewed the world.

    >Object
    >>orientation, by nature, is contrary to the functional view. In fact, it

    >made
    >>top-down obsolete. With objects, the best way to design is bottom-up: Start
    >>with the detailed stuff, and work your way up to the more general. So it
    >>literally turned the old way of thinking on its head.
    >>
    >>(C++ is the object-oriented version of C)
    >>
    >>At least two languages were inspired directly by Simscript. The ones I

    know
    >>are SmallTalk and Eiffel. SmallTalk is the most famous, but Eiffel is still
    >>going strong and has a loyal following. A new version of Eiffel even works
    >>with the .NET framework.
    >>
    >>One of your respondents pointed out that you can still write non-object

    >code
    >>in JAVA. That's true, but it misses the point. When you learn to code in
    >>JAVA, you learn to think in terms of objects. And that makes you a product
    >>of the revolution, whether you know it or not.
    >>
    >>Well, I’d love to talk all night about this, but it’s time for me to meet
    >>my girlfriend and go to a movie (two important functions). If you have

    any
    >>questions you can write me at Jma26@Bigfoot.com.
    >>
    >>- Michael
    >>
    >>

    >

    "MarkN" <java.@127.0.0.1> wrote:
    >
    >Java doesn't force you to write OO code at all. I can put all my code in
    >the main method (and I have seen it). That is not OO. And just because
    >it is in a class doesn't make it OO.
    >
    >Another important thing about Java is the community. Apache, Sourceforge,
    >Javalobby, ... . One other important thing is that it is an open platform.
    >
    >Some would beg to differ that Java supports true OO (100%). It is more

    OO
    >than VB Classic.
    >
    >
    >
    >"Kent" <kb@essential.com.au> wrote:
    >>
    >>Hi Tricia,
    >>
    >>I can give you some points about each language that should point you in

    >the
    >>right direction. Others may have some additional points to make as well



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center