4 ms·
Roughly how would you write code to solve this particular problem in your ideal language?
by creata 6y ago
Roughly how would you write code to solve this particular problem in your ideal language?
- gchamonlive 6y agoJust like I described, detailing the problem in the type system, simplifying the abstractions and proving correctness of code.
- creata 6y agoThat's a lovely ideal, but could you write some pseudocode for this particular problem in such a language?
- gchamonlive 6y agoThat is beside the point. I could produce something in Haskell, but the "magic" would all done in the compiler, so in the context of my original comment I see no reason why I should.
- creata 6y ago> At code level, you should be able to describe your problem in lots of details, use identities to simplify your logic, but leave the optimizations to the compiler. 1. As far as I'm aware, Haskell isn't able to do any of that at the code level. I'm interested in what a language that is able to do that would look like. 2. I'm curious as to what you consider an "optimization" to be left to the compiler, and what you consider part of the "problem". For example, does the compiler decide which implementation of a set to use? 3. I'm also wondering what you mean by "proving correctness." If you're alluding to formal verification, then that is notoriously hard to scale, which conflicts with the stated goal of making optimization easier to scale. Some pseudocode would shed light on all these questions.
- gchamonlive 6y agoI guess I have to admit I punched above my pay grade. Because I can't think of a pseudocode that would shed light to those questions.
- flohofwoe 6y agoZig has a very simple and straightforward solution: Every standard library function which needs to allocate takes an allocator argument. That way it's immediately obvious what functions are potentially expensive. It's not even a magic compiler or language feature, just a standard library convention.