4 ms·
>If you take TypeScript and add pointers, you'd end up with something like Java, or maybe Go. He's not just talking about pointers. He's implicitly talking abo
by deltasevennine 4y ago
>If you take TypeScript and add pointers, you'd end up with something like Java, or maybe Go.
He's not just talking about pointers. He's implicitly talking about allocation and free.
If you want facilities similar to just pure pointers without memory management then you have this already with all high level languages like JS or python. In fact the garbage collectors in these languages work by counting the references (aka pointers) pointing to a primitive.
Thus from this reasoning he's talking about more than just pointers.
- jmillikin 4y agoYou're talking about references. The OP and I are talking about pointers. TypeScript does not have pointers. Python technically does (`ctypes`), but 99.99% of Python code will never touch them. There are important differences between pointers and references, for example the ability to perform arithmetic on them.
- deltasevennine 4y agoNo he's talking about memory management and the notion of some shortcut pointing to it. Typescript with pointers (that do pointer arithmetic) and no extra memory management facilities doesn't make any sense. He's not referring to this.
- jmillikin 4y ago> Typescript with pointers (that do pointer arithmetic) and no extra > memory management facilities doesn't make any sense. That's pretty close to what Go offers. It seems to be quite a popular choice for people who occasionally need manual memory management but are mostly willing to let the compiler handle things. It's pretty obvious that the OP is asking why a language like Rust needs to have a more complex syntax/semantics than TypeScript, and the answer has nothing to do with manually allocating buffers.
- UncleEntity 4y agoI would argue that most of the complexity in low-level languages comes from herding references to memory locations (pointers and whatnot). There’s no reason TypeScript couldn’t be built on top of manual memory management and the concept of raw access to memory locations but I suspect it would start looking a lot like C with just a different syntax for type declarations.