News for hackers. Stuff that matters.
Re:Git's list of banned C functions by unbalancedevh on Thursday March 04, 2021 @06:06PM (#26349779)
It always makes me wonder if there's some hidden overhead that I'm absorbing. When I program in C I feel like I know a lot better what the generated instructions will be. Using higher-level languages for embedded programming where resources are tight makes me uncomfortable.
Re:Git's list of banned C functions by Gene_Parmesan on Thursday March 04, 2021 @07:39PM (#26350753)
In addition to the overhead from dyn alloc and the GC as someone else mentioned, there is also the size overhead that comes with every object in an OO language. The obj overhead for Java is JVM-dependent, but I believe it to be somewhere around 16 bytes.

A mostly unrelated stackoverflow post I found[0] states that an empty standard string in Java occupies 40 bytes due to the normal object overhead and overhead related to the internal byte array for the char storage. Obviously what you gain in return is convenience in programming as well as runtime-enforced safety from buffer overflows. Whether this is worth it depends on what you're doing.

In general, you're definitely absorbing overhead with any managed lang, although it need not be hidden. The specifics should be documented somewhere for whatever platform you're using, and most GCs are pretty tuneable nowadays.

[0] https://stackoverflow.com/questions/56827569/what-is-an-over...

Re:Git's list of banned C functions by golergka on Thursday March 04, 2021 @09:36PM (#26351814)
In cases where perfomance actually matters, you usually have other tools, like StringBuilder in C#. But in my experience, 99% of code that works with dynamic strings is not perfomance-sensitive, but is often very correctness-sensitive and readibility-sensitive.
Re:Git's list of banned C functions by scoutt on Friday March 05, 2021 @03:55AM (#26354540)
Together with parent comment, this is exactly how I feel every time I use something that is not C (I do mostly embedded). Like: ok, I can use a slice here, but what is a slice? what thing is it doing that I don't know? where's the catch? how does it look like in memory? is it calling a function when I access it? is it being copied or referenced?. And so on...
Re:Git's list of banned C functions by astrea on Friday March 05, 2021 @07:45AM (#26356234)
Coming from a hardware education and moving to an almost strictly Python career, I simply cannot enjoy the full fanciness of Python as I'm constantly worried about what weird things it's probably doing in the background. Particularly shaken after an incident of creating objects and appending them to a list, and at the end of the loop the list was the last item n times.
Re:Git's list of banned C functions by gpanders on Thursday March 04, 2021 @06:58PM (#26350307)
Basically every (non-C) string implementation in existence has to do dynamic memory allocation under the hood, which is hidden from the programmer. That’s the overhead.
Re:Git's list of banned C functions by 1f60c on Thursday March 04, 2021 @07:05PM (#26350373)
> When I program in C I feel like I know a lot better what the generated instructions will be.

If you don't know about the Compiler Explorer, definitely check it out: https://godbolt.org

Re:Git's list of banned C functions by userbinator on Thursday March 04, 2021 @08:27PM (#26351212)
There certainly is --- it's very easy to make accidentally quadratic (or worse) algorithms in languages where data structures automatically resize themselves to their contents.
Re:Git's list of banned C functions by kaba0 on Friday March 05, 2021 @11:01AM (#26358287)
To be honest, with today’s compilers you can’t be all that sure about the generated code. They do some insane tricks under the hood to make naively written code perform good. As per a “famous” blog post, C is a high level language.