Post AhwyYdAVquOpsgBY0m by galdor@emacs.ch
(DIR) More posts by galdor@emacs.ch
(DIR) Post #AhwyYdAVquOpsgBY0m by galdor@emacs.ch
2024-05-15T14:51:52Z
0 likes, 0 repeats
In #Go, you cannot call the String method on a literal URL struct ("cannot call pointer method String on url.URL") because the String method has a pointer receiver. String does not modify the object, but it uses a pointer receiver to avoid copying the object for each call.This is what you get when 1/ you design a language with pointers (why would you do that in 2009?) and 2/ you do not have "const".Just bad design.
(DIR) Post #AhwyYenBoavouvHww4 by holgerschurig@emacs.ch
2024-05-15T21:43:14Z
0 likes, 0 repeats
@galdor why would you do that in 2009?One reason could be interop. You could not call many Linux (or BSD) system calls without pointers. And so you still find them in D, Nim, Rust ...If you really don't have them, then you always need some C intermediate later, like Java JNI.
(DIR) Post #AhwyYgeksvNChLMF4C by galdor@emacs.ch
2024-05-15T23:11:28Z
0 likes, 0 repeats
@holgerschurig And yet I use C libraries just fine in Common Lisp, a language which does not use pointers as a language mechanism. No intermediate C. A pointer is just an address, as long as your language has integers and the necessary primitives to call C code, you can use C libraries directly. Ruby FFI does the same thing.
(DIR) Post #AhwyYiCp7kDdVIIxo8 by holgerschurig@emacs.ch
2024-05-16T05:13:26Z
0 likes, 0 repeats
@galdor Using integers for this sounds very lispy: a crude hack that then survives decades. Not because it is good, but only because it is good enough.I mean, which other programming language uses assembler mnemonics from a long died of computer system today? car / cdr ...
(DIR) Post #AhwyYjANYJrEU0AWdU by galdor@emacs.ch
2024-05-16T07:14:52Z
0 likes, 0 repeats
@holgerschurig You do realize that pointers are memory addresses, which are simply integers no matter what the language is, right?
(DIR) Post #AhwyYkh1sPZLDYS7AO by holgerschurig@emacs.ch
2024-05-16T10:41:24Z
1 likes, 1 repeats
@galdor You do realize that pointers are memory addresses, which are simply integersSure. But that's a very incomplete picture. Not outright wrong, but incomplete.Today pointers in C are almost never "void *ptr". But instead "struct foo *ptr". So you get some type checking.So you might frown on pointers in your high-level language ... but when you emulate pointers, you fall back to the worst possible implementation. Some integers that cannot be type-checked at all.Linux for example all the time invents new syscalls and ioctl(). Many more than e.g. the GNU C library covers. Many of these use pointers. And if I write a function prototype for them, then I'd of course use typed pointers. It makes little sense to not use this to prevent --- type checking helps oneself from shooting into the foot.So, if you frown about pointers --- which I can fully understand! --- at least provide a better alternative. Not a worse one.But maybe my view is too much a systems programmer view, I value languages mostly from a systems programming point of view (where I e.g. like Nim, D or Rust, but not so much Python, Lua, and anyone of the 100s of Lisps). So I might be preoccupied!
(DIR) Post #AhwycOV8KML3Y6co08 by amerika@annihilation.social
2024-05-16T13:35:35.033264Z
0 likes, 0 repeats
@holgerschurig @galdor Direct management of memory and data structures has its advantages. Hipster languages just coat everything in layers of abstraction.