Guest hahathhat Posted April 2, 2011 Report Share Posted April 2, 2011 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 Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1549625 Share on other sites More sharing options...
Guest inteeliguntdesign Posted April 2, 2011 Report Share Posted April 2, 2011 Perl is okay. You can write it in the most fucked up way possible if you so desire though. Someone should learn Go and inform me how awesome it ! Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1549690 Share on other sites More sharing options...
kaini Posted April 2, 2011 Report Share Posted April 2, 2011 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 Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide kaini's signature Hide all signatures 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 Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1549691 Share on other sites More sharing options...
Guest Adjective Posted April 2, 2011 Report Share Posted April 2, 2011 derp! Reveal hidden contents #include <stdio.h> void printy(int hi_lo, char ch) { if(hi_lo == 0) { for(int c = 31; c <= 37; c++) { printf("%c[%d;%d;%dm%c ", 27, 0, c, 40, ch); } } if(hi_lo == 1) { for(int c = 37; c >= 31; c--) { printf("%c[%d;%d;%dm%c ", 27, 0, c, 40, ch); } } } int main(void) { for(int a = 0; a <= 5; a++) { int b[] = {32, 66, 85, 77, 80, 32}; printy(1, ':'); printy(0, '|'); printf("%c ", b[a]); printy(1, '|'); printy(0, ':'); printf("\n"); } printf("%c[%d;%d;%dm",27,0,37,40); return 0; } sorry Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1550043 Share on other sites More sharing options...
Guest Babar Posted April 2, 2011 Report Share Posted April 2, 2011 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. Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1550109 Share on other sites More sharing options...
Guest Babar Posted April 11, 2011 Report Share Posted April 11, 2011 (edited) 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 April 11, 2011 by Babar Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1556582 Share on other sites More sharing options...
ericsosh Posted April 11, 2011 Report Share Posted April 11, 2011 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. Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Hide ericsosh's signature Hide all signatures Yo, my name is Saad and I don't give a fuck. Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1556609 Share on other sites More sharing options...
Guest El_Chemso Posted April 11, 2011 Report Share Posted April 11, 2011 At my uni you get marked down for using Gotos. They say they are good for error message directing as you can keep all the error messages in one place then. Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1556642 Share on other sites More sharing options...
kcinsu Posted April 11, 2011 Report Share Posted April 11, 2011 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? Thanks Haha Confused Sad Facepalm Burger Farnsworth Big Brain Like × Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1556902 Share on other sites More sharing options...
Ego Posted April 11, 2011 Report Share Edit Hide Delete Posted April 11, 2011 (edited) 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 April 11, 2011 by Ego Quote Link to comment https://forum.watmm.com/topic/64335-computer-science-corner/page/5/#findComment-1556916 Share on other sites More sharing options...
Recommended Posts