Live data from Hacker News

Learn C in Y Minutes

learnxinyminutes.com

21–30 of 81 posts

Re: Learn C in Y Minutes

#21

As a web developer, who mostly spends time with Go and Python, is there any benefits of learning C?

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

#22

As a web developer, who mostly spends time with Go and Python, is there any benefits of learning C?

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

#23
post #15

Earlier quoted context omitted.

It's more difficult to read and edit.

I wish we could talk about style in objective terms, not just opinion. Opinions are kinda stupid. Here's my opinion: https://news.ycombinator.com/item?id=26790701 (actually that's just a faux opinion to make a point, but you get the point) And if there are no objective facts, then maybe we could just stop calling other peoples' preferred style nasty and "bad habits" as if it were objective.

Your "opinion" is particular "stupid" (your words) since you introduce a false analogy between program code structure and natural language sentences.

Let's see what CMU's SEI has to say: https://wiki.sei.cmu.edu/confluence/display/c/DCL04-C.+Do+no...

Re: Learn C in Y Minutes

#24

As a web developer, who mostly spends time with Go and Python, is there any benefits of learning C?

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

#26
post #23

Earlier quoted context omitted.

I wish we could talk about style in objective terms, not just opinion. Opinions are kinda stupid. Here's my opinion: https://news.ycombinator.com/item?id=26790701 (actually that's just a faux opinion to make a point, but you get the point) And if there are no objective facts, then maybe we could just stop calling other peoples' preferred style nasty and "bad habits" as if it were objective.

Your "opinion" is particular "stupid" (your words) since you introduce a false analogy between program code structure and natural language sentences. Let's see what CMU's SEI has to say: https://wiki.sei.cmu.edu/confluence/display/c/DCL04-C.+Do+no...

I know SEI well.

I have worked on projects where linters enforce that style, and I hate it.

You can read their justification: a programmer or code reviewer might mistakenly believe that the two variables src and c are declared as char *.

"A programmer might not know the syntax" is as stupid a justification for enforcing these rules as "a reader might not be able to read long sentences correctly" is for enforcing a stupid rule over text written in a natural language. I'm sorry that you failed to see the analogy.

They also just drop a statement like "declaring no more than one variable per declaration can make code easier to read and eliminate confusion." I can drop my opinion too: "declaring more than one variable per declaration can make code easier to read and eliminate confusion." It can also make the code shorter and easier to scan & edit.

And I think analogies involving natural language are more relevant than you think.

I would rather read "U, V, and W are phases" than "U is a phase. V is a phase. W is a phase." It's the same goddamn thing, we're declaring things (and optionally initializing them).

Re: Learn C in Y Minutes

#27

As a web developer, who mostly spends time with Go and Python, is there any benefits of learning C?

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.

Re: Learn C in Y Minutes

#28
post #15

Earlier quoted context omitted.

It's more difficult to read and edit.

I wish we could talk about style in objective terms, not just opinion. Opinions are kinda stupid. Here's my opinion: https://news.ycombinator.com/item?id=26790701 (actually that's just a faux opinion to make a point, but you get the point) And if there are no objective facts, then maybe we could just stop calling other peoples' preferred style nasty and "bad habits" as if it were objective.

More difficult to read, more difficult to edit, but the worst thing is how difficult it makes diffing code. You should try using some kind of code versioning, git is a popular choice.

Re: Learn C in Y Minutes

#29

As a web developer, who mostly spends time with Go and Python, is there any benefits of learning C?

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 abl…

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.
Post reply on HN