Jump to content
Science Forums

Developer Woes: Quirks of Programming Languages


saidevo

Recommended Posts

Uhm, but... an instance allocated by new ain't a global! A static member of a class is a global except that it's in the class'es namespace. BTW when I do a certain type of quick coding I just adore declaring globals galore :hyper:, more efficient and less worry of having to pass values around in parameters!

 

C/C++ were certainly concieved a touch more for monolithic programming but it's not just a matter of late linkage, that's even somewhat a platform issue which the JVM makes standard for Java. There's an old legend that elderly programmers are in the habit of calling the linker the "loader" which suggests something to me... :steering:

Link to comment
Share on other sites

yeah i wanted to post but it was late yesterday, you are better off using a gcc based compiler for any c++ development then the VS, at least gcc is standard compliant, and generates cleaner code then VS, there is less junk to deal with and most code online (for windows) will compile on something like DevCpp and will most likely fail with VS cuz their total incompliance with the standards...

I personaly prefer PHP to Java, cuz you can do more stuff, and many times a lot better and faster with PHP rather then Java, its a total hybrid so it makes the best of 2 worlds, oh and it has a perl regular expression engine, which is crazified, makes dealing with text not such a bad thing, and there is less of an overhead with PHP's engine vs JVM... but i'm sure buffy was expecting me to say that :confused:

 

Oh and dammit people, learn not to use globals, they are such weak points in your programs, unless totally needed it is a bad programming practice to do it, so dont unless totally needed...

Link to comment
Share on other sites

Uhm, but... an instance allocated by new ain't a global!
Well not techincally, but if you just start off object-orientedly, you've got your main program instance and anything in there is global to everything that is inside it, so its uh, "global" for all intents and purposes... :hyper:
C/C++ were certainly concieved a touch more for monolithic programming but it's not just a matter of late linkage...
Well, yeah, you'd need to change the calling protocol, but that *is* a compiler/linker issue, and you'd be cutting yourself off from being able to link old libraries, but I say, so what?
and there is less of an overhead with PHP's engine vs JVM... but i'm sure buffy was expecting me to say that
Of course! But with all this horsepower, who cares about efficiency? I'm usually I/O bound on the db access anyway... :confused:
Oh and dammit people, learn not to use globals
Oh amen alex!

 

Globals considered harmful,

Buffy

Link to comment
Share on other sites

Right Alex, globals are a pain in the neck in a complex project, 'specially if names are obscure, for analysing previous code, including your own from years back, but when you're talking about one instance values that are central to the whole project and need to be used by many functions, passing them around in parameters can be no better if not worse.

 

A parameter is itself local to the proc if it isn't a ref but, in any case, who is it really? :hyper: You often need to trace through the call stack to be sure and of course that might not be the same for all possible calls. Old saying: it's 6 of 1 & 1/2 dozen of the other... :confused:

 

you've got your main program instance and anything in there is global to everything that is inside it, so its uh, "global" for all intents and purposes...
But that doesn't make for nearly as easy access as does a static member of some class, which may even be ad hoc for global variables and even an interface for global constants. It's enough for any class to import these, you don't need to have a valid pointer, the class name is enough and, if it's long and needed more than once, I usually declare:

 

GlobalVariables glb;

 

without even assigning anything to it, you can write glb.totRequestsPending or whatever. :singer:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...