Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8467471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:39:18+00:00 2026-06-10T15:39:18+00:00

I often use the Stack data structure in both Java and C++. This is

  • 0

I often use the Stack data structure in both Java and C++. This is a standard data structure, very common in implementing many algorithms.

My question is (and the thing that drives me crazy) why does C++ use “top” as a function-name that returns the top-most element value without removing it, and Java uses “peek” as it’s method name?

I know there is no standard for data structures, but hasn’t computer science come far enough along that there should be a standard? Or am I just too much of a novice to know about a standard…

Do those of you that are professional programmers write your own data-structure libraries that adhere to a common interface across languages? That seems like the best thing to do, in my mind. I write code in C++, Java, Python, C, Perl, and PHP. I just don’t see any other way but to write a custom interface for all of these languages. I like “peek”, but is there any standard I should be aiming for?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:39:20+00:00Added an answer on June 10, 2026 at 3:39 pm

    Writing a custom interface just to make method names the same would be a colossal waste of time. What exactly would be the point? You wouldn’t be able to easily copy-and-paste most code between the languages you’ve mentioned even with such a feature.

    Personally, I don’t like the name of the STL vector method push_back(). I would prefer if it were just called add(), for one thing it’d be less typing. It never occurred to me that I might change it, however. Doing so would just make my code less portable and less readable for others. Now, I suppose this could be done fairly easily with a pre-processor macro, but even that would be a waste of time in my mind.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I often use convenience functions that return pointers to static buffers like this: char*
I have a (dump) question regarding VB/C# I often use third party classes where
I'll often use this: <StackPanel> <StackPanel Orientation="Horizontal"> <Label>Username:</Label> <TextBox /> </StackPanel> <StackPanel Orientation="Horizontal"> <Label>Password:</Label>
Does it make sense to use an OR-mapper? I am putting this question of
We often use stacks or queues in our algorithms, but are there any cases
I often use Ctrl + P to open files, but then I'd like to
I often use the string search feature for an entire solution in VS2008. Is
I often use the net user command to have a look at AD groups
I often use references to simplify the appearance of code: vec3f& vertex = _vertices[index];
I often use the Watch Window in Visual Studio for debugging. But it requires

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.