3 ms·
It would be interesting if you could have a hybrid somewhere between Pascal and Python, where you could start just naming variables, and the compiler could fill
by mikewarot 5y ago
It would be interesting if you could have a hybrid somewhere between Pascal and Python, where you could start just naming variables, and the compiler could fill the types in once the code was complete, then you could iterate and tweak.
You'd end up with fast greenfield code to get your prototype working, but then could tighten it up to run faster, and clear out bad type assumptions as the discipline level goes up.
- goodpoint 5y agoYou are looking for Nim
- pjmlp 5y agoNot quite what you mean, but still, you might find interesting the talks on how to approach coding in languages like Idris, where the compiler is able to support the editor in type suggestions. https://www.youtube.com/watch?v=DRq2NgeFcO0 https://www.youtube.com/watch?v=DRq2NgeFcO0
- rz2k 5y agoSomething like OCaml?
- Zababa 5y agoTo 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.
- dmitriid 5y ago> The type inference is great, so you usually don't have to write any types Does OCaml still have the infuriating "Provided A but elsewhere wanted B" error with no indication what this elsewhere is? I was running into it surprisingly often when I last tried OCaml.
- Zababa 5y agoI 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.
- jabl 5y agoIt'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..
- Zababa 5y agoMulticore 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.
- pietroppeter 5y agoNim
- erik_seaberg 5y agoExplicit typing hurts the signal:noise of the code. I’d like to have invariants and pre/post-conditions, inferred or verified where possible, visually separated from the expressions that do the important work (comments to the right, a block below the body, whatever).