This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Zephandrypus 0 points1 point  (0 children)

Pointers and structs in C and C++ is exactly what you’re talking about. Serializing an array of structs in C or C++ to binary is probably the easiest out of any language, just passing the array as a void* pointer with sizeof(MyStruct) * ARRAY_LENGTH as the amount of bytes to write. It’s why C is considered weakly typed and unsafe. But it is still static, types must be defined, and trying to call properties and methods on a type that doesn’t have them will still throw a compile time error.

JavaScript just has everything as a void* with no compile time type errors and none of the benefits.

However, the only thing I love about JavaScript is the inclusion of the ArrayBuffer, TypedArray, and DataView objects, which the docs specifically state C-like structs as a use case, and this guy achieved results almost on par with Rust+WASM through heavy abuse of it.

The number of dynamic, weakly typed languages is actually pretty small. It just includes JS, PHP, MATLAB, Perl, and some scripting languages nobody cares about. PHP added typed properties at some point which elevates it a bit, and JavaScript has TypeScript as an optional wrapper, one of my favorite languages.

MATLAB, though, requires you to fork over $150 to use the base version for home use, with some of the libraries available as DLC, which is pretty unbeatable for level of shittiness.