| ▲ | cogman10 6 hours ago | |||||||
I've seen some devs prefer that route of programming and it very often results in performance problems. An undiscussed issue with "everything is a string or dictionary" is that strings and dictionaries both consume very large amounts of memory. Particularly in a language like java. A java object which has 2 fields in it with an int and a long will spend most of it's memory on the object header. You end up with an object that has 12 bytes of payload and 32bytes of object header (Valhala can't come soon enough). But when you talk about a HashMap in java, just the map structure itself ends up blowing way past that. The added overhead of 2 Strings for each of the fields plus a Java `Long` and `Integer` just decimates that memory requirement. It's even worse if someone decided to represent those numbers as Strings (I've seen that). Beyond that, every single lookup is costly, you have to hash the key to lookup the value and you have to compare the key. In a POJO, when you say "foo.bar", it's just an offset in memory that Java ends up doing. It's absurdly faster. Please, for the love of god, if you know the structure of the data you are working with it, turn it into your language's version of a struct. Stop using dictionaries for everything. | ||||||||
| ▲ | ronjakoi 6 hours ago | parent [-] | |||||||
I work with PHP, where classes are supposedly a lot slower than strings and arrays (PHP calls dictionaries "associative arrays"). | ||||||||
| ||||||||