Exploring a little bit of language safety
rust | ||
README.md | ||
test.js | ||
test.py |
I read an article recently that described an attempted back door in the Linux kernel and it got me thinking about language safety.
First I tested beloved Rust:
cargo run
error[E0308]: mismatched types
--> src/main.rs:3:8
|
3 | if ligma = 4 {
| ^^^^^^^^^ expected `bool`, found `()`
|
help: you might have meant to compare for equality
|
3 | if ligma == 4 {
| +
For more information about this error, try `rustc --explain E0308`.
error: could not compile `linux_03_backdoor_test` (bin "linux_03_backdoor_test") due to 1 previous error
of course it threw a fit.
Next up is Python:
python test.py
File ".../test.py", line 3
if ligma = 4:
^^^^^^^^^
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
Python caught it.
Next, JavaScript:
node test.js
4
This is why I hate JS.
Yes I am aware of linters but that's not the point. Make it impossible by design.