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

  • Home
  • SEARCH
  • 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 8403161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:16:10+00:00 2026-06-09T22:16:10+00:00

I’m currently preparing to design a C or C++ library for accessing an existing

  • 0

I’m currently preparing to design a C or C++ library for accessing an existing Rest service, but here’s what I’m not sure about:

Most API Client libraries like this that I’ve seen simply provide a calling style that’s very close to the ReST API, where you have to read the ReST API docs to use it. They aren’t really written in they native style of the language, IMO. They are basically wrapping an http library, maybe an XML/JSON library and handling a few special things like auth:

STYLE 1:

paramList.add( "name", "Joe" )
response = makeARestCall( POST, "path/to/resource", paramList, miscAuthData );
if( result.code == 200 ) {
    //success
    xml = response.getXml();
    somethingWeCareAbout = xpath.parse( xml, "response/something/we/care/about" );
    print somethingWeCareAbout
} else {
    print "Something went wrong"
}

It seems much more natural to me to use the conventions of the language, rather than the API. Thinking of using the API as calling functions rather than accessing resources.

STYLE 2:

try {
   Api.setName( UserId, "Joe" );
   print Api.getSomethingWeCareAbout();
} catch( ApiException e ) {
   print e.getMessage();
}

I’ve written API Libraries in the latter style and they take much more work, but I find them much more natural to use and integrate into apps, especially for complex ReST APIs, but I’m not super experienced at this.

Is one style clearly better than the other? Is there a reason, other than ease of development, most seem to be written in the first style?

This library will definitely be used in multithreaded apps, and UIs, so please answer with threading in mind.

  • 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-09T22:16:11+00:00Added an answer on June 9, 2026 at 10:16 pm

    After thinking this over, a partial answer to my own question is that the first style is probably easier to multithread. Someone using the library can create a function like this:

    void asyncRestCall( Method method, String resource, map<String,String> parameters, misc misc, function onCompletion ) {
        //fork a new thread
        ...
    
        //do the call
        result = makeARestCall( method, resource, parameters misc );
    
        //back in original thread
        ...
    
        onCompletion( result );
    }
    

    Whereas doing that once for every function call in style 2 is way more work.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

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.