Question

What language should be used for teaching object oriented programming? java or C++?

Object Oriented Programming at Undergraduate level: Language for object oriented programming

Topics

2 / 0  ·  74 Answers  ·  937 Views

Popular Answers

All Answers (74) Show full discussion

  • Stefan Schuerger · Seven Principles AG
    D is essentially a cleaned-up C++ with lots of direct support for modern concepts (such as design by contract, garbage collection, associative arrays, resizable arrays, clean templates,...).
    The most interesting concept is to have a "safe D" subset of the language which can be enforced and which disallows meddling with pointers, direct memory management, etc., but on the other hand, the language allows the same full access to the hardware or performance as C/C++. This is very powerful, as "harmful" actions can be explicitly restricted to certain parts of the program where they are necessary.
  • Stefan Schuerger · Seven Principles AG
    Here's a feature list:
    http://dlang.org/comparison.html
  • Abdul Renish · Central Informatics Organization
    Thanks for the information Stefan. Is it be applicable for any domain? Is there any live example for the same or any applications to showcase its power.
  • Satish Singh · Nokia Siemens Networks,Bangalore, India
    I think C++ is the better option, Because in C++ graduates will also study about data types safety ans OO concepts.
  • José García · University Carlos III de Madrid
    I am not sure which one should be used.

    However I am sure the one that should not be used: Java.

    Although Java is a good platform form some applications, your students will not acquire some good habits. One of the most important is; resource management. Then when the transition to other languages they will be leaking resources very frequently. Another issue is that they will not be concerned by performance.
  • Anil Pedgaonkar · The Institute of Science, Mumbai
    unforunately gwbasic and qbasic are very easy to use powerful English like languages. the == is overloaded as assignment and equality both . u can exchange the value of an integer with a floting point . such powerful features are absent or impossible in todays fancy languages including java, python ruby and also c from which they derive. the most important principle in programming is natural to use and english like oops and everything else is an artifical jargon unless it naturally comes on lips
  • Stefan Schuerger · Seven Principles AG
    @Abdul:
    The domain is the same as C++: Covering systems level up to high-level OO abstraction.
  • Stefan Schuerger · Seven Principles AG
    @Anil: Having to understand the concept of strong typing is surely a disadvantage when using C/Java as a beginner's language. It adds a level of complexity which clouds the algorithm for a beginner.

    On the other hand, mixing integers and floating point is normally rare. Free types can easily lead to confusion, as in this Perl example:

    $a = 11;
    $b = $a . $a; # (string) concatenation... : $b = "1111"
    $c = $a + $b; # ... vs. integer operations : $c = "1122"

    Conclusion: Perl is not a good choice as a beginner's language....
  • java is good as OOP language but \I think it may be hard as start
  • Amir Nodouzpour · MSRT(Ministry of Science and Research and Technology) of I.R.IRAN
    i think JAVA but is not definitive,
    Because it depends on your skill in teaching.
    http://programmers.stackexchange.com/questions/85191/is-java-a-good-start-to-learn-oop
  • Jurriaan Hage · Universiteit Utrecht
    We have recently switched from Java to C# in our curriculum. This was largely motivated by C# being better suited for Game Programming, but as a non-game programmer, I also find C# to be quite a bit cleaner than Java. A big downside of C# is its proprietary nature.

    I would never start with a scripting language like Ruby of Python. Programmers have to earn the freedom of scripting languages.
  • Stefan Schuerger · Seven Principles AG
    From the "earn the freedom" prespective, COBOL would be a good starting choice - you can tell your students: "once you've all been good boys and girls for some time, we can move on to a nicer language" ;-)
  • Jurriaan Hage · Universiteit Utrecht
    My point was that I'd prefer starting students on languages where the compiler provides some protection.
    I'd not suggest using Cobol. It lacks too many features that I'd like to educate students about.
  • David Abbott · U.S. Department of Veterans Affairs
    Of the two, I think Java is a better first language. The whole business of deallocated pointers leading to bugs that are horribly complex to debug and exhibit seemingly non-deterministic behavior is substantially avoided by Java garbage collection. This is no small thing since even one really rotten experience with debugging can turn a person off to programming for a lifetime. The issue of excruciatingly careful memory management can be left for a follow-up course!
  • Anil Pedgaonkar · The Institute of Science, Mumbai
    What about visual basic, ruby and perl
  • Anil Pedgaonkar · The Institute of Science, Mumbai
    dear Stefan i understand that mixing of int with flot does not occur in comon practice. but the fact remains that 3rd generation gw basic q basic can do it but not todays languages.
    2)also gwbasic and qbasic overloaded = for both assignment and equality , a marvel which is very useful for natural looking programs not possbilei todays langugaes ruby, java , python almost all madly following c.you have not replied for this point.
    3)basic was English like and concise. see the ease in statement input "name and age" name$, age. pri. c would require you to use two statements scanf, printf with awkward syntax. even c++ would require cin cout but basic was more readable and required lesser writing. even java is complicated in this regards.
    4) basic had a simple facility of parameters subroutines Gosub which could transfer some part of computation a logically separate unit to another part of program without other overheads of parameter passing
    5) cobol had built in indexed sequential file, basic could have built in random files one has to program al this i c++, c, java etc. handling of databases is the most important task done in it industry commercially.
    6) in basic there were syntactically different loop structures while .. wend, for ... next, repeat .. until . in all derivatives of c ( c+= java ruby etc ) all blocks begin and end with braces. so it is difficult to spot and separate different types of loops employed.plus for loop is unnatural why this syntax for (exp1:exp2;exp3) compare with basic style syntax for expression1 to expression 2 step expression 3( optional step clause) body of loop next.
    of course one can evolve and define iterators as sets with built in next member and have iterators in addition to for .
    7) in basic a statement did not require semicolon to terminate gr8 . This saves from syntax errors. rather we should have hyphen in case we wish to continue statement on next line. may be sending program over a communication channel the editor can add semicolon at end of statement but programmer should nt be required. spare us from cancer of semicolon.all ruby , java etc suffer as they are derivatives of c.
    8) c cold not overload = and equality so it introduced == and madly all derivatives followed this weakness.
    9) basic allowed arrays with variable dimension . c is very weak in handling even two dimensional arrays and requires the second dimension a constant t be passed as parameter oh my god what a bad design and what a serious lacuna which can only be corrected using pointers and so cryptic code. Ok java has corrected this somewhat by treating arrays as objects.
    100 in java if i have a class student and instance variable x and if i say another y =x a new object is not created but only reference is copied. this creates a subtle bug and here program loses transparency with logical thinking
    one could have avoided artificial looking use of keyword new by modifying design. suppose i say student x, y then two instances of student...
    [more]
  • Well to answer this question I would suggest you to teach object oriented programming using C++. The justification go like this 1) It is easy to understand the concepts of OO 2) You can make use of this features while implementing ..
  • Javier Ruiz Aranguren · Independent Researcher
    Neither. If the goal is to learn and get strong OOP fundamentals, I would recommend Eiffel and Bertrand Meyers methodology "Outside-In". Please have a look to the book Touch of Class. It is a great book for a first course in Programming. Modern, Semi-Formal, and deals very well with motivation.
    It also has three appendix that explain how C++, Java and C# deal with typical and advanced OOP constructs (inheritance, generics, etc..).
    You can also compile Eiffel to Java and .Net bytecode, so it is a powerfull weapon.
  • Java or C++ ?. Java is more easy to learn and to teach (for OOP) than C++. In addition Java is a managed language (the memory is managed automatically) but C++ no.
  • Joseph Coco · Savannah College of Art and Design
    I agree with Michael, the dichotomy seems silly in that there are better languages specifically to teach OO design. That aside, I would recommend Java as it has stronger roots in object orientation. I have found Introduction to Object Oriented Design Using Java to build a solid foundation of object orientation with Java as a catalyst in stead of the usual 'learn Java' approach.
  • Sasikumar Mukundan · Centre for Development of Advanced Computing
    I also recommend Java over C++. C++ has a lot of baggage it inherited from C and others. Java is cleaner and safer. Java compiler is your friend, unlike in case of C++. Java is far more object oriented than C++.
  • Ye Zeyu · Jinan University (Guangzhou, China)
    I think java is more suitable to this task. As we know, Java is far more object oriented than C++, it can make students learn more easily and intuitively.
  • Danijel Radosevic · University of Zagreb
    Well, I think that C++ is a basic programming language for learning OOP because it introduces object model and syntax base for other OOP languages including Java, C# , Delphi (object model), Perl (syntax), PHP (syntax) and even Python (object model, although very relaxed in relation to C++) and Visual Basic (object model).
    So, I prefer C++ at OOP start.
  • I think C++ is great for OOP start
  • Zaheer Sani · COMSATS Institute of Information Technology
    C++ is preferred for learning/understanding basic and pure concepts of Object Oriented Programming.
  • Sasikumar Mukundan · Centre for Development of Advanced Computing
    Zaheer: Not at all. C++ is not a pure OO language by any standards. It is extremely complex and confusing to a beginner to understand it properly. If you know C, you may find the syntax easier -- but if you want to learn OOP, and want to learn programming well, choose a cleaner language like Java. Look at the friend functions, confusing inheritance mechanisms (most of which have nothing to do with inheritance really), all the evils of C, and so on....
  • Tariq Sheakh · Jagdishprasad Jhabarmal Tibrewala University
    Java is a programming language originally developed by James Gosling at Sun Microsystems (which has since merged into Oracle Corporation) and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities than either C or C++. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is a general-purpose, concurrent, class-based, object-oriented language that is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java is as of 2012 one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million user

    There were five primary goals in the creation of the Java language:[22]
    1. It should be "simple, object-oriented and familiar"
    2. It should be "robust and secure"
    3. It should be "architecture-neutral and portable"
    4. It should execute with "high performance"
    5. It should be "interpreted, threaded, and dynamic"
    so it is better to use Java as OOPs for Teaching
  • Sasikumar Mukundan · Centre for Development of Advanced Computing
    Lata: I think, it should be the other way. C++, as I mentioned earlier, is a bad language to learn OO. So learn with Java. If you want to work with C++, you can move there later. You will know what is good and bad in C++, then.
  • Glenn Butcher · The Boeing Company
    I've taught Java, and I currently write both C++ and Java programs demonstrating distributed concepts (equivalent programs, sometimes I start in Java, convert to C++, sometimes the other way around), I'd lean to Java for an OO teaching environment. The reasons are: 1) the 'bare' command-line environment is better-integrated (sorry, IDE guys, I feel it's better to start there), 2) less 'c-baggage' to explain.

    If your specific focus is training OO concepts, one of the scripting languages specifically infused with OO constructs (Python or Ruby, NOT perl...) may be the better choice over either Java or C++. You would have minimal messing with the mechanics of link dependencies - if you can 'see' the text, you can 'link' it...

    I believe the fundamental motivation for teaching OO programming is to develop in others the skills required to write Really Useful classes, so whatever environment best promotes explaining how that works is what's best.
  • Mohamed Hilia · Université Paris-Est Créteil Val de Marne - Université Paris 12
    Smalltalk
  • Herve Verjus · Université de Savoie
    Smalltalk is a "pure" object oriented language and is probably the most suitable language for explaining and understanding object model and underlying concepts. I recommend Pharo (http://www.pharo-project.org/) as a free Smalltalk language for your lectures.
  • Mikhail Simin · University of South Carolina
    I'm with Hackett on this one. Don't do Java or C++. I've been trying to get my department to utilize Processing (http://processing.org/) language for Computer Science intro course.

    A thing you want to require from a language that you're teaching is instant gratification. Java has headaches, C++ has headaches, scripting languages are usually too simple with their utility (such as make an object car that has fuel speed and color... boring)
    JavaScript is my absolute favorite scripting language, but to have an impressionable result you also need to get elbows deep in HTML and CSS, and perhaps some jq-plot.
  • Robert Plantz · Sonoma State University
    "A thing you want to require from a language that you're teaching is instant gratification." Interesting to see how things have changed. I majored in electrical engineering half a century ago. We started with math, then physics, and finally some electrical engineering. We never did build any cool devices in university. I finally got to help design a cool device in my first job -- the horizon scanner for the Gemini capsule. Gratification didn't come until over six years after I started college.

    I'm not making a judgment here, just an observation of how times have changed. I assume that today's youth, who seem to need instant gratification, will do things just as cool and interesting as my generation.
  • Ahmad Hassanat · Mu’tah University
    well from the answers i see the JAVA guys Vs the C++ guys, i am a C++ guy, but i don not see a big difference between both languages in the term of OOP, normally teaching OOP comes after teaching some programming languages, check your students and see which language they are more familiar with, and go on.
  • Синиша Спасојевић · Vision Max Limited
    Depends on what is the purpose of teaching someone programming.

    Is it so that person just has basic understanding of OOP and not extensively use it in his commercial/academic work? Or that person's ability to use the language to it's maximum extend as his main tool in his future work?

    In first case, any OOP language can go and I would even suggest ActionScript3.0 (Flash11) since it has easy to use drawing API for any type of visualisation (eg. draw data-drive diagrams etc.), easy to make GUI etc. Java also could be solution, especially if it's about development on mobile devices running Android.

    However, in the second case, if that person is to use learned language and programming skills extensively in his future work, and make maximum out of it, then C++ is the path. Yes, it has a lot slower learning curve, but keep in mind that what you get in return, once you become 'c++ expert' is unmatched with any other programming language.

    I've seen posts saying that Java can do same as C++ and that is true to some extent: yes it can make loops, and make nice OOP-organized programs... but that's it.

    It will never be able to make it to the level that you can in C++, starting by developing apps using all kinds of external sensors (direct access to Kinect for instance, or any of other sensor solutions, thermal, ambient, tilt etc.). Let alone GPU development with OpenCL/OpenACC and CUDA that can give you tremendous computing power (just imagine, new nVIDIA 650 GTX Ti has 768 CUDA cores)! None of these can be achieved in Java or any other language.

    So it comes to: what do you want to be able to do with your programming once you learn it?
  • David Franco · Armando Alvarez
    hello, i learnt programming with c, and i think that is not a good language to learn programing. it has a very strange syntax for a rookie. I think that is more usefull and better to learn programming languages like java.
  • Haipeng Cai · University of Notre Dame
    Although neither one is the best starter language for learning OO, I would advocate C++ here for people having background in C or other procedure-oriented languages, and Java for people having zero background in any strong-typed programming languages. It has been well acknowledged that C++ is a pure OO language, I recommend it, though, because it will tell you more about the secrets of OO compilers than Java would do. As a matter of fact, as for my limited expertise in Java, I am sure that one can implement a decent OO design purely using C++, at least as good as Java does. But the bottom line is, as I mentioned before, it may not be good starter for people having no knowledge or experience in lower-level high-level language that requires understanding deeper inside the computer system and OS. Also, pointer haters will swarm towards Java, I suppose, just as performance-wise picky guys will do toward C++.
  • Haipeng Cai · University of Notre Dame
    to some one suggesting the "processing" language, I just wanted to add that it is not a real full-blown programming language but a data processing/visualization scripting language, more or less based on Java. I do not think it is quite OO as well according to my experience in using it for two years actually, so is its variant for web graphics, processing.js.
  • Giuseppe Castagna · Paris Diderot University
    The first OOP language I learnt were Simula where the concept of object was first introduced. Today for teaching purposes I would probably use (and actually I partially do) Scala. A good choice is also C# especially if you want to go into the details of the virtual machine
  • Синиша Спасојевић · Vision Max Limited
    @Tilmann

    Great that you are so passionate about Java, and indeed there's always gonna be work for Java developers.

    However, whatever is support for GPU-programming in Java, until high-end development houses, like ID Software, Blizzard etc. switch to Java, there's no evidence that Java can perform better in GPU. Otherwise, Java being easier to learn and thus easier to find developers for it, rather than C++, would make these big money makers switch to Java in no time. Having larger pool of ppl to choose from for Java development, than for C++ development, is market supply-demand law - making it cheaper to get or replace developers than what currently is in C++ world.

    To conclude:

    Yes you will get a job as Java developer. No, you will never be as paid as C++ developer since you are easier to be replaced than a C++ developer.

    Which language is more popular does not determine how many jobs you have for a language. It just means ppl rather choose easier path to go through. Having 10x Java developers than C++ developers means only that C++ developers will have better payments.

    I am currently competing in China, country with probably more developers of all kinds, than in majority of other countries in the world. You cannot possibly imagine how many developers claim to be Java developers. It's a sea of ppl looking for jobs. And yet, I manage, with C++, to have so much projects, that I am rejecting work since I can't do it all.

    So anyone that is just starting with development learning, if you are looking at it from professional perspective (to live from it, raise your kids from it), then C++ is the way to go.

    Anything else is unsafe.
  • Claudio Bisegni · INFN - Istituto Nazionale di Fisica Nucleare
    "learn c++ and you will have all the experience to use all othe language" this said me my teacher many years ago, and he have rigth. So is my opinion that c++ is the best language but for undergraduates student also java is usefool.
  • My biases are that I have written maybe a quarter-million lines of C, and I learned OO in Smalltalk-76. I would go with Java over C++ (if those were the only choices) for 2 reasons. First, Java actually fixes some of the problems with C and C++, which C++ doesn't. Neither one is as safe as some of the modern interpreted languages like Perl, which make even more classes of errors impossible (or at least difficult) to write, but Java is clearly better than C++ in that regard.

    The other reason is more like a lack of a reason. I don't feel like C++ is a more natural and intuitive extension of C than Java is. They both felt about equally easy or hard to make the transition to (and so did C* for the Connection Machine). So I don't think that "similarity to C" should be a reason to prefer C++, even for a C programmer.
  • Mahmood Mohamed · Institute of Statistical Studies and Research
    If they have an experience in programming language before java is good but if this is the first programming language their learn c++ is prefered
  • Gennady Fedulov · Independent Developer
    In my view, the most power program tool is ASP.NET with C#. Please, have a look at the link https://www.researchgate.net/post/Is_Java_too_complicated
  • Abdessamad Naitali · Université Mohammed V Souissi (UM5S)
    In my opinion two programming techniques are to be distinguished : Object Programming (OP) and Object Oriented Programing (OOP). In OP like with java and visual basic , the programmer usually uses predifined objects and costumizes them or build new derrived ones. However in OOP using C++ the programmer is appealed to create new class objects based on elementary data type, which requires many skills of a high level in C and C++ programming. Also and as indicated by Java programming inventor J. Gosling : Java= C++ minus complexity plus security. that is Java can be tought as a secure derrivation of C++ where the objects needed by the programmer are predifined and capitalized as library : For these reasons and based on my own experience in teaching java and C++ for some years ago, I recommand Java instead of C++ since that it is suffisent to introduce the object programing concepts, and is much easier to take in hand than C++ for undergraduated students. But for graduate students in sciences and technology, especially those who will be involved in developping specific enginering appications, I prefere C++ since that it offers a great flexibility in the introduction of OOP concepts and their use in the developpement of usefull software components .
  • Mohamed Hilia · Université Paris-Est Créteil Val de Marne - Université Paris 12
    In my opinion, we can learn the basics of OO programming, ( representation as objects, polymorphism, ...) and then show their implementation is both languages Java, and C++ languages.
  • Kapil Narwal · Maharshi Dayanand University
    I'd prefer C++ as it is universally accepted among all different fields of science and engineering...
  • Aniruddh Mali · Institute for Plasma Research
    first learn C++ then proceed for java. I will prefer C++. comparing java, C++ has higher priority

Question Followers (71) See all