I know we learn C at school for our own good, but it's incredibly frustrating.

Show thread

And IRL I know that I will never use C because it will probably never be the right tool for what I have to do

Show thread

why would use a C program to make a request to an API!!

Show thread

And I compared it to node because that's what I know the best, but most "modern" languages would be similar I guess

Show thread

I don't want to handle memory allocation to extract a value from a JSON file :blobthump:

Show thread

But whatever, that's maybe because I'm a young noob-level programmer :hit_w_feels:

Show thread
@angristan Using C for that makes 0 sense... :( But at least it's curl 'easy' cleanup. Imagine what hard cleanup is.
@angristan *starts thinking of wile hacks to avoid memory management*
knowing how to do these things will help you, though. it's important to keep in mind, even in higher-level languages, when operations will need lots of allocations, because allocations are one of the biggest performance bottlenecks

@angristan Yeah it's definitely cause C is so bad.

After years of changing requirements, eventually you realize that your app is leaking every possible kind of resource, this is the magic of deep C

@CharredStencil @angristan That might also be an indicator of "your" programming skills.

@steelman @angristan My manager skill says that I don't have to use a language that makes the programmer do a compiler's job.

@angristan At least for this case, Rust is shorter.

And people use Rust for writing OS kernel too. 🤔

@angristan yeah, there are many good uses of C, but making a request to a web API and parsing the resulting JSON is not one of them.

It's sad that many teachers can't come up with tasks that show strengths of C, and then the students suffer and get to think C is a bad language.

@Wolf480pl @angristan Calling HTTP APIs is a terrible use for C. However, there are thousands, if not millions, of lines of C that make JavaScript work at all. What C is really good for is writing high-performance JavaScript interpreters, without which those 18 lines of node aren't going very far.

@angristan because C is fastest. And it helps to show who is the _daddy_ in the room.

@angristan Dude, C is awesome. It's great for being able to know what your code is actually doing on your machine.

@ethicsperoxide @angristan Nowadays even X86 and ARM machine codes are translated again in CPU. 🥺

@veer66 @angristan That's a good point. There is a limit to how close to the bare metal you can get with C (or, sadly, even assembler). But at least C will teach you about (virtual) memory and pointers and system calls.

@ethicsperoxide @angristan I suppose that coding in C on 8051 to interface PM2.5 sensor and E-Ink display is more practical than this cURL thing.

I'd be tempted to implement the same in Lisp. One line?

Here i assume you write the code from scratch on both side... only using primitive of the langage. You although compare exection time and memory footprint. Limit your study to the number of line is a strange choice.
I study c and i don't use it irl. Because when i write something i need the result quickly... in professionnal environnement the performance's needs could be a reason why they chose c.

$myProgram = require "myProgram.php";

There, did I win?

@angristan every once in a while the world needs something like Node.js to appear. And it wouldn't be possible if the folks didn't know their memory management

@angristan wait, why JS when curl | jq does just fine here

Sign in to participate in the conversation

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!