The memory models that underlie programming languages (2016)
canonical.org
canonical.org
[1] http://people.csail.mit.edu/gregs/ll1-discuss-archive-html/m...
Meaning the REPL, dynamic code reloading, debugger, ...
Then we had to wait a couple of decades to catch up and aren't still not there.
Hang on! Do you mean some similarity other than what is talked about in the article?
What is a numerical tower?
https://en.wikipedia.org/wiki/Memory_model_(programming)
Regardless, interesting to read about "old" languages, such as Cobol. The way data was laid out in Cobol programs made sense with old computing resource limitations.
"² I’m calling these six conceptualizations “memory models”, even though that term used to mean a specific thing that is related to 8086 addressing modes in C but not really related to this. (I’d love to have a better term for this.)"
I think that's even more wrong. The Wikipedia article gives a pretty good idea what the term means.
I think a good term for what he's talking about is "data [structure] memory layout".
"In this object-graph memory model, if you have several entities of the same type, each one will be identified by a pointer, and finding a particular attribute of an entity involves navigating the object graph starting from that pointer."
I consider even the Cobol case as a kind of data structure, although a very limited and inflexible one:
"For example, an account object might have an account-holder field from bytes 10 to 35, which might contain a middle-name field from bytes 18 to 26."
Sayeth Wikipedia https://en.wikipedia.org/wiki/Data_structure:
"In computer science, a data structure is a particular way of organizing and storing data in a computer so that it can be accessed and modified efficiently"
Anyways, I kinda agree with you as well. Usually when talking about data structures it's related to some particular algorithm, say a red-black tree.
I guess we understand (memory) layout differently. How'd you define it?
[0]: Random as in allocated addresses may vary between invocations.
I think you're getting a little hung up on this being 'wrong' and missing what the thing is trying to convey. Scroll down to the bits about SQL or hierarchal filesystems.
I think a critical approach you can try is that maybe these things are different in some important ways and perhaps that's why there is no obvious unified term that comes to mind to describe them and see where that takes you. 'Kragen confused some overarching abstraction he's trying to describe with "memory layout"' is likely neither true nor fruitful.
The 8086 thing was legitimately called a memory model, choosing how the distinction between the 64k segments would be treated logically by your program. https://en.wikipedia.org/wiki/Intel_Memory_Model
Damn, completely forgot about that despite using many of those segmentation rules like "tiny", "large" and so on a long long time ago.
The use of "memory model" to describe primarily threading/concurrency behavior seems to be a Java innovation that's been picked up by the Go community.
I'd categorize the popular ones like this:
- One sparse byte array: C, C++
- GC heap with class instances with fields: Java, C#, etc.
- Affine structs and enums on the stack, plus library support for heap and other models: Rust
- Dictionaries and primitives: JavaScript, Python, Ruby, etc.
- Immutable structs and enums on the heap: (safe) Haskell
- Textual/array/dictionary variables, global and local: bash and other shells
There's a way in which C# is Java done right. Go can be seen as Java done right, for a different definition of "right". On paper they are virtually identical languages. In practice they are quite different.
Can you explain this? In what sense is Go "Java done right"? The OPs comment isnt offering me much insight into your comment. Thanks.
The biggest example in my opinion is the grave error that Java made in making classes declare their conformance to interfaces. Go's structural typing is uniformly superior, and I believe this one change is roughly 80% of Go's ability to have generally simpler code and to avoid the framework monstrosities that populate the Java world. I fully recognize that sounds bizarre if you've only used one or the other, but I believe it. The ability to declare an interface in my module that some other module that knows nothing about me automatically conforms to prevents people in the Go ecosystem from having to pre-emptively buy into huge frameworks to solve this simple problem. (This is a great deal of the reason I darned near classify Go as a scripting language; for all the drama about "missing generics" I find the experience of writing Go to feel much more like Python than like writing Java.) I have enough of the "explicit better than implicit", formal proof Haskell-y sort of stuff in me to understand where that impulse comes from, but I believe that this is a case where those intuitions are disproved by experience.
Recently I was looking at an crash dump in an Atlassian product, and it clearly had two of those monstrous frameworks in there. We were 600 stack levels deep at the point of the failure. ~100 of them I could excuse as a template renderer recursing on the AST of the template, but there was just this amazing amount of junk in the stack trace. You don't get that in Go code; it looks more like a typical Python dump in depth.
There's a few other places where Go gets things right just by virtue of being newer; again, contra to accusations that the designers have never heard of newer tech, it has closures in it from the get-go. (Yes, I am aware those are hardly new, but if the designers really were completely closed off those wouldn't go in there.) Go has value types from the beginning, which Java is still jamming in. There's a few other things too, like just generally being a bit more memory-aware than Java and a bit more able to put things on the stack, even if the optimizer is generally not that great. It's the combination of these little fixes that are the reason why Go hangs in there with Java performance wise by most measures, and is often more memory efficient, despite the probably 3+ orders of magnitude more effort put into the JVMs.
What does sparse mean in this context?
[1] https://www.complang.tuwien.ac.at/forth/gforth/Docs-html/Hea...
[2] http://www.mosaic-industries.com/embedded-systems/legacy-pro...
I'm thinking of a DSL on top of a pure associative memory, which will remember Things with weighted connections to other Things. Matching consists of not only showing the idea but also related ones more distant. Is there anything like this?
Lua doesn't get quite the cred it should, in the language wars. Its one of those "just going under the radar, getting things done" languages..
EDIT: like, isn't everything a finite map eventually, or at least partially expressible, idktb......
Then LISP models evolved to still use cons cells, but there now are a bunch of primitive objects (which were not introduced by Java, but existed in LISP long before) like certain numbers and characters. LISP then also did not organize everything as atomic symbol. Atoms were not symbols and a bunch of other data types. For example numbers were no longer (pseudo) atomic symbols. There are atoms, but atom then only meant: all data types which are not cons cells. Where originally there were only cons cells and atomic symbols.
LISP tries to avoid to store pointers to primitive numbers/characters and can store them directly. Most objects are tagged and tags for primitive types are stored without added words. Thus a cons cell with two numbers can be two words and each word is some primitive number. The implementation may also avoid to tag cons cells. Instead the pointer to a cons cell will be tagged. Similar is true for vectors. vectors also may not only be vectors of pointers, but can store primitive objects directly and may be optimized for some primitive objects: for example a vector of bits is just a vector header and a one dimensional packed array of bits. The header can't be avoided, but the bits will be stored directly and not as array of pointers to bits. Some objects may be allocated on the stack or in registers - for example primitive numbers may exist multiple times in memory - but other data objects may only exist once - like a string, which is a vector of characters.
So for primitive data types (some numbers, characters, ...) LISP tries to avoid pointers to them, makes them as small as possible, has the tags integrated into the word representation (thus on a 64bit machine typically a fixnum integer will not be able to use all 64 bits, because the tags need to be represented) and integrates the bits in such a way that they can be efficiently set and checked, possibly even by processor instructions - like on a SPARC processor which has 'some' primitive support for that.
Other types of things in memory then are symbols, functions (also machine coded functions) and record-like objects: structures and instances of classes. Those records usually will use a vector to store their slots. Even more data types exist with a low-level representation like hashtables and multi-dimensional arrays. The organization of these objects in memory can be relatively simple (one big pool) or complex (multiple type sorted pools with generations).
I meant:
Atoms were now symbols and a bunch of other data types.