3 ms·
Well, there's Microsoft ".NET". Marshaling is an important, and neglected, subject in language design. Compilers really should understand marshaling as a compi
by Animats 12y ago
Well, there's Microsoft ".NET".
Marshaling is an important, and neglected, subject in language design. Compilers really should understand marshaling as a compilable operation. In many cases, marshaling can be compiled down to moves and adds. Done interpretively, or through "reflection", there's a huge overhead. If you're doing marshaling, you're probably doing it on a lot of data, so efficiency matters.
For Google protocol buffers, there are pre-compilers which generate efficient C, Go, Java, or Python. That works. They're not integrated into the language, so it's kind of clunky. Perhaps compilers should accept plug-ins for marshaling.
Most other cross-language systems are more interpretive. CORBA and SOAP libraries tend to do a lot of work for each call. This discourages their use for local calls.
Incidentally, there's a fear of the cost of copying in message passing systems. This is overrated. Most modern CPUs copy very fast and in reasonably wide chunks. If you're copying data that was just created and will immediately be used, everything will be in the fastest cache.
Fortunately, we can generally assume today that integers are 32 or 64 bit twos complement, floats are IEEE 754, and strings are Unicode. We don't have to worry about 36-bit machines, Cray, Univac, or Burroughs floats, or EBCDIC. (It's really time to insist that the only web encoding be UTF-8, by the way.) So marshaling need involve little conversion. Endian, at worst, but that's all moves.
- cbd1984 12y ago> Marshaling is an important, and neglected, subject in language design. Compilers really should understand marshaling as a compilable operation. I generally agree with what you're saying. This is one of the things COBOL, of all languages, generally got right: You had a Data Definition language, which has been carried over to SQL, and the compiler could look at the code written in that language to create parsers automatically. Of course, COBOL having been COBOL, this was oriented to 80-column 9-edge-first fixed-format records with all the types an Eisenhower-era Data Processing Professional thought would be important. The concept might could use some updating, is what I'm saying. > Most modern CPUs copy very fast and in reasonably wide chunks. And most modern OSes can finagle bits in the page table to remove the need for copying. > strings are Unicode By which you mean UTF-32BE, naturally. ;) > It's really time to insist that the only web encoding be UTF-8, by the way. This might actually be doable, if only because of all the smilies that rely on Unicode to work and the fact UTF-8 is the only encoding that handles English efficiently.
- Animats 12y agoAnd most modern OSes can finagle bits in the page table to remove the need for copying. That tends to be more trouble than it's worth. It usually means flushing caches, locking lots of things, and having to interrupt every CPU. Unless it's a really big data move (megabytes) it's probably a lose. Mach did that, and it didn't work out well.
- sitkack 12y agoSomeday the heap will be a protocol.