Providing JavaScript Developers Helpful Type Errors When They Call Your ReScript Library Incorrectly

Introduction

You can’t use ReScript to call ReScript incorrectly because the compiler will help you make it correct. You can’t use ReScript to call JavaScript wrong because the compiler will help you make it correct.

However, when JavaScript calls your ReScript library, it can do it incorrectly because JavaScript has no compiler; you just run it. This can ruin all the benefits of ReScript: null pointers, runtime errors, and super strange internal ReScript standard library errors that make no sense with stack traces that are not helpful.

Instead, the better thing to do is check the types at runtime, and if wrong, provide helpful runtime errors with what the JavaScript developer needs to do to fix the error. If you’re a ReScript developer providing libraries for JavaScript developers, this article is for you.

Continue reading “Providing JavaScript Developers Helpful Type Errors When They Call Your ReScript Library Incorrectly”

I Hate My Code Again


Good news, I hate my code again.

In 2005 I stopped hating the code I wrote. I felt I had reached a milestone in my career. After 5 years, I one day looked at some code I wrote 6 months ago and went “Man… I actually like this, and can understand it!” That often never happened. My gut instinct was to just rewrite. Suddenly I could start using things I wrote awhile ago in new projects, with confidence and only minor modifications.

Yesterday, rewriting an SDK I wrote 4 years ago, and I would not write it like that today. That tells me I’ve made a lot of progress and changed in 4 years. Skill progress! 😁

I’m glad I keep the tactic I had in 2005, and that’s just keep doing what I’ve been doing and keep improving.