The Big Programming Thread - Page 114
Forum Index > General Forum |
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. | ||
Deleted User 61629
1664 Posts
| ||
esotericc
449 Posts
On February 07 2012 04:53 Inori wrote: Well if you know your way around in programming (i.e. paradigms, design patterns, etc), then language doesn't really matter. Pick something that suits you. Or something trendy like Scala or node.js. Since you have a whole year before school, then you could just learn them all (think of a simple project and build it with scala, node.js, ruby, python, java and c++), doing 1 language/1-2 months. I am fairly rusty as I spent most of my time focusing on HTML and CSS, while I did learn actionscript and PhP during my colledge diploma (different than the degree I am going for) I mostly forgot the ins and outs of each language as I never really used them. Thanks for the advice, I think the one language every few months plan seems like the best course. | ||
SiKStArCuE
United States19 Posts
Problem A. The values of two float variables, x and y, are saved in IEEE single precision floating point format as below. Calculate the value of z in IEEE single precision floating point format if z = x + y. You should begin the calculation with the packed 32-bit representations of x and y and end with the 32-bit packed result for z. x = 0 11100010 00101100000000000000000 y = 1 11100000 11010000000000000000000 | ||
![]()
tofucake
Hyrule18977 Posts
| ||
SiKStArCuE
United States19 Posts
| ||
eFonSG
United States255 Posts
Essentially im suppose to take a string from the user that is a word Im writing a class that with a few different methods that are to help split the word up into syllables and help with pronunciation For one of my methods, Im suppose to change lets say September into sep/tem/ber. Im not really sure how to go about attacking this. We have rules given for when to break syllables up, how to count them, etc. "How to identify syllables: We’ll confine ourselves to just two situations, commonly known as the ‘vccv’ and ‘vcv’ rules. As you scan a word from left to right, if you encounter a vowel followed by two consonants (non-vowels) followed by a vowel, divide between the consonants. For example, “hidden” contains this pattern and is divided into two syllables: ‘hid/den’. If you see the ‘vcv’ pattern, divide before the consonant. Thus, “consonant”, which exhibits both patterns, would be divided like this: ‘con/so/nant’." I just need some direction on a project like this, im pretty lost about where to start. The string were manipulating is user input, so i cant find a consistent way to break it up correctly. Sometimes it feels like my brain just cant make the right connections when it comes to programming -.- | ||
mmp
United States2130 Posts
On February 07 2012 04:53 Inori wrote: Well if you know your way around in programming (i.e. paradigms, design patterns, etc), then language doesn't really matter. Pick something that suits you. Or something trendy like Scala or node.js. Since you have a whole year before school, then you could just learn them all (think of a simple project and build it with scala, node.js, ruby, python, java and c++), doing 1 language/1-2 months. node.js is not a particularly useful skill toi have. I would ignore this advice. Scala is very interesting, but learning & refining your understanding of Java must come first. Scala is not for beginners, and you won't appreciate what it's offering until you've struggled through Java's intricacies. And after using Scala, you may just realize that it is not always the best tool for the job (in which case you might use a combination of JVM languages). If you're going into CS, study Python and C. Python is a decent flexible language to get a lot of general-purpose stuff done, and it's got tons of support & libraries + language bindings where performance is important. Python is your multi-tool utility knife, learn it well and you shall prosper. As a CS, you must understand how C works or you will never understand anything about modern computer architecture. Your degree will probably demand that you become familiar with assembly programming (x86), maybe embedded device programming, and/or fpga programming: knowledge of C (particularly the call stack conventions, segments & object code linking, memory addresses & pointers) should be prerequisite. After you understand C, you can debate the merits of C++/C#/Java(/Go/D/...). Most likely your degree will require you to use one of these three languages in a software engineering course. You will also want to check out lisp, haskell, smalltalk, ocaml, clojure, etc. to get a feel for the alternative school of design that has survived in the shadow of Worse is Better. I think Scala is probably in this category of the Right Thing; it is superengineered to be super awesome, but it ends up becoming terribly difficult to master, adopt in a workplace, and tune for performance. | ||
mmp
United States2130 Posts
On February 08 2012 06:18 eFonSG wrote: Hey, i need some help with string manipulation in Java. Essentially im suppose to take a string from the user that is a word Im writing a class that with a few different methods that are to help split the word up into syllables and help with pronunciation For one of my methods, Im suppose to change lets say September into sep/tem/ber. Im not really sure how to go about attacking this. We have rules given for when to break syllables up, how to count them, etc. "How to identify syllables: We’ll confine ourselves to just two situations, commonly known as the ‘vccv’ and ‘vcv’ rules. As you scan a word from left to right, if you encounter a vowel followed by two consonants (non-vowels) followed by a vowel, divide between the consonants. For example, “hidden” contains this pattern and is divided into two syllables: ‘hid/den’. If you see the ‘vcv’ pattern, divide before the consonant. Thus, “consonant”, which exhibits both patterns, would be divided like this: ‘con/so/nant’." I just need some direction on a project like this, im pretty lost about where to start. The string were manipulating is user input, so i cant find a consistent way to break it up correctly. Sometimes it feels like my brain just cant make the right connections when it comes to programming -.- This sounds like homework... First thing you want to do is think about the problem, think about how you would do it by hand if you were given this task to do instead of the computer. Use pencil & paper to sketch out your strategy. Once you think you've got a basic strategy laid out, look for exceptional cases, anything you think might break your basic strategy. Once you have a sound strategy, write it down as a series of logical steps, pseudocode preferably. Abstract over any details, like converting uppercase to lowercase, or how you will break the word into syllables. Just write what is intuitive. Maybe it is sketched out something like this (don't actually use this, it is non-normative):
Ok, then in Java, you go and code up the lower_case method, the convert_foo_to_bar methods, etc. Once all of the pieces are put together, you test it. If it fails, then you either (a) didn't assemble one of the pieces correctly, or (b) your strategy failed. If you think your strategy is getting too large and complicated for this task, then you need to go back to that pseudocode and find a more concise way of expressing your abstractions (how would you instruct a human to do this task?). Very likely, if you are concise enough in your abstraction, there is probably a library or algorithm already in existence to solve a similar problem. Hint: + Show Spoiler + You shouldn't need to reinvent the wheel. http://en.wikipedia.org/wiki/Regular_expressions http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html | ||
mmp
United States2130 Posts
On February 07 2012 06:21 esotericc wrote: Thanks for the advice, I think the one language every few months plan seems like the best course. I think this is a poor course. Going into a degree program, you will be better served by depth of knowledge in a useful language, not shallow familiarity in irrelevant languages (you can adopt them later once you appreciate how irrelevant they are). Python and C are both practical and relevant, more than any other languages I could recommend. Practical knowledge of Python will let you code up homework, class projects, and personal experiments quickly and with little headache. It's a decent scripting language to know, and is popular in software industry. Deep knowledge in C/C++ will make learning other languages a walk in the park, and is core to your education in computers. You'll do a lot better in compilers, computer languages, operating systems, distributed systems, parallel programming, and other classes that focus on low-level details if you start with an understanding of C. | ||
eFonSG
United States255 Posts
On February 08 2012 07:15 mmp wrote: This sounds like homework... First thing you want to do is think about the problem, think about how you would do it by hand if you were given this task to do instead of the computer. Use pencil & paper to sketch out your strategy. Once you think you've got a basic strategy laid out, look for exceptional cases, anything you think might break your basic strategy. Once you have a sound strategy, write it down as a series of logical steps, pseudocode preferably. Abstract over any details, like converting uppercase to lowercase, or how you will break the word into syllables. Just write what is intuitive. Maybe it is sketched out something like this (don't actually use this, it is non-normative):
Ok, then in Java, you go and code up the lower_case method, the convert_foo_to_bar methods, etc. Once all of the pieces are put together, you test it. If it fails, then you either (a) didn't assemble one of the pieces correctly, or (b) your strategy failed. If you think your strategy is getting too large and complicated for this task, then you need to go back to that pseudocode and find a more concise way of expressing your abstractions (how would you instruct a human to do this task?). Very likely, if you are concise enough in your abstraction, there is probably a library or algorithm already in existence to solve a similar problem. Hint: + Show Spoiler + You shouldn't need to reinvent the wheel. http://en.wikipedia.org/wiki/Regular_expressions http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html Hey thanks for the reply, and it is homework; but its self mandated homework. Im doing this out of a book i bought. But thats why i tried not to ask for direct help instead i just wanted some direction. I Want to be able to do this, so just getting the answer doesnt help all that much. One of my problems though, is that this is straight up not that intuitive to me and im very unfamiliar with writing any code by hand. Still, I appreciate the help, and i like the approach you laid out, ill do my best on this see if i can piece it together. Thanks again Edit: a few hours later and 0 progress, i cant wrap my head around any of this. And ive been doing this for months, i must just be fucking stupid, it will not click in my head. | ||
Kasha_Not_Kesha
United States71 Posts
So anyways. As I've mentioned, I'm third year. All of my knowledge in computer programming comes from my classes. I'll admit I'm not the best student, but I do pay attention when I can and I'm not exactly failing my way through this. I don't ever program on my free time or read programming-related things that aren't school related. This is a huge issue right here. It honestly doesn't even matter that you aren't the best student; the issue is you aren't driven to learn. You need to pursue this stuff in your spare time, and you need to do so because you love it. Math teachers always say "you can't learn math unless you practice it a lot"; the same is true of Computer Science. You can't learn to program unless you do it a lot, and you probably won't do it a lot unless you really truly love it. Any computer-related(or even technology-related) job you ever get will only be familiar, related to your college education, and simple for a short period of time. In case you weren't aware, computers are leaps and bounds ahead of where they were a mere 10 years ago. Look back 20 years, and it's almost like we're dealing with alien technology. Computer related fields are constantly changing, and if you don't love learning/lack the drive to continually teach yourself new things and keep up to date on the major developments that are going on in your field, you aren't going to be very successful (Unless your job involves computer proficiency, rather than computer science). Taking a passive approach to learning programming is a pitfall because it sets you up for failure in a big way, and it doesn't prepare you for a future where everything you learned in college is antiquated and discussed in history books. You have to get yourself interested and knowledgeable about this stuff, because eventually the demands placed on you won't come from a professor that also gives you everything you need to know to meet those demands. The thing is, I feel like I don't know anything. I feel like pepole who have way less education than me are more capable than I am. They probably are. You don't need (nor, in my opinion, should you really have) someone to teach you how to program; there are guides and tutorials galore available for free online, and knowing how to find them is just another skill every programmer should develop as soon as possible. I'm a sophomore in college at the moment, and I have a friend who is two years younger than me that recently graduated High school and isn't going to college. He's never taken a single programming course in his entire life; I've taken somewhere around 8. Despite all of this, he's a hundred times more knowledgeable about computers in general, and a million times better at programming than I am, because he's so damn interested in it, and he has the drive to teach himself and learn, something I only recently developed in myself. What I hope is going on is that I'm being given the basic (and hopefully more advanced, too) programming skills and knowledge that can be applied to all computer science, and then the more specific things I'll be able to pick up without too much effort. If I can give you any advice it's that you not rely on college to teach you ANYTHING. College is more or less a place you go to in order to secure a paper that tells possible employers that you probably aren't too stupid. You won't get anything of value out of college unless you pursue it yourself. Your professors *should* know a hell of a lot, and they are resources you literally can't utilize enough, ever. Ask them questions, ask them for challenges, ask them for interesting topics to look into and read about. Just going to lectures and pulling off B's in all of your classes isn't going to make you a good, or even mediocre programmer. You *have* to work at it yourself and go beyond what is required of you, and the best time to do it is now, while you still have physical access to people that (ideally) know how to answer any questions you could have. | ||
thedz
United States217 Posts
Any computer-related(or even technology-related) job you ever get will only be familiar, related to your college education, and simple for a short period of time. In case you weren't aware, computers are leaps and bounds ahead of where they were a mere 10 years ago. Look back 20 years, and it's almost like we're dealing with alien technology. This. When I'm hiring, candidates that have an existing GitHub or similar account with code that I can look at and appreciate almost always have the leg up, even if someone else has a more impressive educational background. That said, this is in the SF Bay Area, where practical experience trumps nearly everything. | ||
shannn
Netherlands2891 Posts
On February 08 2012 08:44 Kasha_Not_Kesha wrote: I had a couple of responses to Crazyeyes, the guy who's post is quoted in the first post, so I figured I'd throw them out there and see what you all think =P This is a huge issue right here. It honestly doesn't even matter that you aren't the best student; the issue is you aren't driven to learn. You need to pursue this stuff in your spare time, and you need to do so because you love it. Math teachers always say "you can't learn math unless you practice it a lot"; the same is true of Computer Science. You can't learn to program unless you do it a lot, and you probably won't do it a lot unless you really truly love it. Any computer-related(or even technology-related) job you ever get will only be familiar, related to your college education, and simple for a short period of time. In case you weren't aware, computers are leaps and bounds ahead of where they were a mere 10 years ago. Look back 20 years, and it's almost like we're dealing with alien technology. Computer related fields are constantly changing, and if you don't love learning/lack the drive to continually teach yourself new things and keep up to date on the major developments that are going on in your field, you aren't going to be very successful (Unless your job involves computer proficiency, rather than computer science). Taking a passive approach to learning programming is a pitfall because it sets you up for failure in a big way, and it doesn't prepare you for a future where everything you learned in college is antiquated and discussed in history books. You have to get yourself interested and knowledgeable about this stuff, because eventually the demands placed on you won't come from a professor that also gives you everything you need to know to meet those demands. They probably are. You don't need (nor, in my opinion, should you really have) someone to teach you how to program; there are guides and tutorials galore available for free online, and knowing how to find them is just another skill every programmer should develop as soon as possible. I'm a sophomore in college at the moment, and I have a friend who is two years younger than me that recently graduated High school and isn't going to college. He's never taken a single programming course in his entire life; I've taken somewhere around 8. Despite all of this, he's a hundred times more knowledgeable about computers in general, and a million times better at programming than I am, because he's so damn interested in it, and he has the drive to teach himself and learn, something I only recently developed in myself. If I can give you any advice it's that you not rely on college to teach you ANYTHING. College is more or less a place you go to in order to secure a paper that tells possible employers that you probably aren't too stupid. You won't get anything of value out of college unless you pursue it yourself. [Your professors *should* know a hell of a lot, and they are resources you literally can't utilize enough, ever. Ask them questions, ask them for challenges, ask them for interesting topics to look into and read about. Just going to lectures and pulling off B's in all of your classes isn't going to make you a good, or even mediocre programmer. You *have* to work at it yourself and go beyond what is required of you, and the best time to do it is now, while you still have physical access to people that (ideally) know how to answer any questions you could have. This man speaks the truth ![]() Out of 40 or so CS students in my senior year probably less than 8 people know how to program, know the concepts and have the basics under control. The degree really really says nothing when it comes to CS at my college tbh. My study in the past 3.5 years so far consisted 75% of how to work with tools like PowerDesigner, PowerBuilder, ISAH etc and learning ITIL v2. I can't see myself working with any of these tools. I was lucky enough that I was programming on the side for my part-time job and for fun. If I knew anyone RL who is planning to study CS then I'd just quote the above poster and tell him exactly that especially the first bolded part. | ||
mmp
United States2130 Posts
On February 08 2012 08:02 eFonSG wrote: Hey thanks for the reply, and it is homework; but its self mandated homework. Im doing this out of a book i bought. But thats why i tried not to ask for direct help instead i just wanted some direction. I Want to be able to do this, so just getting the answer doesnt help all that much. One of my problems though, is that this is straight up not that intuitive to me and im very unfamiliar with writing any code by hand. Still, I appreciate the help, and i like the approach you laid out, ill do my best on this see if i can piece it together. Thanks again How would you tell a human (me, for example) to do this task in English instructions? Your book told you to "divide between the consonants" in a word. That's a very high-level instruction, so break it down into terms that make a little more sense for a machine. (1) You are given a word (String) as input. (2) The word is a sequence of characters, either classified as "consonants"|"c" or "vowels"|"v". (3) Output a new String that is the word with a "/" character inserted everywhere "vc" is followed by "cv" and everywhere "v" is followed by "cv". This appears to be the same problem, just stated at a lower level. Which parts appear easy to translate into Java, which parts do not? (1) just fetches the argument from the user. (2) is some discrimination of vowel & consonant characters in the word. (3) does some kind of scanning to figure out everywhere the "vccv" & "vcv" patterns occur, and it magically comes up with a new word that has all of the "/"s inserted. Your task is to figure out what that magic component is and dissect it into terms as simple as (1) or (2). This is a top-down problem-solving approach, breaking something abstract down into smaller concrete pieces until the entire task is understood. But when you're trying to solve a tough problem, you have to break it down into the parts that you do understand and the parts that you do not; if you understand everything about a problem except one thing, then you can ignore everything else and try to answer that one smaller problem. So the big problem here is breaking down the magic: (a) How do we scan for "vccv" & "vcv"? (b) Once we've found an instance of either, where do we put the "/"? That is, we need to remember or store in some way the occurrence of a new syllable. (c) However we've scanned the word and analyzed it, we need to form a new word now that has "/"s. | ||
mmp
United States2130 Posts
http://blip.tv/clojure/clojure-concurrency-819147 | ||
Kasha_Not_Kesha
United States71 Posts
On February 08 2012 08:02 eFonSG wrote: Edit: a few hours later and 0 progress, i cant wrap my head around any of this. And ive been doing this for months, i must just be fucking stupid, it will not click in my head. I'm being as serious as I can when I say this; welcome to programming. Programming is all about that state of "huhwah" following your introduction to a problem. First off, you have to understand the concepts intrinsic to the problem itself, i.e. if you weren't a programmer, but in expert in the field most closely related to the problem, how would you solve the problem? That alone is a pretty considerable burden for you. Then you have to break it down into a set of sub-problems you can solve, and get to work solving them. Sometimes you run into something that doesn't seem simple or easy to solve; i.e. it's a pretty major problem that you can't break apart, but which seems pretty hefty. At that point, you should assume there's an easier way, and start trying to find that easier way. Trust me when I say that it has nothing to do with your intelligence or problem solving ability; you're just fundamentally approaching the problem the wrong way, which is not necessarily a negative thing because there are a ton of ways to approach the problem, and only a few are helpful. You don't have the experience needed to immediately know the proper approach to the problem, which is fine, because once you solve this one, you'll be able to apply variations of this solution to tons of problems you might run into down the line. You've been programming for months; I've been programming for years and this problem was still a bit difficult for me to solve. And let me tell you; the problem you're working on is a fun/frustrating one. Hopefully you have a decent grasp of the Object Oriented paradigm, because if you're doing all of this functionally it's going to be hell to try and organize the code you write. I literally just finished something similar to what you have to do here, and if you would like I can tell you two Java classes that will make the solution a lot easier to find. Let me know; I don't want to spoil the research side of it if you want to try to find them on your own, I just know that I wouldn't have found them without my infinitely more knowledgeable friends' help. | ||
Deleted User 61629
1664 Posts
| ||
silentsaint
Germany540 Posts
| ||
Kasha_Not_Kesha
United States71 Posts
| ||
Frigo
Hungary1023 Posts
On February 10 2012 06:47 Kasha_Not_Kesha wrote: Programming books are very rarely worth the money. If you're trying to teach yourself how to program in a specific language, it's usually easier and cheaper (and more beneficial in the long run) to look up tutorials online. That's my opinion anyway =P Read Clean Code: A Handbook of Agile Software Craftsmanship, I doubt you will find that in tutorials. | ||
| ||