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.
On April 12 2012 01:06 phar wrote: @ Above w/ the C++ & Java:
Depending on the scope of your need to communicate between C++ and Java, it may be worth investing some time into looking at JNI Bridge. Despite the fact that it may make you want to pull your hair out, if you are doing a lot of integration between the languages it'll potentially save you a lot of time.
If your need is pretty simple though (e.g. is limited to literally just stuffing one chunk of data at one single point in java to one single point in C++), then JNI Bridge will be overkill.
I just need to start a C++ program and pass it a parameter from within a Java program. I may also want to get a little output from the C++ program, but I can probably do without it.
The Java program is a UI to enable easier access to a much larger C++ program. Right now, the C++ program is just run from command line, but the hope is that eventually non-CS people will be able to use it.
Ok, so I recommend redoing this with an executable that you know works. Try starting up IE or something basic, and stepping through your code. I'm unfamiliar with Java, but I've done this a lot with System.Diagnostics in .Net (Process and ProcessStartInfo classes) and I've been able to capture stdOUT and stdERR reliably.
This may be blatantly wrong (again unfamiliar with java), but doesnt your EXE spawn its own thread and execute when you call process.start() ? This means you're assigning output / input streams after the program has run. Just a guess.
Edit: Because of the class names 'Process' and 'ProcessBuilder' I'm assuming it functions similar to the .NET classes.
The process does start in a separate thread, hence you are assigning input and output streams _while_ the other process is running, not after. But any output occurring is buffered until you actually read it, so you don't miss anything. In fact, some programs you run this way will block because they are either waiting for input or because output buffers just run full and so their print to stdout gets blocked until you start reading from these streams.
I've just been trying it on Hello World right now, and it definitely works, when run on its own. Its when I try to call it from my Java program that I run into trouble.
What bothers me, is that it starts in another thread. Why doesn't the C++ program start its own runtime environment? Why does it get a thread in the Java program?
On April 12 2012 01:06 phar wrote: @ Above w/ the C++ & Java:
Depending on the scope of your need to communicate between C++ and Java, it may be worth investing some time into looking at JNI Bridge. Despite the fact that it may make you want to pull your hair out, if you are doing a lot of integration between the languages it'll potentially save you a lot of time.
If your need is pretty simple though (e.g. is limited to literally just stuffing one chunk of data at one single point in java to one single point in C++), then JNI Bridge will be overkill.
I just need to start a C++ program and pass it a parameter from within a Java program. I may also want to get a little output from the C++ program, but I can probably do without it.
The Java program is a UI to enable easier access to a much larger C++ program. Right now, the C++ program is just run from command line, but the hope is that eventually non-CS people will be able to use it.
Ok, so I recommend redoing this with an executable that you know works. Try starting up IE or something basic, and stepping through your code. I'm unfamiliar with Java, but I've done this a lot with System.Diagnostics in .Net (Process and ProcessStartInfo classes) and I've been able to capture stdOUT and stdERR reliably.
This may be blatantly wrong (again unfamiliar with java), but doesnt your EXE spawn its own thread and execute when you call process.start() ? This means you're assigning output / input streams after the program has run. Just a guess.
Edit: Because of the class names 'Process' and 'ProcessBuilder' I'm assuming it functions similar to the .NET classes.
The process does start in a separate thread, hence you are assigning input and output streams _while_ the other process is running, not after. But any output occurring is buffered until you actually read it, so you don't miss anything. In fact, some programs you run this way will block because they are either waiting for input or because output buffers just run full and so their print to stdout gets blocked until you start reading from these streams.
I've just been trying it on Hello World right now, and it definitely works, when run on its own. Its when I try to call it from my Java program that I run into trouble.
What bothers me, is that it starts in another thread. Why doesn't the C++ program start its own runtime environment? Why does it get a thread in the Java program?
I don't know if it gets an actual java thread or if the JVM just forks off a regular operating system thread to run it in, why does that make a difference? you don't see it anyways.
On April 12 2012 07:02 mazerr wrote: Hi TeamLiquid! Long-time (2yr) lurker here, and I finally decided to post, because I need some help! Lengthy read below, but if any of you programming wizards could give some advice I'd appreciate it! I cross-posted this on reddit careeradvice but don't know if I'll get any responses there.
First, a little about my background:
I'm a 23 year old currently living at home. I was a very 'gifted' person when I was younger, ie got As in school w/o effort, played violin and ended up winning a nation-wide HS competition and performed in Carnegie Hall, won local Math competitions, etc, all with very minimal effort. Because of this I developed a superiority complex and became very apathetic regarding what I wanted to do, as I was good at a number of things and a lot of people were pushing me to do 'their' thing. I didn't know what I wanted to do. So I promptly got into a decent engineering school (Rose-Hulman) spent all my time playing WoW, and bombed out. This shattered my superiority complex and triggered depression, which deteriorated over the years to the point where I was living at home, morbidly obese, smoking, and pissing in bottles and letting food rot in my room while I played video games.
I have step-by-step overcome this, and am now trying to get my life back on track, but I need to move out, my parents can simply no longer support me (nor do I wish them to). I REALLY desperately want to begin a career as a programmer. Out of all of the things I've done, I like it the most by far (barring music which I love too personally to want it as a job). I've dabbled in a number of different languages (Python, AS3 (lol), C, Java, and Obj-C) and I really enjoy them all equally, I enjoy just the process of coding and pick it up relatively quickly as far as I can judge (ie finished a semester's course-work of a few of them in a month).
I need to move out within a few months, but I have enough money to support myself for around a year. What I would LIKE to be able to do is to pick a language and become proficient enough at it within a year to support myself (around 18k USD a year where I live) by either freelance, web-design, independent flash-game development, anything really. I realize without a degree getting a steady job would near impossible. So what I would like to know (apologies for the length of the post) is is this possible, or is it just a pipe-dream? Please do keep in mind I can learn things extremely quickly, but I realize there's a significant portion of it that can't be brute-forced. And if it is possible, what language and career should I focus on?
The alternative is for me to find a regular minimum-wage job and try to go to school and learn programming on the side, but in this economy I'd be working most of my time and likely wouldn't have my degree until I'm close to 30, and the thought of just starting my career at thirty makes me have a sick feeling in my stomach :/
TL;DR: Can someone who is able to learn things relatively quickly learn programming to a degree that is able to support them, and if so, what language and/or area of programming should they focus on?
Thank you for your time!
Somehow reading this post made me angry...
Programming is no "get rich fast" scheme, it requires a lot of dedication, hard work and _experience_. Yes, you can become a web designer by copy-pasting a lot of stuff together, a child could do that. However, you will need a lot more time for everything than an experienced programmer, which means in the end you will have to provide your services either for more money than your competitors or work around minimum wage (or below) anyways.
Get a minimum wage job and start to develop websites or flash stuff on the side, get experience, get references and _then_ you might make it. Otherwise you will be just another of those webdesigners that live by the scraps of what the bigger fish don't want to do.
You might also want to apply at professional companies anyways. You can get jobs without a degree if you can prove that you really know how to program. Tell them you are willing to do an internship for free for a month to prove your skills... just make sure you actually have the skills.
If you really want to go freelance, there are 2 major groups these days: 1. Web stuff: HTML5, a lot of JavaScript, easy to learn, a lot of competition, comparatively easy to get jobs but low win margins these days. The time of the bubble is long gone. 2. Smartphone apps: HTML5 and JS with a converter to native code is ok for a lot of small applications but usually you either need Java for Android or a Mac and Objective-C for iphone development. Harder to learn, less competition, harder to find jobs but the win margins can be significantly higher than for Web stuff.
A portfolio is more important than a degree in the programming world. Make stuff, then on interviews you can say "look at these things I've made" and then you get a job.
On April 12 2012 17:29 Morfildur wrote: Programming is no "get rich fast" scheme, it requires a lot of dedication, hard work and _experience_. Yes, you can become a web designer by copy-pasting a lot of stuff together, a child could do that. However, you will need a lot more time for everything than an experienced programmer, which means in the end you will have to provide your services either for more money than your competitors or work around minimum wage (or below) anyways.
On April 12 2012 01:06 phar wrote: @ Above w/ the C++ & Java:
Depending on the scope of your need to communicate between C++ and Java, it may be worth investing some time into looking at JNI Bridge. Despite the fact that it may make you want to pull your hair out, if you are doing a lot of integration between the languages it'll potentially save you a lot of time.
If your need is pretty simple though (e.g. is limited to literally just stuffing one chunk of data at one single point in java to one single point in C++), then JNI Bridge will be overkill.
I just need to start a C++ program and pass it a parameter from within a Java program. I may also want to get a little output from the C++ program, but I can probably do without it.
The Java program is a UI to enable easier access to a much larger C++ program. Right now, the C++ program is just run from command line, but the hope is that eventually non-CS people will be able to use it.
Ok, so I recommend redoing this with an executable that you know works. Try starting up IE or something basic, and stepping through your code. I'm unfamiliar with Java, but I've done this a lot with System.Diagnostics in .Net (Process and ProcessStartInfo classes) and I've been able to capture stdOUT and stdERR reliably.
This may be blatantly wrong (again unfamiliar with java), but doesnt your EXE spawn its own thread and execute when you call process.start() ? This means you're assigning output / input streams after the program has run. Just a guess.
Edit: Because of the class names 'Process' and 'ProcessBuilder' I'm assuming it functions similar to the .NET classes.
The process does start in a separate thread, hence you are assigning input and output streams _while_ the other process is running, not after. But any output occurring is buffered until you actually read it, so you don't miss anything. In fact, some programs you run this way will block because they are either waiting for input or because output buffers just run full and so their print to stdout gets blocked until you start reading from these streams.
I've just been trying it on Hello World right now, and it definitely works, when run on its own. Its when I try to call it from my Java program that I run into trouble.
What bothers me, is that it starts in another thread. Why doesn't the C++ program start its own runtime environment? Why does it get a thread in the Java program?
I don't know if it gets an actual java thread or if the JVM just forks off a regular operating system thread to run it in, why does that make a difference? you don't see it anyways.
I think it does make a difference though. I think why I can't get any output is that it does start a Java thread, and then control never goes back to the original thread, because the C++ one never ends.
no, the process start returns control flow immediately. if you want to wait for the process to end, you explicitly have to call process.waitFor();
try the following: make a very simple program that does nothing but start the c++ program and then System.out.println("hello"); and execute it. You will see the "hello" immediately after the c++ program has started.
your echo lines with these """""" look rather confusing, i'd assume there's some error in there. I remember from when i wrote some php a few years back, i always put {$variable} in {} because it'd screw up regularly otherwise, maybe try that. but a more readable way to write these things would probably be, to write all html as ' strings and put the $ values in manually without the "-string magic:
echo '<p>'.$title.'<select name="'.$name.'">";
it's not as obvious here but it helps a lot when not using strings, e.g. you can write
echo '<p style="color:red">';
without having to double quote anything etc.
for more help without us having to guess what happens, post some output that gets created. "doesn't work" gives absolutely no indication as to what might be wrong, and a lot of people don't have a php execution environment around and probably won't set one up to test your code themselves to find this information. If it gives an error, post it. If it gives screwed up output, post that.
Hey guys, I was hoping I could get a little bit of help with a project I have due soon.
Basically i've been asked to create a top-down shooter game using Python (pygame). The interesting part of the project though is to create power-ups/weapons that are created in game (not pre-defined). I'm now at the stage where I have the base game which features all the other stuff required, but I still have to implement the power-ups. I'm super rusty with Python right now (not used it for a year or so), does anyone have any suggestions for going about this? Just looking for general ideas, any help would be appriciated!
On April 12 2012 07:02 mazerr wrote: Hi TeamLiquid! Long-time (2yr) lurker here, and I finally decided to post, because I need some help! Lengthy read below, but if any of you programming wizards could give some advice I'd appreciate it! I cross-posted this on reddit careeradvice but don't know if I'll get any responses there.
First, a little about my background:
I'm a 23 year old currently living at home. I was a very 'gifted' person when I was younger, ie got As in school w/o effort, played violin and ended up winning a nation-wide HS competition and performed in Carnegie Hall, won local Math competitions, etc, all with very minimal effort. Because of this I developed a superiority complex and became very apathetic regarding what I wanted to do, as I was good at a number of things and a lot of people were pushing me to do 'their' thing. I didn't know what I wanted to do. So I promptly got into a decent engineering school (Rose-Hulman) spent all my time playing WoW, and bombed out. This shattered my superiority complex and triggered depression, which deteriorated over the years to the point where I was living at home, morbidly obese, smoking, and pissing in bottles and letting food rot in my room while I played video games.
I have step-by-step overcome this, and am now trying to get my life back on track, but I need to move out, my parents can simply no longer support me (nor do I wish them to). I REALLY desperately want to begin a career as a programmer. Out of all of the things I've done, I like it the most by far (barring music which I love too personally to want it as a job). I've dabbled in a number of different languages (Python, AS3 (lol), C, Java, and Obj-C) and I really enjoy them all equally, I enjoy just the process of coding and pick it up relatively quickly as far as I can judge (ie finished a semester's course-work of a few of them in a month).
I need to move out within a few months, but I have enough money to support myself for around a year. What I would LIKE to be able to do is to pick a language and become proficient enough at it within a year to support myself (around 18k USD a year where I live) by either freelance, web-design, independent flash-game development, anything really. I realize without a degree getting a steady job would near impossible. So what I would like to know (apologies for the length of the post) is is this possible, or is it just a pipe-dream? Please do keep in mind I can learn things extremely quickly, but I realize there's a significant portion of it that can't be brute-forced. And if it is possible, what language and career should I focus on?
The alternative is for me to find a regular minimum-wage job and try to go to school and learn programming on the side, but in this economy I'd be working most of my time and likely wouldn't have my degree until I'm close to 30, and the thought of just starting my career at thirty makes me have a sick feeling in my stomach :/
TL;DR: Can someone who is able to learn things relatively quickly learn programming to a degree that is able to support them, and if so, what language and/or area of programming should they focus on?
Thank you for your time!
Hi Mazerr! I am an alum from Rose-hulman, and Id love to offer some advice for how to learn programming. You should not feel bad about bombing out of such a school. Its learning style is not for everyone, and I barely survived my way through it. What others have said about picking up programming is definitely true. It takes years of experience before you can turn it into a living.
Dont be discouraged by that! Most people settle into their careers later in life. Getting out of high school, doing well in college, then starting at an entry level position is not the norm.
First bit of advice) I suggest you find a local hackerspace (google is your friend), and get involved. Those are the local DIY/startup guys, and they love bright self driven people. If you do end up having a natural talent and drive, youll find yourself being picked up before you can even program.
Next bit) Programming is a big word that means a whole lot of nothing. You could be an embedded programmer, a web programmer (back or front end), a high speed programmer, automotive programmer, open source, high reliability, secure, game designer, etc.. The list goes on and on. You're going to end up pidgeonholing yourself at some point, probably after your first 3 years (it takes about that long to get a handle of basic algorithms and concepts). Focus not on the specific part, but the general feel of what it takes to program. You don't need a degree for that, and good employers will know this, and invest their own money to train you to be good at the specific thing they need you for. Its easier and cheaper to find someone trainable and teach them than it is to pay more for the right fit.
Finally) Anything is possible, and you really can live off of <20kUSD a year anywhere in the world. You wont get the 20k in your first year learnign to program, though. There is a TON of competition, so focus on getting somewhere EVENTUALLY, not just right that moment.
On April 20 2012 05:54 Aresien wrote: Hey guys, I was hoping I could get a little bit of help with a project I have due soon.
Basically i've been asked to create a top-down shooter game using Python (pygame). The interesting part of the project though is to create power-ups/weapons that are created in game (not pre-defined). I'm now at the stage where I have the base game which features all the other stuff required, but I still have to implement the power-ups. I'm super rusty with Python right now (not used it for a year or so), does anyone have any suggestions for going about this? Just looking for general ideas, any help would be appriciated!
You can create a class for your powerup. The class can have data members for the x and y coordinates. I haven't used Pygame for a couple years so I don't remember how images are stored, but I'm sure you can figure out how to get the image onto the powerup if you've completed those other things. Then you can have a method for the functionality of the powerup, and call this method when the player is detected as in collision with the powerup.
If you want advice on how to place the powerups in your levels, there's a lot of ways to do that. The easiest to get set up and working would just be a function that places the powerup within the level at a specified coordinate.
i have some questions. first of all, let me say i suck at programming, so my questions might be wrongly worded or just plain stupid. or both.
now, lets say i am using c++, and i declare a pointer to an integer, and i intend to use it as a dynamically-sized array. as far as i know, the computer stores bits sequentially, and variables are just chunks of space in memory, in a line. how does the computer know where to save room for the array? if i declare another integer, how does the computer know where to put it so that it doesnt block the space for the dynamic array? for that matter, does the memory for each part of the array have to next to each other at all? if not, how does the computer know which parts of memory are part of the array and which aren't?
TLDR: how does the computer allocate memory for dynamically-sized arrays?
oops ^^ haven't used anything c-like in ages ^^ actually never really learned c++, just used it for a bunch of things without knowing what i was doing x.X but well, worked out and doesn't really hurt for study tasks :D
When you declare variables without pointers in c++, they are indeed analogous to being "chunks of space in memory, in a line". These variables are stored on the stack. However, dynamic arrays, allocated with the new keyword, are stored in the heap. The heap can be viewed as a vast chunk of available memory, whereas the stack is comparatively limited. Compilers handle the details of heap storage differently, but when you declare an array of 120 items, the metadata of that memory is stored somewhere. The new keyword returns a pointer to the start of the array, but the compiler maintains information about how many elements that array contains, such that when you delete[], everything ends up fine and dandy.
For more information, google/wiki stack vs heap memory.
Assuming that double double-quotes is a way of escaping a single double-quote, your code seems to be fine. Very confusing to look at, but functionally OK. We're gonna need a little more description of what the problem is.
Also, please for the love of God, either A) encase your strings in single quotes so you can use double quotes normally, and use the dot operator to concatenate your php variables, or B) keep with the double quote enclosure but use single-quotes for the HTML. I prefer option A personally, but they each have their merits.
Edit: I think I spoke too soon. I imagine you are expecting some sort of functionality to result from your line of "return $value;". Whatever functionality that is, I'm not even sure, but it's not going to work how you have it set up. What is your goal with the presented code?
On April 24 2012 08:55 RoTaNiMoD wrote: Edit: I think I spoke too soon. I imagine you are expecting some sort of functionality to result from your line of "return $value;". Whatever functionality that is, I'm not even sure, but it's not going to work how you have it set up. What is your goal with the presented code?
well yes, return $value is stupid there because $value isn't bound to a value outside of the foreach loop. But since he's using echo, the code should be printed out anyways. It might however not be in the right position on the site, search the generated html source for the tags that this piece of code writes to find that out.