Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
My joke of a C++ class
Goto page 1, 2  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  <py> Hypertension (Game) Post :: Post java VS c++  View next topic  
Author Message
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sun Feb 04, 2007 3:56 am    Post subject: My joke of a C++ class Reply to topic Reply with quote

So I'm in a C++ class right now designed for Mechanical Engineers who have only ever used MATLAB up until this point for programming. Unfortunately, I actually have to learn stuff now because of this silly restriction I found in the course policy:



which is kind of a pain in the ass since I won't even be able to use stuff like sprintf which has nothing to do with displaying characters on the screen.

So the million dollar question is, is there anything I can do with the preprocessor to have stdio included without having the file contain "stdio.h"?
_________________

Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sun Feb 04, 2007 5:21 am    Post subject: Reply to topic Reply with quote

Might I ask what he recommends instead? I know professors love cin/cout, which is not very often used by real programmers, but does he think that you should use a string class for everything? Are char arrays outlawed as well?

If he blames that they cause buffer overflows and are not type safe, you can either a) tell him to teach Python or Java, b) programming is all about making assertions and to be able to cope with them, be it due to the language being used or the data you are working with, or c) tell him about ISO/IEC WDTR 24731 (pdf) that deals with standardizing secure versions of strcpy/sprintf to prevent buffer overflows.

If you really want to have stdio type functionality without ever having called it directly or indirectly, just use wchar for wide-character support, which has all the same features of stdio, except for wchar_t instead of char.

Not allowing goto's is pretty good, as novices use it more often than they should, and there are much better ways to go about it than using them. There are exceptions to the rule of never using goto's, as one of my own personal projects uses them instead of being a recursive function and a for loop would be unwieldy and cause ugliness to enter the code more than a simple goto jump.

Only once you've programmed something complex in assembly are you allowed to use goto statements in C/C++. Removing char arrays and printf functionality is pretty harsh, but you just admitted that you don't program in C/C++ before you started this class. In the case of learning, as it seems that you won't use C/C++ very heavily in the future, just follow through with what the teacher requires. Use cin/cout and horribly slow string classes. It is not like you are programming for a system with 768K ram.
Back to top
View users profile Send private message Add User to Ignore List Send email
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sun Feb 04, 2007 11:29 am    Post subject: Reply to topic Reply with quote

Code: Show/Hide
#define LOLLERSKATES <stdio
#include LOLLERSKATES.h>

_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Sun Feb 04, 2007 12:52 pm    Post subject: Reply to topic Reply with quote

Ah, thanks Bak. I had been trying that with "s instead of <s

Yeah, we're using cin and cout. Haven't gotten to anything yet that requires actual string manipulation, though I would have preferred to be able to use stdio for formatting. I never said I hadn't programmed in C/C++ before, just that the class was designed for people who hadn't.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Sun Feb 04, 2007 2:07 pm    Post subject: Reply to topic Reply with quote

Then just tell the teacher you have C/C++ experience and would like to use stdio. In every one of my programming classes, I used scanf/printf and never cin/cout. Teacher never cared, because I checked my inputs to make sure it could never allow the program to enter an unknown state, and because the code looked very clean and usually had more features than was requested.

Reminds me of math teachers that required me to show work. Nope, I just threw down an answer, sometimes with a line or two scratched down if I needed it. Every math teacher complained up front, but when I handed in the test a full fifteen minutes earlier than anyone else, it usually calmed them down and stopped marking points off for not showing work. You just need to show the teacher you are competent enough early, and you can generally do things your way.
Back to top
View users profile Send private message Add User to Ignore List Send email
Muskrat
Server Help Squatter


Age:36
Joined: Aug 24 2004
Posts: 829
Location: Swamp
Offline

PostPosted: Sun Feb 04, 2007 6:38 pm    Post subject: Reply to topic Reply with quote

In all my math/physics classes the answers were usually optional, they want to see that last step with pure variables. How do you do proofs?
Back to top
View users profile Send private message Add User to Ignore List AIM Address
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Sun Feb 04, 2007 10:00 pm    Post subject: Reply to topic Reply with quote

You're whining about what library you have to use for output.

Last edited by SamHughes on Thu Feb 08, 2007 12:00 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Sun Feb 04, 2007 10:32 pm    Post subject: Reply to topic Reply with quote

SamHughes wrote:
You're whining about what library you have to use for output. Get a life.

And here's one sentence of useful informativeness. If you wanted to use sprintf, use std::stringstream, which is a good substitute. I now prefer that to sprintf. Or implement your own printf and sprintf functions just to spite them. But why wouldn't you want to use the std::string class? It's easy and it's your friend. And if you're going to be a library bigot, I recommend avoiding programming for the rest of your life.


I guess you were rooting for the Bears? Calm down, I think D1's problem is that his professor is a library bigot, not the other way around.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Sun Feb 04, 2007 11:05 pm    Post subject: Reply to topic Reply with quote

What are the Bears? Please don't take me too personally, or yourself too seriously. The professor may have made that rule for a good reason, so that TAs don't need to be familiar with stdio libraries. iostream is much simpler, much easier to grade, and much easier to help students with, and much easier to teach.
Back to top
View users profile Send private message Add User to Ignore List
Dr Brain
Flip-flopping like a wind surfer


Age:38
Gender:Gender:Male
Joined: Dec 01 2002
Posts: 3502
Location: Hyperspace
Offline

PostPosted: Mon Feb 05, 2007 8:56 am    Post subject: Reply to topic Reply with quote

iostream is also more efficient, though it's been many moons since I've used C++.
_________________
Hyperspace Owner

Smong> so long as 99% deaths feel lame it will always be hyperspace to me
Back to top
View users profile Send private message Add User to Ignore List AIM Address Yahoo Messenger MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Mon Feb 05, 2007 11:17 am    Post subject: Reply to topic Reply with quote

Darnit. I was so glad none of the Java acolytes had posted here, but looks like I celebrated too early.

iostreams more efficient? No. I can tell you for sure that switching from iostreams to stdio both decreased the size of one of my apps and increased the speed of a large file load.

Simpler? Easier to grade? These go together. Which of these is easier to understand?
Code: Show/Hide
cout << "Freq " << freq->id << " has " << freq->flagcount << " flags!";

Ahh, did I put all the spaces in the right place? Man, just glancing at this line I can't get a good idea of what it outputs anyway. Too many symbols and interruptions in the string.
Code: Show/Hide
printf("Freq %d has %d flags!", freq->id, freq->flagcount);

Nice and simple.

Easier to help students with? Easier to teach? Yep, as MGB said intro professors love this stuff because it's easy to teach. That's all.

If you want easy, use Java.
_________________
This help is informational only. No representation is made or warranty given as to its content. User assumes all risk of use. Cyan~Fire assumes no responsibility for any loss or delay resulting from such use.
Wise men STILL seek Him.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Mon Feb 05, 2007 11:23 am    Post subject: Reply to topic Reply with quote

SamHughes wrote:
What are the Bears?


The guys who lost the super bowl. I figured, since you were so pissed off with no actual logical reason, you must have lost some bet on the Bears.
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
D1st0rt
Miss Directed Wannabe


Age:36
Gender:Gender:Male
Joined: Aug 31 2003
Posts: 2247
Location: Blacksburg, VA
Offline

PostPosted: Mon Feb 05, 2007 1:20 pm    Post subject: Reply to topic Reply with quote

It's an automated grader, which is what I had a beef with because if it finds stdio.h in the file it spits it back and won't grade it.

I can see teaching iostream, but not preventing people who are more used to stdio from using it.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Tue Feb 06, 2007 5:43 am    Post subject: Reply to topic Reply with quote

If you use that << gibberish don't you also have to use weird wrapping functions to format decimal places and add left/right padding?

I don't use C++ much but aren't you able to leave off the .h on includes? Like:
#include <stdio>
I guess that would load some special C++ version of stdio.h. I've never tried it myself so I may be talking more gibberish biggrin.gif
_________________
ss news
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Cyan~Fire
I'll count you!
I'll count you!


Age:36
Gender:Gender:Male
Joined: Jul 14 2003
Posts: 4608
Location: A Dream
Offline

PostPosted: Tue Feb 06, 2007 1:00 pm    Post subject: Reply to topic Reply with quote

You're right on all counts, Smong.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Tue Feb 06, 2007 5:36 pm    Post subject: Reply to topic Reply with quote

That would be #include <cstdio>.
Back to top
View users profile Send private message Add User to Ignore List
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Fri Feb 16, 2007 12:03 pm    Post subject: Reply to topic Reply with quote

Um, my professor just gave us a lecture on programming languages. He started off by proclaiming C++ to be the hardest language out of 200 possible programming languages. Which after I think about it, it's possible, but it just makes him sound extremely biased. He followed up by explaining that C++ programmers get the highest wages(which if you believe the Stroustrup interview, both of these things make sense, I guess...), but we shouldn't put TOO much stock in the language, because C# is the best language that exists. He's currently encouraging all of us to take his C# class next semester... um. Now he's telling us we aren't even going to learn to program in this class. Apparently he doesn't teach us how to program until the C# class. -.- Sometimes, I feel like a clown is going to bust through the door and explain that the CS major here was just a joke, give us our money back, and send us home. >_> Is this how class is for the rest of you guys?
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Feb 16, 2007 12:47 pm    Post subject: Reply to topic Reply with quote

I actually wish they taught programming concepts independent of languages, as lots of things would make sense and therefore be easier to learn once you understand them, instead of just memorizing everything and then figuring out the "why" afterwards.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Fri Feb 16, 2007 6:43 pm    Post subject: Reply to topic Reply with quote

Bak wrote:
I actually wish they taught programming concepts independent of languages, as lots of things would make sense and therefore be easier to learn once you understand them, instead of just memorizing everything and then figuring out the "why" afterwards.


I've come to think this way too. But is such a thing even possible? That's learning communication without learning any of the forms. I mean, can you really learn anything without an instance of that thing to understand? Heck, I can't even figure out how to word the question correctly. Anyway, if you find anyone's written a book like that, let me know....
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Fri Feb 16, 2007 9:48 pm    Post subject: Reply to topic Reply with quote

Bak, what do you mean? What would a course teaching programming concepts end up teaching, and what are you referring to by "just memorizing everything"? What's there to memorize?
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri Feb 16, 2007 10:33 pm    Post subject: Reply to topic Reply with quote

hmm I guess it would start at a lower level, then build the language from the bottom up.

like rather than learning the syntax for do while loops, you learn the pseudo-assembly equivilent, then learn how the C abstraction works.

I just remember when learning coding always getting messed up with the syntax, but that's not really what coding's about
Back to top
View users profile Send private message Add User to Ignore List AIM Address
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Fri Feb 16, 2007 11:47 pm    Post subject: Reply to topic Reply with quote

If you don't want syntax, maybe Scheme? Have you ever taken a look at
http://swiss.csail.mit.edu/classes/6.001/abelson-sussman-lectures/ ? But I don't think that's the best introductory course for most colleges. Not even for MIT, which is why they're changing it.

I would agree with the pseudo-assembly language idea. This would force students to use abstractions as a mental model, not a physical thing they write in code.

The first time I tried learning C++, I got bogged down when the book started mentioning stuff like cout.setf(ios::fixed). It was a big WTF. So I gave up on C++, and instead learned programming in Reverse Polish Lisp, on a handheld calculator. That's a stack-based programming language, like Forth and Factor, and like the pseudo-assembly language idea, it forces you to keep your abstractions in your mind, not in code. Then again, the C++ book I had was very bad. CompSci II with Koenig & Moo and Stewart was much better.

Which would be better for a starting language, a stack-based language or an assembly language? I don't see the point in having students manage registers, so I'd go with a stack-based language. I'd bet the Factor language would be a good starting language. I don't think this is a very good "tutorial", but here is one. http://factorcode.org/responder/help/show-help?topic=tutorial . It is a high level language in one sense, but in another sense, it is low level in that students will have to think in a concrete, low level fashion.
Back to top
View users profile Send private message Add User to Ignore List
Muskrat
Server Help Squatter


Age:36
Joined: Aug 24 2004
Posts: 829
Location: Swamp
Offline

PostPosted: Sat Feb 17, 2007 12:21 am    Post subject: Reply to topic Reply with quote

I think the introductory courses should center on a transition from math and stress the connection by maybe starting with some mat lab type coding. That way people will have a better way of understanding where functions come from and how to build algorithms. Besides, the logical thinking involved in math is very much a prereq to understanding formalized language structures.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
SamHughes
Server Help Squatter


Joined: Jun 30 2004
Posts: 251
Location: Greenwich
Offline

PostPosted: Sat Feb 17, 2007 12:49 am    Post subject: Reply to topic Reply with quote

Maybe. But I have to stop when you say "mat lab type coding". That would cause irreparable brain damage. But the general principle... how would you structure the course? What would its table of contents be?

By the way, where do functions come from?
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Sat Feb 17, 2007 3:25 am    Post subject: Reply to topic Reply with quote

You could even do simple things like unary adders with turing machines, computing factorials using abacus machines or designing a binary adder circuit. After doing these a few times you learn to think about problem solving with the tools you're given, and can understand why modular code is a good thing.

Unfortunately it would probably be discouraging to take a computer science course and not learn how to code a real language, as Animate Dreams undoutably feels about his non-programming CS course. It would probably work best to mix in practical programming in a real language with the more abstract stuff, plus it would give students a good foundation for CS theory.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Non-Subspace Related Coding All times are GMT - 5 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 646 page(s) served in previous 5 minutes.

phpBB Created this page in 0.525797 seconds : 50 queries executed (78.5%): GZIP compression disabled