-1

Reading and observing some of the startups and well-known services, almost every time I found that people there are using cross-technology system in their architecture. For example like Twitter, used ruby on rails on their front-end parts, and scala for their more of back-end parts. Or the other stories like how some startup use java and golang or java and erlang for their stack.

Well I'm curious about how is the common practice to implement such cross-technology integration? For Twitter case, do they build the Scala back-end and then wire up some web service technology to create api endpoints for the rails part to consume? Or there's some API for the cross functionality between scala and ruby? Or is there some more common practice to do such thing?

As a rookie, I hope to get some perspective on this subject.

gnat
  • 21,442
  • 29
  • 112
  • 288
caesardo
  • 101
  • 1
  • Network protocols like HTTP are inherently language-agnostic and probably implemented in every language that matters, so usually no special effort is required to make the front end and back end use totally different languages. I'm told until Node.js came along it was using the same language on both ends that was unusual and difficult. – Ixrec Feb 24 '16 at 01:20

1 Answers1

0

Many such systems use RPC systems such as Finagle, Apache Thrift, or gRPC.

With all of these (and many other similar tools) you define the interface in a special language that's independent of the programming language to be used for any particular implementation. You then run the RPC package's code generator, which can generate code for a server and/or client using that interface.

The server it generates will typically just return something innocuous (e.g., a "not implemented" error code) and it's up to you to fill that in with (or connect it to) code that actually does something useful.

Since the interface is defined independently of any individual programming language, you can pretty easily generate code for a server in one language (e.g., Java) and client in another (e.g., Python). The RPC system defines the protocol for what's passed over the wire, so as long as the code on both ends conforms to the standard, the difference in language is irrelevant.

Another widely used possibility is to use a library that defines a language-neutral protocol for the wire exchanges, but requires you to make explicit calls to pass messages back and forth using that protocol. A couple of obvious examples of this genre include Google Protocol buffers and Cap'n Proto. Again, there are lots of alternatives to choose from here. I've just linked a couple with which I'm most familiar.

Either way, you typically end up with a combination of a code generator producing some of the code you need, and a library of pre-written code to handle other parts of the problem.

Jerry Coffin
  • 44,385
  • 5
  • 89
  • 162