Earlier quoted context omitted.
Having `import "github.com/liyue201/gostl/ds/array"` in codebase looks weird and unsafe. Like, who's liyue201 and what exactly I'm importing? Vendoring helps a bit, but it's still ugly. Same problems exist in other languages, although "import numpy as np" doesn't explicitly say that you're importing a random head from someone's master.
It's not much different from import com.mysql.cj.jdbc
GoSTL: Algorithm and datastructure library for Go similar to C++ STL
21–30 of 48 posts
Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#22Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#23Earlier quoted context omitted.
what do you mean by "random urls"?
Having `import "github.com/liyue201/gostl/ds/array"` in codebase looks weird and unsafe. Like, who's liyue201 and what exactly I'm importing? Vendoring helps a bit, but it's still ugly. Same problems exist in other languages, although "import numpy as np" doesn't explicitly say that you're importing a random head from someone's master.
Golang has a pretty solid standard library and process to extend it. The 'x' packages are all reasonably vetted and close to official libraries: https://pkg.go.dev/golang.org/x You could easily make a decree in a codebase that you won't depend on random github code and only use stuff from trusted sources like standard library, x, etc.
Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#24Earlier quoted context omitted.
> It has precisely copied the original API, despite the fact the original API is quite unidiomatic in the new language. STL isn't even idiomatic in C++ ;)
I really wish someone takes the work of ditching the STL as a whole and make an unofficial “version 2” of the same standard library. I mean, IO sucks ass, std::string really sucks, containers like unordered_map are really slow (because of the pointer stability requirements), custom allocators are cumbersome, the regex library is a mess, why are string_view and span different things, yada yada. (And darn those long co…
Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#25Earlier quoted context omitted.
> It has precisely copied the original API, despite the fact the original API is quite unidiomatic in the new language. STL isn't even idiomatic in C++ ;)
I really wish someone takes the work of ditching the STL as a whole and make an unofficial “version 2” of the same standard library. I mean, IO sucks ass, std::string really sucks, containers like unordered_map are really slow (because of the pointer stability requirements), custom allocators are cumbersome, the regex library is a mess, why are string_view and span different things, yada yada. (And darn those long co…
Anyway, API-wise, you at least have ranges in C++20, which affords you some syntactic convenience in the ability to pass ranges rather than pairs of iterators. But I definitely agree that both form-wise and impl-design-wise, a change would be welcome.
Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#26Earlier quoted context omitted.
what do you mean by "random urls"?
Having `import "github.com/liyue201/gostl/ds/array"` in codebase looks weird and unsafe. Like, who's liyue201 and what exactly I'm importing? Vendoring helps a bit, but it's still ugly. Same problems exist in other languages, although "import numpy as np" doesn't explicitly say that you're importing a random head from someone's master.
Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#27There's a lot of good work put into this. If it is intended as a tool to help port C++ code out of C++ into Go, it looks very useful. If it is intended as a tool to help Go programmers, it has made a common, but regrettably very serious mistake, that programmers make when porting code: It has precisely copied the original API, despite the fact the original API is quite unidiomatic in the new language. I don't want a…
But yes I generally agree with your point. The X language version of a Y language library ought to work the way somebody who has never used the Y language but is familiar with X expects it to work.
That's across the board. Go and C++ agree that a "string" might be just any bunch of bytes, who knows how they're encoded, that's somebody else's problem so APIs which do care need to be very explicit, maybe even mentioning it in method names. In Python that's very strange, the strings are always Unicode and so a function name_in_cp1252() is awkward to use, probably just offer name() and cope with the encoding.
There are some subtle but important affordances which a non-native user may not even consider adding because their preferred language just omits the necessary feature. For example Rust's From/ Into/ TryFrom/ TryInto cascade or C++ 20 spaceship operator are things native speakers of those languages expect in a good library but aren't going to fall out naturally from converting a Python API.
Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#28Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#29Re: GoSTL: Algorithm and datastructure library for Go similar to C++ STL
#30Someone (I) should fork this and upgrade it to use generics.