Live data from Hacker News

Swift Algorithms

swift.org

1–10 of 80 posts

Re: Swift Algorithms

#3
post #2

Worse nomenclature than any other big language I can think of, including Go and Python. Why should this package be called "algorithms"?

C++ has similar nomenclature - - the std::algorithms library has generic functions for working with collections: https://en.cppreference.com/w/cpp/algorithm

Whether C++ is a good model to follow is another question entirely, of course! But at least Swift isn’t being completely idiosyncratic in its naming choices.

Re: Swift Algorithms

#4
post #2

Worse nomenclature than any other big language I can think of, including Go and Python. Why should this package be called "algorithms"?

C++ has similar nomenclature - - the std::algorithms library has generic functions for working with collections: https://en.cppreference.com/w/cpp/algorithm Whether C++ is a good model to follow is another question entirely, of course! But at least Swift isn’t being completely idiosyncratic in its naming choices.

[deleted]

Re: Swift Algorithms

#5
post #2

Worse nomenclature than any other big language I can think of, including Go and Python. Why should this package be called "algorithms"?

Huh? It sounds like it shouldn't be called anything BUT algorithms. It implements standard generic algorithms for various operations. The kinds you'd be asked about in an algorithmic test, learn in algorithms 101, and so on.

Of course technically any part of a program is an algorithm, but usually (like here) we reserve the name for general things like here (from path and graph to partition and search algorithms), not for our "business logic" algorithm.

Re: Swift Algorithms

#6
One issue with Go's lack of generics is exactly that it can't have such a package (and have it be type safe, fast, and work across all relevant types), except with repeated code.

Re: Swift Algorithms

#7
post #2

Worse nomenclature than any other big language I can think of, including Go and Python. Why should this package be called "algorithms"?

These functions are designed to be highly generic so can be used as building blocks for many other more specific algorithms while it is not specifically tied to other concepts like container or iterator. Do you have any concise alternatives that reflect these properties?

Re: Swift Algorithms

#9
post #6

One issue with Go's lack of generics is exactly that it can't have such a package (and have it be type safe, fast, and work across all relevant types), except with repeated code.

Sounds to me like a job for a DSL that compiles down to Golang for the final output. That way, the repeated code only exists in the Golang output and not in the code that humans actually write.

Re: Swift Algorithms

#10
post #9
post #6

One issue with Go's lack of generics is exactly that it can't have such a package (and have it be type safe, fast, and work across all relevant types), except with repeated code.

Sounds to me like a job for a DSL that compiles down to Golang for the final output. That way, the repeated code only exists in the Golang output and not in the code that humans actually write.

the solution is... to not use Golang!

more specifically, fairly basic operations on a list of data does not seem like it should call for the complexity of a DSL. IMO unless you need to do this quite a bit on random datatypes, copy & paste would probably be the better alternative. Unless you're referring to a DSL that looks exactly like Golang but with generics & monomorphism.... in which case ok I guess

Post reply on HN