Your "go to" C++ book

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a couple of books on C. My go to book is The C Programming Language 2nd Edition by Brian W. Kernighan (Author), Dennis M. Ritchie (Author). It is arguably the best book on c. Written by the developers of the language in 1978 and updated in in 1988 (2nd edition), this book is an easy read, covers the essentials and still holds up 39 years later. It is not for a beginner and mostly covers the language, not the compilers and assumes you have the head for programming.

 

Does C++ have such a book? I mean, a book that is your go to?

 

"When all else fails, read the directions"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Strostroup

 

(which I probably spelled wrong) 

 

To be honest for anything I want to know about C++ I just go to www.cplusplus.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For me the "go to's" are mainly online:

 

https://isocpp.org/faq

http://www.cplusplus.com/

 

Bjarnes book "The C++ Programming Language" is good for some things, but it (like the language) is a "brick". I have yet to spend money on the other ubiquitous "starter" books just to see if they where worth it. The "C++ Primer" by Stanley Lippman et al gets good reviews by several, and is a bit thinner than Bjarnes at only about 970 pages. I have not looked at it. Yet. (Do not confuse it with Pratas "C++ Primer Plus"!)

 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The best way to learn C++ is to decide whether you wish to become a professional programmer who works on huge systems like a fighter jet and gets paid $80/ hr - or - whether you want the least amount of knowledge to get your embedded-system working.

 

If you want to become a pro then buy every $80-$100 book that you can find on C++ and read them all.  Master all the details including the footnotes and references.  See ya in ten years.

 

If you want to simply get your $3 Nano clone working, then download and study the Arduino library for the application.  Arduino applications are generally written to use the least amount of C++ software theory possible needed to get the silly thing working.  Every now and then, some guy will try to show off his C++ prowess by coding some ridiculous pretentious nonsense like Callback functions into what is supposed to be a simple Arduino sketch.  Figuring out what they are trying to do is about as much fun as deciphering an Albanian crossword puzzle.  Fortunately, this is relatively rare, but it does happen.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
Strostroup

Bjarne Stroustrup, The C++ Programming Language (first published about 1985) +1

Before easy access to all of the resources now on the internet, this was my "goto" for C++.

David (aka frog_jr)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

"Dare to be naïve." - Buckminster Fuller

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Simonetta wrote:
The best way to learn C++ is to decide whether you wish to become a professional programmer who works on huge systems like a fighter jet and gets paid $80/ hr - or - whether you want the least amount of knowledge to get your embedded-system working.
Misguided nonsense.

 

C++ is not about "big systems", it's about making code more maintainable, robust and safe. That applies as well to small embedded as it does to fighter jets.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Simonetta wrote:
... Every now and then, some guy will try to show off his C++ prowess by coding some ridiculous pretentious nonsense like Callback functions into what is supposed to be a simple Arduino sketch.  Figuring out what they are trying to do is about as much fun as deciphering an Albanian crossword puzzle....

Huh? Callback functions can be very helpful when writing GUIs, when they are not required. Here is some Python code I was playing with when I read your post:

 

 1  submenu = gui.Menu('Administration', when=lambda: device.usb_stick.present())

 2  @submenu.action
 3  @gui.progress_display([translated('Mounting USB stick...')],
 4                        [('Cancel', lambda: False)])
 5  class ReadUsbStick(object):
 6      """Read USB stick...
 7      """
 8      def __init__(self):
 9          self._stick = device.usb_stick(self)

10      def poll(self):
11          root = self._stick.mount_read_only()
12          self.line1 = 'Reading files...'
13          result = self.run('ls {}/{}*.tar.gpg'.format(root, _FILE_NAME_ROOT),
14                            shell=True)
15          path = result.stdout and sorted(result.stdout[:-1].split('\n'))[-1]
16          if not path:
17              return False
18          print(files)
19          return False

Lines 1, 3, 4 and 10 all use callbacks: to continuously enabled or disabled a submenu, and to specify: a modal window to open when the user chooses a submenu entry, what to return when a modal window 'Cancel' button is clicked, and how to fill and periodically update the modal window. I shudder to think what this would look like without callbacks, especially in C++ which might need hundreds of lines of code should you also foresake abstractions.

- John

Last Edited: Wed. Apr 26, 2017 - 10:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
ridiculous pretentious nonsense like Callback functions

Now that is nonsense right there!

 

Callback functions are neither ridiculous nor pretentious - nor anything specifically to do with C++ !!

 

They are also very useful in protocol stacks and event-driven APIs.

 

ISRs are, essentially, just callback functions - except that it's the hardware that does the calling.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
Now that is nonsense right there!

+1

 

As of January 15, 2018, Site fix-up work has begun! Now do your part and report any bugs or deficiencies here

No guarantees, but if we don't report problems they won't get much of  a chance to be fixed! Details/discussions at link given just above.

 

"Some questions have no answers."[C Baird] "There comes a point where the spoon-feeding has to stop and the independent thinking has to start." [C Lawson] "There are always ways to disagree, without being disagreeable."[E Weddington] "Words represent concepts. Use the wrong words, communicate the wrong concept." [J Morin] "Persistence only goes so far if you set yourself up for failure." [Kartman]

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I recognize the importance of function pointers.  What I don't understand is how they got the name "callback functions".   There is nothing intuitive about that name.  

 

I don't think that they should be used in Arduino libraries unless critical to the operation of the code.   Arduino is all about the amplification of productivity that results from simplicity in coding.  Adding callbacks to Arduino library code often makes the code much more difficult to understand for non-professional programmers, while adding little if anything to the validity of the library to the application.

 

Arduino is supposed to be simple to understand, both .INO files and the libraries.  Sure, the libraries are more difficult than the .ino overview file.   Programmers will add callbacks to a process that 99% of the time doesn't need a callback.  The extra flexibility that callbacks give to the library is not worth the additional complexity that they bring to code that is being used by a person with, say, six months of programming experience.   It's like being required to understand the chemistry of gasoline combustion when all you need to do is drive a car.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Simonetta wrote:
There is nothing intuitive about that name

Then your intuition must be broken!

 

cheeky

 

In the common use case of an API, they are functions that the user supplies to the API, so that the API can call back to the function.

 

All sounds perfectly logical and reasonable to me.

 

Note that this doesn't necessarily have to be done via function pointers; eg, it could be done statically and the API specifies

 

The user shall provide a public function named user_callback() ...

 

 

 

Simonetta wrote:
Adding callbacks to Arduino library code often makes the code much more difficult to understand for non-professional programmers

I disagree.

 

How hard is it to understand:

You provide this function;

The library calls it "automagically" whenever event X occurs

 

Simonetta wrote:
Arduino is supposed to be simple to understand,

How is the above hard to understand?

 

And, again, none of this has anything specifically to do with C++ - it's just derailed a thread that's supposed to be about book recommendations

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Thu. Apr 27, 2017 - 07:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

awneil wrote:
it's just derailed a thread that's supposed to be about book recommendations

Perhaps #8 and following should be split to a separate thread, leaving #7 updated with a note that the discussion on Callbacks continues there ... ?

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Three books for me:

- B. Stroustrup, The C++ Programming Language

- Scott Meyers, Effective C++

- Steve Oualline, C++ Hacker's Guide