5 ms·
This is far from true. > 1 Restrict to simple control flow constructs. Details give the precision : no recursion allowed. Functional languages are out, there.
by sacado2 11y ago
This is far from true.
> 1 Restrict to simple control flow constructs.
Details give the precision : no recursion allowed. Functional languages are out, there.
> 2 Give all loops a fixed upper-bound.
Func languages give no warranty on that either.
> 3 Do not use dynamic memory allocation after initialization.
You have no access to memory layout, but func languages heavily rely on the creation on-the-fly of data and rely on garbage collection (which is forbidden, too).
> 4 Limit functions to no more than 60 lines of text.
> 5 Use minimally two assertions per function on average.
> 6 Declare data objects at the smallest possible level of scope.
> 7 Check the return value of non-void functions, and check the validity of function parameters.
OK, that might be easier with func languages.
> 8 Limit the use of the preprocessor to file inclusion and simple macros.
Not relevant
> 9 Limit the use of pointers. Use no more than two levels of dereferencing per expression.
OK, no pointer manipulation with these languages.
> 10 Compile with all warnings enabled, and use one or more source code analyzers.
Name one professional code analyzer for any func language of your choice.
- lectrick 11y ago> Details give the precision : no recursion allowed. Functional languages are out, there. > Func languages give no warranty on that either. Actually, what you can do in this case is when you call recursively, pass back an incremented counter variable as part of the state, and if it passes some upper limit, handle it appropriately. You don't need to "avoid recursion" just to get control over the number of times something loops. > and rely on garbage collection (which is forbidden, too) Fair enough, but if I work in a language that doesn't even give me much control (if any) over the GC, then how is this relevant to non-C coders, again? Which was my original point. > Name one professional code analyzer for any func language of your choice. Erlang (and by association Elixir) has Dialyzer http://www.erlang.org/doc/man/dialyzer.html http://www.erlang.org/doc/man/dialyzer.html which is a static code analyzer. Static code analysis has been endorsed by John Carmack (and of course, all the 3 year old links to the blog post are now dead, sigh) For anyone (like me) who is hooked on Elixir, https://github.com/jeremyjh/dialyxir https://github.com/jeremyjh/dialyxir provides a bit of easier Dialyzer management Elixir (and I suppose Erlang) has this concept of "specs" which you don't have to use, but which help code analysis if you do... http://elixir-lang.org/docs/v1.0/elixir/Kernel.Typespec.html http://elixir-lang.org/docs/v1.0/elixir/Kernel.Typespec.html
- sacado2 11y ago> Fair enough, but if I work in a language that doesn't even give me much control (if any) over the GC, then how is this relevant to non-C coders, again? Which was my original point. This is relevant to users of assembly, forth, C++, Fortran, Ada, Rust and probably a few others. Beside the very last one (which is way too young), these are the languages embedded developers used most of the time, precisely because of their virtues regarding the 10 points in the original post. I have to agree with you, though, regarding this list functional languages are probably as good as, or even better than most other high-level languages, but they clearly fail on most requirements. Thanks for the reference about Dialyzer, I'll check it out.