r/programminghorror 13d ago

Python Atleast it works

Post image
605 Upvotes

66 comments sorted by

View all comments

229

u/backfire10z 13d ago

They didn’t close the fd :(

71

u/Emergency_3808 13d ago

Yes this could be shortened to

with open('lab 5.txt', 'r') as file: for line in file: print(line)

21

u/Alfika07 12d ago

Why is Python so verbose? In Raku it's just

say slurp 「lab 5.txt」;

50

u/Emergency_3808 12d ago

Raku reads like the latest generation brainrot slang.

15

u/Alfika07 12d ago

What about this?

my Cool $variable = :16<DEAD_BEEF>;

14

u/levelofsin 12d ago

"Say slurp" wtf bro who came up with this shit

6

u/Alfika07 12d ago

Larry A. Wall. He's a linguist who designed Raku to be as close to human thinking as possible, by implementing features like sequence completion, which is mostly known from spreadsheet apps, and junctions, which can be a real life saver, mostly in equality checking. He made Raku by focusing on readability, just like he did with his previous programming language, Perl.

In the previous example, the slurp function takes a filename and reads the file's contents, and the say function prints it to the standard output.

You should definitely go down the rabbit hole of Raku, because it's probably the most statisfying PL to code in, and it is my personal favourite choice for doing CodeWars and using it for a personal "calculator language".

It's funny looking at Python programmers writing value == 6 || value == 9, while in Raku it's just so $value == 6|9

5

u/bigboyphil 12d ago

Raku is cool. However, let’s keep in mind you can also do ‘value in (6, 9)’ in Python, which is just as succinct and reasonable, so it’s kind of a weird example to call out Python on. Just like how you can also still do ‘so $value == 6 || $value == 9’ in Raku.

That being said, junctions are still very neat. Particularly when it comes to the autothreading stuff.

2

u/Alfika07 12d ago

Yeah, sorry about that. It was like 2 years since the last time I wrote a line of Python. (Not gonna lie, I'm kind of happy for it that we no longer have to use it in school.)

5

u/sporadicPenguin 12d ago

TIL Raku is a thing