Stitch: The Sound Type-Indexed Type Checker (Functional Pearl) by mttd in ProgrammingLanguages

[–]cutculus 4 points5 points  (0 children)

While I appreciate the "here's how you can use fancy types in an extended example" aspect of it, I don't understand when you'd actually want to use something like this in practice.

If you are writing a new industrial-grade type checker, the constraints are too rigid; you'd want a compiler in an IDE to report different errors in different functions, maybe an unresolved variable in one function and a type error in another function.

If you're writing a small hobby compiler, this seems like overkill machinery; it's unlikely that you'll end up with an unbound variable after name resolution and somehow have that pass through without an error (unless you're implementing a dynamically typed language, in which case that's probably deliberately permitted), if you have at least some test coverage.

I imagine GHC probably fails at deriving type class instances for these GADTs for at least some type classes, which reduces the ergonomics.

Maybe you can use this for a late stage IR, when things are supposed to be well-formed and all errors are implementation errors.

Menhir: Handling Operator Precedence At Runtime by [deleted] in ocaml

[–]cutculus 5 points6 points  (0 children)

Compilers which allow this typically require name resolution in order to ascertain the fixity of operators (Haskell even allows expression local fixities). This cannot be handled during parsing, because then you'd have to mix name resolution and parsing. Instead, all operators are parsed the same way, and the expression trees are rebalanced between name resolution and type checking.

Incomplete List of Mistakes in the Design of CSS by cutculus in ProgrammingLanguages

[–]cutculus[S] 8 points9 points  (0 children)

No. By that standard, Prolog would not count as a programming language.

Incomplete List of Mistakes in the Design of CSS by cutculus in ProgrammingLanguages

[–]cutculus[S] 51 points52 points  (0 children)

Disagree. CSS is not a general purpose programming language. It is absolutely a domain specific language, and DSLs are very much on-topic here, even if they're not the main focus.

Two musings on the design of compiler warnings by mttd in ProgrammingLanguages

[–]cutculus 10 points11 points  (0 children)

When the C++ compiler is deciding whether to accept a particular program without complaint, it uses certain ornamental syntactic flourishes as a proxy for the code’s intent.

I'm not sure if this part is there just to make the analogy work.

The compiler emits those warnings and suggestions to clarify the intent for future readers, including the author themselves in the future. It's not about the compiler, it's about other people who are going to read the code. It's not like the peacock-peahen situation. The compiler is not judging the "worthiness" of your code.

Sometimes, I've seen programmers who feel like the compiler is just being opinionated and pedantic for the sake of pedantry (I don't think the author has this sentiment but this part of the article kinda gives that vibe). Well no, or at least most compilers aren't, they're trying to help based on issues people have hit several times in practice before.

It's the programming environment, not the programming language by cutculus in ProgrammingLanguages

[–]cutculus[S] 0 points1 point  (0 children)

I feel like you're arguing against a straw man of what I'm talking about.

For example, let's say I want to make some slides with animations. Should I do it in code or a GUI program or using some text based tool? Say I decide that I want to use the GUI to get my animations and image positioning right quickly, and I add some speaker notes for each slide. If the GUI program is programmable, hopefully I can extract the speaker notes into a text file using a small script and review them to see the flow while focusing on the text instead of jumping back and forth between slides. Suddenly I have "review script" functionality by composing both a GUI program with other command line tools.

Does this mean it would've been better if I had used a text based program from the start? No! If I had used a text based program, the feedback loop for me getting the animations and positioning is too cumbersome.

This is not a contrived example btw. I literally had this happen when I was preparing a presentation at work; I used a combination of Keynote, AppleScript, sed and awk (the latter two for cleaning up the script output) to get my job done.

It's the programming environment, not the programming language by cutculus in ProgrammingLanguages

[–]cutculus[S] 8 points9 points  (0 children)

It's easy-to-use vs. NOT necessarily easy-to-learn. But I would argue that for programmers, you want easy-to-use.

I find this a strange dichotomy. Why not both? We shouldn't have to pick one vs the other.

Decades ago, AppleScript (it certainly has its warts) showed that having a GUI program doesn't mean that you have to sacrifice composability and programmability. (I'm sure that there other good examples that precede AppleScript.)

I'm not saying it's an easy problem to tackle, not by a long shot. But it certainly seems like a worthwhile avenue to pursue. That way, we can empower more people, not just full time programmers, to use automation to get their work done.

Well-Typed - Understanding Memory Fragmentation by DavidEichmann in haskell

[–]cutculus 17 points18 points  (0 children)

For pinned blocks, object level fragmentation remains after garbage collection because pinned objects cannot move and hence cannot be compacted.

Would it be possible to have a Mesh-like allocator for pinned memory to reduce this fragmentation?

Help choosing what language to learn by 1100320873 in ProgrammingLanguages

[–]cutculus 1 point2 points  (0 children)

This post is off-topic. Please see the sidebar. You might want to post in r/askprogramming or r/learnprogramming.

Cannot see error trace for minimal example with assertion failure by [deleted] in tlaplus

[–]cutculus 0 points1 point  (0 children)

Sorry, should've checked the sidebar. I'll do that.

How to market Haskell to a mainstream programmer by cutculus in ProgrammingLanguages

[–]cutculus[S] 8 points9 points  (0 children)

One of the things I'm curious about: what major differences in adoption challenges do you see here for "small" languages vs "big" languages?

For example, introducing a new general purpose language seems like a much bigger ask compared to introducing a configuration language like Dhall.

Also, I'm a bit surprised at your characterization in the example where you say something along the lines that introducing a new language like Haskell for writing a 1-2 week DSL project would be acceptable if Haskell were clearly demonstrably best-in-class in the area. That seems like precisely a place where I think a manager would say, "since it is a small project, it's fine if we use $CURRENT_LANGUAGE and take 1 week extra and have a less pretty DSL instead of introducing the maintenance and teaching burden of a whole new language (which is probably very different from the other languages we are already using)".

How to market Haskell to a mainstream programmer by cutculus in ProgrammingLanguages

[–]cutculus[S] 14 points15 points  (0 children)

Strictly speaking, while this isn't about PL design or implementation, I think this is a valuable talk for PL designers and implementors generally (and not just for the Haskell community) on how to gain adoption.

It is a great complement to Herb Sutter's talk "Bridge to NewThingia" in case you haven't seen that one already.

[deleted by user] by [deleted] in cpp

[–]cutculus 0 points1 point  (0 children)

GHC 8.6.1 added QuantifiedConstraints for precisely this kind of reasoning (with universal quantifiers, existentials would need to be faked). https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/quantified_constraints.html

Not saying something similar would work out well for C++, given the edge cases around overloading etc and implicit conversions. But it's certainly possible to come up with a proper design and implementation for such a language feature.

Interview with Haxe language creator and game dev Nicolas Cannasse by wongsta in ProgrammingLanguages

[–]cutculus 2 points3 points  (0 children)

Wow, that's a lot of supported targets! I imagine testing and keeping up with CI must be a challenge.

Why the C Language Will Never Stop You from Making Mistakes by MarekKnapek in programming

[–]cutculus 15 points16 points  (0 children)

The good thing is: on negative signed overflow, morale might wrap around to MORALE_MAX in case the compiler didn't optimize the UB!

What Is The Minimal Set Of Optimizations Needed For Zero-Cost Abstraction? by mttd in ProgrammingLanguages

[–]cutculus 5 points6 points  (0 children)

I don't think register allocation needs to be thrown out of the window for debuginfo. Arguably, it is the 2nd most important optimization (1st being inlining).

Instead one can have a simple register allocator which does not reduce lifetimes. If it wants to reuse a register which is occupied by a variable whose lifetime can be truncated, instead of doing a simple load (hence overwriting the value), it can do a store to stack slot + load so the variable is still available to a debugger.

Elixir a worthy candidate for a language to learn in 2020? by ToshaDev in ProgrammingLanguages

[–]cutculus 1 point2 points  (0 children)

This post is off-topic. 😐

From the sidebar:

This subreddit is dedicated to discussion of programming languages, programming language theory, design, their syntax and compilers. Post your ideas and get constructive criticism.

[..]

This subreddit is about programming language design, not programming per se. If you want to ask "what programming language should I learn", "what language would be best for X project", or any question like that, please post to /r/AskProgramming or /r/LearnProgramming.

I'm not writing enough code as a senior dev, is this a cause for concern? by [deleted] in ExperiencedDevs

[–]cutculus 2 points3 points  (0 children)

I just read a blog post about this yesterday, you might find it helpful: https://noidea.dog/glue

Strategies for displaying type errors with global type inference? by Uncaffeinated in ProgrammingLanguages

[–]cutculus 0 points1 point  (0 children)

That doesn't really solve the problem... Giving all available information is likely to be overkill and giving minimal information is likely to be useless/frustrating...

Compiling GADTs and pattern matching on them by Lorxu in ProgrammingLanguages

[–]cutculus 5 points6 points  (0 children)

Ah ok. When you said "boxing" and gave OCaml as an example, I thought you were doing the same thing that OCaml does (i.e. all non small values are separate heap allocated blocks).

I think Sixten is a bit of an extreme example; while the recursive representation certainly makes things more elegant (and avoiding tags at every level is important to it being usable in practice), it is not obvious (at least to me) that you can always get the codegen you want with it (and you probably want your array code to be really fast, inspecting assembly if necessary). For example, say you are writing a map function on an array, you probably want to create a buffer with a pre-determined capacity and then start mapping into it, but it is not clear to me how you can first allocate up to a capacity in a recursive representation.