8 ms·
Several things make it easier to maintain: - super fast compile times for fast developer iterations - you can create an interface (set of methods) that your m
by SpikeGronim 12y ago
Several things make it easier to maintain:
- super fast compile times for fast developer iterations
- you can create an interface (set of methods) that your module owns, and apply it to objects created by other modules without recompiling. If you only need one method you can take that one. It encourages decoupling you from your dependencies.
- the code has one correct formatting convention and a tool that will auto-format your code
- many complex rules for numeric conversions that are implicit in C and cause no end of trouble are explicit and much simpler in Go.
- treating concurrency as a series of sequential process connected with channels makes it MUCH easier to reason about.
- Pxtl 12y agoDon't the first 3 apply just as well to python? It compiles fast, and is duck-typed so interfaces are always there and implicit, and the indent-based blocking ends many arguments about formatting.
- dekhn 12y agothe difference is that if you're not careful when you cut-paste indented blocks in python, you can easily change logic.
- mau 12y agoIf you cut and paste probably the misaligned indentation is the least problem. Cut and paste should be avoided if it's not done during a refactoring (so actual moving of code for better design). Beginners usually think Python strong indentation is a weakness of the language. I actually find C++ freedom being more error prone: if (a < b); a = b It's a not very frequent bug, but when it happens it takes you hours to spot. ;)
- maxiepoo 12y agoYes and in Go (and hopefully all curly-brace languages of the future) this is actually a syntax error, you need the braces: if (a < b) { a = b; }
- gnur 12y agoAnd you don't need the semicolons!
- TylerE 12y agoThe thing I don't get...if braces are mandatory (Good), why keep the now completely, unambiguously, irrelevant () around the cond?
- deleted 12y ago[deleted]
- CasualSuperman 12y agoThey're actually not required in Go.
- wtbob 12y agoYou don't need those parens in Go, and go fmt will in fact remove them/
- kyrra 12y agoIf you ran the code through gofmt, it would remove the () around the cond for you. I code go in SublimeText with GoSublime. On every save it runs the file through gofmt and reformats it for me. Keeps my code looking pretty with very little effort.
- dekhn 12y agoThis would never happen to me because I frequently format my doc, and it wouldn't be indented.
- Artemis2 12y agoPython executes, it does not compiles. EDIT: Whoops, it's actually compiled into bytecode then executed by the VM.
- the_paul 12y agoThis is not true.
- runjake 12y agoAs the_paul said, this is incorrect. https://en.wikipedia.org/wiki/Python_(programming_language)#Implementations https://en.wikipedia.org/wiki/Python_(programming_language)#...
- mimighost 12y agoIt actually "compiles" into bytecode, then consumed by the interpreter.
- Pxtl 12y agoit's generous to call the CPython interpreter a VM - the binary encoding of Python isn't some crazy IL bytecode, its' really just python-as-binary. Language constructs converted into opcodes, strings with pre-calculated hashes, and local variables within a scope become a sort of vector... but otherwise, it's a prettymuch 1:1 mapping between Python language constructs and the bytecode form.
- hyp0 12y agoI thought you had meant that Go was "easier to maintain" than python - most of these don't apply to Python: Python has faster compilation times (0); interfaces without recompiling; formatting conventions; and numeric conversions is compared explicitly with C. Channels is the only one that applies to python.
- rakoo 12y agoMaybe he meant that having a typed language that is checked at compilation time is a huge plus for maintenance, and the usual downsides that come with compilation (mainly slowness) are pretty much inexistant with Go.
- TylerE 12y agoAs some who generally prefers Python to Go quite strongly, the formatting situation is no where NEAR equivalent. With go it's trivial to setup your editor to perfectly reformat every time you save, or even on carriage return, and it does in a way that is 100% consistent and will never alter the logic of your code.
- sergiosgc 12y agoI'm not a python expert by any measure, but I've written a couple small projects with it. Python surprises for how well documented it is. In this specific case, PEP8 lays down most formatting conventions, so you'd expect some tooling to be available. Is this not the case? A quick Google search brought up this, for instance:https://bitbucket.org/StephaneBunel/pythonpep8autoformat https://bitbucket.org/StephaneBunel/pythonpep8autoformat
- NateDad 12y agoThe thing is, while this kind of thing is available for pretty much every language, it is standard for Go. As in, if you don't gofmt your code, everyone who looks at it will bug you to format it. That's a huge difference. There's basically zero code in the wild that you'd ever want to use that /isn't/ gofmted.