4 ms·
Most programming languages but not all. Three prominent examples are Pascal which you mention, OCaml, and the POSIX `test`/`[` command which all use `=` for equ
by nequo 4y ago
Most programming languages but not all. Three prominent examples are Pascal which you mention, OCaml, and the POSIX `test`/`[` command which all use `=` for equality. (More specifically, for structural equality, in the case of OCaml.)
More intuitive to complete beginners and definitely not unheard of.
In mathematics, I have seen both `:=` and `\equiv` for assignment. But Go and Pascal also use `:=`. Of these, I would consider Go quite widely used in the industry.
- IshKebab 4y agoGo only uses := for declare & assign. For simple assignment it's =, and equality is still ==. So I would say it is barely different to the norm. POSIX `[` is clearly insane so let's ignore that. Which leaves Pascal and OCaml both of which are quite niche. I think he's right. It's definitely not worth going against the grain with this syntax, and it's debatable if it's even that bad in isolation. I seriously doubt beginners struggle with it.
- nequo 4y agoThis is textbook bikeshedding. If you have a bias for C syntax, everything else will look niche, weird, or "clearly insane" to you. But there's no reason that we should prefer C's syntactic decisions for assignment and equality operators in a non-C language. Go itself deviated from them, and the authors were instrumental to C itself.
- IshKebab 4y ago> But there's no reason that we should prefer C's syntactic decisions for assignment and equality operators in a non-C language. Yes there is - because almost every language uses the same convention, and it's a totally reasonable one. You have to have a really good reason to go against that and I don't see one. > Go itself deviated from them Go didn't deviate from the C convention. It just added an extra shorthand operator to simultaneously declare and initialise variables. The meanings of `=` and `==` are the same in Go as in C. > or "clearly insane" to you I wasn't saying the use of `=` for equality is clearly insane. `[` is clearly insane for other reasons.