Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


From C to ?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
20 replies to this topic

#1 shadowstep00   Members   -  Reputation: 538

Like
2Likes
Like

Posted 12 February 2014 - 02:27 AM

So I want to move on from C to an object oriented language. (C++, C# or Java)

 

My C knowlege is not that advanced.

But I have learned all the basics of the language. (pointer,arrays, structures, input output files, dynamic memory)

 

I don't plan to move on Java because I am going to learn it along with my university class next year.

 

This leaves me with C++ and C#. I think it's best for me to move on to C++. But there's a big fuss on learning C++  the C way. And because I know C I don't want to start using C in C++. This is something I want to avoid.

 

So I want a book that doesn't learn you to program the C way in C++. I don't care if it's an super introductory book I don't mind. I just want the book to explain well the object oriented concepts and the best way to program in C++.

 

 

 

Thanks smile.png

 

 


Failure is not an option...


Sponsor:

#2 jbadams   Senior Staff   -  Reputation: 19324

Like
11Likes
Like

Posted 12 February 2014 - 02:41 AM

If you're still learning some of the basics of C it may be worth spending more time with C before moving on -- have you actually written any small programs or games using the language, or only worked through your book/tutorials?  If you wanted to make a small game with C you could consider using a library such as SDL or Allegro to write some simple graphical games such as a Pong or Breakout clone; the experience of writing a complete program -- even if it's a small one -- can be an invaluable learning experience.

 

 

 

It's absolutely your decision however, and there's not really any correct or incorrect approach.  If you feel you're ready to move on to C++ I'd recommend C++ Primer (5th Edition); it's an excellent book that's been updated to the latest standard (C++11) and attempts to focus on best practices and proper modern use of the language rather than simply showing you the syntax.  If you're looking for an online resource (either as an alternative, or to supplement your book) my suggestion would be LearnCpp.com.

 

 

Hope that helps! smile.png



#3 Aliii   Members   -  Reputation: 1448

Like
2Likes
Like

Posted 12 February 2014 - 03:21 AM

On Youtube you can find long presentations form Stroustrup where he talks about how not to look at at C++ as C with classes and how to do things the C++11 way. They might sound a bit advanced though.

 

This was the last one I saw: "The Essence of C++: With Examples in C++84, C++98, C++11, and C++14"



#4 Nathan2222_old   Members   -  Reputation: -400

Like
0Likes
Like

Posted 12 February 2014 - 08:58 AM

Jumping into c++ and the cplusplus.com pdf

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#5 dmatter   Crossbones+   -  Reputation: 3293

Like
3Likes
Like

Posted 12 February 2014 - 01:46 PM

If your goal is as stated, to learn an object-oriented language then I think C# is the one to choose of the three.

 

Java, as you mention, is something you will learn at university anyway.

 

C++ is an old, large, complex language and has plenty of things in it that don't relate to OO. As I get older I like C++ less and less (or rather I dislike it more and more), the infuriating anachronisms of C++ make it a language I'd advise people to stay away from unless they have no choice.

 

C# is Java-esque, so it will give you an edge when learning Java at uni. But it is actually a much nicer language than Java (and C++, but that's setting a pretty low bar anyway).

 

Another good candidate is Python, btw.

 

If I absolutely had to use a systems language and had my choice of them then I would skip C++ and go straight to Rust or Go.

 

Once you know the C#/Java way of doing things you might actually have a better idea how to approach C++. C-style C++ results in questionable code (unless it was done for a good reason) but C#/Java-style C++ is not a bad place to start and then you can selectively bring in some of the actually-nice C++ features like free-functions, typedefs, better-generics (templates, but don't go overboard with them), deterministic destruction, const, auto, maybe some others. A lot of the C++ language you just want to ignore day-to-day really (javascript's headed that way too).



#6 dejaime   Crossbones+   -  Reputation: 4119

Like
0Likes
Like

Posted 12 February 2014 - 09:14 PM

I learned C++ right after C, and I do not regret it.

When I needed Java, it took me two days to be capable enough for the tasks.

I studied C# to code a tool, and even though it took me longer than Java to get the hang of, the learning was also fast and easy enough.

 

But I like to learn languages as I need them. It reinforces the concept that they are the tools; and that I am not their programmer.

The only times where I research new languages that I won't really need (notice I said research, not learn) is when I am evaluating new technologies, what I do from time to time. Still, this research process should never take over two days.

 

And as you said you'll be needing Java, I'd go for it.

 

I guess the best C++ book recommendation I can give you, following what you asked, is C++ for dummies.


Edited by dejaime, 13 February 2014 - 11:15 AM.


#7 Krohm   Crossbones+   -  Reputation: 3245

Like
0Likes
Like

Posted 13 February 2014 - 01:23 AM

I wouldn't go on C++ right now. Main problem is that there's no such thing as "C++" to start with. I mean just read this:


On Youtube you can find long presentations form Stroustrup where he talks about how not to look at at C++ as C with classes and how to do things the C++11 way. They might sound a bit advanced though (1).
 
This was the last one I saw: "The Essence of C++: With Examples in C++84, C++98, C++11, and C++14" (2)

Here's what I read "between the lines":

  1. The new, non-broken way. But wait, because the new not-broken way is complex.
  2. 4 versions. Four.

I'd probably go C# right now. Java left me a bitter taste and not in the good way.



#8 cdoubleplusgood   Members   -  Reputation: 847

Like
6Likes
Like

Posted 13 February 2014 - 02:43 AM


I wouldn't go on C++ right now. Main problem is that there's no such thing as "C++" to start with.

Oh, come on.

I'm so happy that C++ is evolving again, after so many years of standstill. Simply take a modern compiler like MSVC or GCC and take off. There are still some minor restrictions regarding C++11 support, but well, if it's not one thing, it's another.

And regarding different versions: What C# version are you going to learn: 3, 4, 5? And what .net framework: 3.5, 4.0, 4.5?



#9 shadowstep00   Members   -  Reputation: 538

Like
2Likes
Like

Posted 13 February 2014 - 03:17 AM

Guys I am determined to learn C++ and do some serious stuff with it until the end of the year. :P 

 

I will take a look at the books you recommended me.

I already started with C++ Primer as it is the most advanced and will get me quickly moving. (see if I can keep up with it)

 

 

Thanks for your suggestions!


Failure is not an option...


#10 Karsten_   Members   -  Reputation: 1655

Like
2Likes
Like

Posted 13 February 2014 - 06:23 AM

I'd probably go C# right now. Java left me a bitter taste and not in the good way.

 

If you want an even more bitter taste, try using C# with Windows Metro... They cut out loads of classes for their core profile and does tend to cause quite a few headaches.

 

Whilst C++ is a perfectly robust language, the only one I have known not to evolve in any radical way (for many years) is C.

 

... Oh wait, you say that there is now <stdbool.h>? C99 is Madness!


Edited by Karsten_, 13 February 2014 - 06:36 AM.

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


#11 Bacterius   Crossbones+   -  Reputation: 9262

Like
0Likes
Like

Posted 13 February 2014 - 06:54 AM

 

I'd probably go C# right now. Java left me a bitter taste and not in the good way.

 

If you want an even more bitter taste, try using C# with Windows Metro... They cut out loads of classes for their core profile and does tend to cause quite a few headaches.

 

Whilst C++ is a perfectly robust language, the only one I have known not to evolve in any radical way (for many years) is C.

 

... Oh wait, you say that there is now <stdbool.h>? C99 is Madness!

 

 

There's C11 too, though admittedly I don't use it but have been told it contains mostly atomics/threading stuff and some utilities designed to make writing cross-platform programs useful, such as a standard alignment keywords (read: all major C projects already have platform-independent wrappers for these, especially for platforms which are not going to support C11 anyway - such as MSVC - meaning C11 is pretty much useless all around). Oh well, at least they tried.


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#12 Karsten_   Members   -  Reputation: 1655

Like
2Likes
Like

Posted 13 February 2014 - 09:17 AM

Yes, admittedly I have never even seen C11 code in the wild.

 

I still dont think MSVC fully supports C99 either which is quite annoying. Microsoft's excuse was that they would rather spend time on C++0x functionality.

Now, as a C++ developer, I agree with this choice. Unfortunately their C++ support is a bit lacking too :/

 

With Microsoft's new direction with C++ (Albeit C++/CX) perhaps we will see them make up a bit of ground here in the near future including in C support.


Edited by Karsten_, 13 February 2014 - 09:19 AM.

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


#13 Serapth   Crossbones+   -  Reputation: 5666

Like
0Likes
Like

Posted 13 February 2014 - 05:59 PM

 


I wouldn't go on C++ right now. Main problem is that there's no such thing as "C++" to start with.

Oh, come on.

I'm so happy that C++ is evolving again, after so many years of standstill. Simply take a modern compiler like MSVC or GCC and take off. There are still some minor restrictions regarding C++11 support, but well, if it's not one thing, it's another.

And regarding different versions: What C# version are you going to learn: 3, 4, 5? And what .net framework: 3.5, 4.0, 4.5?

 

 

Frankly, beyond the move to Generics ( 1.1 -> 2 I believe ), almost everything that changed with the language has basically stayed the same.  It's evolutionary changes, like support for parallel programming.  Simply put though, idiomatic C#2 and C#5 are basically identical.  The same can certainly not be said for C with Class to C++14.

 

 

Ironically, one of the biggest warts in C#/.net IS the existence of non-generic containers.



#14 Servant of the Lord   Crossbones+   -  Reputation: 20945

Like
10Likes
Like

Posted 13 February 2014 - 08:28 PM

The new, non-broken way. But wait, because the new not-broken way is complex.

In some ways C++11 has made things simpler by adding higher-level features (abstraction-wise) actually making it easier to learn C++.
There are a few more interesting under-the-hood features that are technical and really powerful, but the average programmer doesn't need to know them anymore than the average programmer needs to know assembly.

4 versions. Four.

No, there's just C++. C++11 (and C++14) are entirely backwards compatible with C++98.
And it's not "oh, we'll add in code to make the language more bulky but backwards compatible", C++11 and C++14 expanded C++98 in very good ways, and deprecated almost nothing. It's the same language. They just made it behind the scenes better, and also added more standard library classes.

Virtually nothing that was in C++ has changed in C++11 or C++14. Stuff has been added, almost nothing has been taken away. Even so, the language is even more streamlined, not just adding stuff willy-nilly but adding features and classes that fill gaps in a seamless and integrated way.

Infact, the exact same code compiled with C++98, if it's recompiled today, A) Should compile fine (barring compiler idiosyncrasies), and B) actually be faster. Ideally - actual results may vary; C++98 was good, C++11 is even better. I actually use C++, and am very pleased with C++11.

C++84 was before C++ was even standardized, and nobody really uses it anymore anyway. It doesn't have a place in discussion of modern C++ (anything 2003 onward), except to discuss history.
It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#15 Xai   Crossbones+   -  Reputation: 1459

Like
6Likes
Like

Posted 14 February 2014 - 06:12 PM

I also love how people complain about C++, C# or Java version issues, and then don't comlain about Perl, Python or Ruby versions issues ... which are absolutely the worst, except most of the history of Perl 5 has been about as stable as C++,C# and Java ... hell, you can just now BARELY get a linux distro that ships with Python 3 (which is at 3.3) because they have a dependency on incompatible Python 2 code.  And ruby, a langauge I actually like, got stuck at 1.8 for more than 2 years after 1.9 was released, and now that 2.0 is released, only 1 major distro ships it.

 

The fact is in my entire C++ history, I had exactly 1 type of code I actually used that wasn't compatible with C++ 11 - related to how it disambiguates names in some cases.  I spent 3 hours fixing my code base, problem gone.

 

Also, in C#, none of my working code has ever failed to work on newer versions, except for 1 change they made with 1.1 as a security fix.



#16 Bacterius   Crossbones+   -  Reputation: 9262

Like
0Likes
Like

Posted 18 February 2014 - 04:51 AM

I also love how people complain about C++, C# or Java version issues, and then don't comlain about Perl, Python or Ruby versions issues ... which are absolutely the worst, except most of the history of Perl 5 has been about as stable as C++,C# and Java ... hell, you can just now BARELY get a linux distro that ships with Python 3 (which is at 3.3) because they have a dependency on incompatible Python 2 code.  And ruby, a langauge I actually like, got stuck at 1.8 for more than 2 years after 1.9 was released, and now that 2.0 is released, only 1 major distro ships it.

 

The fact is in my entire C++ history, I had exactly 1 type of code I actually used that wasn't compatible with C++ 11 - related to how it disambiguates names in some cases.  I spent 3 hours fixing my code base, problem gone.

 

Also, in C#, none of my working code has ever failed to work on newer versions, except for 1 change they made with 1.1 as a security fix.

 

Yeah, the Python 2 vs Python 3 thing is driving me nuts. I get that backwards compatibility is a good thing, but it was just so unnecessary to spawn an incomplete 3.x version leaving 80% of the Python community stranded on 2.x because of dependencies. The amount of developer manpower lost on this issue is probably enough to power a small city for several decades, and is a PITA for anyone considering Python as a development platform.


The slowsort algorithm is a perfect illustration of the multiply and surrender paradigm, which is perhaps the single most important paradigm in the development of reluctant algorithms. The basic multiply and surrender strategy consists in replacing the problem at hand by two or more subproblems, each slightly simpler than the original, and continue multiplying subproblems and subsubproblems recursively in this fashion as long as possible. At some point the subproblems will all become so simple that their solution can no longer be postponed, and we will have to surrender. Experience shows that, in most cases, by the time this point is reached the total work will be substantially higher than what could have been wasted by a more direct approach.

 

- Pessimal Algorithms and Simplexity Analysis


#17 Nathan2222_old   Members   -  Reputation: -400

Like
-6Likes
Like

Posted 18 February 2014 - 04:59 AM

Arrays in c++11 is in no way helpful (it's so confusing especially when multi-dimensional)

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#18 Servant of the Lord   Crossbones+   -  Reputation: 20945

Like
5Likes
Like

Posted 18 February 2014 - 04:31 PM

Arrays in c++11 is in no way helpful (it's so confusing especially when multi-dimensional)

If you are referring to std::array, you have to understand the proper usage for a tool. Metal hack-saws are 'in no way helpful' when I'm cutting stone. Masonry blades are 'in no way helpful' when I'm cutting rebar.
Most of my (real-life) tools sit unused for years until certain circumstances arise where it suddenly becomes the best tool, or even the only tool, for the job. Some tools are general-purpose, like a circle-saw or a drill or a hammer. Some tools are for a really really specific purpose that save hours of hard labor only once in a blue moon.

std::arrays serve a very important purpose because, by not being dynamically allocated, they can place the memory directly on the stack making it more efficient. By default, just use std::vector. But when optimizing code, std::array is available.

std::vector is incredibly fast as it is - plenty fast for anything I want to use it for - and is as fast or faster than similar containers in almost any other language. However, for those few situations that need it, std::array is available to eek out a smidgen bit more performance (when used properly) in certain circumstances. This extra performance is needed in highly graphically-intensive AAA games, or in web servers handling millions of user interactions. Performance gains on servers directly translates into real money savings when added up every year (for some companies, hundreds of thousands of dollars in savings if you can use a tiny bit less electricity or handle two or three more users per server instead of buying more servers).

But default to std::vector. std::vector is general purpose, and lightning fast. std::array is specialized, more limited, harder to use, but (in some very needed cases) slightly faster.
It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]


#19 Nathan2222_old   Members   -  Reputation: -400

Like
1Likes
Like

Posted 20 February 2014 - 07:30 AM

sorry for not specifying the array part. i meant the way it is represented in c++11.

int arr[3][4] is so much clearer than std::array <std::array <int, 3>, 4> arr, at least to me.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32
smile.png
--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy


#20 Servant of the Lord   Crossbones+   -  Reputation: 20945

Like
0Likes
Like

Posted 20 February 2014 - 02:18 PM

Oh yea, that'd definitely be clunky.

I prefer not to use 2D arrays anyway. happy.png I find it is easier to use 1D array and just do the conversions myself:

std::vector<int> arr(3 * 4);
 
//I can iterating over it as if it's 2D:
for(int y = 0; y < height; ++y)
{
    for(int x = 0; x < width; ++x)
    {
         arr[(y * width) + x] = ...;
    }
}
 
//But I can also iterating as if it's 1D:
for(int i = 0; i < (width*height); ++i)
{
    arr[i] = ...;
}

 

But if you want a clean class to use, you could wrap your "std::array <std::array <int, 3>, 4>" into a new (re-usable) template class: Array2D<int,3,4>, and write one or two quick member functions to make it easier to access the data.


It's perfectly fine to abbreviate my username to 'Servant' rather than copy+pasting it all the time.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal

[Fly with me on Twitter] [Google+] [My broken website]

[Need web hosting? I personally like A Small Orange]





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS