Language:
switch to room list switch to menu My folders
Go to page: First ... 105 106 107 108 [109] 110 111 112 113 ... Last
[#] Mon Jan 12 2015 15:33:41 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


I think that answers my question.

I figured that the PHP engine has to include the file, interpret what it included (which involves the stuff that you don't intend for the consumer of a library to use as well as the stuff the consumer will use), and make any functions within the included file available to the consumer.

So, hmmm... the next bit is knowing if it takes more processing power to read a new file in than to have a bunch of extra stuff in the included file.
Or, rather, more time ... processing power might be even less, but the file itself might take more time because of having to stat it, read the file in, etc.

It's just a whole side of things I haven't had to think about until now.
With a compiled language, you know that the compiler has done some up-front work in dealing with all this stuff, and the output is something that's kind of streamlined to do what you need. Not exactly the same with a scripting language, where an interpreter has to parse everything in advance.

[#] Tue Jan 20 2015 13:06:39 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


ProTip:

Recursive functions tend not to come all the way back down the stack if they have a statement like "sys.exit(0)" in them.

<< SMH >>

I spent half a day rewriting code and ultimately wondering whether Python actually has recursion before finding that I had put that trace point in my function. /me needs either more coffee or less, dunno which...

[#] Tue Jan 20 2015 14:17:42 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


As a general rule, I avoid exit() statements, preferring to use block structures and whatnot, for reasons like this.

Unfortunately, apparently, in PHP, using nested blocks is discouraged according to a popular standard of style used by that community, as they regard nested blocks as 'difficult to read'.

I disagree, but conform to their standards when working with others.

[#] Tue Jan 20 2015 15:43:09 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

All true, but in this case I had put the exit() statement in there two days ago because I had wanted the program to stop cold dead after printing out some traces. It was a dummy mistake.

[#] Tue Jan 20 2015 16:14:59 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


Heh... I expect it stopped cold dead rather nicely.

[#] Tue Jan 20 2015 17:26:28 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Yes. In Python the official syntax is "import maxwell_silver_hammer"

[#] Thu Jan 22 2015 19:23:45 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Recursive functions tend not to come all the way back down the stack

if they have a statement like "sys.exit(0)" in them.

<< SMH >>

I spent half a day rewriting code and ultimately wondering whether
Python actually has recursion before finding that I had put that trace

point in my function. /me needs either more coffee or less, dunno
which...

You'reDoingItWrong(tm). Sys.exit(1) in Python is implemented as an exception throw. So it's actually the perfect with to terminate a recursion. Catch SysExit or whatever they call it, and you're golden. <snirk>

[#] Fri Jan 23 2015 07:20:04 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

That's brilliant. Of course, if I had written the program in JavaScript I could have replaced sys.exit() with

throw "yo dawg, I heard u liek trace messages FIXME YOU IDIOT";

[#] Thu Jan 29 2015 16:27:13 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

You'reDoingItWrong(tm). Sys.exit(1) in Python is implemented as an
exception throw. So it's actually the perfect with to terminate a
recursion. Catch SysExit or whatever they call it, and you're golden.


I've since switched to throwing exceptions when I want the program to come to a screeching halt.

The only problem is, Python doesn't allow you to throw an exception.

throw Exception("foo")

doesn't work. You can't throw an exception; you have to RAISE an exception.

F--k that ... ! If I want to throw an exception, I'm going to throw an exception!
Even if it's just an exception thrown from the fact that there's no "throw" command!

Having lived mostly in the C world for decades, though, I can see already that exception handling justifies all sorts of sloppy programming practices.
Why write good code when you can just wrap the whole damn thing in an exception handler?

[#] Fri Jan 30 2015 02:11:49 EST from ax25 @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

[#] Fri Jan 30 2015 08:29:39 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


I used to think exceptions were the bomb.

Now I just think they're a bomb. I prefer more explicit error handling with return codes or the like. I hate having the flow interrupted randomly by who-knows-what deep in the layers of hell.

I guess it has its place, though... I just haven't quite decided for myself where that place should be.

[#] Fri Jan 30 2015 09:15:16 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


I just read a question that kind of blows my mind.

"I don't understand why cURL come into play? I thought this was using rest?
is cURL a type of rest client?"

(I copied the question literally, punctuation and capitalization errors and all).

That last question blows my mind. Is cURL a type of REST client?

It's one of those questions that exposes what feels like a fundamental misunderstanding of several subtle but important concepts. I'm thankful someone else answered it for him, because I'm not sure how I would have started without coming across as a jerk.

How does that question feel to you guys?

[#] Fri Jan 30 2015 10:12:49 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Well, I used exception for that, and re-threw it enriching the error message all the way up the stack; Else you would have to keep some string some where... so exceptions make it more nice.



[#] Fri Jan 30 2015 10:37:27 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

cURL is the correct capitalization. However, the phrase "REST client" sounds like someone doesn't really understand REST.

He/she/it should be using libcurl, not the cURL "client"

[#] Fri Jan 30 2015 14:46:01 EST from LoanShark @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Why write good code when you can just wrap the whole damn thing in an

exception handler?

Been dealing with our Junior Dev(tm) who did just that, this week. No, you can't just write crap in the exception handler and assume that it will never be hit.

[#] Sat Jan 31 2015 18:57:25 EST from fleeb @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]


To be clear, I knew cURL is spelled correctly, however 'is cURL a type of rest client?" has a variety of capitalization problems, which is more along the lines of what I meant about preserving the original. I wasn't making fun of the person's English skills, or even meaning to comment on them, only to indicate that those were not my errors.

[#] Sun Feb 01 2015 07:41:26 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

[#] Mon Feb 02 2015 23:52:44 EST from ax25 @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Like the humor on the right side of the page here:

http://jshint.com/about/

Thanks dothebart.  I will check it out and share it with my co-workers.  I always wondered if a lint tool for javascript would be possible with its syntax :-)



[#] Thu Feb 05 2015 08:44:17 EST from dothebart @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

any of you interested in valgrind these slides may be of interest.

                  https://fosdem.org/2015/schedule/track/valgrind/



[#] Sat Feb 07 2015 15:08:23 EST from IGnatius T Foobar @ Uncensored

[Reply] [ReplyQuoted] [Headers] [Print]

Been dealing with our Junior Dev(tm) who did just that, this week. No,

you can't just write crap in the exception handler and assume that it

will never be hit.

Actually I was thinking the other way around -- that exception handlers can encourage sloppy code because any oddball conditions would cause the handler to cleanly return an error instead of crashing the whole program.

Go to page: First ... 105 106 107 108 [109] 110 111 112 113 ... Last