this post was submitted on 03 Apr 2024
262 points (86.8% liked)

Programmer Humor

32143 readers
561 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] Buffalox 62 points 6 months ago (4 children)

How is this funny? 8 Upvotes at current writing???

[–] [email protected] 102 points 6 months ago (4 children)

It's kind of funny because it looks like it is nonsense dreamt up by a non-programmer. But it actually works.

[–] [email protected] 102 points 6 months ago (4 children)

I thought it was poking fun at the tutorial saying instead of learning to code, import a library from someone who knows how to code.

[–] [email protected] 27 points 6 months ago (1 children)

That's what libraries are for. I'm no security expert and the sensible thing to do is using a library instead of taking a class.

[–] [email protected] 11 points 6 months ago* (last edited 6 months ago) (3 children)

I’m no security expert and the sensible thing to do is using a library instead of taking a class.

Counterpoint: "not knowing your libraries" + "blind trust in the maintainer" will give you stuff like this: https://bitbucket.org/snakeyaml/snakeyaml/issues/561/cve-2022-1471-vulnerability-in

(the thread itself is worth a read. But also very impressive is the list of big players who fell for exactly this mentality)

[–] [email protected] 4 points 5 months ago

Love the part where he claims that if your users are authenticated, it's not untrusted input. I mean, surely you trust all of your users to run any code on your server, right?

[–] [email protected] 2 points 6 months ago (1 children)

Jesus that was one hell of a thread

[–] [email protected] 3 points 5 months ago

I dont want to see the words "low quality tooling" ever again.

[–] [email protected] 1 points 5 months ago

Impressive and unsurprising. As soon as you start getting complex libraries with multiple dependencies it becomes nearly impossible to review everything. At one time I had an interest in contributing to some AI libraries, but they're a mess as soon as you go looking for points of improvement.

[–] [email protected] 17 points 6 months ago

Works as well.

[–] billwashere 6 points 6 months ago

Which is funny because when I first started my CS degree in the late 80s (get off my lawn) we used to make fun of the beginning Java classes because it seems 90% of coding was to import the right library.

load more comments (1 replies)
[–] [email protected] 58 points 6 months ago (4 children)
[–] [email protected] 17 points 6 months ago* (last edited 6 months ago)

Time travel is a prerequisite but don't worry, you can just

from __future__ import antigravity
[–] [email protected] 9 points 6 months ago

"I also sampled everything in the medicine cabinet"

This made me smile.

[–] grue 8 points 6 months ago (2 children)

It's literally this comic, five years and a research team later.

[–] [email protected] 4 points 5 months ago

It's funny how solvable that problem is now. I remember seeing that comic, I think over a decade ago now, and thinking about how true it was. It really shows you have far we've come in CS.

[–] [email protected] 2 points 5 months ago (1 children)

More like all the research teams.

load more comments (1 replies)
[–] [email protected] 1 points 5 months ago

From the hovertext: "I wrote 20 short programs in Python yesterday. It was wonderful. Perl, I'm leaving you."

After years of a dozen other languages, I finally tried Perl the other day.

Never again, if I can help it.

[–] [email protected] 13 points 6 months ago
from Lemmy import Upvote
from Fediverse import Posts
from ActivityPub import Submit

target_post = 'https://lemmy.ca/post/18691085'
num_votes = 8

post = Posts.open(target_post)

package = Upvote(post, num_votes)

package.Submit(target_post)

or something

load more comments (1 replies)
[–] akhial 19 points 6 months ago (1 children)

It's funny because

from apps import facebook-killer as fb

fb.start()

// 3 million seed investment 

[–] [email protected] 6 points 6 months ago (1 children)
[–] [email protected] 1 points 6 months ago

: Inconstistent indentation

[–] [email protected] 13 points 6 months ago* (last edited 6 months ago) (1 children)

Because this example isn't really programming, it's just calling an existing library. Which is the big joke about Python.

load more comments (1 replies)
[–] [email protected] 3 points 6 months ago

My best guess is it's a play at the usual "all you do in python is import libraries without knowing how they work lololol" dig but yeah, I don't find it particularly funny either

[–] [email protected] 31 points 6 months ago

This is exactly why we love Python (and other languages with rich package ecosystem, even when only on their niche usage cases). You can build upon other people's knowledge and effort to do cool things efficiently and effectively!

[–] qx128 25 points 6 months ago (2 children)

Hahaha now code-golf it. One line FTW!

remove(Image.open(‘cl.jpeg’)).save(‘output.png’)

[–] Tangent5280 26 points 6 months ago (3 children)

If I find this in production I'm whipping your ballsack till you change it back.

[–] [email protected] 13 points 6 months ago

import("rembg").remove(import("PIL").Image.open(‘cl.jpeg’)).save(‘output.png’)

[–] [email protected] 9 points 6 months ago

Can i hire you?

[–] [email protected] 3 points 6 months ago

So I'm not going to change it

[–] madcaesar 4 points 5 months ago (2 children)

Code golf! I just learned something new 😂

[–] [email protected] 6 points 5 months ago

https://codegolf.stackexchange.com/

Enjoy a new rabbit hole to dive down

[–] meekah 2 points 5 months ago* (last edited 5 months ago) (1 children)

You never heard of code Golf before? It's usually programming challenges where the goal is to use the smallest number of source code characters possible.

[–] [email protected] 2 points 5 months ago

I haven't either but I like it.

[–] johannesvanderwhales 21 points 5 months ago (1 children)

Remove seems like a terrible name for that method.

[–] [email protected] 16 points 5 months ago (1 children)

While yes, the true issue here is that, for some reason, the code only imports the remove method from the package, instead of importing the package and doing rembg.remove().

[–] trashgirlfriend 3 points 5 months ago

if you only wanted to import remove you could maybe import as rembg_remove

unless there's some weird taboo against doing that I don't know about, I'm an awful programmer tbh

[–] [email protected] 20 points 6 months ago* (last edited 6 months ago) (1 children)

That reminds me back when some time ago, I was tired of dealing with sketchy, and often broken, websites and programs for downloading videos from Youtube. I figured these sorts of programs must be doing something along the lines of downloading the Youtube page, parsing through the massive pile of HTML and Javascript to find the stream, and then saving that to a video file. That seemed like something I could do myself with Python, so I set out to see if I could figure out how to do it.

A few minutes and a couple of web searches later, I discovered that someone else had figured that all out already and I just needed to do "pip install pytube".

[–] [email protected] 18 points 5 months ago (2 children)

Have you ever heard about yt-dl?

[–] [email protected] 13 points 5 months ago
[–] [email protected] 9 points 5 months ago

I did switch over to yt-dlp some time later as development seems to have slowed on Pytube and yt-dlp seems to be where all the activity is.

[–] Thcdenton 18 points 6 months ago (1 children)
[–] aluminium 4 points 5 months ago* (last edited 5 months ago)

*the libraries that are made for python

[–] [email protected] 17 points 6 months ago

There's a python library for everything

[–] j4k3 8 points 6 months ago

No work in micropython on uno? pls help. Need thesis in Rust do tomorgh. Removed French bloat rm -fr catz tut. Why

[–] [email protected] 5 points 6 months ago

Waiting for the “in one line” tutorial

[–] SanndyTheManndy 3 points 6 months ago (1 children)
[–] essell 3 points 6 months ago

All the best things in life are intangible.

[–] HStone32 2 points 5 months ago

Having a similar moment right now. I'm trying to figure out how to compute the transformation matrix for reflecting a bitmap of any given dimension across the y axis, but all the tutorials that come up in my search just tell me to import some python library. Its like nobody wants to learn how to do anything anymore.

load more comments
view more: next ›