You are not logged in.

#1 2015-11-05 10:23:31

vlast777
Member
Registered: 2015-02-10
Posts: 57

C++ or Java first for going-to-be computer scientists

Hey there,

I recently started to study computer science at my local University.

Now the thing is, they offer a programming course for C++ and one for Java, both meant for beginners.

I can't decide which one to pick

I have very basic knowledge if how programming works (i know variables, functions, Objects, Classes, loops etc) but never programmed a real Project.

Now which one would you suggest to pick?
Please don't above me to learn Python or C first.

If it's just between the two above, which one to pick and why?

Thanks!

Offline

#2 2015-11-05 10:32:56

crondog
Member
Registered: 2011-04-21
Posts: 130

Re: C++ or Java first for going-to-be computer scientists

Why can't you do both? Seems a bit odd to me.

Since you said they are for beginners does it mean that they are just teaching basic data structures and OO concepts? If this the case then it doesn't really matter. C++ would be simpler to setup and you don't need to deal with setting up a working java environment.

You can just pick 1 and then attend the lectures of the other one unofficially wink

Offline

#3 2015-11-05 10:58:29

smnpl
Member
From: Germany
Registered: 2015-01-07
Posts: 54

Re: C++ or Java first for going-to-be computer scientists

Agreed with crondog. If it's very conceptual in meanings of oop, inheritance etc. it doesn't really matter or maybe Java would be slightly more efficient in the way that it's closer to "modern" *duckrun* approach of a language. Though, I'd assume, that in C++ you'd as well treat topics like pointers, memory allocation and stuff like that. As C++ is much "closer to metal" you could potentially learn more and wider fundamentals of how a language (as Java does a lot of that under the hood, but still needs to do it), an operating system and a computer in general works.

So for a potentially more fundamental approach of C++ on the topic, I'd choose that.

Last edited by smnpl (2015-11-05 10:59:58)


The road to wisdom? - Well, it's plain and simple to express: Err and err and err again but less and less and less. - Piet Hein -

Offline

#4 2015-11-05 11:06:30

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: C++ or Java first for going-to-be computer scientists

[Edited to favor Java a little more.]

I'd also say it doesn't matter too much, but Java is a safer bet. In any case, pick one and focus on that. You'll probably want to learn the other one as well, but not right away -- I doubt trying to learn two languages simultaneously is a good idea, especially as a beginner who doesn't have a firm grasp of at least one language. If you have any ideas about other differences between the courses, you may want to let those inform your decision. For example, are you free to program on Arch, or do they force you to use some Windows-only IDE/libraries. Perhaps past experiences from older students can also help. If it seems very similar, I'd go with Java.

Of course each language has it's strenghts and weaknesses and for a first language it does make some sense to try and avoid the ones with (too) many oddities. C++ is a rather complex language, but you don't need to know all the details and corner cases to get started [1], so it might work out quite well in the hands of a good teacher. Java will most likely be easier to start with. It's a little awkward that it forces you into classes and objects for almost everything, while C++ (like Python, for example) encourages simple free-standing functions when the OO view is inappropriate/overkill. You'll learn to appreciate these differences as you go on to learn more languages; don't worry about it too much for now.

To put this reply in perspective: my university started with a Java course and then Haskell for a different approach (and optional courses for things like logic programming in Prolog, web programming). I had done some web programming (PHP with SQL for the server side) and toyed with C++98 before I started. Recently, with C++11/14 I've picked that up again and I know Java also has things like lambdas and streams now, but I haven't programmed in Java since these were added.

[1] Seemingly relevant talk (haven't watched it yet): https://www.youtube.com/watch?v=nesCaocNjtQ

Last edited by Raynman (2015-11-06 10:43:28)

Offline

#5 2015-11-05 15:50:11

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,791

Re: C++ or Java first for going-to-be computer scientists

I did learn C first.  Decades before either C++ or Java existed.  And at $DAYJOB I do a lot of embedded development.  As such, I took up C++ and ignored Java.
I also have a daughter and have watched her learn to program.  She started with Java and progressed from there to C, Python and Verilog with ease.

Learn Java. In my humble and highly debatable opinion Java does a terrific job of teaching the good habits in a reasonable well thought out and structured language.  Teaching someone C++ as a first language is akin to teaching someone how to juggle starting with knives instead of rubber balls. The C++ compiler will turn and bite.  As a C++ newbie, you end up fighting the tools so much that you cannot see the forest for the trees.

On your journey, don't miss the opportunity to learn a Lisp based language. Even if one never uses it, the experience is enlightening.

Last edited by ewaller (2015-11-05 15:50:39)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#6 2015-11-05 17:27:25

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: C++ or Java first for going-to-be computer scientists

Both courses are exactly the same, but one with C++ and one with Java?

Spend one hour tonight making a Text Based Adventure in C++. Spend one hour tomorrow night making a Text Based Adventure in Java. Then choose the language you like more. smile

Offline

#7 2015-11-08 10:02:27

vlast777
Member
Registered: 2015-02-10
Posts: 57

Re: C++ or Java first for going-to-be computer scientists

About that Text RPG:

How do I determine, which objects/classes I need to create?

This is a thing I was wondering about for a longer time now. I know how to declare classes and how to create objects from them. But I don't know what for to create classes.

Another example: Let's say I want to programm a calculator, what classes I need to create? I don't know how to explain my problem exactly hmm

I simply don't know what "real world objects" need classes and when. Which classes I need to declare for my project (any project)..Anyone can give me some examples?

Last edited by vlast777 (2015-11-08 10:04:05)

Offline

#8 2015-11-08 13:27:24

bstaletic
Member
Registered: 2014-02-02
Posts: 658

Re: C++ or Java first for going-to-be computer scientists

vlast777,

Well you can make anything an object. An integer class would know about its abillities (add, subtract, defference between two integers, etc). Similar could be said about any data type. These classes are predefined in java (I've just started learning java, so I don't know how are they used. i.e. What they are capable of) and are called wrapper variable types.

Though I don't think it's a good idea to make everything an object. I have been told if one's doing GUI also one should be using classes. In other words a drawn rectangle button would be a perfect candidate for an object.

More obvious example would be databases. Let's imagine a database holding the data about a city population. Every citizen has an ID, name and a lot more info that might be relevant (or not). So one would create a class named citizen with all the relevant info. Relevant info would be whatever one thinks is relevant.

Hope this helps.

Offline

#9 2015-11-08 17:22:32

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,791

Re: C++ or Java first for going-to-be computer scientists

vlast777 wrote:

About that Text RPG:

How do I determine, which objects/classes I need to create?

This is a thing I was wondering about for a longer time now. I know how to declare classes and how to create objects from them. But I don't know what for to create classes.

Another example: Let's say I want to programma calculator, what classes I need to create? I don't know how to explain my problem exactly hmm

I simply don't know what "real world objects" need classes and when. Which classes I need to declare for my project (any project)..Anyone can give me some examples?

That is the crux of what I had said.  That is the design part.  It is what separates a computer scientist from a programmer.

OO is a great programming paradigm, but it is not a panacea.  For a calculator, does it make sense that each button be an object?  It might.  If they were, what would they encapsulate?  What messages would you send them? what messages would they send?
To me it is not obvious that they should be objects.   It might make better sense to define a structure that includes a callback function that is different for each key.

Consider a chess board.  Maybe each square could be an object.  It would be aware of what piece or pawn it contains.  It would be aware of its location on the board.  Member functions could return data structures that identify what squares could be attacked by our piece.  It could return data structures that identify what squares threaten our piece.  Maybe the object can have its own thread and can do processing to generate those structures without having to block the main thread. 

As to the adventure game, maybe each location is a room (a class).  Each room has a description, a list of artifacts (see below) in the room and a dictionary of rooms that one can reach from this room with the keys being directions.   When you instantiate a room, you have to set those structures.  Later, when the player breaks a chalice,  or waters a plant, you would remove the seedling or the crystal chalice from the room and replace it with a different object.   Moves would be made by changing a pointer to the room the player is visiting.  generally that would happen if they went up, down, north, south, east,west.  The room to which they go is based on the direction dictionary.   You might need a class for things. Lets call them artifacts.  A sword, a broken chalice, a seedling are all artifacts.  The instances of the artifact class would have a description of themselves, and have a list of actions that work on them, and the results of that.  Maybe a player can drop an artifact.  Dropping the chalice artifact causes the chalice to destruct and be replaced by a broken chalice.  Dropping a pillow artifact has no effect.

Read up on OO design,  Especially the "is a" and "has a" stuff.  Figure out how to create a data structure that can drive your program,  Don't (repeat do not) think of the program in terms of a giant procedural mess controlled by endless if-then-else;  case-switch structures.  Think of elegant data structures that define states, and how each of those states can transition to other states.  Each state may have a callback functions or, in functional languages may define Lambda functions for those callbacks.

Design first.  Then write test cases. Then code.


Edit:  You might also glance over UML (Unified Modeling Language).  I am not suggesting you learn UML -- at least not now.  But, look at the concepts, it may give you insight into the design aspects of software development.

Last edited by ewaller (2015-11-08 17:29:11)


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#10 2015-11-09 16:00:20

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: C++ or Java first for going-to-be computer scientists

With the information you provided, we have nothing that can be used to help you determine which class to take.

I don't think Java vs C++ matters (I love and hate both, both are professional, both are useful). So just pick the class with the more interesting teacher, or more fun friends, or cuter classmates. smile

Offline

#11 2015-11-22 22:10:57

tyrannis
Member
Registered: 2015-11-06
Posts: 94

Re: C++ or Java first for going-to-be computer scientists

I had a semester of Python, then C++ for the rest of my time at that school.  I've dabbled with Java, and I agree with ewaller that Java is definitely more new programmer friendly than C++, mostly because Java handles much of the memory management and limits the amount of separate compilation you have to do with OOP for encapsulation and information hiding.  However, a decent C++ IDE  will mitigate most of those issues, if that's the case I would recommend  C++ as you will learn more under the hood components of programming: pointers, separate compilation, scope resolution, etc.

Offline

#12 2015-11-25 03:33:46

Zaku140
Member
Registered: 2015-08-14
Posts: 31

Re: C++ or Java first for going-to-be computer scientists

C++ being my first programming language, I am pretty biased. My prof once said, "C++ gives you a lot of rope to hang yourself with." This is true. There are so many ways different ways to do a specific function in the language that you could easily get confused as a beginner. But C/C++ is good to start with because it truly does nothing for you (Of course, assembly language is under the hood). You will learn a about memory management and the "heap" and be aware of how you are allocating memory. I agree that you should learn both because Java and C++ because its good to try learn more languages (they are also similar). But I think that if you start with C/C++, other languages will be much easier to grasp. Sure if you juggle with knives you may cut yourself a few times, but you will learn from your mistakes eventually (can be applied to any language really).

Offline

#13 2015-11-25 07:38:37

dice
Member
From: Germany
Registered: 2014-02-10
Posts: 413

Re: C++ or Java first for going-to-be computer scientists

It is hard to decide for either of the languages. They are both widely used and are also often used as "beginner" language. I would just pick the course which has the better teacher (or the teacher I just like more) as it does not really matter if you start with Java or C++. But you should learn the other language after that course too. At my university programming examples and assignments are usually in java or c++ so it makes sense to know both.

btw: be glad to have that choice. I started programming at university with a course on programming with scheme (though retrospectively I have to say I actually learned a lot in that course) smile


I put at button on it. Yes. I wish to press it, but I'm not sure what will happen if I do.  (Gune | Titan A.E.)

Offline

#14 2015-12-05 00:22:43

pixelou
Member
Registered: 2011-03-30
Posts: 17

Re: C++ or Java first for going-to-be computer scientists

Hi,
Machine learning student here smile. I have learned Java through courses and C++ by myself.
If you read the comments above, you will notice that the intrinsic qualities of each language rarely come into play.
Instead, the research context, the application and the objectives (or your boss) often decide for one or another.
So here are some of the influencing criterions I would consider for a project in Machine learning:

- Which language is popular in that field (that includes the team you might work with)?
- Which language helps me best to translate my ideas to code: depends on your programming workflow? I have the feeling that java helps to implement the global structural architecture of a project, while C++ offers a very large number of programming patterns with maximal flexibility.
- What level of optimization is required?

In terms of courses, I think you should take C++ because it is more difficult to learn by yourself. However, most courses for low-level languages get lost on low-level details. So try to take courses in software design, software architecture and software testing as well. I guess the strong industrial background of java makes those aspect more obvious to java teachers.

One more advice: Java and C++ are not exactly programming languages, I see them as implementation languages. A typical workflow might be:
1 - architecture on paper
2 - test ideas with python or matlab prototypes
3 - implement in C++

Offline

#15 2015-12-05 00:27:42

pixelou
Member
Registered: 2011-03-30
Posts: 17

Re: C++ or Java first for going-to-be computer scientists

Forgot to add: as far as I can see, academic research on Machine Learning is biaised toward C++ (and python for bindings).

Offline

#16 2015-12-20 13:27:35

Lord Bo
Member
Registered: 2012-11-11
Posts: 168

Re: C++ or Java first for going-to-be computer scientists

Another side note: If you ever want to do HPC (High Performance Computing), which is a quite interesting topic in computer science, you will have to write C/C++-code and you need to have (or get) a rather fond look on hardware-near programming (which is something you will learn with C/C++ and not Java). Java is (for example) good if you want to write platform independet Applications for end-users, which is a little bit more difficult (but still possible without too much hassle) using C/C++.

Offline

#17 2015-12-21 16:27:39

SirMyztiq
Member
Registered: 2015-03-24
Posts: 118

Re: C++ or Java first for going-to-be computer scientists

Learn the core and then pick one. I started with Java, did some C++ and moved on to Python, Ruby andy current favorite JavaScript. I feel that it also depends what you want to do with the knowledge. What type of job you are going to look for, what type of Software guy you want to be. For example, most video game programming is done in some varient of C. Tons of commercial apps for older companies is done in Java. Startups and newer tech do Ruby and now the sweetheart of JavaScript.

You know what, take C++ for credit then ditch it to learn JavaScript.

Offline

#18 2015-12-28 20:39:28

memory_leak
Member
Registered: 2015-03-02
Posts: 43

Re: C++ or Java first for going-to-be computer scientists

Pleae, Text base adventure rpg requeires linked lists and as pointed out some knowledge about how to structure program in classes etc, so it surely is not something one do to first find out what language to chooose! Might be a good candidate as a final project to introductory course in programming, not as a first project to choose language from. Get real.

Anyway, if you are going to learn about object oriented modelling and software organisation and structure, than pick Java, if you are going to learn about "programming", simply converting a solution into computer language/instructions, than C++ is choice.

In my opinion Java is better choice since it is a superset of C++, C++ is just a ginormous see of possibilities, and it may be easy to loose track into irrelevant hings for the first course.

Offline

#19 2015-12-28 23:23:19

mpan
Member
Registered: 2012-08-01
Posts: 1,208
Website

Re: C++ or Java first for going-to-be computer scientists

memory_leak wrote:

Pleae, Text base adventure rpg requeires linked lists

The best use of linked lists is to teach a difference between theoretical memory complexicty and real memory costs, but definetly not a requirement for a game — be it RPG or anything else. Also ECMAScript doesn't affect using linked lists if one wants to.

memory_leak wrote:

(…) and as pointed out some knowledge about how to structure program in classes etc, so it surely is not something one do to first find out what language to chooose! Might be a good candidate as a final project to introductory course in programming, not as a first project to choose language from. Get real.

Again, ES is fully object-oriented (order's magnitude more than Java or C++). It just uses prototypal model, not one based on class definitions. But it's neither worse than C++-ish, nor less appropriate for both learning programming and scribing games. Actually multitude of game engines use entity-component-system which fits nicely into the approach found in ES much better than "classic" OOP.

I would not choose ECMAScript for a different reason: ES requires grasping lots of completly new ideas right at the begining and (or rather "but") there is frightfully tiny amount of good teaching material available compared to other languages. Even compared to C++, where most tutorials on the net are a by-product of unbound creativity of students, who started C++ 2 weeks earlier. Also there are barely any libraries for ES oriented towards desktop programming and just a bunch of them for writing backends for webapps. ECMAScript is great when you setup your own rig for it, but first you need a language to build the environment for your script.

memory_leak wrote:

In my opinion Java is better choice since it is a superset of C++

Java is not a superset of C++. If anything, it's influenced by it and shares general syntax of BCPL style and semantics of its successor, C. Otherwise the languages are completly different from base to the top.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#20 2015-12-29 10:46:37

memory_leak
Member
Registered: 2015-03-02
Posts: 43

Re: C++ or Java first for going-to-be computer scientists

Dude, the guy is asking aobut C++ and Java, not JavaScript (ES). Java as a superset of C++ is a statement that target high level view of implemented OOP features and syntax used, not as a low level "implementational part" of langauge, such as C would be to C++. I am sorry if that confuses you.

You may choose whatever you want, it is your life. I would never choose Javascript as a teaching language to introduce object oriented programming, for probably same reasones why I wouldn't use C++, or maybe not even Python. Java as academic OOP language is pretty much unbeatable, albeit even Java with few latest incarnations has added a lot to breadth of features. Of course nobody says a student has to go through all features, but the risk of getting carried away with unrelated stuff if more present in C++ or Javascript than Java.

Offline

#21 2015-12-29 13:42:41

mpan
Member
Registered: 2012-08-01
Posts: 1,208
Website

Re: C++ or Java first for going-to-be computer scientists

@memory_leak
I've misunderstood your post as a comment referring to what SirMyztiq has said. This is where ES thread came in. Hence the two first paragraphs may be ignored. However, the third can't: Java is not a superset of C++ in any way, on any level. Neither is syntax, nor are features. Most features of C++ are not present in Java (and vice versa). Syntax is similar, but that's truth for any BCPL-influenced language.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

#22 2015-12-29 13:46:22

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: C++ or Java first for going-to-be computer scientists

memory_leak wrote:

Java as a superset of C++ is a statement that target high level view of implemented OOP features and syntax used, not as a low level "implementational part" of langauge, such as C would be to C++. I am sorry if that confuses you.

Java is not a superset of C++, and C++ is not a superset of C. hmm

I don't understand the point you're trying to make. Are you suggesting that "If you learn everything in Java then you will know how to do everything in C++, because the functionality of Java is a superset to C++"?

Offline

#23 2015-12-29 16:51:05

memory_leak
Member
Registered: 2015-03-02
Posts: 43

Re: C++ or Java first for going-to-be computer scientists

drcouzelis wrote:
memory_leak wrote:

Java as a superset of C++ is a statement that target high level view of implemented OOP features and syntax used, not as a low level "implementational part" of langauge, such as C would be to C++. I am sorry if that confuses you.

Java is not a superset of C++, and C++ is not a superset of C. hmm

I don't understand the point you're trying to make. Are you suggesting that "If you learn everything in Java then you will know how to do everything in C++, because the functionality of Java is a superset to C++"?

Jesus dude ... how old are you? 12?

I'm sorry if I am rude, but I have no time to argue with someone who read everything literally and can't apply any level of abstrackt thinking. No, I haven't said you will know C++ if you know Java, if I have please point me. No, Java is a superset of C++ in terms of object oriented features and syntax, not as an implementation. Java also ads a set of OOP features of its own which are not present in C++. If it confuses you please go and learn more about both. I didn't say neither that C++ is superset of C, I tryed to illustrate that Java is NOT same as C and C++ where C++ is compatible with C, as I understood that you are understaing me that way. Yes, you don't udnerstand the point, so please don't comment either.

Last edited by memory_leak (2015-12-29 16:53:27)

Offline

#24 2015-12-29 17:40:03

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,791

Re: C++ or Java first for going-to-be computer scientists

memory_leak wrote:

Jesus dude ... how old are you? 12?

I'm sorry if I am rude, but I have no time to argue with someone who read everything literally and can't apply any level of abstrackt thinking.


... And, this thread is done.

memory_leak: https://wiki.archlinux.org/index.php/Fo … ther_users
drcouzelis has been here a lot longer than you and has earned our respect over the years.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#25 2015-12-29 17:42:15

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,530
Website

Re: C++ or Java first for going-to-be computer scientists

memory_leak wrote:

Jesus dude ... how old are you? 12?

I'm sorry if I am rude, but I have no time to argue with someone who read everything literally

Drcouzelis asked a question.  He asked for clarification of something you said; he did not make a judgement of it.  In any case, the first part of this is uncalled for.  The second part is ironic: you don't have time to argue rationally, but aparently you have time to insult.  Feel free to argue (i.e. debate) - insults however serve no purpose.

(Edit: beat by ewaller to this one)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

Board footer

Powered by FluxBB