|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
Debian or Arch Linux would be my pick.
Debian uses the same package management system as Ubuntu so if you've used to Ubuntu, the learning curve is steady and Debian is used commercially in web servers etc...
With that being said, for learning purposes you can do everything you need Ubuntu as well, what exactly do you find Ubuntu insufficient?
Once you get used to the file system and bash commands and how to source your packages then everything else is a manpage away.
|
On May 16 2012 17:54 haduken wrote: Debian or Arch Linux would be my pick.
Debian uses the same package management system as Ubuntu so if you've used to Ubuntu, the learning curve is steady and Debian is used commercially in web servers etc...
With that being said, for learning purposes you can do everything you need Ubuntu as well, what exactly do you find Ubuntu insufficient?
Once you get used to the file system and bash commands and how to source your packages then everything else is a manpage away.
Like I said I could just be ignorant, for me I feel like I haven't had to do anything I couldn't do in windows in Linux yet which includes installing browsers, eclipse etc. I mean I learned I could sudo apt-get install firefox for firefox but I didn't need to / know to / had to look how to, since it had the Ubuntu market like thing I found the basic things I wanted on Linux (Skype/Firefox/Eclipse). Still trying to get used to the file system just since its not what I am normally used to.
|
Hyrule18980 Posts
Gentoo, Fedora, Debian, and Ubuntu are rather similar. If you want to learn Linux and C, and I mean really learn them, check out Slackware.
|
On May 16 2012 18:56 Sad[Panda] wrote:Show nested quote +On May 16 2012 17:54 haduken wrote: Debian or Arch Linux would be my pick.
Debian uses the same package management system as Ubuntu so if you've used to Ubuntu, the learning curve is steady and Debian is used commercially in web servers etc...
With that being said, for learning purposes you can do everything you need Ubuntu as well, what exactly do you find Ubuntu insufficient?
Once you get used to the file system and bash commands and how to source your packages then everything else is a manpage away. Like I said I could just be ignorant, for me I feel like I haven't had to do anything I couldn't do in windows in Linux yet which includes installing browsers, eclipse etc. I mean I learned I could sudo apt-get install firefox for firefox but I didn't need to / know to / had to look how to, since it had the Ubuntu market like thing I found the basic things I wanted on Linux (Skype/Firefox/Eclipse). Still trying to get used to the file system just since its not what I am normally used to.
I guess that's a good thing that Ubuntu has come a long way. Try to install something from outside the official repository, there are heaps of programs in the official repository that won't be the latest version etc... Try installing Brood war via WINE.
You won't really learn much until you start breaking things then fixing them lols
But this isn't really learning C though, Linux isn't some scary technical beast, the basics are a bit more advanced compare to Windows but it isn't rocket science.
|
On May 16 2012 21:29 haduken wrote:Show nested quote +On May 16 2012 18:56 Sad[Panda] wrote:On May 16 2012 17:54 haduken wrote: Debian or Arch Linux would be my pick.
Debian uses the same package management system as Ubuntu so if you've used to Ubuntu, the learning curve is steady and Debian is used commercially in web servers etc...
With that being said, for learning purposes you can do everything you need Ubuntu as well, what exactly do you find Ubuntu insufficient?
Once you get used to the file system and bash commands and how to source your packages then everything else is a manpage away. Like I said I could just be ignorant, for me I feel like I haven't had to do anything I couldn't do in windows in Linux yet which includes installing browsers, eclipse etc. I mean I learned I could sudo apt-get install firefox for firefox but I didn't need to / know to / had to look how to, since it had the Ubuntu market like thing I found the basic things I wanted on Linux (Skype/Firefox/Eclipse). Still trying to get used to the file system just since its not what I am normally used to. I guess that's a good thing that Ubuntu has come a long way. Try to install something from outside the official repository, there are heaps of programs in the official repository that won't be the latest version etc... Try installing Brood war via WINE. You won't really learn much until you start breaking things then fixing them lols But this isn't really learning C though, Linux isn't some scary technical beast, the basics are a bit more advanced compare to Windows but it isn't rocket science.
alright any thing you could recommend me needing/using in Linux to try to get used to dling things out of repository? Maybe something C related or just c00l shi- :3
|
|
Hey guys, i've got a lot of free time this summer, so I decided to learn some languages by myself to be ready for university. Since I already know C and C++, I have decided to learn assembly(preferably MASM) to help me really figure out what is going out when I program something in another language.
So far, all the tutorials I've found are either too short, they doesn't really go far in difficulty or are for experience assembly programmers. So TL, if one of you knows a good ASM tutorial please tell me!
|
On May 11 2012 13:53 Crazyeyes wrote: So it's now summer, and as a CS student with zero experience of any sort I figure it'd be nice to get some. Making some money in the meantmie would also be neat. I've been checking local classifieds and stuff, but am having the common problem of 'MINIMUM 5 YEARS EXPERIENCE.'
Anyways, the few jobs I DO find seem overwhelming and scary. All of them involve things I've never done and therefore do not know how to do. I'm afraid to apply for fear that I do get the job and then find myself lost and overwhelmed.
So I'm here hoping to learn that this is common and that my fears are irrational, I guess. I just wanna have a compsci job ;_;
It'll be pretty difficult to find summer/internship work as you've stated, the field is rather competitive. My best advice is to look long and hard to find a good company that takes in entry level programmers. I've been working at a company called PTC (www.ptc.com) for 2 years now, they hired me about 3 days after graduating from a state college. They hire a lot of other entry level, fresh graduates at the office that I applied at. so they have a very good training program for bringing in new hires. Thats something that is absolutely invaluable. Instead of being thrown to the wolves a good company will ease you in and provide a strong leadership and support team to get you in, and on the road to learning how to work in a professional programming environment.
|
On May 14 2012 23:06 heroyi wrote:whelp I can't figure this out... I was wondering if someone could help explain to me how to utilize bool in a function form. The reason I ask this is because I am working on this tic tac toe game and am trying to make it so that the game keeps going (asking players to make turns) until it reaches to a halt (three in a row) thus ending the game. I can't figure out how to use the boolean operation to a function form... Here is the code to help me on: + Show Spoiler + int a = 0; int b = 0; int i = 0;
int j = 0; char tictac[3][3] = { {'1','2','3'}, {'4','5','6'}, {'7','8','9'} };
void board() //intialize board { for(i=0;i<3;i++) { for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl; }
void choice() //to help mark spot for player one { if(a == 1) { tictac[0][0] = 'X'; board();} else if(a == 2) {tictac[0][1] = 'X'; board();}
else if(a == 3) {tictac[0][2] = 'X'; board();}
else if(a == 4) {tictac[1][0] = 'X'; board();}
else if(a == 5) {tictac[1][1] = 'X'; board();}
else if(a == 6) {tictac[1][2] = 'X'; board();}
else if(a == 7) {tictac[2][0] = 'X'; board();}
else if(a == 8) {tictac[2][1] = 'X'; board();}
else if(a == 9) {tictac[2][2] = 'X'; board();} }
void choice1() //to help mark spot for player 2 { if(b == 1) {tictac[0][0] = 'O'; board();} else if(b == 2) {tictac[0][1] = 'O'; board();}
else if(b == 3) {tictac[0][2] = 'O'; board();}
else if(b == 4) {tictac[1][0] = 'O'; board();}
else if(b == 5) {tictac[1][1] = 'O'; board();}
else if(b == 6) {tictac[1][2] = 'O'; board();}
else if(b == 7) {tictac[2][0] = 'O'; board();}
else if(b == 8) {tictac[2][1] = 'O'; board();}
else if(b == 9) {tictac[2][2] = 'O'; board();} }
void player1() ]//loop to ask for turn for player 1 { cout << "Player 1: "; cin >> a; while (!cin || a == b) // loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> a; } choice(); }
void player2() //loop to ask for turn for player 2 { cout << "Player 2: "; cin >> b; while (!cin || a == b) //loop to help catch bad input { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1(); }
int main() { Sleep(2000); cout << "Lets play tic tac toe between two players" << endl;
for(i=0;i<3;i++) //create board {for(j=0;j<3;j++) {cout << tictac[i][j] << " " ;} cout << endl;} cout << endl;
Sleep(2000); cout << "Here is the board. Enter the number to mark your spot." << endl; cout << "Player 1 is X and player 2 is O." << endl;
cout << "Player 1 goes first. Please enter your number: "; cin >> a; choice(); cout << "Player 2: "; cin >> b; while (!cin || a == b) { cout << "choose a different spot: "; cin.clear(); cin.sync(); cin >> b; } choice1();
[b]//below is the loop/boolean code I am trying to implement but to fail. I have tried different variations and this one here just happens to be the one that I copy and pasted here.[/b]
while(tictac[0][0] == tictac[0][1] != tictac[0][2] || tictac[0][0] == tictac[2][0] != tictac[1][0] || tictac[2][0] == tictac[2][1] != tictac[2][2] || tictac[0][0] != tictac[1][1] == tictac[2][2] || tictac[2][2] != tictac[1][2] == tictac[0][2] ) {player1(); player2(); }
//^^Here I was trying to make it so that as long as three in a row wasn't created then the game would continue in the loop (thus the while loop). However if a three in a row was detected then the statement would become false and would jump out of the loop to "end the game."
{cout << "gg" << endl;} //not the best ending but that isnt the problem.
system("PAUSE"); return 0;
} appreciate the help btw fyi: You can ignore some of my coding in the main function (block of code above my comments). I understand it may not be "consistent" but I was more worried on making the code work. Once I can get the whole thing going then I will go around and clean it up a bit to make it nicer. btw how is my coding "style?" Is there any bad "habits" that I should avoid that is present in my work? ********* off topic: What situation would call for you to use array over vector? Vectors can do everything an array can but better it seems...is it more efficient to use array on a small memory managment or something? ************ sorry for cluttering :/
the problem with your while statement above is that it lacks parenthesis, I don't even want to think about what sort of results that would come up with.
for the decision making to end the game,you could go with a function that would fire after a play is made, and it would start at each position on the board, and "look" at adjacent squares, if it finds a match, looks at the next square in a straight line and returns a true/false based on whether or not a win condition is found.
Another solution is have a method for each of the possible win conditions (Row 1,2,3 across, Column 1,2,3 down, Cross tL/bR, Cross tR/bL) and call all of those and combine that result to find if there is a win condition met. e.g.
+ Show Spoiler +
while(!gameIsWon()) ...
boolean gameIsWon() { boolean win = false; win = rowOneWin(); win = rowTwoWin(); ... return win; }
boolean rowOneWin() { boolean win = false; if( (tictac[0][0] == tictac[0][1]) && (tictac[0][0] == tictac[0][2])) win = true; }
...
you also could easly convert the above to find out who won also by passing in an x and changing the methods to check if each square = the passed in value.
a third, probably best option is, to have a method with nested for loops to check for a win and return t/f the only conditions you can't really check easily in the for is the diagonal wins,
also, your 2 methods for entering in an X or O could be greatly reduced. if you did something like:
+ Show Spoiler + char PLAYER_ONE = 'x'; char PLAYER_TWO = 'o'; void choice(char mark, int position) { switch(position): case(1) { if(tictac[0][0] == "") tictac[0][0] = mark; break; } /* repeat thru case(9) */ }
/*pseudo */
player one make your choice get player one input choice(PLAYER_ONE, choice) player two make your choice get player 2 input choice(PLAYER_TWO, choice)
instead of having the same method twice. pass in the X or O along side the choice.
Hopefully this wasn't too confusing, i kept getting ideas while trying to just answer your question. going to have to go write tic tac toe now, i probably already have one somewhere in my codebase haha.
|
On May 11 2012 13:53 Crazyeyes wrote: So it's now summer, and as a CS student with zero experience of any sort I figure it'd be nice to get some...
I just got a job in a similar situation, and I'd like to share what worked for me. I graduated this month with a mathematics degree, no job experience, and no really applicable courses in comp sci (though the classes I did take in c gave me some great fundamentals). The thing I had that most of the recruiters and hr departments loved, besides the ability to speak in complete sentences, was a list of my independent projects on my resume (including my overlay manager).
In my experience, when teams are looking for entry-level/junior developers, they're looking for someone to raise and groom. They're looking for someone who's willing to learn a technology and who is self-motivated to do so. Having projects you've done on your own will exemplify these traits, even if they're in unrelated technologies to the jobs. I ended up getting 2 technical interviews scheduled every day for the first two weeks I looked, and getting 3 offers by the start of the second week, one of which was too good to pass up. A lot of that volume had to do with me being in the Washington D.C. area, though.
So if you can spare some time to work on side projects that you're really interested in, do it and list them on your resume with all the technologies you used. It helps a lot when you're trying to get into these starting positions.
|
On May 16 2012 21:29 haduken wrote:Show nested quote +On May 16 2012 18:56 Sad[Panda] wrote:On May 16 2012 17:54 haduken wrote: Debian or Arch Linux would be my pick.
Debian uses the same package management system as Ubuntu so if you've used to Ubuntu, the learning curve is steady and Debian is used commercially in web servers etc...
With that being said, for learning purposes you can do everything you need Ubuntu as well, what exactly do you find Ubuntu insufficient?
Once you get used to the file system and bash commands and how to source your packages then everything else is a manpage away. Like I said I could just be ignorant, for me I feel like I haven't had to do anything I couldn't do in windows in Linux yet which includes installing browsers, eclipse etc. I mean I learned I could sudo apt-get install firefox for firefox but I didn't need to / know to / had to look how to, since it had the Ubuntu market like thing I found the basic things I wanted on Linux (Skype/Firefox/Eclipse). Still trying to get used to the file system just since its not what I am normally used to. I guess that's a good thing that Ubuntu has come a long way. Try to install something from outside the official repository, there are heaps of programs in the official repository that won't be the latest version etc... Try installing Brood war via WINE. You won't really learn much until you start breaking things then fixing them lols But this isn't really learning C though, Linux isn't some scary technical beast, the basics are a bit more advanced compare to Windows but it isn't rocket science.
@"Like I said I could just be ignorant, for me I feel like I haven't had to do anything I couldn't do in windows in Linux yet which includes installing browsers, eclipse etc."
Install Xmonad, a window manager where everything requires a hotkey or linux command. I'm literally doing software development on linux at 300 apm, flicking between different workspaces, using my keybinds to open new windows and adjust them exactly the way I want, grep, piping |, pstree, pkill, ctrl+shift+r, vim/emacs, all things that really I miss in windows.
Doing everything on Windows is such a chore and takes so long to do anything, even search is about 1000x slower than linux grep or find -iname or locate. You can find any file within your hard-drive within half a second with locate, its practically instant, not even exaggerating on this. It may seem trivial, but when you realise how long you spend searching for files, when you can find it instantly whenever is quite a big deal and that's like 0.0001% of what linux has to offer. Once you understand linux well, doing anything is immediate and executable/findable within half a second. No pointless mouse-clicks or having to traverse through folders. Half the time I'm not even opening files but still working directly on them with linux commands, with <<, cat, head/tail, or piping it somewhere.
Here is the best thing about package managers, you wanna install this window manager. No browser or pointless configuration, just "sudo apt-get install xmonad" that's it, and you can start using it right away.
|
i have a question. suppose i delcare a class in c++. is there any way to make the variables "read-only" outside of the class, so to speak? as in, functions not part of the class could read the variable, but not change its value.
any help wuold be appreciated.
|
On May 29 2012 06:16 snively wrote: i have a question. suppose i delcare a class in c++. is there any way to make the variables "read-only" outside of the class, so to speak? as in, functions not part of the class could read the variable, but not change its value.
any help wuold be appreciated.
Yes, you make those variables private, and you create for each of them methods that will return their values, but no method to change them.
Even though it requires a bit of work, you can define the behaviour you want for each variable
|
On May 29 2012 06:16 snively wrote: i have a question. suppose i delcare a class in c++. is there any way to make the variables "read-only" outside of the class, so to speak? as in, functions not part of the class could read the variable, but not change its value.
any help wuold be appreciated.
Make the class attributes private (or protected) and only create getters.
Example:
class A { private: int mAttr1; public: int getAttr1(); };
mAttr1 will be readable outside of class A, and you won't be able to change its value.
edit: corrected dat confusing english
|
Hyrule18980 Posts
|
On May 29 2012 06:20 fabiano wrote:Show nested quote +On May 29 2012 06:16 snively wrote: i have a question. suppose i delcare a class in c++. is there any way to make the variables "read-only" outside of the class, so to speak? as in, functions not part of the class could read the variable, but not change its value.
any help wuold be appreciated. Make the class attributes private (or protected) and only create getters. Example: class A { private: int mAttr1; public: int getAttr1(); };
mAttr1 will be readable outside of class A, and you won't be able to change its value. edit: corrected dat confusing english
Also for more complex types, you should return a const reference to the member variable:
class Data { private: int mAttr0[10]; };
class A { private: Data mAttr1; public: const Data& getAttr1() const { return mAttr1; } };
getters suck use friend
Friend classes can break encapsulation by allowing them direct access to the private members of the class bypassing the public interface and potentially breaking the invariants of the friended class. Generally you want to limit the number of paths that update the internal state of your class, allowing unrestricted write access (to the friended class) through friendship does the opposite. While useful in some scenarios, replacing getters/setters with friendship may not be the best idea in all cases.
|
Suggesting friends for his problems makes no sense. You'd have to add a friend to the class for every type that wants to access its members, which is one of the least generic and hardest to maintain ways to program imaginable.
Friends suck. They introduce code-level dependencies between classes (the class who befriends another must know it, because you have to actually declare the friend in the header), while not really solving any problems.
The only case where they're actually useful if you purposefully absolutely require that only a specific set of classes must have access to your private data. However, in practice, this should very, very rarely be the case.
If outside classes need to access your private data in its raw form to do stuff with it, there's either no reason to make it private or you're handling your private state in regards to the public interface incorrectly (I think in practice this probably usually means that you've divided responsibilities incorrectly, resulting in the fact that one type of problem needs to access another type of problem's private data because it can not make do with whatever the class provides publicly).
Getters don't suck. Apart from the minimal typing overhead, there's no downside to them. Optimizing them away is one of the most basic optimizations there is, and as such, they're not even slower, since even if you don't mark them as inline, compilers (even GCC which is relatively bad at inlining) will inline them basically all the time, completely removing the cost of a function call.
For data access, usually either make it public, or use getters and(or) setters. Which of the two depends on your problem. If you think that the way of accessing the data in the member is never going to be anything else other than a direct read or write (such as would be the case with matrices or vectors, for example), then simply make them public. For other cases (where you're not sure, or you already have accessing behavior that is not just read/write) use getters and setters.
|
On May 22 2012 10:38 Carapas wrote: Hey guys, i've got a lot of free time this summer, so I decided to learn some languages by myself to be ready for university. Since I already know C and C++, I have decided to learn assembly(preferably MASM) to help me really figure out what is going out when I program something in another language.
So far, all the tutorials I've found are either too short, they doesn't really go far in difficulty or are for experience assembly programmers. So TL, if one of you knows a good ASM tutorial please tell me!
All of the assembly tutorials are short because other than in class there is a good chance that you're never going to need to know assembly backwards and forwards to write any programs. This is partially due to the fact that its a pain in the ass to get anything really useful done in ASM compared to the other higher level languages but also because the compilers nowadays (at least for C/C++) have been optimized well enough that there are very few times that you're ever going to bust out any inline assembly and have it compile to more efficient machine code than the compiler's code.
Since you're trying to understand what really happens when you are programming it would be good to research materials on the stack (What happens when a function is called? What is stored on the stack? What order are variables and other things stored on the stack? etc.) and the different registers used in the x86 architecture (EAX, EBX, ESP, EBP, .....). Writing some simple ASM programs should be enough to see the concepts that those two things represent in action. But learning ASM so you can write non-trivial programs is most likely going to be unnecessary for you in the long run (ie finding a job).
Chapter 2 of Gray Hat Python has a very nice overview of the stack, and the registers and jumps into a little bit of assembly. That book however is all Python and hacking after the first couple chapters which may or may not pique your interest.
EDIT: Just noticed that the site actually provides chapters 2 and 4 for free (Chapter 2).
|
On May 29 2012 07:00 tofucake wrote: getters suck use friend
Getters are something omnipresent in all languages and in all classes in all languages and if you read 10 lines of code in any program, you're likely to see a declaration of getters or usage of them. So the first observation, "getters suck" is very bad. Getters are The Way to access properties of an object.
Friend is something specific to C++. If you are not really advanced, don't think about such thing as it's something that's seldom useful and something without which you can write your first 100,000 lines of code. Also, there are languages like Java (which runs on like 1 billion devices), which doesn't even support Friend or something similar. So, I'd recomend against using friends unless you know very very well what are you doing.
|
Hyrule18980 Posts
He specifically said he was using C++, and using stuff is (imo) the best way to learn it. And getters do suck. Just because they are prevalent doesn't make them good.
|
|
|
|