Why no pointers? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 4

Why no pointers?

Pointers are really useful, so why not all languages use it?

3rd Jul 2019, 11:44 AM
Airree - avatar
3 Answers
+ 7
Who says they don't? Behind the scenes they actually do--setting variables for one. The pointers themselves aren't exposed because they (the language designers) feel you & I aren't someone who can use it properly and cause memory violations, segmentation fault. The trend is for languages to become higher level and add even greater levels of complexity (abstraction) So something like int a = 2; becomes var a = 2; which in turn becomes a=2 That's the only reasonable explanation i can give.
3rd Jul 2019, 12:42 PM
Lord Krishna
Lord Krishna - avatar
+ 6
They(the language designers) don't feel we can safely use them, memory violations, segmentation fault(a type of program crash). It's not considered(again by the language designers), it's safer to not expose the internals(like pointers, memory management). Then to deal with memory violations you may commit when using them. It's a design choice. Higher level languages tend to abstract things. So pointers, gotos, manual memory management go away with them. Means less power to you. And less chance for you to mess it up-- crash or vulnerabilities(overflow and related bugs). That's my understanding. Based on the languages I use and observe.
3rd Jul 2019, 12:57 PM
Lord Krishna
Lord Krishna - avatar
+ 1
But why can't we use it directly?
3rd Jul 2019, 12:43 PM
Théophile - avatar