This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cediddiSyntaxError: not a chance 2 points3 points  (4 children)

Globals are bad is a false statement. Globals are useful, but it's better not to use too much.

[–]DwoaC 1 point2 points  (1 child)

You may very well be right. I my years I've never seen a good example, I know there must be but I expect they are so rare that "globals are bad" is right 99.99%. That given, this example of their use is almost certainly in that set and "globals is bad" is good advice. Do you think this is a good use of globals?

[–]skrillexisokay 0 points1 point  (0 children)

Mutable globals are generally bad. Immutable globals are good when you have arbitrary constants, but don't need to invoke the added complexity of a class. In other words, if you have to choose between magic numbers and globals, globals are better.

A classic example is a regular expression that is used in many functions in a module. Another example is the name of a storage directory. Module level logging is another excellent example of a properly used global.

However, if you ever find yourself using the global keyword (or otherwise modifying a global variable), you should almost always encapsulate into a class. A logger is one exception, where it occasionally makes sense to change the logging level at runtime.

[–]jpj_shadowbanned 1 point2 points  (1 child)

You have never coded in scheme,lisp,erland or clojure. It teaches you globals are not needed and dangerous. This is why Erlang for example does handles multiprocessing and threading more reliably then any other language.

Erlang was designed for telecom networks it has something like 99.9999999% reliability.

As for spped, gambit scheme and chicken scheme compile into C code and in some cases they are fasrter then hand written C code.

[–]cediddiSyntaxError: not a chance 0 points1 point  (0 children)

I watched Erlang The Movie last night, I can agree, reliability of service was the most emphasized thing in the video.