Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » List or Vector

Credits go to Jonatan Hedborg for helping out!
This thread is locked; no one can reply to it. rss feed Print
 1   2 
List or Vector
Jonatan Hedborg
Member #4,886
July 2004
avatar

I'd argue that if you need to learn it eventually anyway, you might as well do it as soon as possible and get more out of STL (a fair bit of questions regarding lists, iterators etc posted here could have been avoided if they knew how a linked list works). It's not weeks of studying for gods sake... It takes maybe 5 hours to build a decent linked list from scratch if you don't know anything about it - and that time includes googling for help.

It's also a generic knowledge applicable in most languages and programming situations... STL is only in C++ (though most modern languages does have an equivalent).

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

And that's something you learn when you need to.

Data structures and algorithms are something a programmer should learn in CLASS before they even start coding.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Karadoc ~~
Member #2,749
September 2002
avatar

Speedo said:

So, when someone asks for a 2d graphics library, do you recommend allegro to them and then say "but write your own library first, it's good experience and will help you understand the concepts behind it"? Of course not - the idea is pretty silly.

You're right. I would not give that advice. But as Jonatan pointed out, Allegro is not the standard template library. I said that I don't think the point of the STL (or C++) is to allow people to program stuff without understanding it; but rather to allow people to write object orientated code that is easy to read and has a reliable foundation. On the other hand, I do think that part of the purpose of Allegro is to allow programmers to do things without understanding the details.

Regardless of what you or I think STL and Allegro are for, I would still recommend that anyone who wants to learn about programming should at some point use dynamically allocated arrays (do-it-yourself 'vectors') and write their own linked list implementation. I know that I understand pointers and memory addresses and computers in general a lot better for having done those things myself, and the knowledge I've gained from it has enabled me to do more complicated things.

-----------

Speedo
Member #9,783
May 2008

Quote:

It's not weeks of studying for gods sake... It takes maybe 5 hours to build a decent linked list from scratch if you don't know anything about it - and that time includes googling for help.

That's pretty much the point. People always love to make this argument for linked lists - but you basically never see it for vectors, deques, maps, strings, or any of the other STL containers. Why? Because people for some reason have this thing about linked lists...

It doesn't really make sense. There's really no logic to shoving it down the throats of beginning programmers. Honestly, check out some modern intro-to-C++ books - many of them introduce you to vector and string before they even teach things like control structures.

Quote:

Data structures and algorithms are something a programmer should learn in CLASS before they even start coding.

Do we really want to take a poll here to see how many people learned that way? That pretty much falls in the "maybe in a perfect world..." category.

Quote:

Regardless of what you or I think STL and Allegro are for, I would still recommend that anyone who wants to learn about programming should at some point use dynamically allocated arrays (do-it-yourself 'vectors') and write their own linked list implementation. I know that I understand pointers and memory addresses and computers in general a lot better for having done those things myself, and the knowledge I've gained from it has enabled me to do more complicated things.

At some point, yes. Just like everyone who's serious about programming should probably learn some asm at some point.

The point of the argument is, encouraging people to use the STL without trying to force them to understand the details of how it works first allows them to do more, faster, easier. And with a language like C++, keeping people interested... allowing them to actually do things, is often a big component in keeping them engaged to actually learn the language.

LennyLen
Member #5,313
December 2004
avatar

Quote:

The point of the argument is, encouraging people to use the STL without trying to force them to understand the details of how it works first allows them to do more, faster, easier.

Is this a good thing though? Encouraging laziness in students seems to be a modern trend.

Speedo
Member #9,783
May 2008

Quote:

Is this a good thing though? Encouraging laziness in students seems to be a modern trend.

Laziness according to whom? If I have a person who's been learning C++ for a week and is able to properly use vector, string, or list to create programs even though their eyes gloss over when you start talking about pointers or dynamic memory, how are they lazy?

SiegeLord
Member #7,827
October 2006
avatar

Quote:

...their eyes gloss over when you start talking about pointers or dynamic memory, how are they lazy?

If their eyes glaze over when you start talking about those things, they are not lazy; they are stupid, and should get a different major.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Do we really want to take a poll here to see how many people learned that way? That pretty much falls in the "maybe in a perfect world..." category.

Indeed, I'm 100% self taught (programming wise), and I whole heartedly believe in what I said. You NEED to learn and understand the basics or you're just fooling yourself.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Speedo
Member #9,783
May 2008

Quote:

If their eyes glaze over when you start talking about those things, they are not lazy; they are stupid, and should get a different major.

Well, I guess we can't all be geniuses like your holiness. Luckily the real world isn't so picky; if they booted everyone who didn't understand pointers after a week of instruction, there'd be maybe a dozen C/C++ programmers in the world.

Thomas Fjellstrom
Member #476
June 2000
avatar

Quote:

Luckily the real world isn't so picky; if they booted everyone who didn't understand pointers after a week of instruction, there'd be maybe a dozen C/C++ programmers in the world.

We're not talking about a week after. There are retards that somehow get their degree in "whatever it is they took" and don't know what a pointer is, or how any of the data types they use actually work. That is flawed.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Speedo
Member #9,783
May 2008

Quote:

We're not talking about a week after. There are retards that somehow get their degree in "whatever it is they took" and don't know what a pointer is, or how any of the data types they use actually work. That is flawed.

Read my post. Read his reply. We aren't talking about retards, were talking about a particular person being extremely arrogant.

Thomas Fjellstrom
Member #476
June 2000
avatar

I don't think what he said was entirely uncalled for. They really should have learned what pointers and memory is before anything else, unless they are coding in Python or something.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

Neil Black
Member #7,867
October 2006
avatar

I recommend learning to make your own linked list before using the STL to do it for you, mostly for the reasons given above. You learn more about what's really going on, which could help you debug things that are going wacky in your code. And it helps with other things that involve similar concepts.

I'm glad my programming teacher made us implement linked lists ourselves instead of just teaching us how to use java's linked list class. Sure, I'll probably use the pre-made class most of the time when I'm actually coding, but I'll know what it's doing when I use it.

gnolam
Member #2,030
March 2002
avatar

Speedo said:

That's pretty much the point. People always love to make this argument for linked lists - but you basically never see it for vectors, deques, maps, strings, or any of the other STL containers. Why? Because people for some reason have this thing about linked lists...

Because the linked list is the most degenerate case of the basic tecnhique used for most of those containers.

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

Speedo
Member #9,783
May 2008

Quote:

I don't think what he said was entirely uncalled for. They really should have learned what pointers and memory is before anything else, unless they are coding in Python or something.

Ok, seriously, you're grasping at straws now. Why don't you go ahead and cite a few intro to C++ books or show us the syllabus from a course that teaches pointers "before anything else"? I'm sure you know as well is I do that the vast, overwhelming majority of people who teach C++ disagree with you.

count
Member #5,401
January 2005

Quote:

overwhelming majority of people who teach C++ disagree with you.

Sure they disagree with him. That's because he isn't talking about learning c++ but about learning to code. Two totally diffrent things.
And in my opinion a good coder should know how such a basic thing such as how lists are working.
This could be achieved by writing own basic implementations or by looking at the code of finished ones. Depending on skill and personal style each way should be a good way.

CGamesPlay
Member #2,559
July 2002
avatar

Quote:

I'm sure you know as well is I do that the vast, overwhelming majority of people who teach C++ disagree with you.

Source? Are you the majority? :P

In fact, the major for Computer Science at my university has 6 hours dedicated to data structures. Just data structures.

Not understanding the basics of what is going on in a computer is great, if all you want to do professionally is make websites using ASP.NET. You won't be able to write the fancy backend code that does all the hard work, because you will have no idea how to solve the most rudimentary problems that comprise that one.

--
Tomasu: Every time you read this: hugging!

Ryan Patterson - <http://cgamesplay.com/>

ImLeftFooted
Member #3,935
October 2003
avatar

The best way to learn is by doing. If he must learn forever without doing anything he'd give up and become a plumber.

Maybe even change his name to Joe.

 1   2 


Go to: