New to programming, where to start?

Page 4 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
I just don't get why you'd favor C for that either. The C++ code I'm currently writing is very much procedural, and almost every individual line relies on C++ features. Having to write it in C would bloat it probably to something like 3-5x as much code, much less readability, more bugs, less efficiency. And this is for very small individual apps; for a larger system the memory management stuff of C++ would just get more important.

It depends really.I find no difference in professionally written C vs C++ code.But if it needs C++ features I don't hesitate to use it either.I believe my perspective have become biased because of my very early adventures into C.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
It depends really.I find no difference in professionally written C vs C++ code.But if it needs C++ features I don't hesitate to use it either.I believe my perspective have become biased because of my very early adventures into C.

Yeah I think you are aliasing things a bit. Specifically, in setting up a dichotomy where some code is "procedural" and other code "makes sense for C++" (my quotes).

Object-oriented design is not an alternative to procedural design. Almost all code is procedural. Object-oriented design subsumes procedural design by including the state of the things the procedures operate on as part of the fundamental unit of program construction. When you focus on behavior of an object it is still decomposed procedurally.

So I am not sure that you have ever actually made the mental paradigm shift to thinking about programs as naturally decomposable into objects.
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
Yeah I think you are aliasing things a bit. Specifically, in setting up a dichotomy where some code is "procedural" and other code "makes sense for C++" (my quotes).

Object-oriented design is not an alternative to procedural design. Almost all code is procedural. Object-oriented design subsumes procedural design by including the state of the things the procedures operate on as part of the fundamental unit of program construction. When you focus on behavior of an object it is still decomposed procedurally.

So I am not sure that you have ever actually made the mental paradigm shift to thinking about programs as naturally decomposable into objects.

Kinda True yes, C feel very natural to me compared to C++.This book is to blame as well :)
http://www.amazon.com/Algorithms-Str...s+%3D+Programs

Our college teacher recommended this book when I started my Computer Engineering, it is very old but a pure gem.It seems I am still stuck with "Algorithms + Data Structures = Programs" :biggrin:
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Kinda True yes, C feel very natural to me compared to C++.This book is to blame as well :)
http://www.amazon.com/Algorithms-Str...s+%3D+Programs

Our college teacher recommended this book when I started my Computer Engineering, it is very old but a pure gem.It seems I am still stuck with "Algorithms + Data Structures = Programs" :biggrin:

The classic is Sedgewick's "Algorithm's in C." I still pull that out from time to time. Which is important, because it points out that object-oriented code still needs to implement algorithms, and execute procedures :).
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
The classic is Sedgewick's "Algorithm's in C." I still pull that out from time to time. Which is important, because it points out that object-oriented code still needs to implement algorithms, and execute procedures :).

Looks like I missed this one.Thanks for the heads up Mark :thumbsup:
 

iCyborg

Golden Member
Aug 8, 2008
1,353
62
91
I also "grew up" with Sedgewick's Algorithms when I was in high school. Recently a friend lent me "The Algorithm Design Manual" by Steven Skiena, and it's an awesome book. I really enjoyed it, and I no longer read tech books that much, everything is online. It's especially great for preparing for interviews at top companies like Google, MS, Apple etc.
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
I also "grew up" with Sedgewick's Algorithms when I was in high school. Recently a friend lent me "The Algorithm Design Manual" by Steven Skiena, and it's an awesome book. I really enjoyed it, and I no longer read tech books that much, everything is online. It's especially great for preparing for interviews at top companies like Google, MS, Apple etc.

I am not sure any algorithm book can match this
http://www.amazon.com/Art-Computer-P...er+programming
 

Jaydip

Diamond Member
Mar 29, 2010
3,691
21
81
I've had all three volumes for ages. They're still useful, but less practically applicable than Sedgewick just because the examples are all in an abstract language that Knuth developed for, or at least utilized for, the books.

Yeah, looks like I have to give Sedgewick a try :)
 

Headfoot

Diamond Member
Feb 28, 2008
4,444
641
126
Some of terrible advice in this thread.

Do NOT start with assembly. That is the worst idea ever. The percentage of programmers who need to know assembly for actual work is extremely tiny.

Do NOT start with C++, especially if you are self-teaching. C++ is mighty useful for system programming, no doubt about that. But the faster you can get something working and see your results, the more learner engagement you get. Start with something like HTML + JavaScript or even Visual Basic .NET, anything where it is easy to see the results. Then move on to the more complicated languages.
 

smackababy

Lifer
Oct 30, 2008
27,024
79
86
Some of terrible advice in this thread.

Do NOT start with assembly. That is the worst idea ever. The percentage of programmers who need to know assembly for actual work is extremely tiny.

Do NOT start with C++, especially if you are self-teaching. C++ is mighty useful for system programming, no doubt about that. But the faster you can get something working and see your results, the more learner engagement you get. Start with something like HTML + JavaScript or even Visual Basic .NET, anything where it is easy to see the results. Then move on to the more complicated languages.

How can you not see the results of a C++ program? You make a main and you run it. Not that complicated so see your results.
 

Pia

Golden Member
Feb 28, 2008
1,563
0
0
How can you not see the results of a C++ program? You make a main and you run it. Not that complicated so see your results.
Hard to get worthwhile results compared to using something like Python that is actually suitable for beginners.
 

irishScott

Lifer
Oct 10, 2006
21,562
3
0
Hard to get worthwhile results compared to using something like Python that is actually suitable for beginners.

Huh? Don't get me wrong I think Python is a better starting point for a number of reasons, but having witnessed (and taken) introductory programming classes in both languages, the nature of the assignments and "results" is virtually identical; unless you count the c++ class introducing pointers at the tail end of the semester. I suppose Python has more easily utilized graphics libraries so the noobs can make something flashy, but beyond that...
 

Pia

Golden Member
Feb 28, 2008
1,563
0
0
Huh? Don't get me wrong I think Python is a better starting point for a number of reasons, but having witnessed (and taken) introductory programming classes in both languages, the nature of the assignments and "results" is virtually identical; unless you count the c++ class introducing pointers at the tail end of the semester. I suppose Python has more easily utilized graphics libraries so the noobs can make something flashy, but beyond that...
People get into programming in order to do stuff, and almost everything people might actually want to do requires libraries on top of standard C++. Graphics, networking, web, databases, even something as basic as browsing the filesystem for a file (!) requires finding and using libraries on top of standard C++.

Of course, there are myriad ways C++ can trip people up before they accomplish anything at all. One of the leading compilers lacks language features so basic that an example program only slightly more complicated than Hello World can fail to compile. It's a demoralizing and frankly ridiculous task for a newbie to figure out in that situation that it is the compiler's fault. Figuring out incantations like "-std=c++11 -stdlib=libc++ -O3 -Weverything -Wno-c++98-compat" to get one of the better compilers to work properly is not good either. And then you have to figure out how the compilation model works, what headers are for, what the weird preprocessor stuff around the header is etc. - all stuff that has nothing to do with programming in general, and everything to do with C/C++ specifically.

Someone building an elementary programming course can design around a lot of the issues, provide a safe(r) environment, structured approach and guidance that prevents students running into most of C++'s bullshit as long as they stay within the designed exercises. The external motivation provided by the course also lessens the need for motivation that comes from accomplishing something of practical value. The experience of a self-learner is much, much worse.
 

smackababy

Lifer
Oct 30, 2008
27,024
79
86
People get into programming in order to do stuff, and almost everything people might actually want to do requires libraries on top of standard C++. Graphics, networking, web, databases, even something as basic as browsing the filesystem for a file (!) requires finding and using libraries on top of standard C++.
Sorry, but getting into programming, you're not going to be 'doing stuff' until you understand how to do it. Nobody picks up a basketball the first time and expects to be an NBA player. You have to learn the basics, the fundamentals, and then you put in tens of thousands of hours.

Every beginner result you can see just fine in C++. Nothing you listed is anything a real beginner is going to do, and someone who isn't a beginner in other languages will understand how libraries work and that won't be a problem.

I don't understand what 'worthwhile' results are for a beginner. Does it print 'Hello World' to the console in Python more worthwhile than C++?
 

Pia

Golden Member
Feb 28, 2008
1,563
0
0
Every beginner result you can see just fine in C++. Nothing you listed is anything a real beginner is going to do,
Sure they are, if they have a powerful standard library to do it with. It would be a reasonable project for a Python beginner to write a program that periodically checks a web page and alerts if specific text shows up. Or to write a program that goes through a camera upload folder and renames all files to a nicer format. These are both tiny tasks, but ones that can have a real-world benefit and corresponding motivating effect instead of being merely academic exercises.
and someone who isn't a beginner in other languages will understand how libraries work and that won't be a problem.
OK, now you must be joking. Finding, obtaining, installing and using third party C++ libraries is no problem? Compared to Python, no less?

You have no idea how hard people can trip up in the very basics of C++. Even people with previous programming experience. Even in a teaching environment where they have been supplied with computers with all the correct tools installed, and given instructions with all the correct settings and exercise-specific hints.
 

irishScott

Lifer
Oct 10, 2006
21,562
3
0
Sure they are, if they have a powerful standard library to do it with. It would be a reasonable project for a Python beginner to write a program that periodically checks a web page and alerts if specific text shows up. Or to write a program that goes through a camera upload folder and renames all files to a nicer format. These are both tiny tasks, but ones that can have a real-world benefit and corresponding motivating effect instead of being merely academic exercises.
OK, now you must be joking. Finding, obtaining, installing and using third party C++ libraries is no problem? Compared to Python, no less?

And that's great, if you're training a code monkey. But there are tons of academic concepts when it comes to programming, and while you can integrate them into practical projects (and every course I've ever seen does, usually in the form of a final project) you have to master the fundamentals first.

The sports analogy is apt. You don't train a winning team by having them play the sport all the time. 75% of practice time consists of drills, and then you scrimmage at the very end.

Learning to program by doing nothing but "practical tasks" and ignoring fundamentals (including technical fundamentals like memory management) will result in inefficient, hacky code.

You have no idea how hard people can trip up in the very basics of C++. Even people with previous programming experience. Even in a teaching environment where they have been supplied with computers with all the correct tools installed, and given instructions with all the correct settings and exercise-specific hints.

"Tripping up" over dumb shit and learning how to deal with it is the nature of software development. There are tools to make it easier, but it's never eliminated. If you can't put up with looking up command-line flags and configuration settings, programming on a professional level is not for you. Even if you don't need to learn those specific flags, you'll have to do similar tasks. Python is not exempt from this.
 

Pia

Golden Member
Feb 28, 2008
1,563
0
0
But there are tons of academic concepts when it comes to programming, and while you can integrate them into practical projects (and every course I've ever seen does, usually in the form of a final project) you have to master the fundamentals first.
And what makes you think I'm advocating skipping fundamentals? For instance, opening a file on disk, iterating through it and searching for a string match is a classic programming exercise suitable for an introductory course. Checking whether a webpage contains a given piece of text is the exact same thing in abstract. When you have the means to open a file-like object from a URL, which Python standard library does, the two are also equivalent in practice. The latter is just more compelling.
 

Pia

Golden Member
Feb 28, 2008
1,563
0
0
"Tripping up" over dumb shit and learning how to deal with it is the nature of software development. There are tools to make it easier, but it's never eliminated. If you can't put up with looking up command-line flags and configuration settings, programming on a professional level is not for you. Even if you don't need to learn those specific flags, you'll have to do similar tasks. Python is not exempt from this.
I don't see how your argument here has anything to do with the thread. The topic is "where to start?". Languages that have the most dumb shit are the worst choices for introductory programming languages. C++ has tons and tons of dumb shit. It's bad for beginners. The end.
 

irishScott

Lifer
Oct 10, 2006
21,562
3
0
I don't see how your argument here has anything to do with the thread. The topic is "where to start?". Languages that have the most dumb shit are the worst choices for introductory programming languages. C++ has tons and tons of dumb shit. It's bad for beginners. The end.

Or it's good for beginners because they learn what they're up against early on, and those who are really determined will figure it out. But then again I've always been a proponent of teaching to the top of the class.

Dealing with dumb shit is as vital a technique as string manipulation. In dealing with it you learn the structure of the development tools and how everything fits together, as opposed to a black box that does the hard work for you. If you don't like nitty-gritty, or can't stand it, then what are you doing in a programming class?

I agree that Python is a better place to start because you can focus more in-depth on the logic and algorithms, and explain the technical theory before transitioning to a lower level language and implementing it; but I disagree that c++ is bad for beginners. It may not be attractive to beginners, but the difference between starting with Python and starting with c++ is like the difference between the State Police Academy and Marine Corps Training.
 

irishScott

Lifer
Oct 10, 2006
21,562
3
0
Can you further explain this analogy? I don't get it at all.

In a nutshell, "c++ is more hardcore."

Python is easier and doesn't force you to learn many technical details. You make a .py file and start writing code, which consists of clean, readable syntax.

c++ forces you to learn at least some technical details right off the bat just to get it up and running. You have to know to make a main, basic compiler commands, and more complicated syntax.

In short, I'd say someone who's only fluent in c++ will generally be a more highly skilled programmer than someone who's only fluent in python. (Marine vs Police Officer), ditto for someone who's taken an introductory course in c++ vs someone who's taken an introductory course in python.
 
Last edited:

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
In a nutshell, "c++ is more hardcore."

Python is easier and doesn't force you to learn many technical details. You make a .py file and start writing code, which consists of clean, readable syntax.

c++ forces you to learn at least some technical details right off the bat just to get it up and running. You have to know to make a main, basic compiler commands, and more complicated syntax.

In short, I'd say someone who's only fluent in c++ will generally be a more highly skilled programmer than someone who's only fluent in python. (Marine vs Police Officer), ditto for someone who's taken an introductory course in c++ vs someone who's taken an introductory course in python.

I've been thinking about this off and on for the last day or so, and ultimately I think it's wrong. In the end, the things that matter are the definition of what you want the system to do, and the system's actual behavior. All the stuff in between, languages, compilers, etc., are just tools used in moving from where you are to where you have to be. If you could set up a complex system tomorrow by accumulating knowledge and then letting the computer scan your brain then that's what you would do.

I don't think we'll ever get past the fundamental workflow of intent=>symbols=>translation=>behavior because I think it's a basic property of how our brains work and how computers work. I don't think we could structure a complex system by talking the machine through it, for example (although I recognize that I probably just don't have the mental paradigms available to me to see how it could work). But within the existing paradigm, and given the incredibly rapid development in our business, it seems a little silly to take a snapshot at any one point in time and enshrine it as dogma.

The historical fact is that C++ improved on the languages that came before it, and the languages that have come after C++ have likewise improved on what it offered. There is no more reason for most modern developers to be fluent in pointer arithmetic than there is for most modern drivers to understand how to dry a damp distributor.