3 ms·
It’s really good. But it needs generics. This is a huge downside. It’s a typed and clean functional programming language but it arbitrarily followed golangs ear
by threethirtytwo 11mo ago
It’s really good. But it needs generics. This is a huge downside. It’s a typed and clean functional programming language but it arbitrarily followed golangs early philosophy of no generics. Ironically golang is one of the most hated languages among many fp advocates.
By the developers own action of adding generics ultimately the golang team admits they were wrong or that generics are better. If gleam gets popular I think much of the same will occur.
There’s simply too much repeated code without generics. I tried writing a parser combinator in gleam and it wasn’t pretty.
- torben-friis 11mo agoPerhaps this is a silly question but how do you do functional with no generics? Arent they pretty much required for map/reduce/filter?
- threethirtytwo 11mo agoSorry my comment was wrong. It’s been a while when I messed with gleam and I remember it was missing a critical thing but I misremembered what it was. Gleam doesn’t support interfaces. Not generics. You are completely right.
- chongli 11mo agoThere are multiple levels of possible generics at play here: the container type and the element type. You can have a map/reduce/filter that operate on any element type (generic elements) while still being specialized to linked lists. On the other hand, you might prefer a generic map that can operate on any container type and any element type, so that you can use the same map method and the same function to map over arrays of numbers, sets of numbers, lists of numbers, trees of numbers, or even functions of numbers! Haskell allows both sorts of generics. In Haskell parlance they call this higher-kinded polymorphism and the generic version of map they call fmap (as a method of the class Functor).
- lpil 11mo agoGleam does have generics.
- nerdponx 11mo agoMost Scheme implementations don't have generics, and you have to deal with a different map function for every data structure. Gauche has a generic sequence interface which is great, and it's one of the reasons as a Python user I like Gauche as my "daily driver" Scheme.
- NathanaelRea 11mo agoI saw your other comment that you meant interface. But an example of a language that went without a feature people thought the language desperately needed was Go with generics. They only added them more than ten years later, when they figured out the best way to implement them. It might be the same with gleam, with first version in 2019 and 1.0 in 2024. The language authors might think they are either uneeded and lead to anti patterns, or are waiting to see the best way to implement them.
- akkad33 11mo agoWhy does it need generics? There's a great blog post about how you can replace a lot of trait behaviour with just functions. Maybe something like that can be done for generics
- riffraff 11mo agothe comment is wrong, what Gleam lacks is interfaces. Which feels super strange, but doesn't seem to really be a problem, e.g. imagine a language where you'd write fun sum_all_numbers(Iterable<T> it) { it.fold(...) } # an interface sum_all_numbers(a_list) # a list implements iterable Gleam wants you to write fun sum_all_numbers(Iterator<T> it) { it.fold(...) } # a concrete type sum_all_numbers(a_list.iterator) # get the caller to build the right object edit: found an article that explained this a bit better https://mckayla.blog/posts/all-you-need-is-data-and-functions.html https://mckayla.blog/posts/all-you-need-is-data-and-function...
- akkad33 11mo agoYes this is the article I was referring to. Gleam does not need interfaces or traits because functions can do it
- nonethewiser 11mo agoGo touted it's lack of features as simplicity. And it is: on the language writing side. Go is an incomplete language masquerading as a simple one.
- ljlolel 11mo agoThat’s the worse is better philosophy which maybe doesn’t matter as much anymore especially with AI
- NuclearPM 11mo agoWhat do you mean?
- array_key_first 11mo agoI think he means maybe AI can get around languages lacking features - like how codegen was used for a long time. Codegen is more and more rare these days, because languages have so many tools to help you write less code - like generics. LLMs could, theoretically, help you crank out similar repetitive implementations of things.
- ljlolel 11mo agohttps://en.wikipedia.org/wiki/Worse_is_better https://en.wikipedia.org/wiki/Worse_is_better
- NuclearPM 11mo agoI remember the clojure guy saying this and it never made sense to me. “Simple is better” is better.
- lpil 11mo agoGleam has always had generics! There’s no Gleam version without them