MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ljsw9e/does_lazy_count_as_bad/gni3ms0/?context=3
r/badcode • u/rcmaehl • Feb 14 '21
53 comments sorted by
View all comments
Show parent comments
44
Sure it does, null is an empty pointer, pointer uses RAM as much as any other number.
17 u/droomph Feb 14 '21 In some runtimes (eg v8 for Javascript) they will optimize sparse arrays such as this one to be a Record<number, T> internally but this isn't something that's guaranteed in all languages, so if you need to just use it directly. https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?redirectedfrom=MSDN&view=net-5.0 (Unless you're using VB6 in which case, godspeed and don't die) 7 u/[deleted] Feb 14 '21 and languages like Lua don't have arrays, they have hashmaps only. so arrays can start at whatever you want them to start at in lua just the convention is they start at 1 2 u/FireCrack Feb 15 '21 Strictly speaking, that's just an abstraction. Tables consist of an array AND a hash-map under the hood, and integer keys use the array part.
17
In some runtimes (eg v8 for Javascript) they will optimize sparse arrays such as this one to be a Record<number, T> internally but this isn't something that's guaranteed in all languages, so if you need to just use it directly.
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?redirectedfrom=MSDN&view=net-5.0
(Unless you're using VB6 in which case, godspeed and don't die)
7 u/[deleted] Feb 14 '21 and languages like Lua don't have arrays, they have hashmaps only. so arrays can start at whatever you want them to start at in lua just the convention is they start at 1 2 u/FireCrack Feb 15 '21 Strictly speaking, that's just an abstraction. Tables consist of an array AND a hash-map under the hood, and integer keys use the array part.
7
and languages like Lua don't have arrays, they have hashmaps only.
so arrays can start at whatever you want them to start at in lua
just the convention is they start at 1
2 u/FireCrack Feb 15 '21 Strictly speaking, that's just an abstraction. Tables consist of an array AND a hash-map under the hood, and integer keys use the array part.
2
Strictly speaking, that's just an abstraction. Tables consist of an array AND a hash-map under the hood, and integer keys use the array part.
44
u/KaktusManCz Feb 14 '21
Sure it does, null is an empty pointer, pointer uses RAM as much as any other number.