Remix.run Logo
davidee 3 hours ago

Perhaps relevant: https://campedersen.com/loon

This looks like a really neat project/idea; seeing the road map is exciting too, nearly everything I'd want.

I don't love the brackets syntax, or the [op val1 val2] ([* x x]) style, but I appreciate the attempt at clarity and consistency and none of these things are dealbreakers.

I do wonder why they've leaned so hard into talking about the type system being out of sight. Again, not a dealbreaker, but I feel strongly that explicit typing has a place in codebases beyond "describe something because you have to".

Strongly typed languages strike me as providing detailed hints throughout the codebase about what "shape" I need my data in or what shape of data I'm dealing with (without needing to lean on an LSP). I find it makes things very readable, almost self-documenting when done right.

From their docs about their choices: "The reasoning is simple: types exist to help the compiler catch your mistakes. They do not exist to help you express intent, at least not primarily." This strikes me as unnecessarily pedantic; as someone reading more code than I write (even my own), seeing a type distinctly—particular as part of a function signature—helps me understand (or add strong context) to the original author's goal before I even get to reading the implementation.

I find this doubly so when working through monadic types where I may get a typed error, a value, and have it all wrapped in an async promise of some kind (or perhaps an effect or two).

By the same token many languages allow you to leave out type annotations where they may be simple or clearly implied (and/or inferred by the compiler), so again, I'm not understanding the PoV (or need) for these claims. Perhaps Loon simply does it better? Am I missing something? Can I write return types to stub functions?

From the above blog post: "That's how good type inference feels! You write code. The types are just there. Because the language can see where it's going." Again, it feels strongly geared towards a world where we value writing code over reading/maintaining/understanding code, but maybe that's just my own bias/limitations.

Will follow it closely.

cptroot 2 hours ago | parent | next [-]

Good news, there's a line in the "Coming from Rust"[1] page that says

> You never annotate a function signature unless you want to for documentation purposes.

so it sounds like function annotation is still an option for the purposes of communication, just no longer required in all cases.

[1] https://loonlang.com/concepts/from-rust

cptroot 2 hours ago | parent [-]

Aha, here's the syntax in case you're curious (using an example lifted from the playground)

  [type Shape
    [Circle f64]
    [Rect f64 f64]
    Point
  ]

  [sig test_sig : Shape -> Float]
  [fn test_sig [shape]
    [match shape
      [Circle r] [* 3.14159 [* r r]]
      [Rect w h] [* w h]
      Point 0.0
    ]
  ]
Unfortunately it seems like this doesn't currently work as expected when I use it in the playground, so I'm going to go file an issue
ecto 2 hours ago | parent [-]

thank you <3 I will fix asap

mapcars 2 hours ago | parent | prev | next [-]

> Strongly typed languages strike me as providing detailed hints throughout the codebase about what "shape" I need my data in

I agree that seeing types is helpful, though typing them is also not necessary. Perhaps the solution is an IDE that shows you all the types inferred by the compiler or maybe a linter that adds comments with types on file save.

zokier an hour ago | parent [-]

> I agree that seeing types is helpful, though typing them is also not necessary. Perhaps the solution is an IDE that shows you all the types inferred by the compiler

see "The Editor as Type Viewer" section in the docs: https://loonlang.com/concepts/invisible-types

wk_end 3 hours ago | parent | prev [-]

Yeah, the idea that types exist just to help the compiler catch your mistakes shows a depressingly superficial understanding of the benefits of static typing.

Types exist so that the compiler can reason about your code better - but not incidentally, they also help you reason about your code better!

To wit: even when working in dynamic languages, it's often considered a good practice to write down in docstrings the types of objects a function can operate on, even without static enforcement. Thinking about types is helpful for humans, too.

And it's not even just a thing to help you read code in the future - types help me write code, because as I sit down to write a function I know the possible values and states and capabilities of the object I'm working with. In the best of cases I can analytically handle all the possible cases of the object, almost automatically - the code flows out of the structure of the type.

bossyTeacher 40 minutes ago | parent | next [-]

> Types exist so that the compiler can reason about your code better - but not incidentally, they also help you reason about your code better!

THIS. So much. This observation is extremely intuitive to me.

smohare an hour ago | parent | prev [-]

[dead]