Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Poll

What programming topic would you want the next challenge to be about?  (It might be a good opportunity to focus on a subject you're not familiar with or to reinforce knowledge on one that you already know)

Control Flow
- 2 (2.2%)
Arrays, Strings, Pointers, and References
- 8 (9%)
Functions
- 4 (4.5%)
Basic object-oriented programming
- 30 (33.7%)
A bit more advanced OOP (Composition, Operator overloading, Inheritance, Virtual Functions)
- 18 (20.2%)
Templates
- 8 (9%)
Other (Explain)
- 4 (4.5%)
Working with files?  (Streams)
- 15 (16.9%)

Total Members Voted: 89


Pages: 1 ... 5 6 [7] 8 9 ... 78

Author Topic: Programming Challenges & Resources (#bay12prog) Initiative  (Read 97540 times)

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #90 on: May 27, 2010, 08:56:54 pm »

Can you upload an example .sln/.vcproj of something that's giving you LNK2005 somewhere? I can take a look
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #91 on: May 27, 2010, 09:07:50 pm »

Even something simple, like the following:
Code: (a.cpp) [Select]
#include <iostream>
#include <vector>

using namespace std;

void displayNums(vector<int> nums)
{
for(unsigned int i=0; i<nums.size(); i++)
{
cout<<nums[i]<<endl;
}
}

Code: (main.cpp) [Select]
#include "a.cpp"



int main()
{
vector<int> nums;
nums.clear();
nums.push_back(65);
nums.push_back(69);
displayNums(nums);
system("pause");
return 0;
}
It worked just fine in the previous dev environment I used (dev-bloodshed c++) but gives linker errors when building in visual studio.
« Last Edit: May 27, 2010, 09:09:55 pm by alway »
Logged

Total_Meltdown

  • Bay Watcher
  • BEEEEEEEES!!!
    • View Profile
    • Blogus Arbitrarius
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #92 on: May 27, 2010, 09:10:01 pm »

That could have been said with some degree of civility, Blacken.

Uh oh. Someone disagreeing with Blacken. Time to refute some false claims. (inb4 sarchasm)

The suitability of a tool is largely dependent on the task it is supposed to perform.  I avoided MSVC for quite some time because I didn't need a powerful compiler to learn C++ with, I wanted something with text-entry and a compile/build button.  I love it now, the debugging features are freaking incredible, but I still revert to smaller compilers when all I need to do is test a theory or a couple lines of code.

This is fair. I agree. I would also say that C++ is easier on non-Microsoft platforms. (Please don't confuse "easier" with "easy" or "good")

...next to nothing is absolute in programming, but even with what little programming experience I have...

No. Everything is absolute in programming, unless you're talking about race conditions, but I don't think you are, given "what little programming experience [you] have".

there's an exception to almost every "rule"

Nope. If your rules have exceptions, you wrote them wrong.

...never a single library that is always better than all the others.

  • .net threading
  • .net sockets
  • .net xml parsing
  • .net streams
(Pattern not intentional)


Can we please re-rail this topic now?

Meh.

Total_Meltdown

  • Bay Watcher
  • BEEEEEEEES!!!
    • View Profile
    • Blogus Arbitrarius
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #93 on: May 27, 2010, 09:13:23 pm »

Even something simple, like the following:

Code: [Select]
broke-ass code
It worked just fine in the previous dev environment I used (dev-bloodshed c++) but gives linker errors when building in visual studio.

Learning to program requires lots of reading.

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #94 on: May 27, 2010, 09:21:23 pm »

Here is a challenge, for anyone who wants to try it. It is generally easy, and has two major difficulty levels determined by the language in use(specifically, if it treats strings as a primitive type or not)
Challenge:
Read in a string as input(any method. Passing on the command line, stdin, file input/output, anything else).
Once the entire string has been input, print the last character, a new line, then the input string, with every third "e" replaced with "ii". Printing the last character prevents the easy solution of "input character, if it is the third e, write ii, else write that character back out.
Output is also your choice, as long as it can be read.(Technically, the "cheating" that can be accomplished with fseek or equivalent on file output would probably require about as much skill as any other solution in a language without strings that automatically resize to fit any added characters.)
Logged
Eh?
Eh!

alway

  • Bay Watcher
  • 🏳️‍⚧️
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #95 on: May 27, 2010, 09:32:10 pm »

Even something simple, like the following:

Code: [Select]
broke-ass code
It worked just fine in the previous dev environment I used (dev-bloodshed c++) but gives linker errors when building in visual studio.

Learning to program requires lots of reading.
Huh... It seems my programming structure was all wrong. No wonder it was going crazy, I was including the cpp files along with headers... That certainly makes things easier. Which really makes me hate dev-bloodshed c++ for setting me up for that epic fail. It seems my next few days will be spent re-writing the DirectX9 rendering system I wrote completely in header files. >_>

Edit: Actually, I think I will just start from scratch and save these in my folder of programming lolz along with my first C++ text rpg which uses no structs or classes.
« Last Edit: May 27, 2010, 09:50:54 pm by alway »
Logged

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #96 on: May 27, 2010, 09:52:01 pm »

No. Everything is absolute in programming, unless you're talking about race conditions, but I don't think you are, given "what little programming experience [you] have".

Nope. If your rules have exceptions, you wrote them wrong.
Sorry, I wasn't clear.  Insofar as the way you interpretted "rules", you are entirely correct.  Programming is very black and white (I mean, it's basically a really complicated semi-automated switch-board... how much more black-and-white can you get...)  However, are there are absolutely no conditions what-so-ever under which you should use globals, singletons or non-boolean conditionals, ever?  That's what I was trying to say, although I obviously used the wrong terminology.


  • .net threading
  • .net sockets
  • .net xml parsing
  • .net streams
(Pattern not intentional)
I've stayed as civil as I can, but this is ridiculous...  .NET is great, don't take this the wrong way, but it is not the be-all-end-all library... it is many things, but it is not:
  • Cross-platform
  • Small (compiled/include size)
  • Resource light
  • Easily portable (Non-Windows 7 computers have to download a large file manually to run programs based on newer versions of .NET, not to mention differences in the version of .NET used, vs the version installed or non-PC Microsoft platforms...)
Now, it's great, it performs the task it was designed for superbly, but it is not a be-all-end-all library.  I've used it, but I chose NOT to for some projects, simply because I wanted the project to be either cross-platform or small (which including either .Net, Boost, or anything similar kind of prevents...).

This is not a complicated concept... you don't even have to know much about programming to realize that there is very, very rarely (I admit there is on some occasions though) a single tool for every job.  It doesn't make sense.  A library can't be all-encompassing yet small in size at the same time, it just doesn't make sense.  Now can we please move on?  This is getting ridiculous.  I'd gladly continue the discussion via PM or in a separate topic, but it's a waste of space in this thread.  If you have something constructive to add, feel free to do so in a reasonably polite manner.  Blacken is highly intelligent, he doesn't need you to defend him, and in fact sent me a PM about the subject before you even posted this.


@Qwertyuiopas - That's a pretty good one for the input challenge.  A similar challenge was listed in one of the links from the original post, but had the program read a string (either from a file, input, command line, whatever), then output each word, along with any punctuation immediately following it, in reverse order.  For example
Input: "The quick brown fox, jumped over the lazy dog!"
Output: "dog! lazy the over jumped fox, brown quick The"
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

Normandy

  • Bay Watcher
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #97 on: May 27, 2010, 09:57:12 pm »

Does the fact that innitiative is spelled wrong bother anyone else here? Especially for a thread about programming?

@alway:
The reason you are getting LNK2005 is because both main.cpp and a.cpp are being compiled and linked together, but since the contents of a.cpp are already in main.cpp when you included it, there are duplicate definitions of a.cpp and the whole thing breaks. Just thought you'd like to know.



Really, C++ is a pretty terrible language to start learning from, in hindsight. A lot of what you learn to do you eventually realize is some sort of terrible cheap hack that you can't even begin to do in other languages, because their framers recoiled in horror at the language. And don't even get me started on the lackluster literature. There are quite literally no good beginner books on the language that will teach you anything about programming, because there's just simply too much to teach about C++ to be bothered with it. There are hardly any books that will go into how to get a compiler working, how to use multiple files, what happens when a file is actually compiled (compiled down to assembly and .o, linked together), what make is, and even less that will teach you what a bubble sort is, how to solve problems with code, why and how to apply OO design, and work with STL, or teach anything useful in general.

Don't get me wrong, I love C++, but in hindsight, the only reason I'm any good at programming is because I'm naturally a mathematician; C++ taught me syntax and templates and operator overloading and the importance of streams, but it didn't actually teach me any fundamental programming, because I was too distracted trying to learn the features of the language. Even to this day I'm terrible at design.

Personally, I would suggest learning something more minimalistic, like lua. When the entire language can be documented in a few HTML pages, that is when you might be able to use the language to learn something about programming, not about syntax.

For those of you learning C++ though, here are some very helpful sites that I have picked up:
http://www.icce.rug.nl/documents/cplusplus/cplusplus.html
http://www.fredosaurus.com/notes-cpp/index.html
Logged

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #98 on: May 27, 2010, 10:06:14 pm »

Does the fact that innitiative is spelled wrong bother anyone else here? Especially for a thread about programming?

Init is a common phrase, though, so the misspelling may be intentional...

Personally, I would suggest learning something more minimalistic, like lua. When the entire language can be documented in a few HTML pages, that is when you might be able to use the language to learn something about programming, not about syntax.

Most C/C++ tutorials take a *long* detour through specific libraries, input, and output.

If you leave such things out, full documentation would still be more than just a few pages, but it would be far smaller than before. (Hmm. One page on structs/unions; one on pointers,arrays, and related subjects; One for variable declarations; function declarations; preprocessor directives; loops; conditionals; basic math;(none of those in that particular order); Plus one final page with links to documentation on common libraries. Would that be C in less than 20 pages of documentation? Some could be split/combined...)
Logged
Eh?
Eh!

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #99 on: May 27, 2010, 10:20:49 pm »

  • .net threading
  • .net sockets
  • .net xml parsing
  • .net streams
(Pattern not intentional)
I've stayed as civil as I can, but this is ridiculous...
Actually--and I know Meltdown, so this could be dogpiling, but I promise you it's not--he didn't do that as a "hur .NET is great" thing. These libraries are actually really well designed and much, much more developer-friendly than most competitors, which is why he referred to them. Thus, "pattern not intentional."

Quote
.NET is great, don't take this the wrong way, but it is not the be-all-end-all library... it is many things, but it is not:
  • Cross-platform
  • Small (compiled/include size)
  • Resource light
  • Easily portable (Non-Windows 7 computers have to download a large file manually to run programs based on newer versions of .NET, not to mention differences in the version of .NET used, vs the version installed or non-PC Microsoft platforms...)
All of those are actually incorrect. .NET is an open standard that can be (and is) implemented on multiple platforms. It is no more resource-intensive than any other managed language, and Mono actually provides facilities for building native code out of C# programs (much like Java has facilities for doing the same). It is trivially portable if you avoid certain libraries, which are well-known and well-documented.

I was writing .NET code on the iPhone before Apple changed their devkit rules. It is quite capable of everything you said it isn't.

Quote
Now, it's great, it performs the task it was designed for superbly, but it is not a be-all-end-all library.
That's not what he said. He said it was well designed, and that they were superior to the alternatives. Which...well...they are.

Quote
I've used it, but I chose NOT to for some projects, simply because I wanted the project to be either cross-platform or small (which including either .Net, Boost, or anything similar kind of prevents...).
"Small" is not generally a good thing, and can be achieved in .NET anyway. And .NET programs are, again, quite trivially portable (I can even build it in VS and run it under OS X--just "mono appname.exe" and it runs).
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

Blacken

  • Bay Watcher
  • Orange Polar Bear
    • View Profile
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #100 on: May 27, 2010, 10:21:48 pm »

Really, C++ is a pretty terrible language to start learning from, in hindsight. A lot of what you learn to do you eventually realize is some sort of terrible cheap hack that you can't even begin to do in other languages, because their framers recoiled in horror at the language. And don't even get me started on the lackluster literature.
Holy shit. It's like me talking, but there's somebody else's name on the post!
Logged
"There's vermin fish, which fisherdwarves catch, and animal fish, which catch fisherdwarves." - Flame11235

Alexhans

  • Bay Watcher
  • This is toodamn shortto write something meaningful
    • View Profile
    • Osteopatia y Neurotonia
Re: Programming Challenges & Resources (#bay12prog) Initiative
« Reply #101 on: May 27, 2010, 10:35:05 pm »

After a great weekend I've been horribly busy and horribly sick when I could afford it.  I'll take a look at this tomorrow.  Orange, if you see this, patience.  I'll get back at you, too.   ;)

My only advice before I add the challenges and topics people posted and some of my own is that you remember what the goal of this thread was.

We are not interested in finding out who knows more about what, claiming usage of the perfect tool or anything else that's not helping others and challenging yourself for YOUR own growth (which has nothing to do with other people's growth).

I'm also going to have a pastebin (or something) with the solutions as I implement them (And if anyone wants to chip in, you're welcome) so people can see other alternatives to their own solutions. Anyway, the idea is to only be able to access other people's solutions when you've solved them yourself.

It looks like some people are sending some challenge results.  Good.  If you prefer shorter challenges like the one in piratepad do tell.

About the typo in the topic... I've been waiting for someone to point that out a while ago.  And I wanted to see how it was pointed out.  Remember what I said in the OP?  We ALL make mistakes. 
Quote
Finally.  I, as you, am human.  So feel free to point any mistake I might've made so I can correct it.
I did fuck this title up.  It's not the end of the world.  I've learned a new thing.  Hell, maybe other people did too.  That's the approach we must take while learning, and, we are always learning.

If anyone ever needs motivation, here's a wonderful interview with my favourite author:
Divided in Parts 1,2 & 3.
Isaac Asimov on Bill Moyers World of Ideas pt 1
Isaac Asimov on Bill Moyers World of Ideas pt 2
Isaac Asimov on Bill Moyers World of Ideas pt 3

Ok... Too late... Good night.
« Last Edit: May 27, 2010, 10:41:59 pm by Alexhans »
Logged
“Eight years was awesome and I was famous and I was powerful" - George W. Bush.

timmeh

  • Bay Watcher
    • View Profile
    • My Portfolio
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #102 on: May 27, 2010, 10:37:52 pm »

Ah, sorry about that then Total_Meltdown, misinterpreted the "pattern not intentional" as sarcasm, my mistake. 

As far as the cross-platform bit, I could have sworn it was designed solely for Microsoft-based platforms, but I'm probably wrong.  As far as the small bit... it requires a 200MB+ download for the 3.5 runtime installer download.  Perhaps in a professional environment that's far more acceptable, but when I'm trying to keep file sizes low, it's not acceptable.  The resource light bit I'm sure you know more about, it was probably just my being inefficient there I guess.  The easily portable bit, from what I understand, the standards are completely portable from one device to another, but the full-featured version is only available for the Windows OS, which limits portability to say Silverlight or whatever the name of the Microsoft cell-phone firmware is.

Again though, they are only superior if what downsides they have (however few and seemingly insignificant they may be) don't conflict with the project's goals... for example, a small file size....  Which, for those of us who can't really afford a solid web host, is more than a little important if we intend to share anything we finish....
Logged
On the Wall is a Masterfully engraved carving of Urist McHardcastle and Goblins. Urist McHardcastle is surrounded by the Goblins. The Golbins are stamping on Urist McHardcastle. Urist McHardcaste is laughing at the Goblins. The carving related to the prolonged and bloody death of Urist McHardcastle in the Fall of 1659, the Winter of 1659, and the Spring of 1660. On the engraving is an image of Cheese.

DrPizza

  • Bay Watcher
    • View Profile
    • Ars Technica
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #103 on: May 27, 2010, 11:22:18 pm »

but in Direct3D
Yeah, I thought as much.  ;)
::)

Quote
What is it about microsoft products that make the developers that work with them so... what's the word... defeatist? As if the dark hallways of their life are the only way to live it. As if happy coders aren't allowed to exist, or programming isn't allowed to be fun, or making mistakes is the end of the world. Yes, working on a huge project with a big team makes you hate happy-go-lucky programmers whose shit you have to clean up, preferably in overhours just before a deadline, but that is not the case here. Here's people who like goofing off in programming for fun, fail with grace or succeed with ugly shortcuts, and move on to the next project.
What the fuck are you even talking about?
Logged

DrPizza

  • Bay Watcher
    • View Profile
    • Ars Technica
Re: Programming Challenges & Resources (#bay12prog) Innitiative
« Reply #104 on: May 27, 2010, 11:27:18 pm »

Ah, my syntax was,

inaccurate.
Apologies.
I meant to say that
vector<object> uses an array of pointers to objects.
not an array of objects.

You cannot make an array of objects, because the size is not constant.
What the hell are you talking about?

Seriously, what the hell?

You cannot what?

What?

Because the size what?

What the hell?

What the goddamn hell?
Logged
Pages: 1 ... 5 6 [7] 8 9 ... 78