Why do I despise python

Programming, for all ages and all languages.
ggodw000
Member
Member
Posts: 396
Joined: Wed Nov 18, 2015 3:04 pm
Location: San Jose San Francisco Bay Area
Contact:

Why do I despise python

Post by ggodw000 »

It has been source of all trouble:

Reason 1.

Code: Select all

>>> a = 1
>>> b = a
>>> a
1
>>> b
1
>>> a = 100
>>> a
100
>>> b
1
>>>
>>>
>>> list1 = []
>>> list1.append(100)
>>> list2 = list1
>>> list1
[100]
>>> list2
[100]
>>> list1.append(101)
>>> list1
[100, 101]
>>> list2
[100, 101]
>>>

Reason 2. When I ask technical question on python forum (first one that comes up on google search), no one can answer, just try this to see if it works, bunch of guesswork. Most of advices don't work.
key takeaway after spending yrs on sw industry: big issue small because everyone jumps on it and fixes it. small issue is big since everyone ignores and it causes catastrophy later. #devilisinthedetails
User avatar
iansjack
Member
Member
Posts: 4685
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: Why do I despise python

Post by iansjack »

So, don't use Python.
alexfru
Member
Member
Posts: 1111
Joined: Tue Mar 04, 2014 5:27 am

Re: Why do I despise python

Post by alexfru »

ggodw000 wrote:It has been source of all trouble:

Reason 1.
...
It will turn up when googling something like top Python pitfalls.
Perhaps, you just need to learn the language better if you need to use it.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why do I despise python

Post by Solar »

Value vs. Reference. Not much of a problem in a language that makes these kind of things explicit, but somewhat of a bummer in languages that want to be "hip" and "better" and hide the differences so they look "cleaner" but really aren't.

That's why I like sticking to the older languages. They're ugly and they admit it. And the people in the forums can tell you how things work, and why they work the way they do. There's honesty in that.
Every good solution is obvious once you've found it.
User avatar
matt11235
Member
Member
Posts: 286
Joined: Tue Aug 02, 2016 1:52 pm
Location: East Riding of Yorkshire, UK

Re: Why do I despise python

Post by matt11235 »

Image

You can find a lot of similar complaints about JavaScript too.
com.sun.java.swing.plaf.nimbus.InternalFrameInternalFrameTitlePaneInternalFrameTitlePaneMaximizeButtonWindowNotFocusedState
Compiler Development Forum
willedwards
Member
Member
Posts: 96
Joined: Sat Mar 15, 2014 3:49 pm

Re: Why do I despise python

Post by willedwards »

Solar wrote:Value vs. Reference. Not much of a problem in a language that makes these kind of things explicit, but somewhat of a bummer in languages that want to be "hip" and "better" and hide the differences so they look "cleaner" but really aren't.

That's why I like sticking to the older languages. They're ugly and they admit it. And the people in the forums can tell you how things work, and why they work the way they do. There's honesty in that.
C:

Code: Select all

int a = 1;
int b = a;
a = 100;
... b is still 1;

And likewise still C:

Code: Select all

char* list1 = calloc(3);
list1[0] = 100;
char* list2 = list1;
list1[1] = 101;
So just which old languages are you sticking with?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why do I despise python

Post by Solar »

willedwards wrote:

Code: Select all

char* list1 = calloc(3);
list1[0] = 100;
char* list2 = list1;
list1[1] = 101;
So just which old languages are you sticking with?
Well, are list1 and list2 clearly declared as pointers (references), or are they not?

Or C++:

Code: Select all

std::vector<int> a;
a.push_back( 100 );
std::vector<int> b = a;
std::vector<int> * c = &a;
a.push_back( 101 );         // b = { 100 }, c = { 100, 101 }
Every good solution is obvious once you've found it.
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Why do I despise python

Post by dozniak »

Thread should've been called "Why do I despise programmers who don't know programming languages"
Learn to read.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why do I despise python

Post by Solar »

Basically, yes. No matter how "easy" a programming language might look, you need to know it, and its pitfalls, because they're there.

There are no silver bullets.
Every good solution is obvious once you've found it.
dseller
Member
Member
Posts: 84
Joined: Thu Jul 03, 2014 5:18 am
Location: The Netherlands
Contact:

Re: Why do I despise python

Post by dseller »

I fail to see your point at all... you're complaining about how a language works. Now, if this was a curious feature I might agree, but if I do the same in C:

Code: Select all

void main()
{
     int a, b;
     a = 1;
     b = a;
     a = 100;
}
The value of B will still be 1. It isn't that strange.
User avatar
Geri
Member
Member
Posts: 442
Joined: Sun Jul 14, 2013 6:01 pm

Re: Why do I despise python

Post by Geri »

i only see C as a real programing language. i come to this conclusion after trying and/or working in several other languages ( (every random variation of)basic, pascal, php, javascript, c#, c++).

from the languages i know, only C is selfhosting, true crossplatform, separated properly from platform libraries/apis, easy enough for both a newcomer and a senior, proper enough to write literally anything, have a 40 year past behind it while it still survived and popular, proofing its timelessness, have the most serious programs of all time written in it, and its relatively very easy to write a compiler for it. it was also able to avoid the rush of retards who would add playmp3 and createmmorpg function while jerking off, if they could.

second generation of BASIC would also fullfill these demands, but in the last 20 year its evolution taken very bad directions, the most important parts never added to the language, only bullshits, made very bad reputation for the language itself, so i would not put trust into the language any more. (but in theory, it still have the capabilities to do a spectacular comeback - but it will dont make such, the people with serious knowledge left the language very long time ago).
Operating system for SUBLEQ cpu architecture:
http://users.atw.hu/gerigeri/DawnOS/download.html
User avatar
dozniak
Member
Member
Posts: 723
Joined: Thu Jul 12, 2012 7:29 am
Location: Tallinn, Estonia

Re: Why do I despise python

Post by dozniak »

If I snip all bullshit your post reduces to literally this:
Geri wrote:.
Learn to read.
User avatar
Rusky
Member
Member
Posts: 792
Joined: Wed Jan 06, 2010 7:07 pm

Re: Why do I despise python

Post by Rusky »

Solar wrote:Value vs. Reference. Not much of a problem in a language that makes these kind of things explicit, but somewhat of a bummer in languages that want to be "hip" and "better" and hide the differences so they look "cleaner" but really aren't.
Languages like Python or Java that do this "non-primitive values are all by-reference" thing don't do it to be "hip" or "better" or "cleaner," they do it because it massively simplifies and empowers the garbage collector. They're not hiding anything.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Why do I despise python

Post by Schol-R-LEA »

If you don't like a given language, that's all good; unless your job is forcing you to use them, then you don't have to.

That having been said, it helps to understand what it is you are saying you don't like, and why they are the way they are.
Solar wrote:That's why I like sticking to the older languages.
Do I even need to say what I am thinking, here? You, of all people here, should have a better idea of why that are the way they are, and more to the point, how long this approach has been around.

Code: Select all

> (define a 1)
> (define b a)
> a
1
> b
1
> (set! a 100)
> a
100
> b
1
OK, so Scheme isn't the original dialect, but it is only five years newer than C (1973 vs 1968), and the same behavior was true in nearly every Lisp since the original m-expression language definition, before it was even implemented. The basic behavior is mainly due, as Rusky states, to that fact that a symbol (the equivalent of an identifier or variable name) is an name for a reference to the data's address rather than the data's address itself. Since everything is (or can be treated as) going through indirection, assignment becomes setting the reference.

Defining a doesn't set a to 1, it sets a to a pointer to a data cell holding the value of 1; the same pointer is used any time the value 1 is needed. By defining b as a, it is copying the pointer to the value cell, not setting b to a reference to a (to put it another way, it automatically snaps the pointers; there is only one level of indirection in both variables). When a is set (assigned) to 100, it changes the reference a holds, but since b still has its own reference to 1 - not a reference to a - it doesn't change anything about b's value.

This may sound inconsistent, because is looks as if it is treating the primitive values differently; but in fact, it isn't. The operations on numbers and other primitives are always indirected, or behave as if they were - in both (define a 1) and (define b a), it is just copying an address from one symbol to another, but in the first case the 'symbol' is the literal 1. In Lisp, a literal is a symbol, not a syntactic structure, though one which is treated differently in regards to how it gets its own value. Similarly, in Python and Ruby, a literal is just another object, just one whose value is constructed implicitly.

I think that this is what is tripping people up, because they assume that

Code: Select all

 a = 1
is assigning the value of 1 to a, while

Code: Select all

b = a
is assigning a pointer to a. Both are, in fact, copying a pointer to an object, but to a C programmer, it looks like the second one is copying a pointer to a variable - something that doesn't quite exist in these languages (but see below).

Mind you, to Lisp, that's just an implementation detail, and most Lisp compilers* (and some Lisp interpreters) will short-circuit references to primitives and smaller data structures. I am not sure if the 'standard' implementations of either Python or Ruby do. I would expect they do, if the developers are anything close to being on the ball about this. Then again, I would have said the same thing about TCO, but Guido stated outright that he disliked it because it smashes the stack (OK, so there are decorators for tail recursion removal, but those are a bit kludgey).

Obviously, Java and C# don't, because they have a separate set of explicitly primitive types that are treated them as local values (data addresses) rather than references, and you cannot have references to them without a wrapper class. IME, this is the worst option of all - it is neither completely explicit, not completely implicit, and the differences in behavior can be confusing even with the explicit typing those languages use. It was originally selected in Java for efficiency reasons, but in retrospect, that makes no sense - efficient algorithms which could convert conceptual references in heap to concrete values on the stack, and which play well with garbage collectors, were already well known (e.g., Chaney's algorithm), and the only thing it did was simplify the compiler (and by only a trivial degree at that).

There are ways to get multiple levels of indirection in these languages, but not with simple assignment - you need to use a list structure, which in Lisp at least, is just pairs of references chained together and with a null in the second value of the last pair. Pairs are shown like this:

Code: Select all

(2 . 3)
(a . b)
where the first is a pair with a reference to the constant 2 and a reference to the constant 3, and the second is a pair of references to the symbols (references) a and b (these are sometimes called 'improper' lists because they fill both cells with non-null references).

A list, then, would actually be a series of pairs which contain one or more references to either another pair, or a null, so:

Code: Select all

; simple list
(a b c d)  => (a . (b . (c . (d . null))))

; nested list, i.e. , a tree 
(a b (c d (e f) g))   => (a . (b . ((c . (d . ((e . (f . null)) . (g . null)))) . null)) 
The same can be done in Python, but Python also has more specialized data types which get used more often (most modern Lisps do too, actually).

--------------
*) Despite its reputation, Lisp is, and always has been, primarily a compiled language; while Slug Russell's big insight involved using the eval and apply functions described in MacCarthy's paper as an interpreter**, that was pretty much an accident, and the original interpreter was used first and foremost for bootstrapping the first compiler. The misconception comes in part from the use of the REPL in development - which behaves like an interpreter, but often is actually a compile-and-go native compiler - and from the ease with which meta-circular interpreters are written in Lisp. The fact that any fool could write a Lisp interpreter - in any language, but especially in Lisp itself - led to a culture that focuses heavily on defining DSLs and extension languages for things which would be done in a more direct and less abstracted manner in most other languages.

**) The eval and apply functions were defined in a publication language which MacCarthy called the 'm-expression' form, but operated on a symbolic list data structure MacCarthy called an 's-expression'. They had the effect of treating an s-expression as a an expression in a modified lambda calculus, with eval calling apply on the first element of the list with the rest of the list as function arguments, and apply taking the list of arguments and calling eval on each one until it got to just a final literal or value, at which point it would call the function being applied with those final return values as it's arguments.

In the paper, they were only intended to demonstrate that the new language was Turing-equivalent (or rather, Church-equivalent, since he based them on the lambda calculus), something that wasn't really clear for a lot of languages at the time. Steve 'Slug' Russell, one of MacCarthy's grad students, was tasked with hand-converting several of the base Lisp functions into assembly code to demonstrate that they were viable as executables, and help plan out the m-expression compiler. However, around Dec 1958, he decided to try implementing the eval and apply functions to see if they could actually work; they did, and it struck him that they could use the s-expressions instead of the m-expressions, and just use eval and apply in a loop - in other words, he realized he had written an interpreter.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Why do I despise python

Post by Solar »

Schol-R-LEA wrote:
Solar wrote:That's why I like sticking to the older languages.
Do I even need to say what I am thinking, here? You, of all people here, should have a better idea of why that are the way they are, and more to the point, how long this approach has been around.
And the next thing that comes up is a Lisp-alike -- the one type of programming language that I never was able to really wrap my head around. ;-)

I'm not perfect, and I admit it. I'd be scared if I were. ;-)

What I was referring to were those kind of languages that unapologetically expose pointers.

But that's Lisp'ers to you. Always ready to spoil your fun. ;-)
Every good solution is obvious once you've found it.
Post Reply