To expand a bit on the sibling post, this is basically OCaml's niche. The type inference is great, so you usually don't have to write any types (not even in functions signatures like Rust). The language has support for functional, modular, imperative and object-oriented programming. Usually you start with functional code, that's plenty fast (especially compared to Python) since it compiles to binaries, but still optimized for readability. You also have a fast bytecode compiler for a faster development loop. When needed, you can switch over to imperative code and mutable variable for performance, OO for GUI work for example, and modules when defining interfaces between parts of your program.
You can also do the opposite of what you suggest: start by writing the interface file (which has the functions and types that you will expose), and then write the implementation the way you want. This allows you to cleanly separates the API from the implementation, and also gives you fast compilation times.
There may be a slight difference compared to what you suggest, as everything is statically typed, but you can start a program with permissive types and gradually move on to stricted typed. For example, replace a string that can be anything with an enum (called variant types in OCaml).
If you don't need the native compilation/want the C# ecosystem, F# is a close cousin. Scala is a different beast, but shares some origins. It relies more on objects.
It's a shame OCaml never became more popular. The language itself seems pretty fine (in my limited experience), but with popularity there would be more libraries available. And maybe if multicore OCaml would have been a thing a decade ago..
Multicore wasn't a real blocker, JS is single threaded too and everyone is fine with it. OCaml runs circles around Python and Ruby, yet they are more used.
I didn't encounter the error myself for some time, but I don't know if it's because the language improved or I myself improved, so I can't give you a straight answer.
You can also do the opposite of what you suggest: start by writing the interface file (which has the functions and types that you will expose), and then write the implementation the way you want. This allows you to cleanly separates the API from the implementation, and also gives you fast compilation times.
There may be a slight difference compared to what you suggest, as everything is statically typed, but you can start a program with permissive types and gradually move on to stricted typed. For example, replace a string that can be anything with an enum (called variant types in OCaml).
If you don't need the native compilation/want the C# ecosystem, F# is a close cousin. Scala is a different beast, but shares some origins. It relies more on objects.