diff options
| author | Richard Metzler <richard@paadee.com> | 2018-12-23 21:39:18 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-12-23 21:39:18 +0100 |
| commit | 1df16842d2b825aebbebb1d89f3e66308dd1df43 (patch) | |
| tree | 876317059066008475abd740e34955c4daa2998a /README.md | |
| parent | 661bfb00501b7db5385e444a07b9cd9f2dac6352 (diff) | |
Syntax highlighting
Also I think Go has the better error handling. Because it is only one and it is supposed to be next to the fallible Operation.
Last time I counted there were at least these methods to signal an error in JavaScript:
- a return value indicating the error, sometimes as magic number (null or -1)
- throw an Exception
- an error callback function, which is totally dependent on the framework you use
You didn't handle any errors in your JavaScript example, because you aren't forced to.
In Java, there are Exceptions, but calling code isn't forced to handle unchecked RuntimeExceptions and Errors. And if you handle Exceptions wrong - and there are so many ways to do this, like swallowing or rethrowing without the root cause, you'll need much time to look into your production issues.
Go code is explicit and requires the programmer of the calling code to recognize the possibility something might be slightly wrong in some computer sometime. You're still allowed to ignore this warning by using `_` in `a, _ := fallibleOperationA()`, but it is much better and also cheap if your editor has snippet support to just type `ife`and hit tab and atom is expanding it to:
```go
if err != nil {
return
}
```
Diffstat (limited to 'README.md')
0 files changed, 0 insertions, 0 deletions
