4 ms·
Clojure is trying to do that with Clojure.spec and specifications being checked at runtime can get you closer to things you could have automatically proved corr
by scarface74 9y ago
Clojure is trying to do that with Clojure.spec and specifications being checked at runtime can get you closer to things you could have automatically proved correct only with languages with dependent types, nothing against statically typed languages but I feel that your sweeping generalizations hurt the point you are trying to make.
"Checking at runtime* is exactly the problem. Why would checking at runtime be more reliable than compile time?
- flavio81 9y ago>"Checking at runtime is exactly the problem. Why would checking at runtime be more reliable than compile time?* If you use metaprogramming (i.e. Lisp macros, Scheme/Racket macros, Clojure macros), then the only way to have truly reliable checks is at run time. In fact, for debugging and testing, it's much better to have a runtime able to do many things (such as live patching of the code). Contrary to a language like C or C++, where the compiler produces machine language from the source and then goes out of the picture, in most of the Lisp family languages your program runs along with the runtime; this runtime also contains the compiler itself and is usually big on features; it will not just catch the type errors, it will show you exactly all kind of important information about any, error and will allow you to correct the error if you like, without having to recompile and start again.
- deleted 9y ago[deleted]
- kazinator 9y ago> If you use metaprogramming (i.e. Lisp macros, Scheme/Racket macros, Clojure macros), then the only way to have truly reliable checks is at run time. That is a misconception. The macros output a target language and that can be checked. Plus macros can do their own checking before that. A macro expander can perform some static checks. In TXR Lisp, warnings about unbound functions and variables come from the macro-expanding code walk.
- scarface74 9y agoContrary to a language like C or C++, where the compiler produces machine language from the source and then goes out of the picture, I use C#. When you create a Linq expression, you get type safety and it "compiles to" an expression tree that is converted to its runnable form at runtime -- in my case a Sql statement, a MongoQuery, or C# code. It really comes in handy. Theoretically I could change my backing Store from Mongo/C# driver to Sql Server/EF without changing any of the queries. I do this all of the time when unit testing, I substitute an in memory list for a database table and still get complete type safety.
- kazinator 9y agoA run-time check will work even if the compiler has a bug which mistranslated the code or neglected to do a check.
- abhirag 9y agoIn addition to the points flavio81 made, checking at runtime because unless the language is dependently typed i.e. has types as first class citizens(for example Idris) a lot of the information about your code you want to prove to be correct is not available at compile time(for example, you have an integer but is it a non-negative integer, a list but is it sorted). It is not about being reliable, it is about being possible.