i feel like this is what happens when someone sees like a square function and doesn't understand the flexibility of the code or doesn't want to make a mistake or over-complicate it but wants to modify it.
It looks like this comment contains a code block delimited with triple backticks. Unfortunately reddit does not have universal support for this syntax and your comment will not render correctly on old reddit and most mobile apps.
For the benefit of people on old reddit, this link will take you to a correct rendering of the comment.
/u/hhellloo, it would be appreciated, but not required, if you could edit your comment to use the more compatible four space indention format. For single lines or inline code you can use single backticks.
Fun fact: this is actually how my university taught Python for some reason. Took me a while to force myself out of this mindset.
I have no idea why, guess my professor figured it would teach us.... Something? All in all, this course was the worst programming course I have ever attended and I ended up retaking the whole thing with a different professor.
The bad part in this post is the fact that k is deterministically an integer. Using “int()” makes sense of course for user input or other unknown input. Not for something that is guaranteed to already be an int.
My guess is easing the differences from Java (which was the traditional CS language) to Python (which seems to be the modern CS language?). Not sure if for the benefit of the Prof or the student
> If I would develop the app in Java or swift I would have to do it twice to cover iOS and Android Yes, that is the correct way. Then, it will be a truly native app
Not at all, Raect Native is a pretty popular framework, and I've been doing some development in it. Building the app will provide you with a native app, and if you really need something which is not supported yet, you can write native code as an extension to your app. Some complex things might have you writing it for both Android and ios, but it cuts down on a lot of work considering how many things you only need to write once :)
I used to love dynamic typing when i first learned it. It seemed so easy. By the time i graduated college and got a job, the last thing I want to do is use a dynamically typed language.
You might think its ridiculous, but when I TA'd computer architecture courses almost nobody understand what an int or a char was and that they were interchangeable. They all assumed that there was something special about each one. It took a lot of work to convince them that they were both made of bits and that any meaning they had was what you gave them.
Programmers tend to be terrible teachers because they've gotten so used to this that they forgot none of it makes any goddamn sense if you have no prior experience. It's a ruleset defined by humans that can vary from language to language, not some mathematics you can derive by yourself if you think hard enough about the problem.
I don’t think this will ever be ambiguous. Write me a Python program where you can set a variable equal to 1, not cast it as an int, and causes it to not behave as an int when you use it like an int.
I didn't write it, but here you go. Thanks to the fact that you can pass Python arguments to the JavaScript function, it will nicely cast them for you (via JSON) and make them behave per a Javascript object, which can then do some funsies to make it act like a string.
It's a direct translation of a meme in Serbian, in which someone asks a person named Stojan if he masturbates, it's being used as somewhat of an ironic meme. I'm sure that the commenter and op know each other.
Yes, it's true, I am friends with OP. I am not however the guy who wrote the code, I wrote something much worse during my coding time, he might post it, but we will see
Fool, they don’t realize that k is now the string “int(k)”. In actuality, there is no such thing as a non-string variable. It’s strings all the way down.
If only it was strongly typed. This is not an issue with the programmer, but the language. I've see people argue that python is strongly typed, but with examples like this I'm not sure how one could argue the point.
Python is strongly typed, but it's not statically typed. It won't allow you to perform operations with mismatched types, but it also won't stop you from overwriting a variable with a value of a different type, since Python considers only values, not identifiers, to have a particular type.
496
u/Encursed1 Jan 10 '21
He could have even used k = int(1) but no, he had to make it two lines.
170
u/James_Mamsy Jan 10 '21
This just feels like one of those lines that makes no sense but when you take it out the whole program breaks.
107
u/CW_Waster Jan 10 '21
People get traumatised if they use javascript
17
u/DinnerPlzTheSecond Jan 10 '21
Laughs in static typing
32
u/Mr2-1782Man Jan 10 '21
You might think its ridiculous, but when I TA'd computer architecture courses almost nobody understand what an int or a char was and that they were interchangeable. They all assumed that there was something special about each one. It took a lot of work to convince them that they were both made of bits and that any meaning they had was what you gave them.
44
u/the_last_ordinal Jan 10 '21
Not unreasonable. 1 is both a number and a character. The whole program is encoded as text.
3
u/Alvatrox4 Jan 10 '21
JavaScript flashbacks... Pls no
3
u/thesceptical Jan 10 '21
I think your friend got trust issues (lol)
5
u/Mirkec1389 Jan 10 '21
Do you soap your tomcat, Stojan?
2
u/Nall-ohki Jan 10 '21
int() coerces anything to an integer. Doesn't have to be a string.
2
u/Gh0styLNX Jan 10 '21
What are types anyway ;)
2
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Jan 10 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
3
u/ekolis Jan 10 '21
But that's a lowercase ell! 😛
1
u/paradoxpandas Jan 10 '21 edited Jan 11 '21
Eh not entirely bad code, maybe your friend interpreted the 1 as a single character thus potentially a string
1
u/DesiresQuiet Jan 10 '21
Yeaaah not bad. Raise you’re hand if you’re SURE!
1
u/elfballs Jan 10 '21
Could have thought it was a float, no? That would make more sense.
1
u/BackgroundChar Jan 10 '21
typeof k;
1
u/Ochidi Jan 10 '21
Fool, they don’t realize that k is now the string “int(k)”. In actuality, there is no such thing as a non-string variable. It’s strings all the way down.
1
u/Chicchi7393 Jan 28 '21
My friend also does that
1
u/HowToLoseBrainCells Feb 07 '21
I need bleach, be right back.
1
u/Spook404 Mar 09 '21
I always write int instead of just calling the variable because I'm paranoid
-5
u/wiwalsh Jan 10 '21
If only it was strongly typed. This is not an issue with the programmer, but the language. I've see people argue that python is strongly typed, but with examples like this I'm not sure how one could argue the point.