Hacker News new | past | comments | ask | show | jobs | submit | val_deleplace's comments login

I tested with many concurrent goroutines, and confirmed that calling `unique.Make` does not cause any data race condition

Thanks a lot! I also found this blog post where they mention it's thread safe thanks to using HashTrieMap internally

Link: https://go.dev/blog/unique


Yes, the package is designed to be thread-safe

Mere quadratic time complexity is something I would expect to timeout and catch at fuzzing time, as long as we do encourage non-tiny inputs, say 10K and beyond.


Yes, definitely dozens of pretty good online resources. Here are 3:

- Tour of Go: https://tour.golang.org/

- Practical Go: Real world advice for writing maintainable Go programs, by Dave Cheney: https://dave.cheney.net/practical-go/presentations/gophercon...

- Uber Go Style Guide: https://github.com/uber-go/guide/blob/master/style.md


You may upvote the Swift request here: https://github.com/Deleplace/programming-idioms/issues/30


Yep! Curation is though.


It's already possible and encouraged to improve the solutions. The "edit" button shows up on computer browsers, not on mobile if the screen is small.

There's no "debate" capabilities, though.


Indeed! I updated the implementation to hoist the quadratic strlen.


I agree with the 2 example tasks, which are not "simple" to write.

The remove-by-value snippet is 8 lines, and it can be wrong in a subtle way: if list contains pointers, then we have a memory leak beyond the slice final length (pointer values still exists within capacity, and objects are not garbage collected).

I wrote several possible implementations here, none of which is as concise and as obviously correct as an hypothetical "list.remove(v)": https://programming-idioms.org/idiom/136/remove-all-occurren...


Author here: there were 2 initial use cases for me,

(1) I'm familiar with the language X but I forget e.g. how to "check if a file exists"

(2) I'm learning a new language Y, I know that "checking if a file exists" is a legit need and there must be an idiomatic way to do it in Y, so I look at the entry, alongside implementations in other languages that I'm more familiar with, so I can quickly spot the similitudes and the differences.

I do (1) all the time because my brain has very little onboard memory.

The website is open to contributions without prior validations. This means that not all snippets end up being both correct and idiomatic. I manually revert spam and "obviously incorrect" entries. For languages that I don't know very well, I encourage actual experts to fix snippets, or add a better new implementation, when they see poor contents.


Great resource, thank you for building it!


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: