C++, a good starting language?


O

Omar Radwan

I am currently learning C++, from this book http://www.amazon.com/Beginning-C-T...00802533&sr=8-1&keywords=Game+programming+C++ and I am so far on the 200th page. Half way through. The problem is though, I still don't know howto write code in C++, I would have expected to be able to by the half-bookmark. This is my first language, I totally understand the material that istill the 200th page (functions, I/O, arthemitc operators, variables, constants, enumerations, loops, if/else, switch-case, arrays, functions, and refrences), so I also know the concept. But I don't know how to "code" yet. I don't want to become a game programmer. I want to become a system programmer, like in Unix, BSD, and Linux and stuff like that. The reason that I chose C++ is that because it's extremely powerful, low-level like C, and has high level things too, like classes and objects. Am I going through the rightpath? Or should I switch? Do you guys have any idea what I should do?
 
Ad

Advertisements

S

Stefan Ram

Omar Radwan said:
and I am so far on the 200th page.

So, you are on page number 199.
problem is though, I still don't know how to write code in
C++

»int main(){}«.
I would have expected to be able to by the half-book
mark.

I suggest to read this web page:

»Teach Yourself Programming in Ten Years - Peter Norvig«
This is my first language, I totally understand the
material that is till the 200th page (functions, I/O,
arthemitc operators, variables, constants, enumerations,

If you »totally understand« it, then let us know what
your definition of »variable« is.
 
S

Stefan Ram

Omar Radwan said:
I want to become a system programmer, like in Unix, BSD, and Linux

Linus Torvalds:

»C++ is a horrible language. It's made more horrible by
the fact that a lot of substandard programmers use it (...)

I've come to the conclusion that any programmer that would
prefer the project to be in C++ over C is likely a
programmer that I really *would* prefer to [move on], so
that he doesn't come and [disturb] any project I'm involved
with. (...)«

http://lwn.net/Articles/249460/
 
O

Omar Radwan

I am currently learning C++, from this book http://www.amazon.com/Beginning-C-T...00802533&sr=8-1&keywords=Game+programming+C++ and I am so far on the 200th page. Half way through. The problem is though, I still don't know how to write code in C++, I would have expected to be able to by the half-book mark. This is my first language, I totally understand the material that is till the 200th page (functions, I/O, arthemitc operators, variables, constants, enumerations, loops, if/else, switch-case, arrays, functions, and refrences), so I also know the concept. But I don't know how to "code" yet. I don't want to become a game programmer. I want to become a system programmer, like in Unix, BSD, and Linux and stuff like that. The reason that I chose C++ is that because it's extremely powerful, low-level like C, and has high level things too, like classes and objects. Am I going through the right path? Or should I switch? Do you guys have any idea what I should do?

Ok, maybe I wasn't clear enough, by writing code, I meant to be able to write a text editor, or a terminal web browser, or an ftp or http ot tcp server or client. But I did write a Pi calculator program which can calculate about 10 different shapes involving Pi
 
S

Stefan Ram

Omar Radwan said:
Ok, maybe I wasn't clear enough, by writing code, I meant to
be able to write a text editor

My take at a text editor in C++ (I do not yet have ::std::stoi):

#include <iostream>
#include <cstdlib>

int main()
{ ::std::cout << "i1 insert \"1\"\n+1 move cursor right\n-1 "
" move cursor left\nd1 delete 1 character\n";
::std::string s{ "alpha" }, c; int pos = 0; do
{ ::std::cout << s << '\n' << ::std::string( pos, ' ' ) << '^' << '\n';
::std::cin >> c; switch( c.at( 0 ))
{ case 'i': s.insert( pos, c.substr( 1 )); break;
case '+': pos += atoi( c.substr( 1 ).c_str() ); break;
case '-': pos -= atoi( c.substr( 1 ).c_str() ); break;
case 'd': s.erase( pos, atoi( c.substr( 1 ).c_str() )); break; }} while( 1 ); }
 
W

woodbrian77

I am currently learning C++, from this book http://www.amazon.com/Beginning-C-T...00802533&sr=8-1&keywords=Game+programming+C++ and I am so far on the 200th page. Half way through. The problem is though, I still don't know how to write code in C++, I would have expected to be able to by the half-book mark. This is my first language, I totally understand the material that is till the 200th page (functions, I/O, arthemitc operators, variables, constants, enumerations, loops, if/else, switch-case, arrays, functions, and refrences), so I also know the concept. But I don't know how to "code" yet. I don't want to become a game programmer. I want to become a system programmer, like in Unix, BSD, and Linux and stuff like that. The reason that I chose C++ is that because it's extremely powerful, low-level like C, and has high level things too, like classes and objects. Am I going through the right path? Or should I switch?
Do you guys have any idea what I should do?

Not really, but you could do worse than C++.
Java sucks and I don't like Perl either.
I suggest starting a company. When you have some
free time, work on the company. The company can become
a foundation for your future; a vehicle that can
help you with taxes and such. You don't have to
start a company this year, but don't put it off
too long.


Brian
Ebenezer Enterprises - Heavenly code.
http://webEbenezer.net
 
Ad

Advertisements

Ö

Öö Tiib

Ok, maybe I wasn't clear enough, by writing code, I meant to be able
to write a text editor, or a terminal web browser, or an ftp or http
ot tcp server or client. But I did write a Pi calculator program which
can calculate about 10 different shapes involving Pi

Calm down, no one becomes brain surgeon or system programmer after
reading 200 pages. It takes years to learn of doing things properly.

Take Python as first language for to trying things out quickly. Or maybe
take Scheme that is one of the most minimalist programming languages.
Later you can learn C++ or Java.

Web browsers like Firefox or Chrome contain millions of lines of C++.
Do not aim to make such huge things that take years of effort from
big teams of engineers.
 
J

Jorgen Grahn

Linus Torvalds:

»C++ is a horrible language. It's made more horrible by
the fact that a lot of substandard programmers use it (...)

If you agree with that, why are you here? Trolling?
Or did I miss your point?

/Jorgen
 
J

Jorgen Grahn

So you guys think I should learn C instead?

Based on what you said you wanted: no!

I want to become a system programmer, like in Unix, BSD, and Linux
and stuff like that. The reason that I chose C++ is that because
it's extremely powerful, low-level like C, and has high level
things too, like classes and objects.

You can do Unix systems programming easier and better with C++. You
just need to be aware that in existing code, C is much more common,
and a lot of C programmers are prejudiced against C++. Also in my
experience it's easier to get a job doing C programming.

/Jorgen
 
A

Aditya Raj Bhatt

The answer is, it depends. For me, I learnt a bit of visual basic and logo in
school (this is when I was a kid in 7th grade or so) which taught be a bit about
variables and other basic concepts (loops, statements). But this stuff can be
understood very easily if encountered the first time in C++ too. Apart from
that, I started learning C++ in 11th grade, and then 12th. In that time, I
learnt all about structures, functions, OOP, templates and other advanced
concepts very easily. It helps if you have a good book.

As far as a starting book is concerned, your game programming one is not ideal
in my opinion. I think you should start with _C++ Primer_ (get the latest fifth
edition).

NOTE : Not to be confused with C++ Primer Plus, which is not as good.

C++ Primer is a very good book and has been updated for the latest C++11
standard. It teaches all the basic concepts and does not assume knowledge of C
in the reader (although it will not hold your hand for the fundamentals, like
what are variables, functions etc. but from your post, I think you already
understand these).

Buy this book from
http://www.amazon.com/Primer-5th-Edition-Stanley-Lippman/dp/0321714113 and also
go through this list of c++ books on stackoverflow
http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

Good luck, and if you have any further questions, email me at
(e-mail address removed) or post in this group.

P.S - If you can not afford the book, email me and I will send you a pdf version
(although I can afford my books now, I was not able to for a long time, and
learned to program by torrenting books (though I bought them all later) so I can
understand if you want the pdf)
 
Ad

Advertisements

J

Jorgen Grahn

Calm down, no one becomes brain surgeon or system programmer after
reading 200 pages. It takes years to learn of doing things properly.

Take Python as first language for to trying things out quickly. Or maybe
take Scheme that is one of the most minimalist programming languages.
Later you can learn C++ or Java.

I think he can start with C++.
Web browsers like Firefox or Chrome contain millions of lines of C++.
Do not aim to make such huge things that take years of effort from
big teams of engineers.

True. But it needs to be pointed out that C++ isn't just for monsters
like those. Specifically, anything that's worth doing in C can be
done better in C++.

OP: since you're on Linux I recommend reimplementing some of the simpler
Unix commands: ls, sort, uniq, ... Don't bother with all the options
at first.

Another option is to study and modify some existing, good C++ program.

/Jorgen
 
Ö

Öö Tiib

If you agree with that, why are you here? Trolling?
Or did I miss your point?

The point was perhaps humorous coincidence of situation:
* OP describes himself as extremely substandard programmer.
* OP wants to do system programming in C++ on Linux.
* Linux is crown-child of Linus Torvalds.
* Linus Torwalds is militant against C++ for the very reason above.

:D

Otherwise it is outright irrational stance because programmers
thought can not be someway "squeezed into a cage" of vocabulary
and grammar of programming language that they use. No one does
literally think in C++ or C or Java so what they talk about are some
conveniences, complexities or hidden costs of expressing particular
designs in particular ways. IOW minor issues on general case.
 
S

Stefan Ram

Aditya Raj Bhatt said:
that, I started learning C++ in 11th grade, and then 12th. In that time, I
learnt all about structures, functions, OOP, templates and other advanced

I you »learnt all about« »OOP«, then answer these questions:

Who coined the term OOP, and what was his definition of OOP?
 
S

Stefan Ram

I am biased by the path I have followed. Personally, I think it
is better to first learn to program with something simple -- C,
Pascal, BASIC -- to get the core concepts. That view is not dominant

Pascal, BASIC, and C are all simpler than C++, but C is more
close to today's popular languages.

BASIC is less clearly specified (which specification exactly does
»BASIC« refer to?) and less well supported on modern operating
systems. Pascal is more clearly specified (one still has a choice
among several versions), but also less supported today.

C has the unique feature that very often its calling convention
also is the OS' ABI.
 
S

Stefan Ram

Jorgen Grahn said:
If you agree with that, why are you here?

Maybe you have misunderstood the name »comp.lang.c++«:
It does not mean it's a newsgroups for /C++ advocates/,
it is a newsgroup for /discussions about C++/.

(Moreover, I have not written that I agree with that.)
 
Ad

Advertisements

A

Aditya Raj Bhatt

I you �learnt all about� �OOP�, then answer these questions:



Who coined the term OOP, and what was his definition of OOP?

Please do not test me like this, I know about Alan Kay's definition of OOP (he
was the one who coined it) and the distinctly different implementation of it in
Smalltalk (as opposed to C++). No, I do not claim to know smalltalk (apart from
some toy programs to see what message passing was all about). I know about Alan Kay's different definitions only because I waste a lot of my time trawling
through programming blogs online. Right now, I am trying my hand at lisp and
know only high-school level C++ properly (I'm 17, by the way).

So I probably will not be able to answer any detailed questions you may ask
me.
 
S

Stefan Ram

Aditya Raj Bhatt said:
Please do not test me like this

When someone says he knows »all about« something, I sometimes
cannot resists the temptation to try to learn something from him.
through programming blogs online. Right now, I am trying my hand at lisp and
know only high-school level C++ properly (I'm 17, by the way).

When I wrote my first LISP programs I must have had the same
age. Gradually, today, all other programming languages try
to incorporate some parts of what LISP already had had many
decades ago.
 
J

Jorgen Grahn

Maybe you have misunderstood the name »comp.lang.c++«:
It does not mean it's a newsgroups for /C++ advocates/,
it is a newsgroup for /discussions about C++/.
(Moreover, I have not written that I agree with that.)

True, but it was posted as a response to a newbie and without comment.
Someone suggested it might have been a joke: was it?

/Jorgen
 
Ad

Advertisements

J

Jorgen Grahn

Pascal, BASIC, and C are all simpler than C++, but C is more
close to today's popular languages. ....
C has the unique feature that very often its calling convention
also is the OS' ABI.

It's not unique -- you can use those OS interfaces just as easily from
C++. At least on Unix.

/Jorgen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top