|
FamDav posted:Awesome post. You should write for an MRA newsletter. Yeah , probably not the best way of putting it. Fair point.
|
# ? Mar 6, 2014 18:35 |
|
|
# ? May 19, 2024 08:25 |
|
I'm an undergrad on a systems track and I've never done anything besides assignments and projects for classes (all of them in either C or C++11). I'm about to finish a class on operating systems implementing Pintos, and while it's fun and challenging, I have zero ideas about what I can do to feel less worthless as a programmer in the real world. Any advice?
|
# ? Mar 6, 2014 21:58 |
|
UnfurledSails posted:I'm an undergrad on a systems track and I've never done anything besides assignments and projects for classes (all of them in either C or C++11). I'm about to finish a class on operating systems implementing Pintos, and while it's fun and challenging, I have zero ideas about what I can do to feel less worthless as a programmer in the real world. Any advice? get an internship.
|
# ? Mar 6, 2014 22:44 |
|
UnfurledSails posted:I'm an undergrad on a systems track and I've never done anything besides assignments and projects for classes (all of them in either C or C++11). I'm about to finish a class on operating systems implementing Pintos, and while it's fun and challenging, I have zero ideas about what I can do to feel less worthless as a programmer in the real world. Any advice? Find something interesting on GitHub and fix an outstanding task. Working in other people's code is an important skill, as is going through code review. The Awful iOS app could be a good place if you're into that.
|
# ? Mar 7, 2014 01:00 |
|
jesus, shrughes has a lot of alt accounts
|
# ? Mar 7, 2014 02:06 |
|
What. How many do I have?
|
# ? Mar 7, 2014 02:56 |
|
tbf if you want to work on a good app you should probably avoid awful
|
# ? Mar 7, 2014 03:16 |
|
shrughes posted:What. How many do I have? I'm beginning to think suspicious dish may be a gimmick account and announcing suspicions of people having alt accounts is the gimmick.
|
# ? Mar 7, 2014 03:36 |
|
Suspicious dish is shrughes antagonizing himself
|
# ? Mar 7, 2014 03:41 |
|
My alt account is sarehu FYI. Lost its password years ago.
|
# ? Mar 7, 2014 03:42 |
|
FamDav posted:tbf if you want to work on a good app you should probably avoid awful Working on good code isn't really the norm, honestly even for me dealing with my own previous stuff. Builds character, or something. Tip, though: if you see pthread_* just back away. Life's too short for raw shared-state multithreading.
|
# ? Mar 7, 2014 03:42 |
|
code:
|
# ? Mar 7, 2014 03:45 |
|
shrughes posted:
Yeah, it's probably too late for you, and someone has to do the dirty work, but if you're looking for something to get started on raw POSIX threading is not a sign of joy. Don't get me wrong, I've done my time (even with linuxthreads, may it rest in agony), I just don't wish it on people. Too many guns for so few feet.
|
# ? Mar 7, 2014 03:55 |
|
I've been working primarily in C89 on a variety of embedded platforms for about three years now, and I want to pick up modern C++ for more "normal" systems programming; I haven't touched C++ since before the C++11 standard came out, and I'm rusty in general. What's the best reading to help me quickly reacquaint myself with the joys of RAII and other C++ distinctives?
|
# ? Mar 7, 2014 21:44 |
|
Otto Skorzeny posted:I've been working primarily in C89 on a variety of embedded platforms for about three years now, and I want to pick up modern C++ for more "normal" systems programming; I haven't touched C++ since before the C++11 standard came out, and I'm rusty in general. What's the best reading to help me quickly reacquaint myself with the joys of RAII and other C++ distinctives? http://www.amazon.com/Primer-5th-Edition-Stanley-Lippman/dp/0321714113
|
# ? Mar 7, 2014 23:37 |
|
UnfurledSails posted:I'm an undergrad on a systems track and I've never done anything besides assignments and projects for classes (all of them in either C or C++11). I'm about to finish a class on operating systems implementing Pintos, and while it's fun and challenging, I have zero ideas about what I can do to feel less worthless as a programmer in the real world. Any advice? Most professional programmers are garbage too. If you can write code thats clean, concise, tests well and neatly encapsulates what its supposed to do with minimal cruft and maximal safety, your already doing more than most professionals in the field. In short: Don't worry about it, just try and get in the door. Incidently the way I got into programming was offering myself for "work experience" to places that didn't actually do internships. First place I contacted , the guy said "I like your ambition kid" and gave me an actual job with pay. Granted it involved maintaining horrifying old COBOL code, but hey, it was the 90s and I had to start somewhere.
|
# ? Mar 8, 2014 01:00 |
|
I'm having issues with cin.get() waiting for inputs. Can someone explain why it goes to infinite? I have the following loop: code:
How do I get it to let me enter a new input each time the loop runs?
|
# ? Mar 8, 2014 07:29 |
|
HootTheOwl posted:I'm having issues with cin.get() waiting for inputs. Can someone explain why it goes to infinite? When the user presses the enter key, a new line (\n) character is added to cin. cin.get() sees this newline and terminates the string, but doesn't actually remove it from the input buffer. Each successive call to cin.get() sees this newline and immediately returns, hence your infinite loop. You'll have to remove it yourself, like so: code:
Does that make sense? Scuzzywuffit fucked around with this message at 08:15 on Mar 8, 2014 |
# ? Mar 8, 2014 08:09 |
|
Scuzzywuffit posted:When the user presses the enter key, a new line (\n) character is added to cin. cin.get() sees this newline and terminates the string, but doesn't actually remove it from the input buffer. Each successive call to cin.get() sees this newline and immediately returns, hence your infinite loop. You'll have to remove it yourself, like so: It makes sense. Somewhat. If I understand you: The user's input is finalized when they enter the '\n' (return key). The cin.get() reads and accepts everything up to the '\n'. It leaves the '\n' as an input so every time my loop ran it would have the '\n' still being inputted thus causing my loop to repeat forever. So I took your advice on cin.ignore and rewrote my code: code:
|
# ? Mar 8, 2014 15:52 |
|
Is there some sort of console enhancement library for windows that's awesome? I do a lot of debugging out to the console as I'm learning and tinkering and it seems like simple things like rewriting lines instead of new line\scrolling requires way too much code. Simple stuff like changing the text color would be nice.
|
# ? Mar 8, 2014 19:11 |
|
bobua posted:Is there some sort of console enhancement library for windows that's awesome? I do a lot of debugging out to the console as I'm learning and tinkering and it seems like simple things like rewriting lines instead of new line\scrolling requires way too much code. Simple stuff like changing the text color would be nice. If you need more you'll need to look into using some other command line interpreter like powershell or take command. Personally I'm a big baby and settle for just running Console2 over cmd for my windows shell needs but YMMV. Well, I totally misunderstood your meaning and should learn to read. Xerophyte fucked around with this message at 21:44 on Mar 8, 2014 |
# ? Mar 8, 2014 19:51 |
|
I'm probably not explaining it really well. Right now, if I'm trying to output the state of a variable I can just do cout << i; over and over again, but if I want to keep the state of i on the top left corner of the console at all times there is a ridiculous amount of code needed. I guess I'm looking for a middle ground between learning one of c++'s gui libraries and just outputing to the console.
|
# ? Mar 8, 2014 20:08 |
|
HootTheOwl posted:
Sort of - it's actually because no characters were read, because the very first character is a "\n". In this situation, according to the docs, get(...) will set the failbit of cin internally and after that (until the state is clear'd) get(...) and ignore(...) won't work, so there'll be an infinite loop.
|
# ? Mar 8, 2014 20:23 |
|
bobua posted:I'm probably not explaining it really well. Right now, if I'm trying to output the state of a variable I can just do cout << i; over and over again, but if I want to keep the state of i on the top left corner of the console at all times there is a ridiculous amount of code needed. code:
If it's just for your own use though, ANSI escape sequences are convenient. Edit: corrected the order of x and y. roomforthetuna fucked around with this message at 20:27 on Mar 8, 2014 |
# ? Mar 8, 2014 20:25 |
bobua posted:Is there some sort of console enhancement library for windows that's awesome? I do a lot of debugging out to the console as I'm learning and tinkering and it seems like simple things like rewriting lines instead of new line\scrolling requires way too much code. Simple stuff like changing the text color would be nice. Are you really sure this is what you want? Have you looked into what your debugger can do?
|
|
# ? Mar 8, 2014 23:38 |
|
roomforthetuna posted:ANSI escape sequences Thanks, I'll play with this. nielsm posted:Are you really sure this is what you want? No, definitely not sure. But I do need the info output while compiled, ie my program has a 'debug mode' that outputs the data i normally wouldn't need to see.
|
# ? Mar 9, 2014 01:23 |
|
I'm working on a project to print, simplify, and evaluate logical expressions. Printing and evaluating is easy, but my partner and I are stuck on the simplification part. In the project description, we're provided with a list of 16 axioms that can help simplify expressions with an undefined component (e.g. x AND false simplifies to false). I think creating a big long list of if/else blocks would work, but if there's a better way, could someone help point us in that direction?
|
# ? Mar 10, 2014 13:55 |
|
hooah posted:I'm working on a project to print, simplify, and evaluate logical expressions. Printing and evaluating is easy, but my partner and I are stuck on the simplification part. In the project description, we're provided with a list of 16 axioms that can help simplify expressions with an undefined component (e.g. x AND false simplifies to false). I think creating a big long list of if/else blocks would work, but if there's a better way, could someone help point us in that direction? Assuming you have a tree structure, and an expression like x AND (False AND y) could be constructed something like AndOp(Var("x"), AndOp(Literal(false), Var("y")), you could write a structural matching/replacement function, and then have all your axioms as data: code:
|
# ? Mar 10, 2014 21:37 |
|
Scaevolus posted:It depends on how the expressions are represented. Ok, yeah, expressions are conceptually represented by a tree, but because they're all in the same class hierarchy, not because they're in a data structure (although it seems you meant the classes, rather than the expressions being in a tree data structure). However, I don't understand your code. What is going on with the double empty square brackets?
|
# ? Mar 10, 2014 21:46 |
|
hooah posted:However, I don't understand your code. What is going on with the double empty square brackets? He's creating a 2-dimensional array and initializing it.
|
# ? Mar 10, 2014 22:26 |
|
hooah posted:Ok, yeah, expressions are conceptually represented by a tree, but because they're all in the same class hierarchy, not because they're in a data structure (although it seems you meant the classes, rather than the expressions being in a tree data structure). However, I don't understand your code. What is going on with the double empty square brackets? patterns is an example of how you might have an array to perform a structural find/replace. These are the axioms represented: code:
|
# ? Mar 10, 2014 22:33 |
|
How do you mean their in the same class hierarchy? Do you have something like this?code:
As to your original question, it's more towards doing the checks in an intelligent fashion and only doing the checks when appropriate.
|
# ? Mar 10, 2014 23:00 |
hooah posted:Ok, yeah, expressions are conceptually represented by a tree, but because they're all in the same class hierarchy, not because they're in a data structure (although it seems you meant the classes, rather than the expressions being in a tree data structure). However, I don't understand your code. What is going on with the double empty square brackets? If your representation is based around polymorphism, with having a base ExpressionElement (or whatever) class which might have specializations such as AndExpression, which then in turn holds its own children (which would also be instances of ExpressionElement classes), then you could have each class know how it might simplify. Something like virtual ExpressionElement* Simplify() const. That would return a possible replacement expression for that element. For instance, calling it on an AndExpression would have the AndExpression first simplify its own two arguments, and if one of them simplifies to (or is) a literal ConstantFalseExpression then the entire AndExpression simplifies to a ConstantFalseExpression. Effectively, calling Simplify() on a (sub-)expression will produce a new expression with equivalent truth value. But making this deal with all sorts of cases could get ugly, e.g. I can't think of a good way to make it deal with (a OR b) AND b, which should simplify to just b but requires knowledge of the entire expression tree to derive.
|
|
# ? Mar 10, 2014 23:20 |
|
BirdOfPlay posted:How do you mean their in the same class hierarchy? Do you have something like this? nielsm posted:If your representation is based around polymorphism, with having a base ExpressionElement (or whatever) class which might have specializations such as AndExpression, which then in turn holds its own children (which would also be instances of ExpressionElement classes), then you could have each class know how it might simplify. nielsm has it right; the expressions are all part of a composite polymorphism tree, with Expression, Negate, Literal, BinaryExpression, etc. Since the point of this project is to use the Composite and Visitor patterns, we're pretending like we already had completed the Expression classes, and now we want to do operations on them, like print, evaluate, and simplify, which are Visitors. I think this requirement precludes doing Simplify() in each class. I think I understand the 2-dimensional array that Scaevolus was talking about, so I'll look into going that route. Thanks, guys!
|
# ? Mar 11, 2014 02:04 |
|
I don't think there's any need for an array at all? If you've got 15 simplification rules and like 5 subtypes of expression, that's and average of 3 things to go look for on each method in the visitor. I have no idea why you think this is ugly or too much for a method? Are you forgetting that in each visitor method you know what the root of that subtree is? Like, you don't need to check the OR rules in "visitAndExpr".
|
# ? Mar 11, 2014 03:20 |
|
crazypenguin posted:I don't think there's any need for an array at all?
|
# ? Mar 12, 2014 05:41 |
|
So we've tried going the non-array route, but it's gotten ugly quickly (as in, using typeid()). We added a Var class that derives from Exp and changed the Literal class to derive from Variable. I've done the SimplificationVisitor methods for visiting Literal and Negate classes (easy), and have been hacking away at the visitAnd method for a day or so now, and it doesn't seem to be going too well. If I zipped up the thing and threw it up on Dropbox, would anyone be willing to help us straighten this project out off the forums? I'd love to go to the TA, but he won't help with code-specific things, only conceptual issues.
|
# ? Mar 15, 2014 00:03 |
|
The hierarchy should almost certainly be flat. And there's no way constants as a subclass of variables makes sense even if it wasn't flat. And you'll probably want helper visitors. Consider writing a "constantValue" visitor that returns an enum of NONCONST, CONST_TRUE, CONST_FALSE. Or something like that. (perhaps two: "isConstant" and "constantValue" that returns a boolean.) Once you have this, there's probably no reason you'd ever need to ask specifically what class a child tree is rooted with. edit: also, I'd say your "coding issues" are stemming from some conceptual problems here, so asking the TA is probably appropriate.
|
# ? Mar 15, 2014 02:26 |
|
crazypenguin posted:The hierarchy should almost certainly be flat. And there's no way constants as a subclass of variables makes sense even if it wasn't flat. What do you mean by a flat hierarchy? We're required to use the Composite Pattern for the expression stuff. What are helper visitors? I also don't know about enums :/
|
# ? Mar 15, 2014 02:31 |
|
|
# ? May 19, 2024 08:25 |
|
hooah posted:What do you mean by a flat hierarchy? We're required to use the Composite Pattern for the expression stuff. Flat hierarchy means everything should derive from Exp. Nothing deriving from other things that derive from Exp. I'm not sure what the composite pattern is, so perhaps they're making you do something that makes things hard for no reason. Helper visitor is just another visitor, like the ones I suggested. If you haven't done enums, then writing the two I suggested that just return booleans works too.
|
# ? Mar 15, 2014 02:41 |