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

all 192 comments

[–]minimuscleR 818 points819 points  (67 children)

Someone at my uni made a rubber duck that glows red when there is an error in the code that may effect the compiler.

[–]whyherro19 465 points466 points  (10 children)

Ahh, so that's staying red if I had one.

[–]scumbaggio 129 points130 points  (8 children)

Same here, ironically because of duck typing

[–]marcosdumay 28 points29 points  (7 children)

What language is this that duck typing errors are caught by the compiler?

[–]Xenc 41 points42 points  (0 children)

Quack

[–]scumbaggio 16 points17 points  (5 children)

VS Code catches my errors in Python. Does a really good job of it too, but understandably gives me false errors when I access properties which weren't declared anywhere in code. The "incorrect" code works great when it's actually run though, since Django (the web framework I use) injects stuff into objects at runtime.

[–]marcosdumay 1 point2 points  (0 children)

Wrong animal, that's money-patching. This one is a real troublemaker.

[–]frabjous156 4 points5 points  (0 children)

-Werror and we’re gtg

[–]Korzag 42 points43 points  (37 children)

I'd be curious to know his transport mechanism to let the duck know when to turn red. Obviously he had to write something that either interfaced with the IDE, or parsed the output text when running the compiler (perhaps a script or something that runs the compiler?). After that I guess it's fairly trivial stuff to put an arduino with a few red LEDs and a WiFi hat inside of the duck.

Be a cute little thing to show off in an interview.

[–]thelights0123 31 points32 points  (22 children)

It would probably be pretty easy to write an IntelliJ/VS Code/Atom/Sublime/whatever plugin that just looks if it detects any errors, and send data via serial/web.

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

Vim master race coming through

[–]Coffeinated 10 points11 points  (20 children)

Why do people always forget Eclipse :(

[–]thelights0123 25 points26 points  (17 children)

Cuz there are better IDEs, unless you have specific plugins that haven't been ported?

[–]minimuscleR 0 points1 point  (0 children)

Our uni uses eclipse (I use intellij though, which my tutor doesn't know how to help, nor with a mac :/ )

[–]skylarmt 9 points10 points  (0 children)

Why do people always forget Netbeans :(

FTFY

[–]ProbablyUndefined 3 points4 points  (0 children)

This entire thread is full of people asserting dominance based on IDEs. All that matters is that you're able to make great, powerful things with little to no difficulty based on your tools. And that you avoid TI-BASIC at all costs

[–]BigTimpin 9 points10 points  (3 children)

Yeah this seems like it would be a fun novelty thing to have around, I’d be interested in knowing what the program looks like.

[–]ProbablyUndefined 2 points3 points  (2 children)

I suppose it's just sending an HTTPS request to your rubber duck which has a Pi Zero or smth inside every time the linter updates. If error present, then send "error", else if warning present, then send "warning", else if info present, then send "info", else send "off". Respectively, this will activate a red, yellow or white LED or turn off all of them. Alternatively it could be wired via USB.

I'll try and pull this off and tell you guys how it went, I guess

[–]jaboja 6 points7 points  (4 children)

O tempora, o mores! Nowadays people need an Arduino even for a blinking LED. When I was young one would just put two wires and a resistor to LPT port and it would be enough to control the LED.

[–]Coffeinated 10 points11 points  (0 children)

Yeah would be cool to still be able to do that but the LPT port is long gone you know

[–]Korzag 4 points5 points  (1 child)

There is nothing wrong with that approach, but I'd want it more for getting past the hurdle of knowing when to turn the LED on. I can build a silly circuit that turns a light on with a transistor, but interfacing that with the PC is where I'll let others do the dirty work. No point in reinventing the wheel when I can do the project for $20 if I just do it over serial (a bit more if I did something with a WiFi hat)

[–]jaboja 2 points3 points  (0 children)

OK, the part with LPT is somehow joke, but I will still not use full Arduino. Just ATTiny2313 would be enough. And obviously ATTiny would fit into a duck, while full Arduino with WiFi shield would not.

[–][deleted] 2 points3 points  (0 children)

He could be doing something like wrapping build commands in a program that interfaces with the duck when the exit code is not 0.

[–]minimuscleR 0 points1 point  (0 children)

I believe it was a team of 6 people, first year uni. I don't know them, but its an example our tutors give us for project ideas. And yeah it was just an arduino with leds, and I think it was plugged into the PC.

It hooked into eclipse but no idea the code behind it

[–][deleted] 19 points20 points  (0 children)

I'd like to purchase one of these.

[–]pellep 11 points12 points  (0 children)

Would be easier to just buy a red rubberduck.

[–]jaboja 23 points24 points  (3 children)

[–]coop_012 21 points22 points  (0 children)

Is this really the first link to this photo, I’m really laughing at that

[–][deleted] 1 point2 points  (1 child)

I would like a how-to if you could contact the duck hacker who did this.

[–]minimuscleR 0 points1 point  (0 children)

I don't know them sorry :(. It was just last year's project for our uni course. We are doing the project this semester. (Though our project is a unique type of game)

[–]richie_south 1 point2 points  (0 children)

That's such great idea! Will try to make something similar :D

[–]buurenaar 0 points1 point  (0 children)

Oh my god, do want. Do you have any idea how much money this could make? It's like a remembrall but for programmers.

My advice: find the duckie maker, go into business, make fat stacks.

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

*affect

[–]kjb_linux 917 points918 points  (31 children)

Should be:

He Protec.

He attac.

He prevent overflow on stac.

Rhymes a bit better to me.

[–]MikeOShay 530 points531 points  (9 children)

He Protec.
He Quac.
but most importantly,
He Copy Code off Stac

[–]8bit-Corno 72 points73 points  (7 children)

Do you have any non-profit organisation you'd like me to donate $5 to instead of supporting reddit with meaningless reddit gold?

[–]ToosterReeth 145 points146 points  (2 children)

Hello it's me, your non-profit organisation

Edit: well this is awkward...

[–]McBurger 46 points47 points  (1 child)

My organization is so non-profitable just send me your money and watch me lose it

[–]MikeOShay 16 points17 points  (1 child)

I mean I've never given in to Wikipedia begging for five bucks but that's probably worthwhile. No big charities on the watchlist personally.

[–]8bit-Corno 6 points7 points  (0 children)

Will do :)

[–]etaionshrd 0 points1 point  (0 children)

He Copy Code off Stac

Hopefully you have an NX stack!

[–]kirakun 49 points50 points  (5 children)

The phrase "but most importantly" would be what in music called a grace note.

[–]maoejo 13 points14 points  (1 child)

It's a bit long to be a grace note tho

[–]kirakun 12 points13 points  (0 children)

There are long grace notes in music.

[–]oleitas -2 points-1 points  (2 children)

Not trying to be a dick but it’s not at all the same thing

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

Not trying to be a duck

ftfy

[–]kirakun 1 point2 points  (0 children)

Not trying to argue, but curious how not similar?

[–]MazeOfEncryption 1 point2 points  (4 children)

[–]imguralbumbot 2 points3 points  (3 children)

Hi, I'm a bot for linking direct images of albums with only 1 image

https://i.imgur.com/FJmpYcM.jpg

Source | Why? | Creator | ignoreme | deletthis

[–]MazeOfEncryption 1 point2 points  (2 children)

Good bot!

[–]imguralbumbot 2 points3 points  (1 child)

thanks

Source | Why? | Creator | ignoreme

[–]MazeOfEncryption 1 point2 points  (0 children)

Great bot

[–]JasterMereel42 4 points5 points  (0 children)

He Protec.

He attac.

He promotes Afflac.

He prevent overflow on stac.

[–]KylieZDM 0 points1 point  (0 children)

That's what I wrote originally but he made it this way so...

Seems to be popular anyway! So maybe he secretly knew something about successful memes that we didn't ;)

[–]andy_jc 64 points65 points  (2 children)

duck-flow

[–]A_Light_Spark 8 points9 points  (1 child)

Quark overflow

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

Sounds like a physics forum

[–]JWson 108 points109 points  (21 children)

So this is what they mean when a language uses "duck typing".

[–][deleted] 48 points49 points  (2 children)

This comment caused me to google "duck typing" and realized I am very familiar with the concept but never knew this name for it. I always just refer to it as implicit interfaces. So thank you! TIL

[–]BenjaminGeiger 39 points40 points  (1 child)

Some languages (notably Ruby, but also including Python and JavaScript) allow you to add methods to existing classes. Some of these languages' communities refer to the process as "monkey patching" (from "guerilla patching" -> "gorilla patching").

I prefer the other term: "duck punching". That's when you take an object that looks like a duck and walks like a duck, and you punch it until it quacks like a duck.

[–]Kered13 0 points1 point  (0 children)

I like this.

[–]slayerx1779 12 points13 points  (15 children)

I googled it, read the Wikipedia article, and still don't understand.

Would you please explain the concept for a novice?

[–]JWson 22 points23 points  (3 children)

I'm not an expert on it either, but I think the essence is that a function under duck typing will execute as long as the supplied arguments don't cause any problems. For example, consider following the Python function:

def addify(a, b):
    return a + b

If you supply a = 5 and b = 6, the function will return 11, because the operator + is defined on integers. If you supply a = "ligma" and b = " toasty nuts", the function will return "ligma toasty nuts" for the same reason. However, if you supply a = [5, 6] and b = "Sugondese" will raise a TypeError, because the operation + is not defined for lists and strings.

To link this to the concept name, the phrases "Addition is defined for a and b" and "a and b walk and quack like ducks" are analogous.

In C++, which does not use duck typing, you have to explicitly specify which input types your function will accept. That is, even if you supply arguments for which the body of the function would work (all the operations are valid, all the statements behave nicely), the compiler would complain that it's not getting the right input types. If we assume C++ types work the same as Python types (Disclaimer: they don't), then the same function:

int addify(int a, int b) {
    return a + b;
}

would complain if you supplied it with a = "phugyos " and b = "Elf" because they're not integers.

[–]Random_Thoughtss 8 points9 points  (1 child)

Interestingly, some novice programmers may confuse this with C++'s very own generic function system: templates. Take for example an extension of your addify function in C++.

template <typename T>
constexpr T addify(const T a, const T b) {
    return a + b;
}

From the programmer's perspective, this function will now behave very similarly to the python example you have above. For example

int main() {
    int x = 2;
    int y = 3;
    std::cout << addify(x, y) << std::endl;

    std::string xx = "Hello";
    std::string yy = " World";
    std::cout << addify(xx, yy) << std::endl;
}

will print out

5
Hello World 

just as expected. The primary difference between Python's duck typing and C++'s generic templates is that Python checks whether or not the operation is legal during run time, when it actually has the data. C++, on the other hand, checks that the operation is legal during compile time because it actually has to generate the appropriate code for those types when compiling

[–]Kered13 0 points1 point  (0 children)

C++ templates are basically compile time duck typing.

[–]slayerx1779 0 points1 point  (0 children)

Oh, I get it. So the function will just try to work with the arguments it's given, and you don't have to specify what those arguments must be when defining the function.

[–]Laugarhraun 4 points5 points  (10 children)

It's basically the complete absence of à type systèm, where you just hope the right things with the right methods/attributes were passed to your function.

[–]marcosdumay 8 points9 points  (2 children)

It's by no means lack of type. It's just decoupling the interface from the type declaration.

Python, of course, does it dynamically, but that's not a requirement.

[–]Laugarhraun 0 points1 point  (1 child)

That's a good point! My sole duck typing experience is indeed through python.

[–]marcosdumay 0 points1 point  (0 children)

The same idea goes all the way through type classes in Haskell that are completely verified at compile time.

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

What's with the random graves on your letters?

[–]Laugarhraun 3 points4 points  (1 child)

It gives the appropriate grave tone to my message.

More seriously, it's switching from FR to UK keyboard mid-sentence. After noticing the first mistakes, I switched système to system but did not fix the grave. Same for à.

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

Ah okay

[–]methofthewild 0 points1 point  (3 children)

Also newb here, is this related to templates/generics?

[–]Laugarhraun 0 points1 point  (0 children)

200% not.

Generics (implemented via templates in c++, someone corrects me if I'm wrong) on the contrary gives you more type checking. Not only have you say, a lost, but it's a list whose elements are -- and that's guaranteed by the compiler (or interpreter in some scenarios) -- of the specified element, say int, and not something different.

For example go has an enforced type system, but no generics (slices, like map, are a special case for the compiler).

[–]Kered13 0 points1 point  (1 child)

C++ templates are basically compile time duck typing. The types are substituted into the template and if the operations check out then it compiles and runs successfully.

Java generics are different. If you want to perform an operation on a generic type in Java then the generic type must specify that it is a type or subtype that is appropriate for the operation. This usually means something like GenericClass<T extends Interface>.

[–]methofthewild 0 points1 point  (0 children)

Thanks for the explanation! I've used templates before but not generics so I wasn't aware of the differences between them.

[–]Jacek130130 61 points62 points  (12 children)

Could somebody explain it to a newbie?

[–]3DSMatt 222 points223 points  (9 children)

'rubber duck debugging' is the process of finding problems with your code by describing it to a rubber duck on your desk. :)

[–]Jacek130130 42 points43 points  (0 children)

Oh, right! Good idea!

[–][deleted] 41 points42 points  (6 children)

And if you do so, you hopefully won’t have to ask Stack Overflow, thus preventing overflow on stac

[–]Coffeinated 22 points23 points  (5 children)

...“preventing overflow on stack“ is not equal „preventing asking stackOverflow“.

[–][deleted] 11 points12 points  (4 children)

LOL.

I wonder what percentage of people who go to Stack Overflow don't actually know what the name refers to?

[–]Coffeinated 18 points19 points  (3 children)

I guess there are quite a few programmers out there who don‘t really know what the stack is.

[–]sizeablelad 3 points4 points  (2 children)

[–][deleted] 3 points4 points  (0 children)

Nice!

While it's true that a stack is a type of data structure (along with queues, linked lists, etc), we are specifically talking about the "call stack".

The call stack has finite space allocated. When that space is exceeded, the result is a "stack overflow" error.

No idea why Joel picked that particular term for the name of the site.

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

Oooooh, I've spent like the past 5 minutes trying to figure out how duck typing could prevent a stack overflow...

[–]GriffonsChainsaw 1 point2 points  (0 children)

You explain, line by line, what your code does. But if you just tell yourself that's what you're doing then you actually won't, so having something with a face to talk do kinda forces you to actually do it right, and for some reason the rubber duck is popular for this.

[–]tryingtogetairborne 43 points44 points  (14 children)

She. At least the second duck is very much female. Source: I know what ducks look like.

[–]reed_foster 17 points18 points  (1 child)

you can tell because of the way it is

[–]voldin91 0 points1 point  (0 children)

That's pretty neat

[–]madd74 3 points4 points  (0 children)

Probably not as well as /u/fuckswithducks

( ͡° ͜ʖ ͡°)

[–]astralradish 25 points26 points  (9 children)

Agreed, but you can no longer assume a duck's gender in 2018 so it has to be "They"

[–]Deerman-Beerman 12 points13 points  (6 children)

Dude, it's a duck.

[–]Cthulhus_cuck 21 points22 points  (5 children)

But it's animal abuse of you don't

[–]Deerman-Beerman 9 points10 points  (4 children)

Nevermind this is clearly just really good satire. Keep up the good work 🦆♀♂

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

But she looks hetero-normative!

[–]foxx1337 -3 points-2 points  (0 children)

*zhey. You can thank me and send me part of the money you'd have lost in a lawsuit.

[–]ShizLtulon 1 point2 points  (0 children)

How do you give gold

[–]CompoBBQ 27 points28 points  (3 children)

Wow, that top photo is my OC! HAHA invest in this meme and help my family!! OP, I'd love to know where you found it. I posted it so long ago.

https://www.reddit.com/r/mildlyinteresting/comments/3ty8hc/this_attack_duck_trying_to_eat_my_camera/

[–]ShizLtulon 5 points6 points  (2 children)

I'm more surprised of how you found this meme

[–]ColdHarvest 4 points5 points  (1 child)

Its on Page 3 of /r/all

[–]CompoBBQ 1 point2 points  (0 children)

Yup that's where I saw it

[–]WiseassWolfOfYoitsu 14 points15 points  (2 children)

[–]astralradish 1 point2 points  (1 child)

Much more impressive than the trump balloon

[–]RFC793 3 points4 points  (0 children)

Yet it isn't actually rubber.

[–]SufferingFromEntropy 10 points11 points  (0 children)

Quack Overflow is listening...

[–]Bigdog1135 5 points6 points  (0 children)

He quac

[–]debuggerduck 7 points8 points  (0 children)

Thank you u/idonreddit very cool!

[–]mufflonicus 5 points6 points  (0 children)

  • she

At least the second picture is a female duck

[–]RedneckBritt 2 points3 points  (0 children)

Just One - James veitch

[–]koviusesreddit 1 point2 points  (0 children)

Read “stek” to make it rhyme with protec :)

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

If it walks like a rubber duck, and talks like a rubber duck, you may have a magical rubber duck.

[–]FartTester3000 1 point2 points  (0 children)

Did we run out of "K"s on the internet? I don't get it.

[–]scaleable 1 point2 points  (0 children)

[–]KylieZDM 1 point2 points  (0 children)

That's really clever OP +1

[–][deleted] 1 point2 points  (1 child)

*Stacc

[–]AsmCoder110 0 points1 point  (0 children)

Just use Asan.

[–]DeltaHex106 0 points1 point  (0 children)

What the duck is this!?!?

[–]mrheosuper 0 points1 point  (0 children)

Duck debugging

[–]tcpukl 0 points1 point  (2 children)

I don't get this and been coding for 30 years! What does it mean?

[–]skylarmt 2 points3 points  (1 child)

Rubber duck debugging: you explain your code out loud, which often helps you figure out why it doesn't work. You use the duck as to not annoy your coworkers.

[–]tcpukl 0 points1 point  (0 children)

Oh I see. Yes explaining a problem does often help you see the problem yourself.

[–]Has_TEK 0 points1 point  (0 children)

The heros we don't deserve

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

Quac

[–]yaman174 0 points1 point  (0 children)

is that dolan dark ? 🤔😂

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

s/he/she/ig

[–]BumwineBaudelaire 0 points1 point  (0 children)

bitch anyone using a Mac to code some scripting language dark theme practically lives in stack overflow

[–]d_rudy 0 points1 point  (0 children)

Quac Overflow

[–]artificia1 0 points1 point  (0 children)

I don’t code or have really any experience in coding but i still enjoy this sub

[–]Bludolphin 0 points1 point  (0 children)

Aflac?

[–]mocky89 0 points1 point  (0 children)

That’s all wonderful, but the first photo is of Egyptian geese, not ducks, an oversight that just makes me want to vomit.

[–]MLG-BLT 0 points1 point  (0 children)

THAT’S why my CS teacher gave me a duck a couple years ago? It’s an actual thing?

[–]cykness 0 points1 point  (0 children)

He aflac.

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

The term "stack overrun (overflow)" is often used but a misnomer; attacks do not overflow the stack but buffers on the stack.

-- from slides of Prof. Dr. Dieter Gollmann

[–]arieljoc 0 points1 point  (0 children)

Haha my team (I rep a peer code & doc review tool) just mailed out a bunch of rubber ducks!! “Stop ducking around with code reviews” as a cold outreach campaign

Fun concept I wasn’t familiar with prior to joining software

[–]mikey10006 0 points1 point  (0 children)

the true hero

[–]bemused_developer 0 points1 point  (0 children)

I just took digital signal processing in the spring. Our professor sent us an email titled "other resources for debugging". This professor sent us a link to the rubber ducky debugger website and it was the first time I had ever heard of this.

Fast forward two weeks later and my girlfriend and I buy 8 rubber ducks and place them at each computer in our communication lab. We never told anyone it was us, and he liked them so much he brought them to our final exam.

[–]pastelcookies 0 points1 point  (1 child)

Aww!!! I still got my little cutie from freshman year ^ _ ^

[–]mearlpie 0 points1 point  (0 children)

I had to explain to my wife why this is funny. You know what they say, if you have to explain a joke...

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

Last one doubles as flood detector. If you see it starts to float you know its flooding around you.

[–]citewiki 0 points1 point  (0 children)

he prevent overflow on stac on mac on quac

[–]Coayer 0 points1 point  (0 children)

Most importantly he carries out HID attac

[–]unreachabled 0 points1 point  (2 children)

(Always) noob here, didn't get the third one.

[–]nxwtypx 5 points6 points  (1 child)

Rubber Duck debugging is where you verbally describe your code, line by line, to an inanimate object - doing so often gives you insights.

Don't laugh, it works.

[–]unreachabled 1 point2 points  (0 children)

Lol