Introducing SwaggerSocket: A REST over WebSocket Protocol

Today we are proud to announce the first release of  SwaggerSocket, a REST over WebSocket Protocol.

Why?

REST is a style of software architecture which is almost always delivered over HTTP.  It powers most of the World Wide Web and has enabled the rapid construction of APIs–it has allowed developers to easily integrate many complex services with their applications.  It has been truly transformational over the last 10 years.

The problem is, HTTP is a chatty, synchronous communication protocol based entirely on “request/response”.  That is, there is no easy way to open continuous communication between a client and a server.  You have to “ask a question” and wait for the response.  There have been a number of techniques developed to make HTTP less “chatty”–these include long-polling, Comet, HTTP streaming and recently, web sockets.  While REST over HTTP has transformed “over-the-internet” communication, it is usually a poor choice for high-throughput or asynchronous communication.  For example, most software programs do not communicate to their databases over HTTP.  It’s typically too slow because of HTTP overhead.

Websockets, however, have provided a new type of communication fabric for the Internet.  By being full duplex–meaning, a program can both ask a question and listen to a response simultaneously–and truly asynchronous, they can not only speed up software by “doing more things at once”, they can provide a more efficient pipe to send information through.

The challenge, though, is that WebSockets are simply a protocol for communication–they do not define the structure itself.  All the goodness that came with REST (structure, human readability, self-description) is abandoned for the sake of efficiency.  This is why Wordnik created SwaggerSocket!

How Does SwaggerSocket Work?

First, let’s see how SwaggerSocket improves performance over a typical REST implementation:

Note this is a simple, sample of REST over WebSocket performance. A follow-up post will go into the gory details of testing methodology and scenarios, as well as to the theoretical why performance will be better. For the record, the above graph was produced on an Amazon M1.Large EC2 server.

The REST resource used for testing looks like this simple Swagger annotated resource:

object Counter {
  @volatile var count: Double = 0 
  def increment: Double = { count += 1 count } } 

trait TestResource {
@GET
@Path("/simpleFetch") 
@ApiOperation(value = "Simple fetch method", notes = "", 
  responseClass = "com.wordnik.demo.resources.ApiResponse")
@ApiErrors(Array( new ApiError(code = 400, reason = "Bad request")))
def getById(): Response = {
  Counter.increment Response.ok.entity(new ApiResponse(200, "success")).build }
} 

@Path("/test.json") 
@Api(value = "/test", description = "Test resource")
@Produces(Array("application/json")) 
class TestResourceJSON extends Help
  with ProfileEndpointTrait
  with TestResource

On the client we incrementally hit the resource by either using the Jersey REST Client (for REST) or using SwaggerSocket Scala Client for WebSocket (based on AHC). As you can see, SwaggerSocket can easily outperform normal REST requests. To keep the comparison fair, the SwaggerSocket client used is blocking waiting for the response. This is the same way that a typical REST client would behave–using an asynchronous programming style will not only be faster for the client, but it allows the server to degrade more gracefully under load as well as perform batch operations transparently.

Introducing the SwaggerSocket Protocol

The SwaggerSocket Protocol is:

  • Pipelined: unlike the HTTP protocol (unless HTTP Pipelining is used), when you open a connection and send a request, you don’t have to wait for the response to be arrive before being allowed to send another request. SwaggerSocket requests can be sent without waiting for the corresponding responses. Unlike HTTP Pipelining (which is not supported by all browsers), SwaggerSocket works with any browser supporting WebSocket.
  • Transparent: The SwaggerSocket Protocol implementation from Wordnik is transparent and doesn’t require modification of existing applications. For example, any existing JAX RS/Jersey applications can work with no changes.  For the client side, an application can either use the SwaggerSocket’s Javascript library,  SwaggerSocket’s Scala library or open WebSocket and manipulate the protocol object.
  • Asynchronous: The  SwaggerSocket Protocol is fully asynchronous. A client can send several requests without waiting or blocking for the response. The server will asynchronously process the requests and send responses asynchronously.
  • Simple: The  SwaggerSocket Protocol uses JSON for encoding the requests and responses. This makes the protocol easy to understand and to implement.

How does it work?

The SwaggerSocket Protocol uses JSON to pass information between clients and servers via a WebSocket connection. A client first connect to the server and wait for some authorization token. On success, the client can start sending requests and gets responses asynchronously.

Software Languages Supported

SwaggerSocket as a protocol can be implemented in nearly all programming languages.  The Wordnik implementation currently supports Java, Scala, Groovy and JRuby for the server components, and ships with a Scala and Javascript client library.  The swagger-codegen will be updated to support SwaggerSocket for other clients

How can I try SwaggerSocket?

The easiest way to try SwaggerSocket is to go to our Github site and download one of the sample and read our Quick Start. Details of the  SwaggerSocket Protocol can be read here.

Getting involved

To get involved with SwaggerSocket, subscribe to our mailing list or follow us on Twitter or fork us on Github!

 

 

Word Soup Wednesday

While the television show The Soup brings you “the strange, obscure and totally unbelievable moments in pop culture, celebrity news and reality TV,” Word Soup brings you those strange, obscure, unbelievable (and sometimes NSFW) words from talk shows, sitcoms, dramas, and just about anything else on TV.

cahoots

Art [to Boyd]: “You’re not as dumb as you look. I like the use of the word cahoots, though.”

“Slaughterhouse,” Justified, April 10, 2012

Cahoots is defined as a “questionable collaboration; secret partnership,” and either comes from the French cahute, “cabin, hut,” or the French cohorte, “a word said to be in use in the South and West with a sense of ‘companions, confederates.’”

disadvertunity

Stephen Colbert: “While some people see a disaster, KFC Thailand saw a disaster advertising opportunity, or disadvertunity. Hey, I say there’s no reason SOS couldn’t stand for soup or salad.”

The Colbert Report, April 12, 2012

During a tsunami scare in Indonesia last month, KFC Thailand told people on their Facebook page: “don’t forget to order your favorite KFC menu.” Disadvertunity is a blend of disaster, advertising, and opportunity.

disarm

Raylan: “You know what they’re saying at the office? I disarmed him.”

“Slaughterhouse,” Justified, April 10, 2012

SPOILER ALERT: Disarm means “to deprive of arms; take the arms or weapons from.” In this context, Raylan is using the word literally.

hobbyturnity

Randy: “Filmmaking was just another hobbyturnity for me.”

“Food Trucks,” Bob’s Burgers, April 15, 2012

Hobbyturnity, a blend of hobby and opportunity, is a hobby that is also a career opportunity.

hooah

Jon Stewart: “Sarah Palin’s rather dramatic pin is in fact a barometer that tells you what side of the culture wars you’re on. If you’re a patriotic real American, you read it like this.”
Soldier: “Hooah!”
Jon Stewart: “But if you’re from New Jersey and some liberal east coast elite, you think it’s just a tongue-in-cheek homage to the Sopranos.”
Ralph Cifaretto: “She was a hooah [whore].”

The Daily Show with Jon Stewart, April 16, 2012

Hooah is the battle cry of the U.S. Army. The origin of the word is unknown though there are several theories.

inquizzical

Virginia: “I was immediately inquizzical of this mystery.”

“Inside Probe,” Raising Hope, April 10, 2012

Inquizzical, a blend of inquisitive and quizzical, is an example of an eggcorn, a lexical misuse that makes sense to the speaker or listener.

pentimento

Dr. Lee: “[Pentimento] refers to when art historians inspect a painting and discover traces of earlier work. Evidence that the artist changed his mind in the course of creating it. This is a perfect metaphor for what your mind has done.”

“Ricky’s Tacos,” Awake, April 12, 2012

In Italian, pentimento means “correction,” and comes from the Latin penitire, “to regret.”

puninator

Matt Lauer: “President Obama, meanwhile, is back at the White House this morning, following a trip to Colombia, a visit that was overshadowed by a prostitution scandal involving members of the Secret Service.”
Jon Stewart: “To the puninator!” [Cut to screen: On Her Vagesty’s Secret Service]

The Daily Show with Jon Stewart, April 16, 2012

Puninator is short for pun generator.

reverse-Urkel

Tracey: “Son, we have a lot of work today if I’m going to reverse-Urkel you.”

“Meet the Woggels,” 30 Rock, April 12, 2012

Urkel refers to Steve Urkel, a nerdy African-American character on the sitcom, Family Matters. African-American nerds are also known as blerds, a blend of black and nerd. To reverse-Urkel means to turn someone from a nerd into a non-nerd.

talk-portunity

Liz [to Jack and Colleen]: “I know it won’t be welcome, but I will point out that this is your final talk-portunity.”

“Meet the Woggels,” 30 Rock, April 12, 2012

A talk-portunity, a blend of talk and opportunity, is an opportunity to talk about one’s feelings.

transvaginal

Liz [to Jack regarding her decision to adopt or remain childless]: “You’re being so transvaginal right now.”

“Murphy Brown Lied to Us,” 30 Rock, April 19, 2012

Transvaginal refers to transvaginal ultrasounds, which some states have attempted to make required for women having abortions. In this context, Liz means that Jack is being invasive about her decision about having children.

Winklevoss

Schmidt [to Nick about their invention]: “I’m not gonna be Winklevossed.”

“Normal,” New Girl, April 10, 2012

Winklevoss refers to the Winklevoss twins who claimed that Mark Zuckerberg stole their idea for Facebook. Here, Schmidt is accusing Nick of stealing his idea for Real Apps, a set of utensils that attaches to a cell phone.

Yoko

Liz: “Wait, you’re trying to break up a children’s group?”
Jenna: “Well, it checks off a lot of boxes on my sexual walkabout list. Yoko a band, make love to a beloved children’s entertainer, be with a non-aboriginal Australian.”

“Meet the Woggels,” 30 Rock, April 12, 2012

Yoko refers to Yoko Ono, who some accused of breaking up the Beatles. Yoko in this instance is an example of anthimeria, “the use of a word from one word class or part of speech as if it were from another,” especially “the use of a noun as if it were a verb.”

That’s it for this week! Remember, if you see any Word Soup-worthy words, let us know on Twitter with the hashtag #wordsoup. Your word and Twitter handle might appear right here!

WotD Challenge Roundup: The Haiku Edition

Every week, we pose a challenge: using any word of the day from the week, create a perfect tweet, otherwise known as a twoosh. If we like it, your tweet will appear on our blog. This week we honored National Haiku Poetry Day by giving you the option to tweet the words of the day in “twaiku.” Non-twaikus were accepted as well.

Here are our favorites:

Thanks to everyone for playing! Remember, to get the word of the day, follow us on Twitter, like us on Facebook, or subscribe via email.

Shakespeare Soup

Oberon, Titania and Puck with Fairies Dancing. By William Blake

Today marks what is observed as William Shakespeare’s birthday. How will you celebrate? Perhaps you’ll talk like Shakespeare, or maybe you’ll conduct some computational analysis on the Bard’s plays. As for us, we’re Word Soup-ing some now-common words and phrases that Shakespeare coined or popularized.

bated breath

Shylock: “Shall I bend low, and in a bondman’s key, / With bated breath and whispering humbleness / Say this: / ‘Fair sir, you spit on me on Wednesday last?’”

Act 1. Scene I, The Merchant of Venice

With bated breath means “eagerly; with great anticipation.” According to World Wide Words, “Shakespeare was the first known writer to use” the phrase, and “bated here is a contraction of abated,” which means “reduced, lessened, lowered in force.” Thus, bated breath “refers to a state in which you almost stop breathing as a result of some strong emotion, such as terror or awe.”

be-all and end-all

Macbeth: “It were done quickly: if the assassination / Could trammel up the consequence, and catch / With his surcease success; that but this blow / Might be the be-all and the end-all here.”

Act 1. Scene VII, Macbeth

Shakespeare was the first to use this phrase meaning “the essential factor; the all-important element; the supreme aim.”

Brave New World

Miranda: “How beauteous mankind is! O brave new world, / That has such people in’t!”

Act 5. Scene I, The Tempest

The use of this phrase is ironic in both The Tempest and Aldous Huxley’s dystopian novel: in the play, it’s used to describe the first strangers Miranda has seen, “drunken sailors staggering off the wreckage of their ship,” while in the novel, “Huxley employs the same irony when the ‘savage’ John refers to what he sees as a ‘brave new world.’” The novel also contains numerous quotes from Shakespeare’s plays.

foul-mouthed

Hostess: “So I told him, my lord; and I said I heard your grace say so: and, my lord, he speaks most vilely of you, like a foul-mouthed man as he is; and said he would cudgel you.”

Act 3. Scene II, Henry IV

Foul-mouthed is defined as “using scurrilous, opprobrious, obscene, or profane language; given to abusive or filthy speech.”

hazel

Mercutio: “Thou wilt quarrel with a man for cracking nuts, having no other reason but because thou hast hazel eyes;–what eye but such an eye would spy out such a quarrel?”

Act 3. Scene I, Romeo and Juliet

Shakespeare was the first to use hazel in reference to eye color, according to the Online Etymology Dictionary. In the play, hazel refers to a “reddish-brown color. . .in reference to the color of ripe hazel-nuts.” Today hazel eyes may also be yellowish- or greenish-brown.

misquote

Worcester: “Look how we can, or sad or merrily, / Interpretation will misquote our looks.”

Act V. Scene II, Henry IV

Misquote, in this context, “to misread; misconstrue; misinterpret,” was first recorded in Shakespeare in the 1590s. Quote is attested to the 14th century and comes from the Middle English coten,”to mark a book with numbers or marginal references,” which comes from the Medieval Latin quotare, “to number chapters.”

Nick Bottom

Nick Bottom is a weaver and a bottom was, at the time Shakespeare was writing, a skein of thread or a structure around which thread was wound.”

Shakespeare’s Bottom,” The Virtual Linguist, November 9, 2011

Weaver-related definitions for bottom include “the cocoon of a silkworm,” and “a color applied to a fabric with a view of giving a peculiar hue to a dye which is to be subsequently applied.” As for the buttocks meaning of bottom, the Virtual Linguist says that “only dates back to the late 18th century, well after Shakespeare.”

odds

Prince of Wales: “I am content that he shall take the odds / Of his great name and estimation, / And will, to save the blood on either side, / Try fortune with him in a single fight.”

Act 5. Scene I, Henry IV

Odds meaning “the amount or proportion by which the bet of one party to a wager exceeds that of the other” and hence, the “probability or degree of probability in favor of that on which odds are laid,” was first found in Shakespeare in 1597. Odds is the plural of odd, which comes from the Old Norse oddi, “point of land, triangle, odd number.”

one fell swoop

Macduff: “What, all my pretty chickens and their dam / At one fell swoop?”

Act 4. Scene III, Macbeth

Shakespeare was the first to use this phrase meaning “in one stroke.” According to World Wide Words, fell here doesn’t refer to falling but to an old meaning of the word, “of a strong and cruel nature; eager and unsparing; grim; fierce; ruthless,” and comes from the Old French fel, “cruel, fierce, vicious.” Related is felon.

petard

Hamlet: “Let it work; / For ’tis the sport to have the engineer / Hoist with his own petard.”

Act 3. Scene IV, Hamlet

A petard is “an engine of war used to blow in a door or gate,” or “a small paper cartridge used in ornamental fireworks.” World Wide Words says the word only survives in the phrase hoist with one’s own petard, which means getting “injured by the device that you intended to use to injure others.” Petard ultimately comes from the Latin peditum, “to break wind.”

puckish

“Mischievous behavior is called puckish ostensibly after Shakespeare’s Puck from ‘A Midsummer Night’s Dream,’ but the Bard of Avon was following a folkloric tradition in which spirits called pucas caused trouble for travelers.”

“’Puckish’ lifted from Bard’s play,” The Deseret News, July 17, 1990

Puck probably comes from the Middle English pouke, “goblin,” which comes from the Old English puca.

salad days

Cleopatra: “My salad days, / When I was green in judgement, cold in blood, / To say as I said then.”

Act 1. Scene 5, Antony and Cleopatra

Salad days refer to “a time of youth, innocence, and inexperience.” Although it first appears in Antony and Cleopatra in 1606, “it only became popular,” says World Wide Words, “from the middle of the nineteenth century on.” The link between salad and youth is the color green, like that of “young green shoots of spring.” Today salad days also refers to “a period in the past when somebody was at the peak of their abilities or earning power, in their heyday, not necessarily when they were young.”

sea change

Ariel: “Nothing of him that doth fade / But doth suffer a sea-change / Into something rich and strange.”

Act 1. Scene 2, The Tempest

Sea change has the literal meaning of “a change caused by the sea,” as well as the figurative, “a marked transformation.” World Wide Words cites one of the first figurative uses occuring in 1877. We found one from slightly earlier, in 1861: “A year or two ago they would have foreboded nothing more than a straggling riot; but kings and people have undergone a sea-change in the interval, and such indications can no longer be safely set down at their old value.”

seamy

Emilia: “O, fie upon them! Some such squire he was / That turn’d your wit the seamy side without, / And made you to suspect me with the Moor.”

Act 4. Scene II, Othello

Shakespeare popularized the figurative use of seamy, “sordid; base.” This comes from the idea, says the Online Etymology Dictionary, that “the seamy side of a sewn garment [is] the less attractive, and thus typically turned in.”

swagger

Puck: “What hempen home-spuns have we swaggering here, / So near the cradle of the fairy queen?”

Act 3. Scene I, A Midsummer’s Night Dream

Swagger, “to strut with a defiant or insolent air, or with an obtrusive affectation of superiority,” was first recorded in this 1590 play, and is a frequentative of swag, meaning “to move as something heavy and pendent; sway.” (A frequentative is “a verb which denotes the frequent occurrence or repetition of an action.”)

What are some of your favorite Shakespeare words and phrases?

This Week’s Language Blog Roundup

Welcome to this week’s Language Blog Roundup, in which we bring you the highlights from our favorite language blogs and the latest in word news and culture.

The new season of Game of Thrones has begun, and the linguist who created the Dothraki language on the show explained how to create a language from scratch. Meanwhile, The Economist fretted over panflation, the inflation of everything, while at the Macmillan Dictionary blog, Stan Carey wondered if linguistic inflation was insanely awesome. Also at Macmillan, Orin Hargraves discussed adverbial modification in British and American English, and Michael Rundell explored true synonyms.

In The New York Times, Ben Yagoda delved into the comma, and at Lingua Franca answered readers who had trouble with his only placement. Constance Hale kicked back with some verbs while Geoffrey Pullum took issue with Hale’s description of passive and active verbs – “Where does she get the idea that become is ‘passive’ and wonder ‘active’?” – and Lucy Ferriss expressed concerns over the writing ability of Hale’s readership.

Jan Freeman covered hoodies, hoods, and ‘hoods; Mr. Verb noticed a new Dubya-ism, some other body; and Ben Zimmer examined Obamacare. Arrant Pedantry questioned grammar, morality, and the real George Zimmerman’s really bad grammar, while Johnson considered the memorability of Hollywood phrases as well as Sweden and gender neutrality.

At Language Log, Mark Liberman gave us a taste of evaluative words for wine, such as leesy, “descriptor of a wine that possesses a rich aroma and/or flavor that is a direct result of the wine resting on the lees,” and deliberated on baboons and word recognition. Ben Zimmer posted about cupertinos, mistakes made by autocorrect, and the first “asshole” in The New York Times. Meanwhile, Victor Mair tried to figure out the Chinglish, shut the fat fully.

At Lingua Franca, Carol Saller pondered repetition avoidance, Ben Yagoda mused on repetition compulsion, and Allan Metcalf analyzed nicknames for the heroic and divine and the value of OK. At Sentence First, Stan Carey examined unusual uses of sparse and cahoot while Arnold Zwicky discussed who(m). Jessica Love at The American Scholar explained what makes nouns and verbs sound real; Motivated Grammar wrote about the meaning of moot in American English; and the Dialect Blog looked at inmigration, “transplantation within the borders of a single country,” and the importance (or not?) of vowels.

Fritinancy was soitenly perplexed over The New York Times’ spelling of a Stoogeism, and for words of the week noted chewdaism, “the theory that chewing food slowly and thoroughly delivers health benefits,” and subsidiarity, “a Roman Catholic principle that says policy decisions should be made at the lowest level possible and the highest level necessary.”

Erin McKean’s lexical roundup included mevushal, a wine that has “been heat-treated so that [it] might be handled and opened by people other than Sabbath-observant Jews”; fungoes, in baseball, grounders served up by coaches “during the dead time between pitches”; and dark pool, “a platform that brings buyers and sellers together privately, using software to match their orders.” In The Boston Globe, Erin wrote about nounjectives, “the conversion of adjectives to nouns.”

The Word Spy spotted success disaster, “massive problems created when a person or company is unable to handle an overwhelming success,” and diarrheaist, “a person who shares too much online.” The Virtual Linguist wrote about nutmeg as a footballing term and the origin of naysayer.

We learned how this year’s full moons got their strange names (Full Strawberry Moon, a partial eclipse or Prince’s new album?); what it’s like to edit at Hustler magazine (cover babe or coverbabe?); and some valuable Seuss-isms. We discovered why puns and playful language matter, and that there is a disease that causes people to make jokes and puns constantly. It’s called Witzelsucht, which translates from the German as “laugh or joke (Witz) addiction (Sucht).”

That’s the week in a nutmeg. We soitenly hope you had fungo!

WotD Perfect Tweet Challenge Roundup

Every week, we pose a challenge: using any word of the day from the week, create a perfect tweet, otherwise known as a twoosh. If we like it, your tweet will appear on our blog.

Here are our favorites from last week:

Thanks to everyone for playing! Remember, this week for National Haiku Poetry Day, we’re inviting you to tweet the words of the day in haiku, if you should so choose. And to get the word of the day, follow us on Twitter, like us on Facebook, or subscribe via email.

This Week’s WotD Challenge: Haikus

You may be familiar with our weekly Word of the Day (WotD) Perfect Tweet challenge: using any word of the day from the week, create a perfect tweet, otherwise known as a twoosh. If we like it, your tweet will appear on our blog. This week for National Haiku Poetry Day, we invite you to tweet the words of the day in haiku, or twaiku, as some might say.

As you know, a haiku is a Japanese form of poetry made up of “three unrhymed lines of five, seven, and five syllables, traditionally invoking an aspect of nature or the seasons.” The word comes from the Japanese hai, “amusement,” plus ku, “sentence.” A senryu is a haiku that’s humorous or satirical, and is named for poet Senryu Karai who popularized the genre in the 18th century.

We love this haiku from Japanese Zen poet Matsuo Basho:

The temple bell stops.
But the sound keeps coming
out of the flowers.

If you can fit your haiku in one tweet, great! If not, we ask that you number your tweets for easy reading. And of course you have the option to use this week’s words in regular sentences too if you’re not a poet and you know it.

Happy haiku-ing!