Post evidences of retardation of programming language designers

Post evidences of retardation of programming language designers.

Attached: Screenshot from 2018-05-30 21-53-25.png (235x205, 6K)

Other urls found in this thread:

en.wikipedia.org/wiki/Leap_second
open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0977r0.pdf
youtube.com/watch?v=zt0OQb1DBko
stackoverflow.com/questions/4776033/how-to-change-an-element-in-a-list-in-erlang
cr.yp.to/libtai.html
twitter.com/AnonBabble

>I don't know how references work

I could easily spam this thread with C++, JS and Python proposal papers and documentation.

Attached: tm structure.png (314x151, 8K)

Attached: nigger.jpg (480x640, 19K)

en.wikipedia.org/wiki/Leap_second

But thats a closure

Attached: sddefault-12-640x480.jpg (640x480, 47K)

time is one of the most difficult things for os/language designers, along with languages

What triggers me is "day of the month" starts at 1 (so apparently that's acceptable) but then they do "months since January" [0-11] - why not just "month" [1-12] ?

wtf, never knew Python was this retarded. Why does it do this?

Not this.
THIS.

It uses the same list instance each time

Instead you have to do
def f(default=None):
if default is None:
default = []
default.append(10)
print(default)

Yea, I was wondering why it doesn't reset each time - the parameter should be initialized again with each call shouldn't it?

Well, unless there is more demand, let's start with something meta:
open-std.org/JTC1/SC22/WG21/docs/papers/2018/p0977r0.pdf

Python is retarded what did you expect ?

IMO the real problem is functions like .append() altering the original array instead of just returning a new array with the value appended.
The latter makes for far nicer looking code and should be the standard for all array functions.

then do, that's why a thread died for this

>en.wikipedia.org/wiki/Leap_second
isn't it why the default time format should be Unix epoch time? (with better resolution) it always just increments

probably it prepares the array and sets the pointer as the default value under the hood, once resets for new function call it's still the same pointer value thus carries the side effect
wonder if this can lead to memory management error

is it supposed to reallocate and copy whole array? are you crazy?

>Default parameter values are evaluated from left to right when the function definition is executed. This means that the expression is evaluated once, when the function is defined, and that the same “pre-computed” value is used for each call. This is especially important to understand when a default parameter is a mutable object, such as a list or a dictionary: if the function modifies the object (e.g. by appending an item to a list), the default value is in effect modified. This is generally not what was intended. A way around this is to use None as the default, and explicitly test for it in the body of the function, e.g
I've never defined a list/dict inside a parameter, there's really no point to with a dynamic language like Python. instead define it first and then run it through the function, or define it locally inside the function and it behaves like you want it to. had no idea it behaved like this for dicts/lists tho.

see But let's go on nice and easy...
Pic related shows two common Python memes:
a) Naming their things differently to hide their fuckups in said things. Compare for "lists" in Python.
b) Resolving stuff at runtime that should be resolved at compile time (and you could even have a check-only mode), even in a dynamically type-checked language. Having mandatory variable declarations could catch typos at compile time. Even VBA, Perl and JS are better at this when in strict mode. From here on, you could think further what else should be resolved at compile time...

Attached: pytards.png (738x349, 53K)

No, the problem is that the scope of "default" is larger than the function.

the joke is solid interpreter could compile given files and statically check for errors nearly as quicklu as python's runtime starts

So .append() is effecting the variable at the memory address and the function keeps referring back to that same address. Seems like a pretty simple fuck up from the point of view of the developers of the language, is this meant to be intentional?

Maybe even faster.
Remember, all kinds of stuff like doing operator overloading, defining classes and metaclasses are statements.
With compile time types the interpreter would have to parse the source code and construct a type table.
But now it has to parse the source, execute the statements and change the type table, doing more costly memory operations.

Of course not.
You append as normal, just copy the pointer.

I looked it up in specs and there is even warning on that

Attached: Screenshot from 2018-05-30 22-55-45.png (818x264, 61K)

Remember when you have to pass "this" to methods?
It's likely another fuckup of spilling interpreter guts excused as "explicit programming".

Man, if there wasn't the Cube guy I'd think the Dutch suck at programming languages.

Jesus.

Re-using the same default value can lead to huge performance gains, both in speed and memory use, if the default is big.
And the only alternative would be to define the default outside of the scope, which can be quite ugly.

Mutability is bad.

youtube.com/watch?v=zt0OQb1DBko

>x: t@ype
>declare variable x that has a type of unspecified size
this is not a typo

>what is technical debt

know to choose different tools for different problems you brainlet

>I don't know what closure means

>If you make a copy of the pointer you can modify the struct without affecting other copies of the pointer and without allocating a new struct.
Oh, you're retarded

You mean functions? Python doesn't have methods, if you use a function as a descriptor it binds the owning instance as the first argument.

>appends to the same mutable object
>waa why is this happening
Imagine being too retarded for Python.

Attached: Screenshot_2018-05-30_14-36-12.png (217x139, 4K)

nice font rendering bro

stock Ubuntu on shit low-res display (thinkpad)

user, this is Jow Forums. the ratio of people here who literally have no fucking idea what they're talking about, but will post this kind of shit acting like they're fucking blowing people out of the water, to people who actually have a clue is kinda hilarious. nobody here knows a fucking thing

OK, let me write it out for you brainlet:

An array object consists of 3 values:
- a pointer to the first element of the array
- the size of the elements in bytes
- the current length

The "append()" function does two things:
- first it writes a value to (pointer + (length * element_size))
- then it adds 1 to the length

My "append()" function would:
- first it writes a value to (pointer + (length * element_size))
- it would NOT increase the length of the original array, just LEAVE IT THE FUCK ALONE and it would be the same as before
- then return a new array with same pointer, same element size but length+1

You can do that already:
>>> old = [1, 2, 3]
>>> new = old + [4]
>>> new
[1, 2, 3, 4]
>>> old
[1, 2, 3]
Append is logically in-place, as it signifies a dynamic array.

then you need to distinguish between view and array
he proposes that new and old reference to the same memory
>>> old = [1, 2, 3]
>>> new = old + [4]
>>> new
[1, 2, 3, 4]
>>> old
[1, 2, 3]
>>> old[0] = 666
>>> old
[666, 2, 3]
>>> new
[666, 2, 3, 4]

current behavior makes new copy

D already does this
void main()
{
int[] array;
array.reserve = 100;
array ~= 10; //no alloc
auto copy = array;
array ~= 1; //no alloc
copy ~= 5; //extra room already taken, must reallocate
assert(array == [10, 1]);
assert(copy == [10, 5]);
}

see a)
They'd be better off not implementing methods at all.
In the end, they'd have dynamic dispatch via dynamic type-checking anyway.

you just accidentally proved that you yourself don't know what you're doing.

>>> class F():
... def __init__(self):
... self.a, self.b = 0, 1
...
... def __next__(self):
... _ = self.a
... self.a, self.b = self.b, self.a+self.b
... return _
...
... def __iter__(self):
... return self
...
...
>>> f = iter(F())
>>> for _ in range(10):
... print(next(f))
...
...
0
1
1
2
3
5
8
13
21
34


it's called iterators you fucking plebian. learn about the behavior of default values CHRIST.

Attached: 1525424349229.jpg (630x478, 53K)

>An array object consists of 3 values:
Python doesn't have arrays.

Great idea, but now you broke the GC.

see

C is deprecated like Pascal

functional languages are memes, i dont even know why you think this deserves thread

In the history there is a time where they lost 11 days when changing the calendar.
There can be a month where the first of X doesn't exist, where days since the first of month is undefined; or that the next day of 15/X(14/X-1) is 27/X, but from the definition of days since month, it would be (15/X-1), not (26/X-1).

Java streams

And if you want type hints
from typing import List

def f(default: List[int] = None): # Can put any type in the brackets
if default is none:
default = []
...

>set default parameter as an instance of an object
>call method to mutate said object
WAHHH WY IT DO DIS PYTON RETARD

Attached: 1512287655455.png (936x772, 28K)

op demonstrates why reference types without referential transparency are fucking cancerous

value semantics > all

The default parameter should be an expression, not a pre-evaluated value. There are basically no circumstances where the current semantics are desired; the language implementor should have realized this and implemented default params as expressions accordingly. Besides, you can still get the previous behavior by lifting the default object to a global variable and referencing it in the default param; this way the behavior is very explicit.

Yeah, I've been avoiding languages like Python/Java that tend have rampant use of mutable references lately. I'm happy about that.

Fun Python fuckery:

g = "ok"

def func1():
print(g) # -> "ok"

def func2():
print(g) # runtime error
g = "notok"

what the fuck? is this some variable hoisting bullshit

How would that work if you use your new append twice on the original array?

a = [1,2] # len=2, ptr=0x1234, in memory: [1] [2] [garbage ...]
b = a.append(3) # in memory: len=3, ptr=0x1234, [1] [2] [3] [garbage ...]
c = a.append(4) # in memory: len=3, ptr=0x1234, [1] [2] [4] [garbage ...]

print(b[2]) # -> 4 ... wtf??

I could see this behaviour being potentially useful for tail recursion.

? This doesn't have anything to do with tail recursion, and Python *explicitly* doesn't support tail recursion anyways ....

[] == false //true
![] == false //true
!![] == false //false

C'mon, JavaScript's == is a dead horse by now.

Thanks man
This is a great explanation
Unironically, this is why I sometimes love Jow Forums

>Having mandatory variable declarations could catch typos at compile time
Why though?
Python is a dynamic language where everything is an object
In my opinion the most elegant language of the imperative dynamic scripting languages
Why mess up the syntax and semantics by implementing something that wasn't intended
Just use another language

Nice

On the other hand that's what good about Jow Forums
By letting people anonymously defend ludicrous ideas you can either tear them down completely (thus learning why the best practice is really the best) or proving that the ludicrous idea wasn't so ludicrous after all and can be useful
Either way you learn something that you wouldn't learn in an echo chamber
That's why I like Jow Forums and I think it's both fun and educational

PEP 484
PEP 526

Python supports type annotations since version 3.5. It's not mandatory, but you can use it if you want.

wrong person
meant for

The way shit is passed in python is so fucking stupid

Based JavaScript doesn't do this

This has nothing to do with objects.
This has also nothing to do with implementing something that wasn't intended.
This is solely GVR not knowing the first thing about language design.
There is nothing elegant about dynamics that give literally no benefits but defer error checking to runtime.

>hurr durr just use another language
That's not how language economics works. As soon as enough cancermonkeys fall for it, one will be forced to face it sooner or later. The only way to be safe is to destroy Python once and for all.

That has little to do with what is complaining about. Also, optional tacked on type anotations are close to useless.

As much as I love Erlang..

stackoverflow.com/questions/4776033/how-to-change-an-element-in-a-list-in-erlang

I didn't know it was even possible, but sure. Make python even slower. Maybe people will finally stop using it.

Attached: 1483208260516.png (576x402, 58K)

Unix time is not perfect.
It always increments, but slows down during leap seconds.
The best would be TAI or Temps Atomique International. It's completely based on atomic time and not on earth rotation, so it's continuous and does not include leap seconds.

The smartest programmer in the world figured that out: cr.yp.to/libtai.html

g is redefined in the scope of func2, so python doesn't go looking in globals

On a technical level, each function maintains a dictionary of variables used in the function, and the interpreter will only call back to the global dictionary if the requested key is not in the local dictionary

lists are linked lists in erlang
or are you hoping there would be a built-in function?