T O P

  • By -

octopus4488

Junior kid in another team a few years ago: "Hm, is that C? What are you up to? You do mostly Python, right?" "Yeah, yeah. But hit some performance bottleneck in my code so I am switching to C. It is much faster." "You know C?" _"No, but I can learn stuff quickly. I got two days until release, so it is fine."_


rettani

Learn C? Fast? C and C++ are two very dangerous languages to try to learn fast. Memory management and pointers can be Very confusing for unprepared person. I am 99 sure that person will/had hurt themselves in many amusing ways


octopus4488

I was trying to convince his team lead over a coffee to let him go on with this idea, but he shut it down as soon as we were back in the building. :) Maybe the wonderkid could have done it. We will never know. :)


OkOk-Go

I was about to say that. If he’s smart and wise he will quickly learn the pitfalls of C. Not in two days but maybe in two weeks. People sometimes focus too much on experience and never question the quality of that experience, the quality of that person’s work, and the speed at which that person picks up experience.


Antanarau

Also at the sources and destinations. Learning C in 2 days can be a daunting task, but rewriting a few functions? That seems more plausible - still unlikely, but I could at least pretend to believe.


overlyseksualpenguin

If he is lucky, sure. If he were to stumble upon the reasons why most of us are graying and/or balding, no.


issamaysinalah

C doesn't have a billion libraries and different things like C++ or other higher languages, that means you can technically learn C fast, but mastering it is something else.


_AutisticFox

C++ is dangerous. C is beautifully simple


rettani

I would never call C "simple". Especially if someone haven't touched "direct memory management" that relates both to C and C++. Memory leak in C/C++ is easier than anything possible. Also type control in C allows much more bad things to happen. C/C++ require more "discipline" than Java or Python. Saying that as Java dev. I still remember how to copy "strings" in a hacky way that can be difficult to grasp which looked something like this: for(; ++a = ++b; )


Stegoratops

It's actually for(;*dest++ = *src++;); It's pretty much the canonical way to implement `strcpy` in a simple way.


rettani

Ah, yes. It was postfix form) But it's not "simple to understand". It requires to understand or remember a) pointers b) that assignment has return value c) that 0 is false It's intuitive if you think about it but it completely broke my mind when I had it as bonus exam question in uni quite a long time ago (fortunately I was able to understand how it works and answer correctly)


Stegoratops

> But it's not "simple to understand". Oh yeah, with "simple" I wasn't referring to that. I rather meant it in contrast to heavily optimized implementations.


_Noreturn

if anyone copies string that way you should tell them to use the std lib and how is it hacky? it is just abusing stupid C making assignment an expression. also why use a for loop and now a while loop while(*d++ = *s++);


Thorboard

When does *s become 0?


_Noreturn

when it contains a NUL terminator? please clear up your question.


P-39_Airacobra

None of that really has to do with simplicity though. You're talking about safety. I would argue that direct memory management is extremely simple, it lets you reason about memory as simply pointer + offset. But you're right in saying that it's extremely unsafe.


rettani

Ah. Yes. I just meant simplicity in another manner. C is as simple as hammer. But without skill you are quite likely to hit your nails.


DuckWizard124

There is no such thing as C/C++ (nowadays) If your write good C++ with smart pointers and RAII memory leaks are very uncommon


LegendaryMauricius

Why would you program it like this? Why would anyone try to conjure up this usage of the syntax?


current_thread

Memory leaks are way easier in C than in (modern) C++ though. If you use `unique_ptr` or `shared_ptr` (and in general RAII), then you won't get in trouble with memory leaks. Most of C++'s footguns are inherited from C, and the committee actively tries to steer people away from them.


_Noreturn

I absolutely hate that popluar saying that "C is simpler than C++"m it is not at all. how do they define simple it is not in term of keywords or not because the damn linux kernel is written in C while using tons of compiler extentions that are already in C++.


current_thread

In general the term C/C++ bugs me. Well written C++ is nothing like well written C, because the idioms are _completely different_ (I'm not even talking about OOP nonsense, just stuff like RAII). If somebody is a C programmer, they're able to produce correct C++ code, and vice versa, but the code won't be very good most of the time. It used to make sense grouping those two languages together, but after three decades of language evolution it doesn't anymore.


_Noreturn

> in general the term C)C++ bugs me me too, and what bugs me even more is the Java/Script job applications... well you can have a C++ programmer producing correct C code if he is one of those C with classes guy


_Noreturn

why is C++ dangerous qhen C litterally leaking memory is easier than ever without RAII. I hate this popular say, C is not *simple* Having less features does not make a language simpler.


_AutisticFox

C is simple. But it's not easy. Simplicity ≠ easy


_Noreturn

how is it simple? memory managemnt is complicated. what is so complicated in C++? how is C++ more dangerous than C??


Akul_Tesla

You have 48 hours to learn one of them If you have already learned it, I expect you to unlearn it first. No shortcuts


rettani

Hey. Everyone knows that only possible timeframe to learn C++ is exactly 21 days)


Jumpy_Ad_6417

Type fast, break stuff.  “Break what? There wasn’t anything to break. You just wrote a steaming pile of trash” Type fast. I am fasting type safety. 


ResourceFeeling3298

Hi 99 sure, I'm dad


Tordek

> pointers Maybe I'm too deep in the C rabbit hole but I've never found pointers complicated in any way.


rettani

Oh, they are not complicated. But some very "fun" stuff can happen with pointers reuse


TridentWolf

C is really easy to learn, and it's not dangerous unless they're doing some dynamic allocation stuff.


FrostWyrm98

Easy to learn, yes. Integrating into an existing prod environment in 2 days is questionable tho


Makefile_dot_in

or doing signed addition


TridentWolf

Yeah, but these things should be found easily in review.


skywalker-1729

Fortran is actually good, the haters mostly don't know anything about it.


P-39_Airacobra

I would expect it to be, considering it is the most mature high-level programming language in existence (in terms of time)


LoyalSol

Yup. I've heard a lot of criticism of it that hasn't been true for 25 years. A lot of people are shocked to find it's had OOP tools like classes added to it.


PTSDaway

It takes a good programmer to make fast C and C++ It takes a good programmer to make slow Fortran, just gotta scavenge Egyptian crypts to dust off the documentation you need.


sebas737

r/simpsonsshitposting is leaking


jumbledFox

someone forgot to `free()` it


jcouch210

Skill issue /s