4 ms·
I can understand having to import the "dirty" parts of the stdlib, like I/O, or the "heavy" parts, like Unicode or timezones. But why force someone to import ev
by orthoxerox 2y ago
I can understand having to import the "dirty" parts of the stdlib, like I/O, or the "heavy" parts, like Unicode or timezones. But why force someone to import every single type? Most functional languages have a prelude that covers the types every non-trivial program uses: booleans, numbers, strings, collections.
- Jtsummers 2y ago> But why force someone to import every single type? That's not importing the types, it's importing a suite of functions related to the types. https://hexdocs.pm/gleam_stdlib/gleam/int.html https://hexdocs.pm/gleam_stdlib/gleam/int.html - gleam/int for example. The int type is already in the language and usable, this import brings in some specific functions that are related to operations on int.
- mixmastamyk 2y agoWhy not methods of the type?
- Jtsummers 2y agoThe answer to "why not methods" would be because it doesn't have methods.
- mixmastamyk 2y agoAnd why not?
- Jtsummers 2y agoBecause they selected to make a functional, not OO, language based largely on BEAM which was designed for Erlang, a functional, not OO, language. Why would you make an OO language if your goal is to make a functional language?
- mixmastamyk 2y agoDogma not appreciated. Personally don't care if a lang is functional or OO, they aren't exclusive categories. For example, several OO langs have added functional features. Don't see why this one couldn't use static methods for its immutable types. Wouldn't hurt anything, would it? As mentioned in this thread, having to import libraries to operate on basic types is suboptimal to say the least.
- lpil 2y ago> Wouldn't hurt anything, would it? One of Gleam's design goals is to not have multiple ways to do the same thing, so having to pick between using method chains or pipelines would work against that. > having to import libraries to operate on basic types is suboptimal to say the least. The language server will do this for you in a Gleam project.
- mixmastamyk 2y agoI could imagine a method call done in a pipeline, but would have to work out the details. Maybe self/this or omit the variable name? Not sure how doable. Folks recommended tools to alleviate Java verbosity back in the day as well. But you still have to read it—which unfortunately happens 100x more than writing.
- lpil 2y agoGleam dodges the problem by not having methods at all. Totally. Gleam priorities reading over all else, and generally it is praised for being unusually easy to understand code written in it