Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

How are people still making the classic `foo`/`foo_safe_version` mistake? In a supposedly modern language. And they didn't even name the safe version clearly! If the rest of Nim is designed on this level then I hope it never succeeds.

Note that Rust got this exactly right. assert, debug_assert. Clear and fail-safe.



I don't understand, what's wrong with assert and doAssert?

They are both enabled in release AND debug modes. You would have to explicitly compile code with -d:danger flag to disable any assertions.

> And they didn't even name the safe version clearly!

In this context safe version is clearly named as "release" mode, and unsafe one is even more clear - "danger" mode. "danger" obviously implies it should be used with caution.


Ok I guess we've all got to learn it at some point. Maybe there should be some kind of test of lessons that "the industry" has learnt for new people. Anyway...

1. There's no semantic different between `assert` and `doAssert`. Does `assert` not "do" the assert? Of course it does. The names are meant to communicate what the functions do, and these fail. It should be called `assert` and `always_assert` or something....

2. Except that it shouldn't because the "obvious" one to use (`assert`) should be the safest. People don't always read the manual (including you) and they sometimes make mistakes (yes, including you), so the default actions should be safe. Danger should be opt-in, not opt-out-if-you-happen-to-know-you-have-to.

That's why it's `assert`/`debug_assert` not `release_assert`/`assert`.

There are a couple of famous examples where they got it completely wrong: Python's YAML library has `load` and `load_safe`. MySQL has `escape` and `real_escape`. There's probably more.


> There's no semantic different between `assert` and `doAssert`.

There is a difference, but I agree that it's very subtle. In english do before a verb adds an emphasis so it's like "assert assert" or "really assert" put in a short easy to type form.


Any subtle difference you might be imagining is completely unrelated to the actual difference between them, and there's absolutely no way you could infer that difference.

They very clearly chose `doAssert` because they already had `assert` and couldn't think of a good name for a second similar-but-different kind of assert.


The names do not communicate what's happening and when. Do assert and assert, what's the difference? Something like debugassert and alwaysAssert would be much more understandable


Nim is my anti-language... I'd make the opposite language design choice in almost every instance.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: