Live data from Hacker News

Switching to C over 'Modern' Programming Languages

devtails.xyz

31–40 of 170 posts

Re: Switching to C over 'Modern' Programming Languages

#31

> After looking up compatibility for SDL, I noticed it is able to run on iOS 6 and greater, meaning it supports iOS devices all the way back to iPhone 3GS. Whoah, I was convinced there is no way to write and run apps on these older iPhones - I wonder how difficult the whole process is.

I don't understand using SDL, it's not that hard to write something in Objective-C that runs on earlier versions of iOS as well. You can even cross-compile from Linux, or even run clang directly on iOS if you jailbreak. My own experience is with iOS 4 - 6.

Re: Switching to C over 'Modern' Programming Languages

#32
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

I'm a programmer since the early 90's, but I have seen this problem only ever with Rust so far (where people are eager to learn something new, pick Rust, and then quickly get jaded - case in point, that's also me - I learned enough Rust to write a home computer emulator but in the process realised that it is not the right language for me, even though it should be from its feature set).

It feels a bit like a speed run of C++, at least this took around 2 decades for people to get fed up and turn away ;)

(and interestingly, I also switched back to 'mostly C' for my hobby stuff, and I'm quite happy with it)

Re: Switching to C over 'Modern' Programming Languages

#33
post #30
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

While I agree, I also have to say that Rust does a lot more than just solve some specific C and C++ issues. It doesnt solve all of them (e.g. logic errors, so if thats 90% of your issues you wont benefit too much), it repeats some design issues of C++ (massive complexity from the start, many ways to do the same thing), and implements a C-like unsafe{} language anyways. If Rust was just C but with strong typing, a bor…

> But it isnt - its a whole different beast which by far is not perfect and repeats many issues it didnt need to repeat (e.g. terrible async like python).

Not gonna lie, I don't see too much value in async, but that said, I can see where they (the Rust devs) are coming from. It was an oft requested feature, and it was in the pipeline for ages, leading to Rust dev burnout.

That said Rust team is working on making it fully usable, albeit the space of efficient, zero-cost abstraction closures that work with lifetimes is a set of one language - Rust.

Re: Switching to C over 'Modern' Programming Languages

#34
post #28
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

> they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? It sounds to me like they keep learning languages with the same illusions and failing to take any lessons between their language exploration escapades. All programming languages suck. It's just about finding the one that sucks the least for you (or your project/business). They m…

Disagree on c++. Even if you forego the significant improvements in the last decade then: RAII and templates make it worth not using C anymore. Having to use shoddy macros for a resizeable array is just unreasonable.

Re: Switching to C over 'Modern' Programming Languages

#35

I’ve been enjoying writing libraries in C and being able to use them both from native applications and in web apps via WASM. I personally avoid emscripten and just implement the minimal C/JS glue and utilities myself.

What library or such if any do you use for string.h/math.h/snprintf and such?

For snprintf I use stb sprintf [1]. For the reasonable functions from string.h (memset, memcpy, memmove), you can just use compiler builtins (__builtin_memset, etc.) as long as you enable the bulk memory extension (-mbulk-memory). I haven’t needed much of math.h for the stuff I’ve made, when I have I just called stuff on the `Math` object in javascript.

[1] https://github.com/nothings/stb/blob/master/stb_sprintf.h

Re: Switching to C over 'Modern' Programming Languages

#36
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

I'm a C programmer by day and I disagree with them, C is only simple if you're trying to do simple tasks with it.

The very common thing I want to use in C is some sort of variable size string object. But no, I have to dynamically allocate a buffer that I know will be at least the right size for any text I ever put into it, or do I create a buffer that's the correct size for that string but re-alloc if I ever change it to a longer string. But then how do I store the buffer size? Do I want to create a struct that constains a point to the buffer and the length, or use sizeof() to calculate the string length? But then I can't use sizeof() if I pass that buffer into a function via a pointer. If I pass that string to a function is it being copied straight away or just storing the pointer so I can't change the string at a later date. I can't enforce copy semantics

And god forbid you ever forget to include space for the NULL

I just want a string I can dump some text in, I don't want to go searching for libraries, I don't want to have to consider allocation and copying and all that crap. If I wrote half of my boilerplate C code in python it would look just as simple and beautiful (if not more)

Re: Switching to C over 'Modern' Programming Languages

#37
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

Maybe the zeitgeist is "being different from others for no reason"...

Re: Switching to C over 'Modern' Programming Languages

#38
post #36
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

I'm a C programmer by day and I disagree with them, C is only simple if you're trying to do simple tasks with it. The very common thing I want to use in C is some sort of variable size string object. But no, I have to dynamically allocate a buffer that I know will be at least the right size for any text I ever put into it, or do I create a buffer that's the correct size for that string but re-alloc if I ever change i…

>I'm a C programmer by day and I disagree with them, C is only simple if you're trying to do simple tasks with it.

C gives you enough rope to shoot yourself in the foot. And rightfully so. It came out in a time when everyone was coding assembly. It's meant not to hold you back from doing voodoo with low-level stuff, therefore it won't hold your hand.

Not very practical in the world of today when we've been spoiled by 'better' languages and you need to quickly ship stuff that mostly works without worrying about the little things, but at the time it was revolutionary.

Re: Switching to C over 'Modern' Programming Languages

#39
I've been learning Rust lately. Working on a little game. First few thousand lines of code in I was having some doubt. After being a little frustrated with borrows and lifetimes and with my strong tendency to prematurely optimize all the things I was soooo tempted to just switch to C and have full unfettered access to my sweet sweet pointers.

I'm glad I haven't switched though. Performance (which I'm measuring a ton of) is great. The situations where I wanted to bow out and take the 'easier' path were mostly bad design choices on my part and I think partly just laziness.

Rust forces me to think a little bit more, and I've really enjoyed learning about how/why the various language features were designed. Now I'm one of those damned Rust evangelists that have been annoying me for years =)

Re: Switching to C over 'Modern' Programming Languages

#40
post #16

Is this becoming a thing now (or maybe it was always a thing), where a language, like Rust, has become popular enough that instead of everyone talking about learning it, they now want to talk about how “simple” and “beautiful” C is for no other reason than signaling how different you are from the zeitgeist? Rust exists for a reason, and it solves specific problems. That’s the “magic”, just like any abstraction in any…

> Is this becoming a thing now

Maybe we are entering an era where C is cool again!

Post reply on HN