What should I learn first before heading to C++? [closed] - c++

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm learning C, but after that or in the meanwhile, what should I learn first and subsequently before getting into C++ ? Compilers, Data Structures, UML or Design Patterns ?(also when start to learn Win32 API ?) I'm not in a hurry at all, so I can grasp the requirements from the deepest beginning. I just don't want to get lost for being cursory and negligent.
In addition to this, which subjects on mathematics has most impact on coding very well ? Linear Algebra, Discrete Mathematics, Calculus ?
I'll be thankful if someone guides me through this journey. There are many questions I would like to know the answers. Thanks.

First you should learn that C++ is not a superior language. C has its uses as more than a stepping stone into C++. C, and "C-style" C++ are used because they:
Generate smaller binaries
Use less memory
Compile faster
Do not require OS-support
Are simpler, and easier to implement
Data structures are by far the most useful of the listed to learn, followed by algorithms. If you intend to go into C++, it's also useful (mandatory?) to have good design skills.
You should not necessarily learn Win32 at all. Consider learning the POSIX APIs, GTK+ and Boost, as they're more portable, and work on platforms other than Windows.
The best decision you can make is to learn C thoroughly as a separate skill on a Unix platform, before crutching yourself by not being able to see the difference between C and C++.
Of the listed Mathematics disciplines, I've only used discrete mathematics. Linear algebra is also useful, but by far and away the best discipline for programming is set and number theory.
Enjoy your time in C, don't become dependent on Windows/Visual Studio, and don't rush into C++.
Update0
Almost forgot! You absolutely must use a decent C compiler. A central reason to C++'s wide use in enterprise, and the bad reputation C has among Windows developers is Visual Studio. Visual Studio is easily the best C++ IDE, however it's also the worst C compiler I know of. Be sure to use a C compiler with C99 support, such as GCC, mingw or Clang. My first experience with C was using LCC, which was very easy to use on Windows, but I haven't used it since moving to Linux, so I can't comment on its C99 status.

Compilers, Data Structures, UML or Design Patterns ?
Data Structures and Algorithms.
In addition to this, which subjects on mathematics has most impact on coding very well ? Linear Algebra, Discrete Mathematics, Calculus ?
Discrete Mathematics and Number Theory.

You should learn to program in a well structured language first: Ocaml is recommended, Haskell is also good but a bit harder to get a working compiler and harder to learn because it is purely functional.
Mathematics is of little use in programming (the math that is useful is too hard, namely category theory). However some basic type theory is useful.
You can't learn good programming in languages like C, the important stuff is too deeply buried in housekeeping tasks and historical stupidities.

Related

Allow ONLY c++ 11 coding features and style [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is there a way to enforce the use of modern c++ 11 features from the compiler?
We have to start a new project and stay in C++ will benefit us from the use of the our existing tools and libraries, but what is currently hurting us to the death is the abuse of C style coding, raw pointers, C style vectors and all the dangerous C features that are so error prone or produce errors that are really hard to track, you know what i mean.
I read a note about what is bad in C++ today (c++11 and beyond) is the c++ past and the abuse of low level/old features when is not necessary.
I really would like to enforce from the compiler or with other tool the use of c++ 11 features like smart pointers, containers, reference parameters, c++ standard library and not C libraries, etc.
Thank you very much.
EDIT: I thought it is not necessary to clarify the use of code review. etc. I just ask if there is or not a tool/mechanism that filters creating features, or enforce modern safer features/coding practices. All the lose ends we will manage or figure out later. Thank you very much!
You might want to take a look at clang-modernize, it can help with some of what you're looking for. In addition running static analysis to help catch bad practices could help identify areas of your codebase in particular need of some attention / modernization. There are a number of such tools associated with clang and MSVC also has its own static analysis if you're working with Visual Studio.
The only way to ensure c++11 features like auto variable declarations, using lambda definitions, range based for loops, etc. are used preferred to older techniques are human based code reviews.
Usage of deprecated stuff, like usage of std::auto_ptr may be sorted out by warnings already.
But enforcing new way styles might become hard, without having a 2nd pair of experienced eyes looking at the code.
I could think of instrumenting an appropriate static code analysis tool, to detect old style patterns and propose the c++11 standard way to do it, but that's a way too broad topic, and depends on the static analysis tool used.
At the risk of getting downvoted to oblvion.
So you or your "expert" on C++ programming, want to ban certain practices.
Because you know they are bad.
One such practice is using raw pointers. Shame that there are C++ programmers who not only use pointers very often, but think they are a good thing thing to use. Guys like Herb Sutter, who in a recent talk ( CppCon I think ) said exactly that.
Another practice you mention is using C style vectors. Not a problem since C does not have vectors.
Those are really the only two that you mention. But you do talk about banning features that cause errors. That can easily be achieved. Instead of issuing your programmers computers. Issue them etch-a sketch's.
Other then that, I would say that your company should hire people who are real experts, not some guy who read a Herb Schildt book.
PS: I was trying to remember what your post smelled like, now I remember. It smells like one of those deign doc review, where one guy spend half the time arguing about spelling errors in the design docs.

implementing neural networks using c vs using c++? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm imlementing Neural Networks using C language for a class. I haven't programmed with C++ nor with C for a long time. I started my first couple implementations using C language and it was a pain in the neck!
Now, I am not sure is it because of the language or its how NN is with any language??
BTW, we are not allowed to use any NN toolbox or libraries.
Some people told me its much easier to do it in C++. But I am in a very tight schedule and I'm afraid I might waste "valuable" time transitioning to C++ to find out the benefit is marginal!
So I thought you might guide me into this? Will it be worth it (time efficiency wise) to switch to C++ or not?
Thanks
Just like any other programming task (that doesn't rely on some framework which is only available in 1 language), there is no magical advantage gained by using a special language for Neural Networks.
If you agree that writing code in C++ in general is much easier than writing code in C, then writing Neural Networks code in C++ is much easier than writing Neural Networks code in C. But that is a highly opinion based topic.
Transitioning to C++ could be worth your time, especially if you've already developed some Object Oriented skills and understanding (even if not with the C++ language itself). However if OO is difficult for you, then the transition may cause more harm than good. It depends on you as a programmer.
The transition won't be as hard as you think. In my opinion, it's less like learning a new language altogether, but instead more like learning new features to a language. Keep in mind that all C code you write will still compile in C++ (mostly, I think? See Kitsune's comment on this answer) because C++ is almost a superset of C.
There's no... direct benefit, so to speak. You can still solve the problem in C, but C++ and Object Orientation may help you create a better, more sharable and understandable solution as although I don't know so much about Nueral Networks, I'm pretty sure some of the characteristics can be neatly abstracted thanks to Object Orientation.
Then again, if OO isn't your peice of cake, then this may end up making it even harder for you. Consider your strengths as a programmer: could you draw a class diagram to figure out how everything fits together comfortably? Do you have a good understanding and appreciation of OO concepts like interfacing and abstraction? If not, then OO could do more harm than good.

Is it worth learning C/C++ before learning Python? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 months ago.
Improve this question
I want to learn python, but I feel I should learn C or C++ to get a solid base to build on. I already know some C/C++ as well as other programming languages, which does help. So, should I master C/C++ first?
In my opinion it's better to start learning Python.
I found it easier to learn then C or C++. It has libraries to do virtually anything you might need, and can do essentially anything.
The only reason to use a more difficult language like C/C++ is if you need the performance or are writing code for an embedded system. They are not, however, what you should be learning initially.
C# is a fine language, but nothing beats Python for ease of use.
The scope of Python is quite broad, here are some examples:
Create a website (Django, etc.)
Create scripts to do tasks ranging from image manipulation to server maintenance
Create GUIs (Tkinter, etc.)
Create games (pygame)
Scientific computing (SciPy)
Python can interact directly with arbitrary C code, meaning anything which can be done in C, can be done in Python with a little work. Python is popular enough that an interface has been created for virtually everything already.
For a better look at what can be done with python out of the box, take a look at the standard library which comes with python: http://docs.python.org/library/
In short, if it can be done with a computer, and doesn't require the speed of C/C++, it can be done with Python.
I would say it depends on what you want to achieve (cheesy answer...)
The truth is, learning language is a long process. If you plan on learning a language as a step toward learning another language, you're probably wasting your time.
It takes a good year to be proficient with C++, and that is with basic knowledge of algorithms and object concepts. And I only mean proficient, meaning you can get things done, but certainly not expert or anything.
So the real question is, do you want to spend a year learning C++ before beginning to learn Python ?
If the ultimate goal is to program in Python... it doesn't seem worth it.
Real mastery of a language takes time and lots of practice .. its analogous to learning a natural language like French . you have to do a lot of practice in it. but then different languages teach you different programming methodologies.
python and c++ are all object oriented languages so you will be learning the same programming methodology
The order in which you learn languages doesn't really matter but starting from a lower abstraction to higher one makes understanding some things easier..
In my opinion you should defiantly learn Python before attempting to learn C or C++ as you will get a better understanding of the core concepts, C++ is mush lower level than Python so you will need to make more commands to do something that you can do in one line in python.

Resources to learn C++ itself, not the basics of programming? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I'm something of a new, reluctant convert to C++ from a Pascal, Ruby, and PHP background. I haven't worked with Pascal since a few months of torture with "Delphi Turbo;" since then I've practically been eating and sleeping Ruby and PHP. I'm already well acquainted with object oriented programming and many various subjects.
My main trouble is that I already know the rudiments of C/C++ programming, less the actual experience of working with C++. I worked with C for long enough to realize that even without macros, etc, I didn't want to work with it. (Some of the disgust was from maintaining a CGI application in C, when accustomed to Pascal's automatic string management.) I know just enough C++ to be dangerous to myself and anyone else unwitting enough to use my "code."
I'd really like to work up to a good enough understanding of C++ to use libraries like Crypto++ and Boost without major problems or in-depth knowledge of the language's intricacies. I just need to figure out how to work with C++ without killing myself (either with C++, or with the long-standing dislike that I'm already battling).
What are effective resources that will teach me C++ without assuming that I must be retaught all basic programming? I'd rather not relearn concepts that I already know, unless the paradigm in C++ is significantly different. I'm also learning on my own time, so don't recommend me a book complex enough to need a guru to explain to me, please! And I have an effective budget of $0 for learning C++, so please keep suggestions to quality online resources or books common enough that I could likely find them at the library.
Read Effective C++ by Scott Meyers - it's a good guide for getting past the basics of C++ and showing how to write and use "correct" C++ code
The C++ FAQ Lite is a great resource.
I highly recommend Stroustrup: The C++ Programming Language (Third Edition). As the author of C++ he is the authority on the language, and the book is useful as a reference as much as it is for learning the language. It's common enough that most good general purpose libraries will have a copy. He goes into quite some depth on all the features of C++, including explanations of why certain design decisions were made in the language. Personally, I think this is the best book around for programmers to learn C++.
Once you have a good grip on core C++, David Abrahams and Aleksey Gurtovoy's book, C++ Template Metaprogramming, goes into further depth and provides many examples of how C++'s template system allows you to perform complex compile-time programming, a highly valuable skill these days. This one is a little less common but you can probably find it at a university library.
I can give you a couple of keywords you might want to research in more detail:
RAII (Is pretty much the technique that ensures you don't have to worry about memory leaks. Very convenient)
Generic Programming (The STL in particular. Experiment with iterators and the standard library algorithms, and see just how powerful these abstractions are. They're a key part of what I like about C++)
Functors (Perhaps too simple on their own, but the way they can be used instead of function pointers with the algorithms mentioned above is interesting)
And just get familiar with templates, and "mild" forms of template metaprogramming. (Traits classes, for example, and (partial) specializations.
And just keep an eye on the C++ questions here on SO. A lot of interesting topics are regularly brought up.
But the best advice is probably to keep it completely separate from C. Forget everything you learned about how to use C. It either doesn't apply in C++, or leads to inferior code that is harder to read and maintain.
It's an interesting language in its own right, and has a number of unique features. Leverage those, and it can actually be fun to work with C++. Treat it as an overengineered Java, PHP or C, and it'll just make you want to throw up.
You need to write code. A lot of code in C++. There is no substitute. You also need to read good code.
I agree with the suggestion for Scott Meyers' books though. Those are pretty good.
Part of your learning will be the leap from procedural programming to OO.
I would highly recommend the book "C++ Common Knowledge" by Stephen C. Dewhurst. Don't know if it's common enough to be found at the library (it's not at mine, but my library sucks for computer books that aren't 5-10 years out of date), but it does an excellent job of taking the complex aspects of C++ and making them easy to understand, without dumbing anything down for beginners. Definitely worth the investment.
To quote from the back of the book:
This book is for you if
You're no "dummy," and you need to get quickly up to speed in intermediate to advanced C++
You've had some experience in C++ programming, but reading intermediate and advanced C++ books is slow-going
You've had an introductory C++ course, but you've found that you still can't follow your colleagues when they're describing their C++ designs and code
You're an experienced C or Java programmer, but you don't yet have the experience to develop nuanced C++ code and designs
You're a C++ expert, and you're looking for an alternative to answering the same questions from your less-experienced colleagues over and over again
C++ Common Knowledge covers essential
but commonly misunderstood topics in
C++ programming and design while
filtering out needless complexity in
the discussion of each topic. What
remains is a clear distillation of the
essentials required for production C++
programming, presented in the author's
trademark incisive, engaging style.
Here is a link to a question with answers that should help you.
https://stackoverflow.com/questions/1227764/i-need-to-improve-my-c-skills-fast-is-this-realistically-possible/1227805#1227805
For effective stuff you can find online Cplusplus.com has a pretty good reference and information.
If you can find the book "C++ Common Knowledge" (Stephen Dewhurst) at the library or cheaply online, I would add that to the list posted on the StackOverflow link above as well as "The C++ Programming Language" (Stroustrup). Going through the questions under the C++ tag right here on SO should give you some good pointers and code examples to get you on your way.
Here's a list of good C++ books which teach you C++ rather than basics of programming.
Sit down and write some C++ code.

c++ - relearning [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I haven't done C++ for about three years and looking to get back and ready. What is the best way? any open source projects that I might want to look at to recall all the details and be ready for interviews?
I started reading (again) C++ Primer 5th edition but was wondering whether there's more efficient way since I did program in C++ for few years before.
Just wanted to add: Does anyone know about open source projects related to finance? (e.g. servers, fix, etc)
I was facing a similiar situation a while back, and my conclusion was - no matter how many smart books you read nothing will suit you better then practicing.
Find some tutorials or set yourself some simple goals and learn by doing.
Hope that helps
PS. A friend of mine asked me once "How do you eat an elefant? - in small pieces, one at a time"
I'd start in on a real project.
If nothing else, download an open source C++ project that's in the same realm as the jobs you want to target, and start modifying. Practice helps more than anything for being comfortable.
If you're going to focus on reading, or in addition to practice, I'd actually focus on reading books that work more on using C++ well, not necessarily learning C++. Effective C++, More Effective C++, and Effective STL are great for this - you'll learn new things while refreshing your old knowledge. You can always use the primer book as a reference to study things you've forgotten as you read about them elsewhere.
Pick something that you know very little about and attempt to make a program that works with that subject area. For example if you've never done GUI work fire up C++ and try to create a simple paint program in the GUI framework of your choice (Qt, WTL, whatever). Or if you've never worked with a database grab SQLite and create a little app that manages your time. Or better yet, combine all these areas into a larger program.
The key is to force yourself to learn how to do real, practical things and solve problems using the languages paradigms. Books are great to reinforce certain practices but they'll never replace hours of frustration trying to figure out why your pointers aren't pointing where they're supposed to.
If you are good at maths (or statistics, probability, finance, geometry) and want to recall how to build re-useable functions, classes, and templates, you are welcome to help us at mathlibcpp. I recommend it, its good learning. Building a complete library on a large subject is very educatively hard ;) I found a chance to use all OO methods I know in C++, even forced to learn more.
Regarding Fix, there is QuickFAST, a very efficient implementation of the 'Fix for streaming' protocol.
Regarding C++, I would look for something that uses Boost, as it seems to be a premiere library for C++ (QuickFAST uses it to some degree).
Check out http://www.topcoder.com. This is an amazing tool for practicing programming in many different languages (C++, Java, C, C#). You can even win money if you get good at it:)
As with anything, write many programs, (re)read the best books (such as Effective C++, already mentioned). :-)
And ledger is an open source finance program written in C++. (GnuCash is another but written in C.)
Most of KDE is written in C++, albeit with Qt's signal extensions. Probably lots of examples of good code there.