19 ms·
Yes, hashes in Ruby, associative arrays in PHP, maps in Go[1], dictionaries in Python[2] and C#[3] represent the same concept, a collection of key-value pairs.
by software_writer 3y ago
Yes, hashes in Ruby, associative arrays in PHP, maps in Go[1], dictionaries in Python[2] and C#[3] represent the same concept, a collection of key-value pairs.
[1]: https://gobyexample.com/maps https://gobyexample.com/maps
[2]: https://docs.python.org/3/tutorial/datastructures.html#dictionaries https://docs.python.org/3/tutorial/datastructures.html#dicti...
[3]: https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.dictionary-2?view=net-7.0 https://learn.microsoft.com/en-us/dotnet/api/system.collecti...
- my_new_account0 3y agoYes. The OP's post is basically "baby's first API." The are a very handy API but relying on them at scale is much less efficient than structs or arrays. This post doesn't even go into the different performance characters of these APIs, which can be a major foot gun. I've noticed a lot of novice-level posts on here lately. Although I admit the post was very well written.
- ceautery 3y agoNovice level posts are great. Someone found something exciting to them, not new to us, but we should encourage them to keep exploring and writing.
- schrodinger 3y agoAlso, the votes imply interest!
- dikei 3y agoI find it funny that he said he didn't know what to pick between 5 types of IDictionary in C#. * Hashtable * SortedList * SortedList<TKey, TValue> * Dictionary<TKey, TValue> * ConcurrentDictionary<TKey, TValue> I don't even know C# (just Java), yet I know that you'd probably want to use Dictionary<TKey, TValue> most of the time.
- software_writer 3y agoTo be honest, I wrote that just to add a little drama ;)
- djur 3y agoMy experience is that Struct only performs better than Hash in a pretty narrow set of circumstances, rarely enough to be a deciding factor unless profiling suggests it to be.
- Glyptodon 3y agoRuby structs or c-family structs?
- crote 3y agoThe interesting thing is that it definitely feels different to me. While the basic data structure is obviously identical to its counterparts, the way it interacts with the ecosystem as a whole makes it feel way more powerful. The interaction of hashes, symbols, and blocks lead to a language which feels like it is designed with DSLs as first-class citizens. This leads to things like Ruby on Rails, which at first glance feels like pure magic. I get a somewhat similar feeling about lists in Python. Because of its very extensive list comprehension you start thinking in lists, leading to some very clean code which would be extremely awkward to implement in many other languages.
- software_writer 3y ago> The interaction of hashes, symbols, and blocks lead to a language which feels like it is designed with DSLs as first-class citizens. Totally agree.