Breaking News
Blog

What's the Best C/C++ Course for a Hardware Guy?

NO RATINGS
View Comments: Newest First | Oldest First | Threaded View
Page 1 / 2   >   >>
Clive
User Rank
Author
Re: Online courses
Clive"Max"Maxfield   1/19/2016 2:29:05 PM
NO RATINGS
@dong: ...My self-pride was instantly deflated when the system replied "I thought so!"

Kudos to the programmer of that one :-)

donq_#1
User Rank
Author
Re: Online courses
donq_#1   1/16/2016 1:04:55 PM
NO RATINGS
@Max... "and it said "are you sure" and I said "yes" and it said "are you really sure" and I said yes".

Sounds like the prompts from the "Flex" operating system on a 6809 machine that I worked with in the '80s. After awhile, your fingers just hit "y" twice on autopilot to erase files. One time, I caught myself just before I erased a bunch of files with a misformed wildcard entry (something like *.* instead of *.bak). It had already prompted "are you sure?" and I had responded "y", then it asked "are you really sure?" and I was so proud of myself for overriding my muscle memory and being able to respond "n", saving myself a lot of grief. My self-pride was instantly deflated when the system replied "I thought so!"

Max The Magnificent
User Rank
Author
Re: Simplicity rules
Max The Magnificent   1/13/2016 10:25:40 AM
NO RATINGS
@perl_geek: ...(Guess which one I favour. :-)*)

Python? LOL

Max The Magnificent
User Rank
Author
Re: Online courses
Max The Magnificent   1/13/2016 10:23:43 AM
NO RATINGS
@betajet: ...Some wag in the back of the room sang out "You mean on purpose?"...

This took me back to when I was working on a massibe machine (1/2 way between a monster and a mainframe) and I wanted to erase a sub-disk and I issued the command and it said "are you sure" and I said "yes" and it said "are you really sure" and I said yes" and it said "Erasing dask xxx" and I thought "Just a minute, isn't disk xxx the main system disk? ..... arrgghhhh".

Sad face :-(

Max The Magnificent
User Rank
Author
Re: My recommendation: stick with C
Max The Magnificent   1/13/2016 10:18:05 AM
NO RATINGS
@betajet: ...I learned from C on my own from K&R...

I did the same -- but it was many, many years ago, and I've forgotten most of what I learned. Also, I don't recall them telling me I could have multiple inits and updates in for() loops or using the comma as an operator -- maybe they did and I just forgot.

betajet
User Rank
Author
Re: My recommendation: stick with C
betajet   1/12/2016 2:59:21 PM
NO RATINGS
K&R is a great book for learning C on your own if you've already programmed in another language.  If you've never programmed before there are probably better books.

(For that matter, C is not a good first programming language IMO.  I think Pascal is far better, since it was designed to teach good programming practices rather that write clever concise code.  However, a hardware guy probably doesn't have the time or inclination to learn more than one language, so given that constraint C is the best choice.)

As perl_geek says below, you do want the second edition, which covers ANSI C.  ANSI C makes a number of improvements to the original K&R C, especially function prototypes.

General advice: don't try to understand function pointers until you're comfy with the rest of C :-)

w_greene
User Rank
Author
Which to take C or C++...
w_greene   1/12/2016 2:25:20 PM
NO RATINGS
I got my degree in electrical engineering but have spent most of my career writing embedded software.  My suggestion is to learn C.  What you will find as you go along is that C compilers accept many of the C++ forms.  Much of C++ is of little value to deeply embedded code since it uses data structures that have a non-deterministic effect on timing and code size.  The base syntax is the same for both languages.  If you are writing code for a higher level system where performance is less important, C++ can be more understandable/expressive if the constructs are well understood.  My advice is to realy learn C first, then supplement with C++ as needed.  C++ constructs are more for Object Oriented programming.

perl_geek
User Rank
Author
Bipolar classes
perl_geek   1/12/2016 1:58:44 PM
NO RATINGS
@rcurl "I took a course a couple of years ago where the instructor began by asking how much programming experience everyone in the class had, &c"

That situation, a 4-sigma spread concentrated at the ends,  is an instructor's nightmare. You know you're going to lose someone, and the question then becomes, "whom?" The noob(s) from overload or the hotshots from boredom? The best solution I found in meatspace was trying to get a friendly experienced type alongside the beginner as a coach.

perl_geek
User Rank
Author
Simplicity rules
perl_geek   1/12/2016 1:46:52 PM
NO RATINGS
I'll go along with all the endorsements of the New Testament (K&R, 2nd ed.) Even if you aren't using a member of the Unix family, you might want to add "The Unix Programming Environment" http://www.openisbn.com/isbn/013937681X/ It shows how to combine simple C code into programs that will do complex things, while still remaining simple. Elegant simplicity takes skill. (I'm sure there are hardware analogues.)

The principal benefit of object orientation (the difference in purpose between C & C++) is reusability of code to deal with complex concepts. That's fine if you need to deal with psrticular kinds of objects repeatedly, especially if someone else has created them for you, but there's an overhead to learning them, (or even discovering that they exist). You don't need O-O to create a personal library of subroutines for things you do often.

If you're just flipping switches on a low-power machine, or your code has to be REALLY fast or tiny, C-generated machine code is likely all that will fit. If you're running something with an OS (Linux or whatever), consider a dynamic language for many jobs, especially controlling processes. (Guess which one I favour. :-)*) Not having to go through a compile/link/debug cycle will speed development. Sometimes, you may want to develop an algorithm in a dynamic language, and you may well find it runs fast enough without having to translate to C.

 

DougInRB
User Rank
Author
Re: My recommendation: stick with C
DougInRB   1/12/2016 12:22:34 PM
NO RATINGS
I totally agree.  Read the K&R book to get started and when you have any questions about what the right thing to do is, Google it.  The answer will almost always be on stackoverflow.com.

When you want to start doing hardware-like things, Google "bit twiddling hacks" and you'll be shown a wonderful reference within stanford.edu.

Have fun!  Writing in C is just about as close to the CPU as you can get without writing in assembly - and hardware engineers should be able to write the fastest C code because they (should) understand things like registers, caches, ALUs, and clocks per instruction.  Don't get too enthralled with the sophisticated looking code that is produced from a pure software guy.  It may look pretty and be concise, but it may be a lot slower than what you can do with a couple of extra lines of code.

Page 1 / 2   >   >>

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)
Like Us on Facebook
EE Times on Twitter
EE Times Twitter Feed