[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Say No to global-by-default
- From: Petri Häkkinen <petrih3@...>
- Date: Wed, 4 Jul 2018 10:39:16 +0300
The last time I checked our work in progress codebase of a game project had about 2000 global functions. Nothing wrong with them. Actually, it’s pretty handy to be able to live update any of them. Plus autocompletion, ref browsing and other IDE must-haves work out of the box because there’s no renaming / namespacing going on.
”globals are evil” usually refers to mutable global state. We have that too, although we try to avoid it if possible (grouping global vars into namespaces helps).
With this backstory you probably understand why having to prefix every global with $ would make our eyes hurt...
I also think typos in variable names are pretty easy to find and fix. On the other hand when doing large refactorings to the codebase, some sort of optional static type checking for function args and automatic type inference for vars would be very useful. A much more difficult problem unfortunately...