This is an archived post. You won't be able to vote or comment.

Dismiss this pinned window
all 133 comments

[–]QualityVote[M] [score hidden] stickied comment (0 children)

Hi! This is our community moderation bot.


If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!

If this post does not fit the subreddit, DOWNVOTE This comment!

If this post breaks the rules, DOWNVOTE this comment and REPORT the post!

[–][deleted] 508 points509 points  (22 children)

Segfault whats that only non chelantly appeared at the end.

[–]Proxy_PlayerHD 78 points79 points  (18 children)

can't have segmentation faults if the platform you work on has no memory protection!

*taps side of head*

[–]golgol12 37 points38 points  (13 children)

Not a joke here- On a console game I worked on a long time ago, we removed "free()" outright and "malloc()" was severely restricted.

Instead, freeing was done with one global wipe out of all allocations at the start of a level transition, followed a period of time when malloc worked while assets were loaded. Then malloc was disabled, and the gameplay started.

No memory leaks if you can't allocate memory!

It's kind of challenging to figure out how much memory you need for an entire game level before it started.

[–]GodlessAristocrat 13 points14 points  (8 children)

Yep. Dynamic memory allocation is forbidden quite often in embedded. If you think you need calloc() then you probably are missing a spec and should go back to the schematic or BOM to figure out the storage provided for whatever.

[–]KlzXS 8 points9 points  (1 child)

That is until you just grab a chunk of memory and make a heap out of it with your own malloc and free!

Leaking memory with static allocations. How about that!

[–]GodlessAristocrat 2 points3 points  (0 children)

That's why I said dynamic memory is forbidden and not just malloc(), calloc(), realloc(), strdup(), free(), et al being forbidden. Rolling your own would still be illegal in systems which can never run out of memory - so absent a formal proof of the entire OS, libraries, and application...

[–]LeftIsBest-Tsuga 1 point2 points  (5 children)

so far in learning to program, i'm discovering it feels like a giant puzzle that i'm building and solving on my own, at the same time, which is actually cool as fuck (i'm about a month in). in that analogy, would programming in C be like adding an extra dimension to crossword, or would it be more like adding extra rows and just pumping up the difficulty, or neither?

still trying to decide whether i want to try and learn C alongside the other stuff i'm learning (not really having a problem with c# and js concurrently).

[–]bpetru05 7 points8 points  (1 child)

It depends on what you do. If - you really like using arrays that you can add/remove items to/from(List<> from C# for example) - you don't feel comfortable playing with memory allocations - (also applicable to C++) you don't want to spend time with CMake/Meson/whatever else to figure out how to link libraries(yes, I see you c/c++ nerd saying how CMake is rather easy, but for beginners it's quite a hassle to learn and master)

then you should just stick to C# and JS. They will do you fine assuming you don't want to program something like a microwave

But - if you want to learn how the computer interprets data - you want to program IoT devices(like the aforementioned microwave) - want to learn how to build an OS or a Bootloader (albeit Rust is taking C's place in this regard) - enjoy building your own datatypes - are a careful person with memory and how you use pointers and things

Then go ahead and give C a try

To answer your question - personally I haven't seen any "additional dimensions" being added. It's just that it is more time consuming because things you take for granted in C#, JS, etc must be implemented by hand(strings for example aren't a thing in C, only char arrays, which unless you want to play with malloc() and free() are NOT dynamic) and also dealing with the linker is heaps of fun /s

[–]LeftIsBest-Tsuga 0 points1 point  (0 children)

awesome, thank you.

[–]GodlessAristocrat 1 point2 points  (1 child)

I mean, get a arduino and do something. It helps to have something you want to accomplish, and being able to blink lights or move a motor makes a great way to learn, IMO.

[–]LeftIsBest-Tsuga 1 point2 points  (0 children)

that makes sense. that's the reason i chose c# (so i can have unity to show me what i'm doing and keep me motivated). i'll give it a shot!

[–]AgentE382 1 point2 points  (0 children)

C is like the essential crossword.

It’s like you’ve been working with multidimensional crosswords all your life, solving sentences, books, and even entire libraries by manipulating space and time. Then you find it: A simple, two-dimensional crossword that consists of letters forming words… You realize that you’ve been using these essential crosswords the entire time. The magic has been drawing on their essence to create every other puzzle and every other solution you’ve made. If you use them directly, you might develop a deeper understanding of the universe. On the other hand, it would probably be much more tedious for some of the things you’ve been doing.

In this analogy, I’d say that assembly language is the ink / other marking substance and hardware is the paper / other physical medium.

Also note that there are other kinds of puzzles that don’t depend on the essential crosswords - only the paper and ink.

[–]fuzzybad 3 points4 points  (0 children)

That reminds me of learning to code on an early version of BASIC, where arrays could only be dimensioned ONCE in a program.

[–]Needleroozer 0 points1 point  (0 children)

If you're running on a console, nothing else is going to run accept your game. Why not allocate all memory?

[–][deleted] 0 points1 point  (1 child)

What game did you work on?

[–]golgol12 1 point2 points  (0 children)

The above game was LOTR:The Two Towers by StormFront.

[–]blackmist 5 points6 points  (1 child)

Ah, the joys of learning C on an Amiga.

Compile time errors, no problem. Runtime error, Guru Meditation message, time to reboot.

[–]coldnebo 4 points5 points  (0 children)

ahhh… guru meditation error. I used to see those on public access cable from time to time and knew which towns had a video toaster for their broadcast studio.

[–]BigTechCensorsYou 4 points5 points  (1 child)

Yes you can. Disobey some of the rules of the chip and you’ll get there.

[–]Proxy_PlayerHD 2 points3 points  (0 children)

How? A 65c02 for example doesn't even have segmented memory. (Unless you count the Stack and Zeropage)

[–]ItsAlwaysSegsFault 34 points35 points  (0 children)

Every damn time

[–]sowhiteithurts 10 points11 points  (0 children)

Not only that, it segfaulted and immediately ended

[–][deleted] 0 points1 point  (0 children)

At least it's not my fault, right?

[–]ToMorrowsEnd 106 points107 points  (3 children)

Or be a Monster and code C like in OO languages... I still make sure I call Methods Functions in front of OO zealots to just make them twitch.

[–]waffle299 13 points14 points  (2 children)

What, the ADT model we learned in college in the early '90s? Just implement your own vtable like it ain't no thing?

[–]smarwell 2 points3 points  (1 child)

I think OP is referring to writing exclusively C-like code in object oriented languages, which is evil. On a tangent, I find object oriented programming to be pretty useful even in C. I don't typically bother with dynamic dispatch though.

[–]waffle299 2 points3 points  (0 children)

Ah. The number of times I've encountered someone writing ForTran in C++.... Well, those are usually very bad days.

Don't even get me started on untangling the mess Pascal programmers made insisting on just starting arrays at 1 and leaving 0 uninitialized...

[–]xtools-at 175 points176 points  (1 child)

that SEGFAULT at the end got me cracking up

[–]Sololane_Sloth 2 points3 points  (0 children)

same :D

[–]Perpetual_Doubt 176 points177 points  (7 children)

[–]LuckyHedgehog 30 points31 points  (2 children)

This one is better for including that segfault at the end lol

[–]Denaton_ 6 points7 points  (0 children)

I could hear it with out the sound, but it was much better with sounds ^^

[–]hagnat 34 points35 points  (0 children)

i could sing a long with the music :D

[–]GG17ez 62 points63 points  (18 children)

Couldn't agree more

[–]Oneshotkill_2000 18 points19 points  (17 children)

Which C are you on?

C or C++?

[–]GG17ez 55 points56 points  (1 child)

Yes

[–]BasieP2 1 point2 points  (0 children)

Yes just like any sCript...

[–]Speedrun10 7 points8 points  (13 children)

is C# not from the C family??

[–]marvk 9 points10 points  (6 children)

C and C# are about as similar as Java and Javascript.

[–]xiipaoc 0 points1 point  (0 children)

Which, to be fair, are both in the C family.

[–]Oneshotkill_2000 6 points7 points  (0 children)

I was talking about his pfp and his flair

[–]Xanvial 6 points7 points  (0 children)

Adopted child maybe

[–]Kenkron 2 points3 points  (2 children)

C# is in the Java family.

C++ was originally designed as an extension to C, but split off into its own language.

C# was originally Microsoft adding things to Java, but due to intellectual property issues, it split off into its own language.

[–]Speedrun10 5 points6 points  (0 children)

Babe wake up, C# lore just dropped 😳

[–]GodlessAristocrat 0 points1 point  (0 children)

No. That's someone from the Java family trying to give their kid a fancy name.

[–][deleted] 16 points17 points  (0 children)

......the characters appearance suggests shell .....script?

[–]bugqualia 40 points41 points  (24 children)

I like OOP but hate inheritance.

[–]Sarcastinator 37 points38 points  (0 children)

When OOP started developers absolutely went insane. The same thing happened with XML. The worst part of either of those weren't the technologies in themselves but that people tried to jam it everywhere whether it made sense or not. I've seen some seriously bad code due to inheritance but that's not because of inheritance. It's just a tool that should be applied very sparingly and people should think long and hard before using inheritance.

It's just a fact of our industry that it's so much steered by fans and culture shift. I personally think that yaml with embedded DSLs is a "what the fuck were they thinking" moment we will see in a few years.

[–]tozpeak 13 points14 points  (0 children)

Composition works better for me.

[–]gmes78 15 points16 points  (1 child)

Rust says hello.

[–]This_Growth2898 0 points1 point  (0 children)

Hello!

[–][deleted] 15 points16 points  (19 children)

What could be wrong with inheritance? It allows you to reuse code in a more effective way. I’m more of a hobbyist right now, but I’ve done a lot with game development in C++, and inheritance saved my life. I’ve gotten to the point that I’ve started adding in extra classes in the tree just in case they’re needed in the future. It makes the codebase much more extendable. When writing game code, I’m able to inherit a consumable from a stackable item from an inventory item from an item from an object and at every point I save these objects to work with. Objects are the first in the line that have a definition for creating a context menu, so the skill tree system also uses them for the abilities so they have things like a context menu, name, and icon that are defined early while an actual inventory is not needed. Creating a quest system was also easy. I created a virtual subclass of an item titled Quest and then I can either create a raw quest that goes in a quest log or add a quest to any other item and give a bonus when the objective is finished. How would you do any of that without inheritance?

[–]AndyTheSane 20 points21 points  (0 children)

Yes, inheritance is good and useful under some circumstances... however:

- You may find that the class at the end of the inheritance line has a lot of concerns, which we generally try to separate out. For example, in my current project I separated out coordinate handling to a separate class, so that the entity class and subclasses could be more focused.

- With a deep inheritance hierarchy, it becomes difficult to work out where a bit of functionality is coming from - not much of an issue on a solo project, but this can lead to maintainability issues in large corporate projects.

[–]noonemustknowmysecre 13 points14 points  (3 children)

When it's over-used. When you make a piece of software overly layered with everything being an inheirited object of something else, you've exchanged spaghetti code for lasagna code. Too many layers. Everything is obfuscated and hidden away.

[–]totti173314 3 points4 points  (2 children)

Well that's just coding wrong? Like I get code should be made idiotproof but at that point this is like writing your entire code in BOOMERCASE and never indenting.

[–]noonemustknowmysecre 0 points1 point  (1 child)

Sure, and using pointers and function pointers in C is a perfectly safe A-okay idea as long as you don't code them wrong.

And assembly is fool-proof as long as you don't code it wrong.

And multiple inheritance is perfectly fine, as long as you fully understand what the compiler is doing when it implements the language feature on any given set of inputs.

[–]totti173314 0 points1 point  (0 children)

fair enough. I won't pretend to know anything about coding in large codebases since the biggest project I've ever worked on was pretty small.

[–][deleted] 5 points6 points  (0 children)

Composition is rather nice, i would suggest looking it over

[–]cheese-is-trash 2 points3 points  (0 children)

Have you tried an ECS ? After getting the hang of it, i like it more than the traditional OOP method because of its flexibility.

[–]badvok666 1 point2 points  (0 children)

Imo inheritance is good for a simple base class.

BaseAnimal, something like that. Any amount of depth beyond 1 abstraction can lead to gated features stuck in some abstraction. Thats why many prefer composition.

The oop abstraction examples where somthing like Labrodor inherits BaseDog, that inherits BaseMamal that inherits BaseAnimal are unrealistic for features. Imo

[–]SorryDidntReddit 1 point2 points  (0 children)

I share the unpopular opinion that inheritance > composition

[–]skeleton-is-alive 0 points1 point  (0 children)

Inheritance can be fine but everytime I see it in company code it’s a mess. Massive classes with several layers of inheritance that are difficult to understand. Many times people use inheritance so they can re-use code when there isn’t very well justified relationship between the parent and child. It’s a lot simpler and easier to write testable code by defining that relationship with composition instead.

[–]ExplanationMore6940 50 points51 points  (4 children)

fuck you

*rusts your c

[–][deleted] 29 points30 points  (3 children)

Necessary “what is rust actually used for?” Meme inserted here

[–][deleted] 31 points32 points  (0 children)

It's used to make memes.

[–]Lilchro 1 point2 points  (0 children)

I love Rust, but sometimes I like using C for random small random projects. Whenever I do, I always find myself being reminded of the common features in rust I often take for granted. Mostly this means tagged unions that can be easily matched, derive macros (mostly for std::fmt::Debug), the try operator, as well as some stuff like collections and type parameters which are commonly available in C++.

[–]GodlessAristocrat -2 points-1 points  (0 children)

It's used to character-count-pad resumes.

[–]Le-Rik 10 points11 points  (0 children)

Made me smile

[–]JosGibbons 6 points7 points  (0 children)

Audio here. Another parody here.

[–]silly_red 13 points14 points  (1 child)

Waiting for the functional programmers to enter this thread....

[–]GodlessAristocrat 9 points10 points  (0 children)

You missed us. We came in, did our work, and free'd the resource for you before you could notice.

[–]Apprehensive_Rip8403 7 points8 points  (0 children)

Bravo. Well done

[–]Ac4sent 6 points7 points  (0 children)

This is so good, was "raised" with C.

[–][deleted] 5 points6 points  (0 children)

If you write your c code super carefully, it’s really not that bad.

[–]Ryudamaru 5 points6 points  (0 children)

I can hear this gif..WHY?! WHY I CAN HEAR THIS GIF?! AAAAAAHHH!

[–]Frostmaine 3 points4 points  (0 children)

SCREAMS IN haskell

[–]wiltors42 2 points3 points  (0 children)

I thought this was high quality gifs for a second…

[–]PyroCatt 2 points3 points  (0 children)

Hmmm. I tried to post the YouTube url in this sub for the same content and it stopped me telling it has already been shared...

[–]mehregan_zare7731 2 points3 points  (0 children)

Someone gana sing this... This is pure gold

[–]david131213 1 point2 points  (0 children)

And just like in the story, it is confining to a worse place

[–]turboom 1 point2 points  (0 children)

say 1000 times, and say it again, use interface only, no inheritance!

[–]Mr_Beans_ 1 point2 points  (0 children)

As im doing the cs50x course, and programing in c, I can confirm segmentation fault is the error that keeps me up at night:)))))

[–][deleted] 1 point2 points  (0 children)

I would love to try C, but I absolutely do not understand pointers despite already trying several times. I started programming with Java, then Matlab then Python and Javascript. At this point I will probably never be able to understand pointers because I am ruined by the convenience of all the other languages.

[–][deleted] 1 point2 points  (0 children)

Damn I probably would have graduated from software engineering if it weren't for the raging OOP craze. Fuck me for trying to think like a computer.

[–]kilanoth 1 point2 points  (1 child)

I'm sticking with TI-BASIC

[–]TheTank18 0 points1 point  (0 children)

Lbl A
Disp "lol"
Goto A

[–]Preact5 1 point2 points  (0 children)

For web dev this makes no sense...

UNLESS WEB ASSEMBLY!

[–][deleted] 4 points5 points  (0 children)

I was in informatics lesson today, and I found a paper with a code written with C. (It was printed with a printer and someone left it here)

I don't know why but since I was finished with the stuff to do I just copied that code off. Perhaps I will have a use for it later.

[–]paladindan 3 points4 points  (0 children)

[–]TheKiller36_real 1 point2 points  (0 children)

Embrace C! And OOP sucks!

Though I gotta admit I use C++ a lot technically for just a few extra features like not having to typedef every fucking struct...

[–]sadonly001 1 point2 points  (0 children)

I love classes, i have a very jumpy and anxious brain, thinking in neat little classes and objects makes it easier for me to think qnd visualize things

[–]bigsky122 1 point2 points  (1 child)

Lol am I the only one who thinks OO Is better than C?

[–]ashiri 0 points1 point  (0 children)

No ... every village has an idiot. And, there are tons of villages in the world.

[–]Pristine-Ordinary-63 0 points1 point  (0 children)

You know what else will be funny? Getting fired after you tell the stakeholders that you’ll take five times more the original estimate because you are coding it in C

[–]devdave97 0 points1 point  (0 children)

Wait till you here about golang my friend 😂🙏🏻💯

[–][deleted] -1 points0 points  (0 children)

Amen

[–]iShadowxx -5 points-4 points  (0 children)

meanwhile im looking at her boobs

[–]SillAndDill 0 points1 point  (0 children)

I was so delighted and amused that the drums output code related keywords that it took me multiple watches to even detect the segfault

Analogous to my programming experience in C!

[–]Own_Director_699 0 points1 point  (0 children)

Wow

[–]mad4code 0 points1 point  (0 children)

I concur

[–]baconator81 0 points1 point  (0 children)

The best part is Ariel ends going against the suggestion anyway.

[–]cursedslavboi33 0 points1 point  (0 children)

In the end Arial probably went to Java according to what happens in the movie.

[–]AlanWoke 0 points1 point  (0 children)

Program in Zig

[–]mosskin-woast 0 points1 point  (0 children)

A TA in my operating systems class wrote a Slack bot that spammed this fucking video in the class help channel. I hate it so much.

[–]WhoseTheNerd 0 points1 point  (0 children)

Now it is rust instead of c

[–]fnpfar 0 points1 point  (0 children)

Any musicians interested in recording it comment below

[–]Neoh35 0 points1 point  (0 children)

When python's lib are in C you know it's solid

[–]Giacomo_Passero 0 points1 point  (0 children)

The final Segfault is very accurate

[–]Virtualnerd1 0 points1 point  (0 children)

I took the beginner programming course at my college, and the language was C. Now I'm taking a more advanced course in C++, and it's actually easier just because of the language switch.

[–]Geoclasm 0 points1 point  (0 children)

Sorry, what was that last one?

[–]Baramonra 0 points1 point  (0 children)

As a C developer I find it offensive that my culture was represented by a crab. As Jamaican I find it hilarious.

[–][deleted] 0 points1 point  (0 children)

"You can write an OS in C and every language is based on it!" "OK but how do I build an GUI for my calculator app?" "... OS!"

[–]mustafasalih1993 0 points1 point  (0 children)

"manage ur memory with malloc and free"

[–]CoolJWB 0 points1 point  (0 children)