LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2024, 06:03 AM   #16
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 447Reputation: 447Reputation: 447Reputation: 447Reputation: 447

I don't agree with the options.

For example, you start with a simple linked list. In the beginning of a project, it's not easy to guess where the bottlenecks will be. And when you implement it yourself, it's not easy to find out. Is it inserts, lookups or whatever? How long is the list? Experimenting is a lot of work. You need to change the implementation many times.

With a good library, it's easer to change between map/tree/list/hash/array and more. Then you can simply try different things and get some real numbers.

I think it's usually better to use some library. STL is a good choice, and there's also CTL for plain (modern) C. And I'm sure there are many others.
 
Old 01-29-2024, 07:02 AM   #17
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 998

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
You can't disagree with the survey.

Programs often use multiple data structures. For example, sorting a list is done by building an array of pointers and then sorting the array. Hash tables often use lists to handle collisions.

My experience has been that data structures have to be designed along with the algorithms. They can be tuned later on, but replacement requires a rewrite.

4 votes for plain c++
2 votes for STL
1 vote for no preference

Ed
 
Old 01-29-2024, 02:05 PM   #18
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
I suppose that my original key point was that container classes already implement many of these things: hash-tables, linked lists, and various kinds of trees. And they "hide" these implementation details from you: "it's 'a container,' and it works." This is certainly one of the key benefits of the "C++" language, and the vast contributed-software library which goes with it. Take advantage of it if you possibly can. (And you are not just limited to the "standard" library! Plenty of "voodoo" out there!!)

Hey, "I'm all for 'debugging things,'" unless someone else already did it for me.

Last edited by sundialsvcs; 01-29-2024 at 02:08 PM.
 
Old 01-29-2024, 04:12 PM   #19
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 998

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
sundialsvcs - We keep repeating ourselves.

The starting point is not a blank screen but rather a large code base that has a lot of infrastructure. The infrastructure provides better solutions than any generic library.
Ed
 
Old 01-30-2024, 03:04 PM   #20
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,662
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
@EdGr: Obviously, if you have an existing code base ... especially one that didn't start with C++ ... then you very-carefully "continue in the present vein." Write new code that looks just like it has always been there. The programmers "already know what to expect," and you should not surprise them. Those "C techniques" still work as well as they always did.

In my past experience with such projects, one of the first things that the programmers did was to create application-specific "objects" to encapsulate and thereby conceal some of the (legacy ...) "pointer twiddling." And a lot of the justification was simply that this was more expressive, and less prone to "mistakes." Like a subroutine library, only better.

Last edited by sundialsvcs; 01-30-2024 at 03:11 PM.
 
Old 01-30-2024, 06:21 PM   #21
EdGr
Member
 
Registered: Dec 2010
Location: California, USA
Distribution: I run my own OS
Posts: 998

Original Poster
Rep: Reputation: 470Reputation: 470Reputation: 470Reputation: 470Reputation: 470
I think we have all the responses we are going to get. Thanks for the inputs everyone!

4 votes for plain c++
2 votes for STL
1 vote for no preference

Ed
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
linked list traversal Deepak Inbasekaran Programming 3 05-16-2007 10:33 PM
Config Nat traversal on Mandrake 9.2 superfreeswan why1957 Mandriva 0 02-16-2004 11:08 PM
recursive directory traversal klfreese Linux - Newbie 2 08-20-2003 07:27 PM
Winxp linked to Linux Linked to home network OverboardKiller Linux - Networking 2 06-09-2003 09:59 AM
preventing directory traversal in programs tristan_vdv Linux - Security 4 06-04-2002 04:03 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration