News for hackers. Stuff that matters.
Re:Learn C in Y Minutes by avinassh on Tuesday April 13, 2021 @07:11AM (#26790663)
As a web developer, who mostly spends time with Go and Python, is there any benefits of learning C?
Re:Learn C in Y Minutes by heinrichhartman on Tuesday April 13, 2021 @07:28AM (#26790789)
Writing correct C is REALLY hard and slow (strings, manual memory management, concurrency pitfalls). So the investment is not paying off unless you are writing highly performance critical backend services.

What can pay-off is learning to read C. Node.js, Firefox, Postgres, Linux are all written in C/C++ so if you ever want to really understand what's going on or have to debug a nasty bug, then you will need to be able to find your way around these code-bases.

Re:Learn C in Y Minutes by roryrjb on Tuesday April 13, 2021 @07:42AM (#26790890)
Also beyond the codebases themselves, interactions with the running code via GDB or tracing frameworks like dtrace, bpftrace, where you often reference C data structures. As well as being able to more fully understand the output of strace and other tools.
[dead]
Re:Learn C in Y Minutes by jcelerier on Tuesday April 13, 2021 @09:09AM (#26791663)
Most people do that on Arduino which is as c++ as it gets, with templates, etc...
Re:Learn C in Y Minutes by Yoofie on Tuesday April 13, 2021 @11:57AM (#26794152)
If you mean hobbyists, then probably yes. But there are whole industries who use embedded C as the defacto standard, such as automotive.
Re:Learn C in Y Minutes by jcelerier on Wednesday April 14, 2021 @07:48AM (#26805759)
I've worked on automotive and that was definitely C++, to a very deep level
Re:Learn C in Y Minutes by flohofwoe on Tuesday April 13, 2021 @07:30AM (#26790799)
Not really, but it depends. For instance, C is pretty great for compiling simple logic into WASM modules because the size overhead is minimal compared to most higher-level languages, or even C++ with careless use of the stdlib (and the missing memory safety isn't such a critical problem because everything runs in the WASM sandbox anyway).

E.g. I think the size of my WASM demos is quite reasonable for what they do:

https://floooh.github.io/tiny8bit/

https://floooh.github.io/sokol-html5/

However, AssemblyScript is also a pretty good choice for this type of stuff from what I'm hearing (while for instance languages with a complex runtime like C# are not).

Re:Learn C in Y Minutes by pdpi on Tuesday April 13, 2021 @07:49AM (#26790950)
I find that there is a lot of value in learning "how the sausage is made". Implementing your own baby version of the things you take for granted in higher-level languages is an interesting exercise — e.g. things like dynamic dispatch.

These are things that are not directly useful, but help you have a better mental model of how your language of choice actually works.

Re:Learn C in Y Minutes by bitexploder on Tuesday April 13, 2021 @07:26AM (#26790775)
C is a low level language that compiles down directly to assembly. It is similar to Go in this regard, but is a bit lower level. You have to manage memory yourself and pointers in C are much more dangerous. Reasons to learn C would include: absolute performance needed maybe for say a Python C extension, kernel hacking, some other project you want to contribute to uses C.

I think it’s good to at least play with C and understand how memory management and pointers in C work, but I don’t think I would recommend you go out of your way to learn C or spend any significant amount of time writing it. At the end of the day it’s just another tool in the toolbox. I would recommend the book Code, by Petzold, if you want to really want to explore computers at a low level in a friendly format.

Re:Learn C in Y Minutes by fractalb on Tuesday April 13, 2021 @09:14AM (#26791707)
nitpick. I think C compiles directly to machine code. There's no intermediate step of compiling to assembly first.
Re:Learn C in Y Minutes by inb4_cancelled on Tuesday April 13, 2021 @09:06AM (#26791635)
> language that compiles down directly to assembly

Directly to machine code, not assembly.

Re:Learn C in Y Minutes by antegamisou on Tuesday April 13, 2021 @07:48AM (#26790940)
If you're interested in:

-Embedded/cyber-physical systems software (firmware dev)

-Driver development (applies to Win/macOS/UNIX/iOS/Android)

-Contributing to the Linux kernel/OS dev in general

-Contributing to many large OSS projects (Apache, ffmpeg)

-Exploit/malware dev/reverse engineering

-Emulator development

you'd need to learn C.

Re:Learn C in Y Minutes by 10x-dev on Tuesday April 13, 2021 @07:34AM (#26790833)
Your question is too vague. Are there benefits in general? Of course, every language has something to offer.

Is it useful as a web developer? Only if you want to write extensions to Python in C or step away from the web developer label and learn systems programming.

Re:Learn C in Y Minutes by aiioquip on Tuesday April 13, 2021 @07:38AM (#26790865)
For you, yes: you will better understand Python's source code, which is written in C. Poke around the source code a bit just out of curiosity after learning a bit of C and it becomes a bit interesting.