[Libre-soc-misc] Rust & correctness
Luke Kenneth Casson Leighton
lkcl at lkcl.net
Fri Dec 18 21:35:01 GMT 2020
On Friday, December 18, 2020, Jacob Lifshay <programmerjake at gmail.com>
wrote:
> The article compares/contrasts the http libraries from NodeJS,
yyeah that's about as helpful as comparing a plastic kid's bow and arrow to
a Sherman Tank and saying, "but look, they're both weapons, no really!"
however even there, the analogy is broken and flawed: making comparisons of
strongly typed languages against polymorphic ones then effectively saying
"strong typed languages are automatically better" entirely and completely
misses the benefits of both.
polymorphic languages have the huge advantage of being able to satisfy the
Liskov Substitution Principle *without* the need for the base class, older
(prior-written) or newer code to even know that the new variant satisfying
the LSP is even being used.
where for strong declarative languages, due to the strict typing it is
simply impossible to deploy LSP.... *unless the programmer has planned for
that in advance* at the base level of the API.
the disadvantage of LSP in polymorphic languages is that unless there
exists huge amounts of unit tests, even a simple change at the base level
(older code) can have massive damaging undetectable consequences [to which
a legitimate response is: what the bloody hell are you doing writing
library API code that doesn't have unit tests]
the advantage of strong declarative languages is that type checking detects
errors very easily with the compiler.
the *dis* advantage of strongly typed languages is also is advantage. the
complaints about Bluespec BSV were endless. the inconvenience of the
compiler refusing to let the developer do even the simplest and most basic
of operations severely hampered them and led to significantly increased
development time, most of which was reading and re-reading the PDF
containing the APIs, again and again and again.
the disadvantage of polymorphic APIs is, agsin, its advantage: the fact
that no errors are given until the function is executed means that code can
be written extremely quickly, but if the *programmer* does not catch an
error (and does not test it) they get no warnings.
in short, both approaches have advantages and disadvantages, and saying
categorically "one is better than the other" does both a huge disservice.
l.
--
---
crowd-funded eco-conscious hardware: https://www.crowdsupply.com/eoma68
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libre-soc.org/pipermail/libre-soc-misc/attachments/20201218/8b8526e8/attachment.html>
More information about the Libre-soc-misc
mailing list