[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
what does the snake say? >>> 4 / 2 2 >>> 5 / 2 2
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 98
Thread images: 11
File: opengraph-icon-200x200.png (8 KB, 200x200) Image search: [Google]
opengraph-icon-200x200.png
8 KB, 200x200
what does the snake say?

>>> 4 / 2
2
>>> 5 / 2
2
>>
Sometimes I forget how much better Python 3 is.
>>
>>54798965
are you retarded ?

put a .0 and see what happens
>>
>>54798965
Wow, integer division yields an integer.
You can do 5/2.0 if you want float, amazing amirite?
>>
>>54798965

>>> 4.0 / 2
2.0
>>> 5.0 / 2
2.5

I don't see the problem anon, you are dividing integers, instead of decimals.
>>54798994
this.
>>
>>54798965
>>54798994
I cannot tell if this is just a friendly nerd thread for python geeks or if it is a trolling thread to say why python is bad.

Python is pretty cool. Know what you are doing (Explicit before implicit).
>>
>>54798994
>>> 4./2
2.0
>>
>>54799016
Which is correct.
>>
>>54799067
4/2=2
5/2=2.5
>>
>>54798965
Only on python 2 kek
>>
are you pretending to be retarded?
>>
>>54798976
>>54799165
Everyone here is missing the point
>>
File: fl1nzvkAl2Q.jpg (26 KB, 604x604) Image search: [Google]
fl1nzvkAl2Q.jpg
26 KB, 604x604
>>54799165
>>> 4/2
2.0
>>> 5/2
2.5

> 2.0
> .0
> .0
>>
Implying burgerstani """""""""programmers"""""""""" know difference between decimal and integer
>>
>>54799138
> implying 2.0 != 2 in python
>>
>>54798965
STOP USING PYTHON 2
>>
> -1 % 5 is actually -1
Really Java?
>>
>>54799381

F/IGHT ME NIGGER!!!
>>
File: penn_jillette.png.jpg (31 KB, 300x400) Image search: [Google]
penn_jillette.png.jpg
31 KB, 300x400
>forced indentation
>>
>>54799416
>forcing conventions is a bad thing
>>
>>54798965
You python 2.0 niggers are the reason we can't have nice things.
>>
>>54799422
>getting cucked by a computer program
>>
>>54799439
All programs do that though...
>>
>>54799416

> implying that's not the best fucking thing about python.

If you want to make an argument from unnecessary syntax, you brought a dull knife to a gun fight.
>>
>>54799455
Man it's like you have virtual stockholm syndrome.
>>
>>54799472
but all programs restrict you in one way or another
I assume that's what you meant by "cucked" unless your memes have been evolving
>>
 int i = 5; i = ++i + ++i; 

10, 11, 12, 13, 14 or 16?
>>
>>54799600
language?
>>
>>54799381
theres no pypy for python3
>>
>>54799608

looks like C
>>
>>54799608
Anything you wish. Try on C++ or C or C#.
>>
>>54799416
>using curly brackets

fuckoff micropenis.
>>
>>54799628
undefined behaviour
>>
>>54798965
>I want my programming language to change the types of variables I am using withought telling me
Do you seriously not understand the dangers of not being able to control if a line of code is going to return a double or an integer?
>>
>>54799650
Really in most cases it doesn't matter. Which is why Python 3 does it differently and you have to use a different operator to get integer division.
>>
>>54799650
you can explicit tell which type you want.

but normally it doesn't matter anyway, the type it return will be compatible with your next function.
>>
>>> L1 = [2, 3, 4]
>>> L2 = L1
>>> L1[0] = 24

>>> L1
[24, 3, 4]
>>> L2
[24, 3, 4]
>>
>>54799823
DELETE THIS
>>
>>54798965
> doesn't know how integers work
>>
>>54799600
13
>>
>>> 2.1 + 2.2
4.300000000000001
>>
>>54800222
js?
>>
>>54800222
Reminder that if you don't know why this happens you are officially a code monkey.
>>
>>54800262
That's standard IEEE floating point behavior.
>>
>>54799823
Inexplicable
>>
>>54800278
im code monkey and even black but im knowing this
>>
>math.floor(8.2-0.2)
7

Explain this
>>
>>54799600
++i is pre-incrementation.
from left to right
>i = (++i) + (++i)
>i = (i += 1) + (i += 1)
>i = 6 + 7
>i = 13
>>
File: 1433334990838.png (160 KB, 731x645) Image search: [Google]
1433334990838.png
160 KB, 731x645
>mfw /g/ still doesnt understand how floating point arithmetic works
>>
>>54800583
>from left to right
no
>i = (++i) + (++i)
>i = (i += 1) + (i += 1)
>i = (i += 1) + 6
>i = 6 + 7
>i = 13
>>
>>54799823
>mfw interpreter is forcing pass-by-reference behaviour
>irb(main):001:0> x1 = [1, 2, 3]
>=> [1, 2, 3]
>irb(main):002:0> x2 = x1
>=> [1, 2, 3]
>irb(main):003:0> x1[0] = 24
>=> 24
>irb(main):004:0> x1
>=> [24, 2, 3]
>irb(main):005:0> x2
>=> [24, 2, 3]
>>
>>54800619
I think that kind of behaviour is more intuitive, even if we're dealing with primitives.
>>
>>54800612
Honestly i'd blame the shitty way coding principles are taught nowadays. I've done code reviews for tons of college grads and they just arbitrarily force conversions between int/float/double wherever and have no idea what each of them should be used for or why, and then they wonder why they get 15.00000000000000000000000000001 as an answer.
>>
>>54800640
I don't think it's more intuitive, but performance-wise it makes sense for it to be the default.
>>
>mfw a pythocuck and a nodebabby get into an argument about performance

Holy shit, how incompetent can developers be?
>>
>>54799823
what's wrong with that?
you guys seriously need to take a formal programming languages course so that you understand why some things work in a certain way in a certain language
>>
>>54799823
This is something I hate of Python. In other languages you clearly know when something is a reference.
>>
>>54799422
>configure your editor for this project or else

You would THINK python would be able to handle mixed tabs and spaces just fine. It's a simple thing to program. But no. It can't. It might mess up the alignment and trigger someone's autism.

Remember the 90s, when you could just put two vim and emacs lines at the bottom of the file and have indentation settings automatically applied? Things were better then.
>>
File: tumblr_ny1cp8ZbHP1ul80vfo1_1280.png (171 KB, 1280x1280) Image search: [Google]
tumblr_ny1cp8ZbHP1ul80vfo1_1280.png
171 KB, 1280x1280
>>54798965
(python 3.5.1)
> 0.2 + 0.1
0.30000000000000004
> 12345 / 54321
0.22726017562268735

(sbcl 1.3.1)
> (+ 0.2 0.1)
0.3
> (/ 12345 54321)
4115/18107

>mfw no "modern language handles numbers as well as lisp
>mfw lisp is still king
>>
>>54803292
Gotta love that number tower.
>>
True + True = 2
>>
>>54803181
Everything in python is a reference.
>>
>>54799600
>undefined behavior
It will probably just compile to a nop with optimization on
>>
>>54800517
It probably rounds to 7.9999999999 and then rounds down with floor
>>
>>54804810
Hence a pointer.
>>
>>54799613
http://pypy.org/

>PyPy is a fast, compliant alternative implementation of the Python language (2.7.10 and 3.2.5). It has several advantages and distinct features:
>and 3.2.5
>>
>>54806465
Does it implement tail call optimization?
>>
>>54806525
No idea. I don't use pypy.

The post I was responding to said that it didn't exist. Now if the issue is that it doesn't perform as someone would like it to, that's different.
>>
>>54799600
I'm getting 14 in C.
>>
Ok this is getting far too serious for weekend /g/, now what does the fox say?
>>
>>54799416

This. This is the single reason why I don't use Python. Don't get me wrong, Python is terrible on so many levels I'd still not use it if it didn't have the indentation bug, but that alone is enough for me not to use it.
>>
>>54807330
Because you never indent your codes?
>>
>>54807381

>I'm gonna mix logic and styling, and when you say that's a bad idea, I'll accuse you of never styling

Didn't expect anything else from a pythonfag.
>>
>>54807486
>I'll accuse you of never styling
Yes I never style my code. Neither did I sign them. It's useless, a signature is a stain in code. And my signature is the perfection of my code.
>>
>>54798965
>what does the snake say?
what does the fox say?
>>
>>54803192
this

Working with a team where someone has a different tab configuration completely fucks up a program, and python can't even say what line it happens on.
>>
>>54807058
In C this is undefined behavior.

>>54807486
>>54807536
this
>>
>>54799823
triggered
>>
>>54803070
Because data types are mutable by default in Python, therefore it's not really useful in any serious (i.e. multithreaded) environments.

That's completely fine because Python is a scripting language -- it's not designed to create robust, scaleable, and performant software. But if I'm writing a script, then I'd rather use Bash. If I want an embedded scripting language, I'd rather use Scheme or Lua.

That basically leaves Python for a very small set of tasks that other languages can be used for just as successfully.

Python users have an identity crisis as they lack any real focus. Python tries to be a good task for everything, so it's great at nothing.
>>
>>54808851
Just in case you actually believe what you wrote, the statement
>Because data types are mutable by default in Python, therefore it's not really useful in any serious (i.e. multithreaded) environments.
does not make sense at all, in any context.

Python does have a lot of problems (and by default can't multithread), but the mutability of data types has nothing to do with it.

Everything is essentially mutable on any practical language (functional languages are not practical).
>>
>>54808958
Not in Clojure.

Mutable data types require the use of application-level data locks that are known to generally lose in performance compared to STM primitives and are more bug prone.

If I can't mutate an object, two threads can safely access it.
>>
>>54799600
I'm getting 14 using g++, but clang fails with a linker error
>>
>>54804718
if True + True then print("eat shit") endif
>eat shit
>>
File: file.png (3 KB, 227x97) Image search: [Google]
file.png
3 KB, 227x97
>>54799600
python
>>
>>54799195
python 2 interprets 4 / 2 as floor division when both of the arguments are integers. if you wanted to treat them as floats, you should have cast them as floats.

if you want python to just magically make sense of this stuff, did you also complain when you said
someVariable="2"
print someVariable/2

and it gave you some error? did you want python to intuit that you meant to treat it as something it clearly wasn't?
>>
>>
>>54807330
>the indentation bug
>bug


Why do you tards insist on naming features you don't like "bugs"?
>>
>>54809912
It's a bug when you're actually on a team, and someone's editor has a different indentation scheme and the code fails without any meaningful diagnostic information.

I keep forgetting the majority of posters on /g/ don't work on teams.
>>
File: what.png (168 KB, 1344x1118) Image search: [Google]
what.png
168 KB, 1344x1118
>>54809961
>without any meaningful diagnostic information
yeah it's so vague.
>>
>>54803192
Anyone who mixes tabs and spaces in a file is a total PEBKAC. If they're hired by a company and can't even figure out indentation, they shouldn't be touching code to begin with.
>>
File: tabs.png (167 KB, 1344x1118) Image search: [Google]
tabs.png
167 KB, 1344x1118
>>54810076
and if you're talking about tabs
>>
>>54809961
>It's a bug when you're actually on a team, and someone's editor has a different indentation scheme
Pre-commit hooks exist for a reason. Wrongly-indented code shouldn't even be getting checked in to begin with.
>>
>>54810168
this. teams should have clear norms about how to code. i agree that a language shouldn't throw an error over this, but if you all aren't on the same page (or worse, if you're just LETTING everyone use their own preferred approaches), then you need to take a project management course or something.

standardizing code isn't just some OCD thing; it makes it easier (read possible) for arbitrary new members to join the team without feeling like they're walking around in in Eastern Europe in the 90s (like every 5 steps they take lands them in a different regime)
>>
>>54810168
>wrongly indented
implying that the standard dictates whether to use tabs or spaces

>>54810145
Wow, one example of an informative error message. I have seen Python give complete garbage line numbers in the error message on files that are a few hundred lines long.

>>54810189
>increase the indentation standards
Or you could use a brace and save the time taken to setup the indentation and avoid the possibility of any unpleasant mistakes.

I really don't see why the brace is such a big deal. It makes everything explicit.
>>
>>54810244
>implying that the standard dictates whether to use tabs or spaces
your team should have standards. whether you follow pip8 or not is up to you; you'll notice python won't scream at you for using tabs as long as you're consistent. that's because it was designed to meet autistic people halfway. but that means you have to meet it halfway.

i've never seen this, even in long codebases. generally error messages are within the right ballpark of the code. can you give an example, or do you just get to vaguely tell me that your codebase is some sort of fucking disaster and that's definitely python's fault and not yours?

>save time
having a standard format is time-saving. this is basically one line in documentation for on-boarding team members ("we use 4 spaces for indentation"). your on-boarding documentation should be comprehensive, meaning several pages worth of text, to avoid misunderstandings about literally every decision that could be left up to the programmer. even what sort of variable naming convention to use. you don't need to have a debate over this, either, just dictatorially say "we're using camel case for variables, but class methods get underscores and stay lowercase" or whatever. literally just pick something and write it down. then stop discussing the confusion of it all on 4chan.

this is basically a drop in the bucket.
>>
>>54810244
>>wrongly indented
>implying that the standard dictates whether to use tabs or spaces
Actually, pep8 DOES say to use spaces instead of tabs, except when working on things that already use tabs.
But even if you don't give a shit about pep8, the correct style is always whichever one is already in the file.

>I really don't see why the brace is such a big deal. It makes everything explicit.
So does indentation.
Braces aren't infallible either. You can forget a closing parenthesis or brace somewhere and not notice. Much harder to do the equivalent in Python.
>>
>>54810376
this. if someone on my team consistently committed code like
for whatever in someCollection {
foo();
bar();
etc();
}

(using not-really-java as an example relying on braces)

we would have a talk with them about indenting shit consistently. they wouldn't just get to do that and have nobody give them shit for it.

if we require everyone to keep indentations aligned, then it shouldn't be an issue that the braces are there or not. i can understand a mild preference to have them there, but this shouldn't be something that you object to the use of python for.
>>
File: 1461691021548.gif (2 MB, 300x290) Image search: [Google]
1461691021548.gif
2 MB, 300x290
>>54798965
What did you expect? That's like the first thing you learn about programming.
Thread replies: 98
Thread images: 11

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.