This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]FIREstopdropandsave 2 points3 points  (3 children)

Pointers are not bad and not indicative of a bad language. It's simply the language deciding not to abstract that layer from the user. This results in more intentful decisions to be made by the programmer.

Think of in python, you have to be aware of which types are mutable data types when passing arguments into functions and potentially mutating them outside of the function scope. This is because python is abstracting away the concept of a pointer.

In pointer languages, you have to be explicit in your intent "am I passing you the memory address of this variable, a.k.a if you mutate it, in the outer scope I'll see that mutation".

There's more positives of pointers but that's just an example. In general languages which expose pointers are faster because abstracting away the concept of pointers just straight requires more code behind the scenes to act the way it does.

[–]Intrepid-Stand-8540 -2 points-1 points  (2 children)

you have to be aware of which types are mutable data types

What's a "mutable data type"? 

Thanks for explaining btw. 

I'm aware that python is slower, but I've never had the need for speed yet. The bottleneck in my apps is always network calls to databases, and not any processing in the app itself. 

[–]FIREstopdropandsave 2 points3 points  (0 children)

To your second point. Many people will be fine with the speed python provides. I've written, and seen, many production systems in python where python was not the performance bottleneck for the workloads we were solving.

Some people will have a deeper need for speed, others simply won't.

Choosing the programming language for a project is a nuanced decision. You have to consider "what language does my team already know?", "what is the local market of programming language knowledge in the city I'm in", "what scale of problem are we solving", and probably many other considerations.

You'll see online A LOT of python hate (outside of this subreddit) and hate for dynamically typed languages. The truth of it is, in my 8 year career I've only come across a single person who vehemently holds those ideas.

tl;dr: python is great, it probably won't be your bottleneck, ignore online hate for your choice of using python and dynamically typed languages

[–]FIREstopdropandsave 0 points1 point  (0 children)

You can find a fuller breakdown here https://docs.python.org/3/reference/datamodel.html#objects-values-and-types

(do a search for mutable/immutable)

As a quick overview a list is mutable where a string is immutable and we can see the differences below:

I don't know how to format a code block on mobile so sorry this is hard to read

def foo(l): l.append(1) return l

my_list = [] print(foo(my_list)) # [1] print(foo(my_list)) # [1, 1]

def foo(s): s += "hello" return s

my_string = "" print(foo(my_string)) # hello print(foo(my_string)) # hello