Jump to content
IGNORED

Computer Science Corner


Recommended Posts

Guest hahathhat

i forget who said this, but it's apt: "perl assumes the programmer knows what he's doing."

 

that is, many things that would be a typo in another language mean something to perl... and there are always zillions of different ways to be cheeky with the syntax.

 

in short, yes, it is indeed a nightmare to read :braindance:

  • Replies 109
  • Created
  • Last Reply

Top Posters In This Topic

  On 4/2/2011 at 1:26 AM, inteeliguntdesign said:

Perl is okay. You can write it in the most fucked up way possible if you so desire though. Someone should learn Gobrainfuck and inform me how awesome it !

 

ftfy

  On 5/7/2013 at 11:06 PM, ambermonk said:

I know IDM can be extreme

  On 6/3/2017 at 11:50 PM, ladalaika said:

this sounds like an airplane landing on a minefield

Guest Adjective

derp!

 

  Reveal hidden contents

 

Guest Babar
  On 4/1/2011 at 11:50 PM, phling said:

so how will this enhance your ability to write software?

i don't think it has to do with code design, it's more like syntactic sugar or something..

yes. As I said, it could allow one to understand code a few deciseconds faster. Needs to be proved through. I won't use this newly defined 'unless' block though, as it doesn't get coloured by xcode's syntactic highlighter.

 

 

  On 4/1/2011 at 11:56 PM, hahathhat said:

have you tried perl, babar?

Yes. A few months ago I received a message from my german mate in skype: "do you want to have access to a botnet ?" "-yeah sure". he sent me some perl scripts he found on his server and within minutes i knew perl was a despicable language. It was just a 'silent' irc bot designed to retransmit messages to the shell. There was even the server's ip in the source, so i logged into it, changed my name to a bot-ish name (vm_072) and waited for orders to be given. Once i knew what the syntax was like, I browsed a few bots : mainly minor webservers. My mate dismantled the botnet or something.

 

I wouldn't have thought it was that easy to set up a botnet. I have some kind of adage about programming : "it's always simpler than it seems to be". It's the opposite for natural languages though.

  • 2 weeks later...
Guest Babar

I'm currently programming in objective-c, and I have several options :

NSRect previousFocusedRect;  //initialized as an NSZeroRect.
NSArray previoyusFullyVisibleRects  //initialized as an Array with a size of 0.

 

 

void myFunc() {

....//blablabla

....if ( NSEqualRects(previousFocusedRect, NSZeroRect) || [previousFullyVisibleRects count] == 0 ) {
........previousFocusedRect = focusedRect;
........previousFullyVisibleRects = fullyVisibleRects;
....}

....//some more blabla

....previousFocusedRect = focusedRect;
....previousFullyVisibleRects = fullyVisibleRects;

}

 

or

 

 

void myFunc() {

while(1) {

....//blablabla

....if ( NSEqualRects(previousFocusedRect, NSZeroRect) || [previousFullyVisibleRects count] == 0 ) {
........break;
....}

....//some more blabla
....break;
}

....previousFocusedRect = focusedRect;
....previousFullyVisibleRects = fullyVisibleRects;

}

 

or

 

void myFunc() {

....//blablabla

....if ( NSEqualRects(previousFocusedRect, NSZeroRect) || [previousFullyVisibleRects count] == 0 ) {
........goto endOfMyFunc
....}

....//some more blabla

....endOfMyFunc:
....previousFocusedRect = focusedRect;
....previousFullyVisibleRects = fullyVisibleRects;

}

 

To me, the last solutions looks like the best solution, but i've heard using goto statements is wrong. Is it in this case ?

Edited by Babar
  On 4/11/2011 at 9:19 AM, Babar said:

To me, the last solutions looks like the best solution, but i've heard using goto statements is wrong. Is it in this case ?

 

You could negate the condition of the if-statement, which would eliminate the need of the goto or the need of duplicate code. Using goto statements can indicate that you're doing it wrong, but that needn't be the case. Check this old article by Donald Knuth about how structured programming with gotos isn't a contradictio in terminis. It's a fun read.

Yo, my name is Saad and I don't give a fuck.

Anyone care to explain good usage of try catch blocks? My programming friend said it's for writing lazy code, but sometimes appropriate. So... When is it appropriate?

Catching errors is not lazy. They can be used lazily in an environment where exceptions will always be shown to the user unless you catch them (often done with an empty catch body.)

 

Exceptions are a very good way to catch errors and use fallbacks or warn the user something has gone wrong. What I really like about exceptions is that they bubble up until catched. (may not be true for all languages)

 

The classic example is file opening ofcourse:

try {
   new File("/path/to/file").createNewFile();
} catch (IOException e) {
   System.out.println("Unable to create file: "+e.getMessage());
}

Not catching this error can be a bad thing, but way, way worse is catching it with an empty catch body.

Edited by Ego
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.

  • Recently Browsing   1 Member

×
×