• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Tomat

Wanna hear a good joke? Waste your time helping me! LOL!
Best advice I can ever give anyone after the program I just turned in:

NEVER

WAIT

UNTIL

THE

LAST

MINUTE.

EVER.

I hate myself right now.
 

neemmss

Member
So I want to get into web development and programming. What would be the best way to start learning how to do this? I know a little bit of php, but have been reading that django (python) is a better language that is more cleaner for bigger scale projects and that such.

What do you recommend? I would like to be able to eventually make a small scale "social network" like site for myself for fun.

Edit: Or Ruby on Rails?
 
Ah np. I've actually had the same problem when I was doing my first few projects in C++...

I think depending on the IDE/compiler you use, some will actually warn you about using = vs == in some places, but it's definitely something to watch out for in general.

You should turn the expression around:

Code:
if( 1 == current_size ) {

If you only type a single = here for some reason you will always get an error because you cannot assign a value to a non-variable.
 

usea

Member
So I want to get into web development and programming. What would be the best way to start learning how to do this? I know a little bit of php, but have been reading that django (python) is a better language that is more cleaner for bigger scale projects and that such.

What do you recommend? I would like to be able to eventually make a small scale "social network" like site for myself for fun.

Edit: Or Ruby on Rails?
First let me preface my post by saying that I am not a fan of php at all, and I think python is great. I also love mvc for web apps (django is an mvc framework).

When somebody says language X is better than Y, you should take it with a grain of salt. Most of the time it's like arguing flavors of ice cream when at the end of the day they'll all get you equally fat. The differences are very minor in reality.

If you just want to get something done and you're not working with a team or anything, you need to choose your language based on a combination of:
1) whatever you're already comfortable with
2) the right tool for the job. Some languages are just not suited for some things. I wouldn't write a website in C++ for example (but hey, OkCupid was done that way!)

Given that php is absolutely fine for making websites, you have the right tool for the job part down. And if that's what you know best, then you might as well leverage that knowledge to help you get stuff done faster.

Don't get me wrong, I think learning new things is awesome. I am currently writing a website in Go even though it's kind of crappy, just because I want to learn about it. Python is great. If you have the time, by all means learn it. But there's nothing wrong with php unless you're a programming snob.
 

Ixian

Member
Best advice I can ever give anyone after the program I just turned in:

NEVER

WAIT

UNTIL

THE

LAST

MINUTE.

EVER.

I hate myself right now.
Some of my fondest college memories include staying up all night to finish a programming assignment, going in to school to submit it and then immediately leaving to go home and sleep.
 
Best advice I can ever give anyone after the program I just turned in:

NEVER

WAIT

UNTIL

THE

LAST

MINUTE.

EVER.

I hate myself right now.

One of my professors basically made this a rule of his class. We had to putty in to the university unix server to do most of our work. He checked who was logged in every night. If you weren't logged in regularly he would give you no leniency in grading. By the end of the term we realized he was looking out for us and not just being a hard ass.
 

Noirulus

Member
One of my professors basically made this a rule of his class. We had to putty in to the university unix server to do most of our work. He checked who was logged in every night. If you weren't logged in regularly he would give you no leniency in grading. By the end of the term we realized he was looking out for us and not just being a hard ass.

I wish my prof did this. I'm facing hell this week with two assignments due on thursday, one in C and one in Java. I need to work with a lot of double pointers in the C assignment. Fucking pointers are the bane of my soul. Procrastination as well, I guess.

Also, it doesn't help that the my VM Ubuntu is lagging like a bitch for whatever reason. Ugh.
 

usea

Member
One of my professors basically made this a rule of his class. We had to putty in to the university unix server to do most of our work. He checked who was logged in every night. If you weren't logged in regularly he would give you no leniency in grading. By the end of the term we realized he was looking out for us and not just being a hard ass.
That's dumb. Professors should leave that hand-holding shit for high school. If I want to do it on my own machine and upload when I'm done, that's my business. If I want to do it the night before, that's my business. Metrics like that used as part of grading is absolutely ridiculous.
 
That's dumb. Professors should leave that hand-holding shit for high school. If I want to do it on my own machine and upload when I'm done, that's my business. If I want to do it the night before, that's my business. Metrics like that used as part of grading is absolutely ridiculous.

Double this, penalize those that dont finish on time.
 

Noirulus

Member
That's dumb. Professors should leave that hand-holding shit for high school. If I want to do it on my own machine and upload when I'm done, that's my business. If I want to do it the night before, that's my business. Metrics like that used as part of grading is absolutely ridiculous.

I'm guessing the reason his prof had such a system is because it's not a good habit to fall into the cycle of doing assignments in the last minute. In my University we have a giant C++ project during 3rd year that involves spending hours and hours each day in order to get it done by the end of the semester, and many people fail because they procrastinate.
 
That's dumb. Professors should leave that hand-holding shit for high school. If I want to do it on my own machine and upload when I'm done, that's my business. If I want to do it the night before, that's my business. Metrics like that used as part of grading is absolutely ridiculous.

You didn't HAVE to write your code on the unix server. You certainly had to test against it. I usually coded on my own pc, depending on the language, but you're an idiot if you don't test against prod, which required a login.

He also put test scripts on the unix server and other assets. He would ask that if you had questions about your code that it was on the server so he could look at it too. He was literally the best prof I ever had.
 

usea

Member
Yeah I am just venting because I hate stupid rules. Having to do that is a reality at most universities, because a much larger portion of the class would fail if you don't. But I still think it's stupid.

I really like the schools that have automatic testing submission systems, where you can submit your program at any time to the system and it will run it through some tests and tell you which tests it fails. And you can do this before submitting it for a grade. Those are pretty great, because it helps with the ambiguity that a lot of cs assignments unfortunately exhibit.
 
Yeah he put up test scripts so you could test before the deadline. If you didn't get an A in his class it was basically your fault, but the course was still very challenging.
 

Kalnos

Banned
I really like the schools that have automatic testing submission systems, where you can submit your program at any time to the system and it will run it through some tests and tell you which tests it fails. And you can do this before submitting it for a grade. Those are pretty great, because it helps with the ambiguity that a lot of cs assignments unfortunately exhibit.

This is how my OS (Minix VM) and databases classes worked, it's pretty awesome.
 

jon bones

hot hot hanuman-on-man action
+1 older dude going back to school. perhaps you guys can help me out with this problem i've been trying to solve:

using c++ / assembly:

move 'ABBA' to the EAX register. write code to rearrange it to BABA.

mov eax, 'ABBA'
mov ebx, 00000000000000000100001001000001b
and eax, ebx //eax = 00BA
shl ebx, 16 //ebx = BA00
or eax, ebx //eax = BABA

now i've got BABA into the eax register, but i can't get it to display or move it to a string. how on earth do i do this? i've been googling around but there appears to be no elegant solution i can think of.
 

Tomat

Wanna hear a good joke? Waste your time helping me! LOL!
This might not be the right question (I'm still new to Assembly), but are you using something like Easy68k or programming for a Motorola 68000?
 

jon bones

hot hot hanuman-on-man action
This might not be the right question (I'm still new to Assembly), but are you using something like Easy68k or programming for a Motorola 68000?

ah - i'm just using microsoft visual studio 2010. it's done in c++ with the assembly done like so:

int main (){

_asm{

//some code

}

return 0;
}
 

Tomat

Wanna hear a good joke? Waste your time helping me! LOL!
ah - i'm just using microsoft visual studio 2010. it's done in c++ with the assembly done like so:

int main (){

_asm{

//some code

}

return 0;
}
Ahhh, sorry! I'm sure someone around here knows what's up.
 

jon bones

hot hot hanuman-on-man action
Are you getting a second bachelor's or first?

i got my BS in finance back in 2008, worked on wall street for nearly 5 years and then lost my job.

now i'm back in school at the age of 27 getting my MS in comp sci - but i need to take a handful of pre-req classes first, including assembly.

i've been messing around with programming since high school though - i'm no pro, but i understand the basic concepts, data structures and algorithms involved in coding.

Ahhh, sorry! I'm sure someone around here knows what's up.

it's ok - i appreciate the help!
 

hateradio

The Most Dangerous Yes Man
i got my BS in finance back in 2008, worked on wall street for nearly 5 years and then lost my job.

now i'm back in school at the age of 27 getting my MS in comp sci - but i need to take a handful of pre-req classes first, including assembly.
I'm in a similar situation. I got a BA in a different field, but I want to go back to school.

What are you focusing on with the MS? And how did you get into a program without having the BS in CS, or what do you mean that you need some pre-req stuff?
 

jon bones

hot hot hanuman-on-man action
I'm in a similar situation. I got a BA in a different field, but I want to go back to school.

What are you focusing on with the MS? And how did you get into a program without having the BS in CS, or what do you mean that you need some pre-req stuff?

well when i applied for my MS i made sure i:
-got 2 solid recommendations from ex-colleagues (one hedge fund manager, one ceo of an investment firm)
-i had a decent GPA in college (around 3.0)
-i had a good GRE score (i forgot, but i think it was around the 80th percentile)
-i already took a few high level math courses and low level coding courses back in undergrad

now i am accepted to my MS program but cannot take MS level classes until i finish 2 semesters worth of undergrad courses: 2 math courses and 6 programming courses.
 

SolKane

Member
well when i applied for my MS i made sure i:
-got 2 solid recommendations from ex-colleagues (one hedge fund manager, one ceo of an investment firm)
-i had a decent GPA in college
-i had a good GRE score
-i already took a few high level math courses and low level coding courses back in undergrad

now i am accepted to my MS program but cannot take MS level classes until i finish 2 semesters worth of undergrad courses: 2 math courses and 6 programming courses.

What math courses do you have to take? I'm thinking of going for an MS too without a BS.
 

neemmss

Member
First let me preface my post by saying that I am not a fan of php at all, and I think python is great. I also love mvc for web apps (django is an mvc framework).

When somebody says language X is better than Y, you should take it with a grain of salt. Most of the time it's like arguing flavors of ice cream when at the end of the day they'll all get you equally fat. The differences are very minor in reality.

If you just want to get something done and you're not working with a team or anything, you need to choose your language based on a combination of:
1) whatever you're already comfortable with
2) the right tool for the job. Some languages are just not suited for some things. I wouldn't write a website in C++ for example (but hey, OkCupid was done that way!)

Given that php is absolutely fine for making websites, you have the right tool for the job part down. And if that's what you know best, then you might as well leverage that knowledge to help you get stuff done faster.

Don't get me wrong, I think learning new things is awesome. I am currently writing a website in Go even though it's kind of crappy, just because I want to learn about it. Python is great. If you have the time, by all means learn it. But there's nothing wrong with php unless you're a programming snob.

So which language do you think would be more valuable to learn? Should I learn python with django because I might have more options with python than php?
And why do programming snobs say bad things about php?
 
So which language do you think would be more valuable to learn? Should I learn python with django because I might have more options with python than php?
And why do programming snobs say bad things about php?

It's not snobby to say that PHP is a bad language, it's well documented fact.

The short version, disadvantages:
- Inconsistent standard library naming conventions and behaviour.
- Shallow wrappers around C functions
- Unpredictable behaviour based on anything from compile time flags so server config to local code changes
- Stupid syntax decisions
- Uselss operators ( == is not even transitive )
- Language constructs disguised as functions
- The only language that has a worse "include" is JavaScript, which has none
- Dumbest error handling system known to man

Advantages:
- It's everywhere so finding other people's shitty code for copypasta is easy.

I could keep going but why bother, the language is a disaster.

That being said it's not like learning it will ruin you forever, and you can still pick up lots of important core paradigms involved in programming just fine. It's just that it's a mess and I feel bad that people have to use it.
 
So which language do you think would be more valuable to learn? Should I learn python with django because I might have more options with python than php?
And why do programming snobs say bad things about php?

Disclaimer: I'm a RoR developer and previous to that I was a Perl developer.

I would go with either python or ruby. It's not that I'm snobby about PHP, but from my experience, your average php developer writes worse code than your average ruby/python/(sometimes) perl developer. When I slog through some php, I find that it's not DRY at all, poor naming of variables, classes, hard to read, lots of security holes, etc.

What lorebringer said about ability to copypasta being an advantage of PHP, I find is a big disadvantage. People who stupidly copy/paste from one thing to another without understanding the code makes code a pain to maintain and terrible to debug.

What I like about python and ruby is that the language is a little more strict or structured, so you don't have to worry about getting too weird or mickey-mouse with your code, which is one gripe i had about programming perl. I also like that there are some pretty good, maintainable, easy to read, libraries out there for any common methods you need to use.

In general, I don't think it really matters what language you pick up first as long as you understand the underlying grammar of how to program: common design solutions, algorithms, pros and cons of when to iterate and when to recurse. Just find the right tool/language for the thing you want to do and go from there.
 

Gadfly

While flying into a tree he exclaimed "Egad!"
+1 older dude going back to school. perhaps you guys can help me out with this problem i've been trying to solve:

using c++ / assembly:

move 'ABBA' to the EAX register. write code to rearrange it to BABA.

mov eax, 'ABBA'
mov ebx, 00000000000000000100001001000001b
and eax, ebx //eax = 00BA
shl ebx, 16 //ebx = BA00
or eax, ebx //eax = BABA

now i've got BABA into the eax register, but i can't get it to display or move it to a string. how on earth do i do this? i've been googling around but there appears to be no elegant solution i can think of.

Have you tried:

mov foo,eax
?
where foo is a stack variable in your C++ function.
 

r1chard

Member
As a first language I still recommend Python over Ruby; with the former you just have less to learn (though the extra Ruby you have to learn is usually in the DSLs people love making), but at the same time Python and Ruby are extremely powerful and perfectly cromulent as day-to-day go-to tools for almost any job.
 

hateradio

The Most Dangerous Yes Man
I went from PHP to Ruby quite simply, but that's probably because I was toying with OO design while I was using it. I think the next language I want to learn is Python . . . as soon as I create a simple portfolio with Rails.
 
What lorebringer said about ability to copypasta being an advantage of PHP, I find is a big disadvantage. People who stupidly copy/paste from one thing to another without understanding the code makes code a pain to maintain and terrible to debug.

Sarcasm doesn't carry well on the internets. :p

thatsthejoke.gif
 

usea

Member
So which language do you think would be more valuable to learn? Should I learn python with django because I might have more options with python than php?
And why do programming snobs say bad things about php?
You said you already knew php. So my advice was to not learn anything new, just get things done with what you already know.

If you insist on learning something, python is the best option. It's definitely a better language than php. By a lot.

A language snob is somebody who says "Don't use language X for your project. Y is better. Learn it" when both languages are widely used and very productive. All the people who replied above me are language snobs. I am a language snob.


I think php is shitty. But that statement is in a certain context. The context is an ideal fantasy world where you have infinite time, no constraints like team skills, no previous code base, no previous experience with one language over the other, or you just want to screw around rather than get things done. Programmers live in this world when they make stupid statements like "php is shitty."

Personally, I would never begin a project in php. Unless I went to work at a company that did php, or any of 50+ other reasons that exist in the real world happened.
 

jon bones

hot hot hanuman-on-man action
Have you tried:

mov foo,eax
?
where foo is a stack variable in your C++ function.

i did, didn't work. what i did was just move each register to a character, then display each character in a row.

i asked the prof and he said he fucked up - moving eax to a string is a huge process and isn't what he was trying to teach in class. he didn't mean to word the problem like he did. it is now considered extra credit. thanks for the help, though!
 

Gadfly

While flying into a tree he exclaimed "Egad!"
i did, didn't work. what i did was just move each register to a character, then display each character in a row.

i asked the prof and he said he fucked up - moving eax to a string is a huge process and isn't what he was trying to teach in class. he didn't mean to word the problem like he did. it is now considered extra credit. thanks for the help, though!

I am surprised that it didn't work for you. I have used this several places in my code (Windows operating system if you must know!). Make sure foo is a UNLONG64 variable though.

This is not to say that once you moved this to a local variable you can display it easily. You have to typecast a pointer to this variable to UCHAR* and then fetch every character and print it. My point was to show how the result of an operation done in an asm block can be transferred to a local variable (which I thought your problem was).
 

r1chard

Member
Yeah he put up test scripts so you could test before the deadline. If you didn't get an A in his class it was basically your fault, but the course was still very challenging.

Been thinking about this some more and I still say screw that :)

When I was lecturing Python (which I'm not any more because of budget cuts - I really enjoyed it) my main assignment required the students to write their own unit tests for the application code they'd written (the API was meticulously defined.) Markers then ran submitted applications against my tests and their unit tests against my application.

And yet I still had students requesting (quite forcibly) that I supply them with a test script to run against their application.
 

mantidor

Member
all this assembly talk is confusing me and I did my thesis in assembly D:

Isn't assembly heavily dependent on the hardware you are using? because none of that is familiar to me, and I used to program Motorola microcontrollers.

This was more than 10 years ago, thats probably the reason.
 
Been thinking about this some more and I still say screw that :)

When I was lecturing Python (which I'm not any more because of budget cuts - I really enjoyed it) my main assignment required the students to write their own unit tests for the application code they'd written (the API was meticulously defined.) Markers then ran submitted applications against my tests and their unit tests against my application.

And yet I still had students requesting (quite forcibly) that I supply them with a test script to run against their application.

He was smart about it. He didn't actually give you test scripts or tell you what he expected results were. You submitted it to a directory, executed a command, and it ran the program with his test data and told you whether or not it executed correctly and on which step it had failed. His sample data was also not the same as his final test data as I recall. He certainly didn't make it easy, he just was more lenient with people who worked hard and started early than he was with people who only started a few days before the project was due. The nice off shoot of this was you basically got an instant grade.
 

r1chard

Member
He was smart about it. He didn't actually give you test scripts or tell you what he expected results were. You submitted it to a directory, executed a command, and it ran the program with his test data and told you whether or not it executed correctly and on which step it had failed. His sample data was also not the same as his final test data as I recall. He certainly didn't make it easy, he just was more lenient with people who worked hard and started early than he was with people who only started a few days before the project was due. The nice off shoot of this was you basically got an instant grade.

Ah, that is good.
 

remz

Member
Best advice I can ever give anyone after the program I just turned in:

NEVER

WAIT

UNTIL

THE

LAST

MINUTE.

EVER.

I hate myself right now.
Pretty much learning this tonight. First year java student who left my bigass assignment till the night before. I suck so bad too :(
 

hateradio

The Most Dangerous Yes Man
You can simply write it like this.

Code:
<? if ($foo) : ?>
  <i>Foo</i>
<? else ?>
  <b>Bar</b>
<? endif; ?>

Short tags (meaning <? instead of <?php) are common.
 

gryz

Banned
that feeling when you finally figure out that really hard bug in your program and then you can't be bothered to fix the rest of the easy shit that you need to do.
 
Just an anecdote from my early days of programming in C - my data storage mechanism was basically a huge struct serialized to a binary file with fput or whatever the hell it was (been a long time since I've done file io in C). But when I read it in it was ALWAYS garbage. I spent two days, literally, trying to figure out what was going wrong. (Keep in mind I was by myself at a smaller company and the only programmer). Finally, after much travail, I realized that I was opening the file for the write as binary and opening it for a read as ascii (or vice versa). Could not believe it. Almost caused me to give up programming because I thought that if I didn't see that sooner then I completely suck.
 
Top Bottom