Live data from Hacker News

Learn C

medium.com

51–60 of 182 posts

Re: Learn C

#51

> You’ll realize that Object Orientation is not the only way to architect software. Actually, pretty much all the "good" C code I've seen is using some form of object orientation, for example using structs with function pointers, or information hiding through incomplete types and void pointers. I think the better observation is that you don't need much language support to do mostly-OOP. That and a lot of people in th…

People who use the preprocessor heavily tend to use a fairly non-OO design.

See http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html for an interesting example of a design technique enabled by that. I also note that said technique is problematic in practice not because it isn't good - it is - but because it causes people to suffer a brain freeze.

Re: Learn C

#53
post #21

We need less code written in C, not more. We already have a problem with a massive, unreliable, insecure ecosystem of legacy C code that is hard to escape; writing more software in C makes that problem worse. Most software is written to solve high-level problems. Using a high-level language is sensible, time-saving, budget-saving, improves portability, and saves on headaches later. The same rule that applies to COBOL…

Was there any study done to the (un)reliability of C? I know for a fact practically every piece software I use is programmed in either C or C++. The sole exceptions are Anki and Gentoo's portage system, both Python. And I'm pretty sure the reason portage is so extremely slow is because it is in Python (I've checked, it's not I/O-bound). And Anki is some very unreliable software. In fact, give me a single big desktop…

Just three, ask for more if you wish:

The original version of Skype was done in Delphi.

The first versions of Mac OS were done in Apple Pascal.

Photoshop was originally done in Apple Pascal.

Re: Learn C

#54

Earlier quoted context omitted.

My point is there are fundamental computing concepts that you can pick up by learning C. In a world of high-level, low-LOC languages you can get by without learning those concepts, but it serves your and the ecosystem's best interest to learn them.

I think the disagreement we have may stem from our notions of what constitutes "fundamental computing concepts." I rank the lambda calculus much higher than C or assembly language when it comes to that. I would say that knowing your data structures and how to analyze algorithms asymptotically is vastly more important than knowing how code is being executed at a low level. Even for the cases where low-level code must…

> There is no particularly good reason for C to be anywhere in the software stack;

Really? Not anywhere?

Who is handling your hardware interrupts? How is your keyboard and mouse input being handled? What about your video card drivers?

Now I will grant that you can bootstrap an initial run time in assembly and place your favorite high level language4 on top of that, if you add extensions to your favorite language to better interact with HW you can do everything in a higher level language, but as it stands, LISP doesn't have built in support for doing a DMA copy from memory buffer to a USB port.

My question then becomes, why the heck bootstrap in ASM rather than C?

Re: Learn C

#55
post #28
post #4

This is a fair point, but it brings to mind another point I didn't really understand till the last couple of years. Learning about how compilers work is just as important. Building a small lisp compiler was a life-changing experience for me in terms of going one level deeper, as much as understanding C was. For those who've never written lisp before, the reason I recommend a lisp compiler is that lisp compilers are t…

Write an emulator! If you write an emulator, you can probably skip "learning C".

What might I read to begin to learn which platform to emulate and how to get started?

Re: Learn C

#56
post #21

Earlier quoted context omitted.

Was there any study done to the (un)reliability of C? I know for a fact practically every piece software I use is programmed in either C or C++. The sole exceptions are Anki and Gentoo's portage system, both Python. And I'm pretty sure the reason portage is so extremely slow is because it is in Python (I've checked, it's not I/O-bound). And Anki is some very unreliable software. In fact, give me a single big desktop…

"I know for a fact practically every piece software I use is programmed in either C or C++." How confident are you that that software will work as expected? How much are you willing to bet? The fact that a language is popular does not prove that the language is good, nor that it should be used, nor that it is not causing us problems. Just the other day on HN, there was an article about a massive number of vulnerabili…

Perhaps you should face your fears and learn C ;-)

Re: Learn C

#57
post #54

Earlier quoted context omitted.

I think the disagreement we have may stem from our notions of what constitutes "fundamental computing concepts." I rank the lambda calculus much higher than C or assembly language when it comes to that. I would say that knowing your data structures and how to analyze algorithms asymptotically is vastly more important than knowing how code is being executed at a low level. Even for the cases where low-level code must…

> There is no particularly good reason for C to be anywhere in the software stack; Really? Not anywhere? Who is handling your hardware interrupts? How is your keyboard and mouse input being handled? What about your video card drivers? Now I will grant that you can bootstrap an initial run time in assembly and place your favorite high level language4 on top of that, if you add extensions to your favorite language to b…

Agreed; OS kernels and firmware for embedded systems all require low-level access to hardware in a way that high-level desktop applications do not. Being able to easily reason about how C is going to use resources and be compiled down to machine code for the architecture you are using can sometimes be an important asset.

Re: Learn C

#58
post #51

> You’ll realize that Object Orientation is not the only way to architect software. Actually, pretty much all the "good" C code I've seen is using some form of object orientation, for example using structs with function pointers, or information hiding through incomplete types and void pointers. I think the better observation is that you don't need much language support to do mostly-OOP. That and a lot of people in th…

People who use the preprocessor heavily tend to use a fairly non-OO design. See http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html for an interesting example of a design technique enabled by that. I also note that said technique is problematic in practice not because it isn't good - it is - but because it causes people to suffer a brain freeze.

I tend to see these as orthogonal. What does a macro do but generate more code? So shouldn't the use of macros be reducible to ordinary code? That, and you can still employ this stuff at the micro level and your chatter between compilation units or library boundaries can still be OO.

Re: Learn C

#59
post #3

You'll learn to feel every line of code you write This is exactly how I felt when I started writing C. I started out with .NET and Java. Both had quite high abstraction levels, and not much deep integration with hardware. I took my control statements, conditionals, and high-level object-based programming for granted -- I never WANTED to learn C. I took one look at K&R and was turned off by the insane amount of low-le…

A small part of C was beaten into us for 2 years at the 11th and 12th grade. Today (I'm not a CS guy by the way), even when I write programs in python or any high level language I have this nagging feeling of 'loss of control' and that the code is not efficient enough. I know this is wrong but I can't help this feeling when now things are handed to you as compared to flipping every figurative bit in C.

Re: Learn C

#60
post #34

Earlier quoted context omitted.

> We already have a problem with a massive, unreliable, insecure ecosystem of legacy C code A ton of the world's software with the highest reliability requirements is written in C and C++. Nuclear power plants? Yes. [1] Joint Strike Fighter? Yes. [2] Mars rover? Yes. [3] Your Tesla? Yes [4] US telephone systems. Stock exchanges. Bloomberg. Your cell phone OS (incl. many years before smartphones). The list goes on and…

"Reliability and security requirements are up to the developer to impose on any language" This is a common fallback in these discussions, but it is misguided. Yes, you have to work to make software secure in any language; no, this does not mean C is equivalent. In C, you still need to worry about high-level problems like SQL injection, while simultaneously having to worry about low-level problems like integer overflo…

Well, I actually see that as an advantage vs. placing trust in an abstraction you have no control over that can provide security problems for you. So I guess we'll agree to disagree on this one.

Curious though, in what would you implement the examples I gave?

Post reply on HN