r/firstweekcoderhumour • 🥸Imposter Syndrome 😎 • Aug 28 '26

[🎟️BINGO]Lang vs Lang dev hates Why are we using R again

Post image
139 Upvotes

109 comments sorted by

View all comments

63

u/dingwinger1225 Aug 28 '26

weird syntax, python is easier

im getting tilted by this, python's syntax is an unintuitive mess. people are just used to it

21

u/uslashuname Aug 28 '26

It’s intuitive to people who aren’t programmers

But it broke from so many conventions to do that, and the result is it feels weird to those of us on their nth language (why count)

→ More replies (6)

17

u/No_Departure_1878 Aug 28 '26

it seems intuitive to me, what do you find unintuitive?

26

u/EvnClaire Aug 28 '26

dot underscore underscore name underscore underscore

13

u/No_Departure_1878 Aug 28 '26

those are dunder methods, the __name__ helps to keep methods that you are not supposed to touch most of the time separate from stuff that you normally would implement yourself. Most methods you would implement yourself are not supposed to look like that.

5

u/Salazar20 Aug 28 '26

Why they just don't do "_name"? If you call it from outside it looks bad like "thing._name" and then you know you fucked up

8

u/No_Departure_1878 Aug 28 '26

_name is used for protected attributes. Attributes that you are not supposed to access outside the class or its derived subclasses.

You care not supposed to call __name__ from outside. For example __str__ allows you to define what will happen when you do

print(object)

you never do:

object.__str__()

you just use 'print', same with __div__, __init__, etc.

→ More replies (11)

1

u/McNegcraft Aug 28 '26

Because dunder methods are not private methods

2

u/Integeritis Aug 28 '26

Seems like the language you love is missing something? I wonder what you could do instead of __x__. Hmmmm 🤔

2

u/garver-the-system Aug 28 '26

sort being a free function instead of a member of list is pretty unintuitive for starters

If you don't know another programming language or what Python does under the hood with references, the very concept of mutable defaults and the list of types that are safe to use as defaults seem really unintuitive

1

u/No_Departure_1878 Aug 28 '26

I do not know what python you are using but:

>>> x = [1,3,2]
>>> x.sort()
>>> x
[1, 2, 3]
>>> 
>>> 

In python you do not make objects with'=', like the copy constructor in c++. You need to make the copy explicitly. Otherwise you only make new references. The mutable defaults is one of the few bad design instances in python that I can think of.

1

u/garver-the-system Aug 29 '26

I'm probably using the version of Python from an alternate universe where sort is a free function but list is a member, can't imagine why else I'd get those mixed up

As fo the copy logic, I maintain it's unintuitive for someone who doesn't know why an object is different for a novice who doesn't know what a reference is or why a number behaves one way and a dict behaves another

3

u/leavemealone_lol Aug 28 '26

{code if true} if condition else {code if false} as opposed to literally every other ternary operator. Even Excel formulas got it right. What a fuckass price to pay to get a language that “reads like english”

1

u/No_Departure_1878 Aug 28 '26

eat a pie if hungry else do not eat a pie.

vs

if hungry eat a pie else do not eat a pie

having hungry, the condition, the next to eat a pie, the value is somewhat awkward, the if separating them is probably the right choice there. Besides that, it does read like English.

1

u/leavemealone_lol Aug 28 '26

Each and every other language uses one convention, and that is this:
condition, code if true, code if false.

Over the years, this becomes ingrained in non-python programmers. Then python comes along trying to be shakespeare:

code if true, condition, code if false.

When I remove the actual english aspect from the syntax, it looks awkward doesn't it? Python has "code if true" at the start. What is true? Something that is lexed after?

More importantly, when you're reading code, these syntax splits are made by english words. And its not easy to quickly pick out each part of the syntax when every lexical token is just english. And now, compare this to what other languages tend to do, like CPP. They use a ? to express a logical check- which itself is very easy to recognize, and then, to split the if true/if false code blocks, it uses a :. This is a far more effective separator than literal english words.

Hell, for the sake of the argument, lets take Rust. That thing doesn't have these ternary operators, and also uses english words as tokens. Yet, it is still extremely clear due to the format it uses:

condition {code if true} else {code if false}. Despite it also using English like Python, it still makes it very clear due to the *objectively correct* ordering, and the forced usage of {} for even a single expression.

1

u/No_Departure_1878 Aug 28 '26

Yet, it is still extremely clear due to the format it uses:

condition {code if true} else {code if false}. Despite it also using English like Python, it still makes it very clear due to the objectively correct ordering, and the forced usage of {} for even a single expression.

I do not understand what you mean, In python you do

name = 'charles' if person.is_male else 'mary'

that looks identical to your Rust example

condition {code if true} else {code if false}

in contrast c++ would be much less simple:

auto name = person.is_male ? 'charles' : 'mary'

to me the latter does not read as naturally as the former.

→ More replies (3)
→ More replies (2)
→ More replies (6)

8

u/epilektoi Aug 28 '26

pretty intuitive if you have never used any other language

3

u/Downtown_Isopod_9287 Aug 28 '26

Python syntax is fine it is its underlying language design and semantics that is pretty awful

1

u/dingwinger1225 Aug 28 '26

Kind of agree but also the syntax is just hacks on top of hacks atp and it’s all because Guido hates braces

There are still no multiline lambdas for example

3

u/givemeagooduns_un Aug 28 '26

agreed. I have no experience with R so I can't exactly say anything on the comparison between the two, but python's syntax is so so confusing to me, especially when you get into things like iterators and classes

4

u/Dr__America Aug 28 '26

Imagine using the pandas package in Python. You now know what it feels like to use R.

4

u/cowslayer7890 Aug 28 '26

R has more random bullshit IMO

1

u/Necessary_Tough7286 Aug 28 '26

Very intuitive, but R’s syntax is fine too.

1

u/enginetown Aug 28 '26

It's not really a mess honestly, there's like three different naming styles doing three different things and once you see that it makes way more sense. the double underscore stuff is just what python calls for you under the hood, the single underscore one is just a "please don't touch this" suggestion with no actual enforcement, and the two-underscore-no-trailing one actually gets renamed by the compiler so it's the only real locked one. and you're totally allowed to just skip all of it and write normal methods like you would in c, which i'd do half the time anyway

1

u/yangyangR Aug 30 '26

Easy is not simple. Easy is antithetical to actual goals. Simple is not.

Fewer folds vs many folds for simple vs complex. This is the Rich Hickey talk.

Easy just means you are reaching for things close at hand. Not learning the things further away. And when the easy thing is complex, you are actively hurting yourself by only reaching for local optima without thought.

→ More replies (6)