Live data from Hacker News

Effective C: An Introduction to Professional C Programming

nostarch.com

81–90 of 109 posts

Re: Effective C: An Introduction to Professional C Programming

#81
post #23

What is going on with the sudden profusion of books on C? 21st century C, Modern C, Understanding and Using C Pointers? Okay, I realize "profusion" might seem a bit overblown, but honestly, in C world (and in comparison to other languages), this is practically a publishing boom. Not that I'm complaining; C was my first programming language (back some time in the mid-90s), and it's still my favorite. But I wonder why…

Don't jinx it! If this can get the non-C programmers to learn and understand the usefulness of a simple, minimal and direct language ("modern" languages are just too bloated), it is well worth it. I have said it before and say it again; C will allow you to program everything from itty-bitty MCUs to honking server machines. It is also the de-facto universal "glue" language and its real-world benefits far outweigh any…

Glue language aside (which arguably is a lot more true of unices than other platforms), I'd argue Forth might make a better language / minimal environment for learning the low-level parts of a computing system.

It's got interactivity (bundled compiler/interpreter in one system), a large number of implementations (possibly more supported CPUs than C++, but that might be more due to its age), and a Forth system is easier to "pick apart" and learn how its compiler's implemented than a C compiler.

Re: Effective C: An Introduction to Professional C Programming

#82

I started learning C at the start of this year by going through K&R and Understanding and Using C Pointers. I will likely pick this is up, it looks good and I really like No Starch Press books. Does anyone have pointers on where to start with actual embedded programming? I have a couple Arduinos and RPis laying around, but I'm wondering if there are more 'real' ways to do it.

Much of my job is embedded engineering, to establish a bit of credulity for the following recommendations. My employer is partial to ST Micro and Renesas, so keep that in mind. Others may suggest Silicon Labs, Microchip, or Texas Instruments. This will also be biased by my own education and work experience (e.g. no robotics, more sensors/lights stuff).

I'd recommend getting a dev kit like the STM32F4DISCOVERY (https://www.st.com/en/evaluation-tools/stm32f4discovery.html). ST Micro's boards are often used for courses (https://www.udemy.com/course/cortex-m/) so you may like to take some of those courses. You'll often hear about the TI MSP430 as another microcontroller but AFAIK it's beginning to be a bit dated. Although come to think of it, there's probably more educational material out there for it, if you're willing to search.

Grab a kit like the Sparkfun Beginner's Kit (https://www.sparkfun.com/products/13973) and read some of the tutorials on their website about creating circuits. Tutorials or courses for your dev kit should get you to a point where you can light an LED controlled by the micro.

From there, you may like to do more advanced stuff like communicating with sensors over specific protocols (Sparkfun's Tinker Kit and associated guides may be of use https://www.sparkfun.com/products/14556 though you will have to translate from Arduino to C code, which can be good practice for knowing how Arduino works under-the-hood).

At this point, you'll probably know whether you want to keep learning more about sensors/lights/IoT type stuff, or want to branch out to other embedded-related topics. More advanced IoT material will be things like taking sensor measurements, storing measurements to memory, interfacing with displays, sending data via WiFi or Bluetooth.

Edit: I skimmed over a lot to keep it short. There's a lot hiding behind how casually these recommendations are made, so feel free to reach out with any questions (email in profile).

Re: Effective C: An Introduction to Professional C Programming

#83

I started learning C at the start of this year by going through K&R and Understanding and Using C Pointers. I will likely pick this is up, it looks good and I really like No Starch Press books. Does anyone have pointers on where to start with actual embedded programming? I have a couple Arduinos and RPis laying around, but I'm wondering if there are more 'real' ways to do it.

If you are looking for a full course this one isn't bad: Embedded Systems Shape the World[0] it does hew pretty close to platform specifics (Windows/Keil/TI Launchpad) which can be good for specifics and not good for holistic understanding.

I have had a lot of fun following Ben Eater's[1] projects, which aren't always embedded-specific (sometimes they're TTL, sometimes Arduino) but are excellent for understanding concepts deeply.

I tend to learn best with a specific project that can grow or morph as my interest or experience dictates. You might find something to build with an Arduino, using the toolchain/IDE/libraries, get it working and then start stripping out libraries for your own implementations, or getting a toolchain of your own to cross-compile and flash.

[0]: http://www.edx.org/course/embedded-systems-shape-the-world-m...

[1]: https://eater.net/

Re: Effective C: An Introduction to Professional C Programming

#84

Earlier quoted context omitted.

Actually, you should research about the story why php was created... it was primarily envisioned as a templating language and the creator wanted people to use c/c++ for business logic etc, however people didn't do that because it was easier with php. There is absolutely no reason why a website should be build with c, sry... Edit: link to rasmus lerdorf on 25 years php: https://m.youtube.com/watch?v=wCZ5TJCBWMg

> There is absolutely no reason why a website should be build with c, sry... Please tell this Felix von Leitner (fefe.de, blog.fefe.de), and post his reply in this forum. His blog software is written in C. It's one of the most frequented blog in German speaking countries and running on a single machine (AFAIK). Of course, not everybody has the expertise to build something like a blog in C.

I know this blog very well and fefe is definitely enought of a geek to do something like this...

This is howevwr not a good example you know that right?

I don't think that it is a question of expertise, more like choosing the right tool for the right problem.

Re: Effective C: An Introduction to Professional C Programming

#85
post #51

Earlier quoted context omitted.

Not to be rude to the author but what makes him the best person to be writing modern C books?

"Not to be rude to Ford but what makes Ford the best manufacturer of trucks?"

So it's hard to say that Ford is the best company to make trucks. A slightly lower bar might be, is Ford the best company that has actually made a truck?

Re: Effective C: An Introduction to Professional C Programming

#86

I started learning C at the start of this year by going through K&R and Understanding and Using C Pointers. I will likely pick this is up, it looks good and I really like No Starch Press books. Does anyone have pointers on where to start with actual embedded programming? I have a couple Arduinos and RPis laying around, but I'm wondering if there are more 'real' ways to do it.

If you are looking for a full course this one isn't bad: Embedded Systems Shape the World [0] it does hew pretty close to platform specifics (Windows/Keil/TI Launchpad) which can be good for specifics and not good for holistic understanding. I have had a lot of fun following Ben Eater's[1] projects, which aren't always embedded-specific (sometimes they're TTL, sometimes Arduino) but are excellent for understanding co…

Thanks for the recommendations! That's how I like to learn as well, and kind of why I started learning C in the first place. Tinkering with electronics is super fun (I think).

I actually have built the clock module from Ben Eater with the intent of building the 6502 computer project at some point in the future. I really like his stuff.

Re: Effective C: An Introduction to Professional C Programming

#87
post #82

I started learning C at the start of this year by going through K&R and Understanding and Using C Pointers. I will likely pick this is up, it looks good and I really like No Starch Press books. Does anyone have pointers on where to start with actual embedded programming? I have a couple Arduinos and RPis laying around, but I'm wondering if there are more 'real' ways to do it.

Much of my job is embedded engineering, to establish a bit of credulity for the following recommendations. My employer is partial to ST Micro and Renesas, so keep that in mind. Others may suggest Silicon Labs, Microchip, or Texas Instruments. This will also be biased by my own education and work experience (e.g. no robotics, more sensors/lights stuff). I'd recommend getting a dev kit like the STM32F4DISCOVERY ( https…

Thanks! I definitely like messing around with sensors so I'll check some of these out.

Re: Effective C: An Introduction to Professional C Programming

#88

I started learning C at the start of this year by going through K&R and Understanding and Using C Pointers. I will likely pick this is up, it looks good and I really like No Starch Press books. Does anyone have pointers on where to start with actual embedded programming? I have a couple Arduinos and RPis laying around, but I'm wondering if there are more 'real' ways to do it.

If you are looking for a full course this one isn't bad: Embedded Systems Shape the World [0] it does hew pretty close to platform specifics (Windows/Keil/TI Launchpad) which can be good for specifics and not good for holistic understanding. I have had a lot of fun following Ben Eater's[1] projects, which aren't always embedded-specific (sometimes they're TTL, sometimes Arduino) but are excellent for understanding co…

From a C-veteran perspective, what do you think about type safe (e.g. dependent types such in ATS, or F*/KreMLin, or other DSLs) languages that compile to C, or a subset of C?

How could one get the safety promises that are observed in Rust in C?

Thanks!

Re: Effective C: An Introduction to Professional C Programming

#89
post #75

Can any more experienced C developers give an opinion on the author/contents of this book? I'm a Python/Julia developer starting to learn C. I have K&R already, and Test Driven Development for Embedded C (Grenning). I did order 'Modern C' by Gustedt but the publisher never delivered to Waterstones so they had to cancel the order (about 6 months ago, book still unavailable from Waterstones as of today).

I took Seacord's virtual class (CMU SEI? Can't remember) on Secure C coding a few years back and own, love, and regularly use the The CERT C Secure Coding Standard. I learned from K&R, but highly recommend Seacord's books if you're looking for how to write secure C and a more modern take on some of the trickier parts of C.

Thanks! NCC Group is reselling the online Secure Coding Training and we also deliver instructor-led courses, although these might need to be delivered by webinar until the current crisis abates https://www.nccgroup.trust/us/our-services/cyber-security/se...

Re: Effective C: An Introduction to Professional C Programming

#90
post #72
post #63

Earlier quoted context omitted.

If I buy a copy of your book, will you abuse your position to get constexpr into C? It would be a big improvement over complex macro magic. I'll buy an extra copy if you can get 'defer' in there too! Those two features would really be the bee's knees :)

If you're looking for a low-level performance targeted language where anyone can add anything whatsoever, I've got great news! C++ already exists!

I get your point. C is not C++, and it shouldn't get every feature under the sun.

But it's also not exactly -complete-. The standards committee makes changes every few years, including language additions.

I'm a fulltime C programmer, and I would _love_ to have both of the features I suggested - for the following reasons.

- defer: I could defer a free() statement after every malloc, guaranteeing that I won't miss one or forget about it. Lots of memory leaks and file-descriptor leaks could be easily avoided if C provided 'defer' as a language feature. GCC already offers something kind of similar with its __cleanup__ attribute, and a lot of programs rely on it. How much better would it be for the language to support it natively?

- constexpr: I am _so tired_ of writing really complex macros. Like say I want to populate a lookup table for a sine-wave (for fast use in a realtime system). Wouldn't it be nice if I could just populate my lookup table with a constexpr function? Then I wouldn't need really nasty macros, and I'd also be able to ensure that the calculations all happen at compile-time.

Post reply on HN