Coder Social home page Coder Social logo

cpx's Introduction

C+X

The Web is all the rage these days, and everyone knows that in order to write a good webapp, you need to use a framework. One of the popular options these days is React, which comes with its own syntactic extension for an XML-like syntax in JavaScript.

But who wants to write JavaScript, right? It's all slow and sluggish. Naturally, we want to write our webapp in a language that's performant and close to the metal, so C++ is the clear choice. But, I hear you wonder, how do we express XML trees in C++? If only we had an extension letting us embed an XML-like syntax in our C++ source code.

Wait no more: enter C+X. It's like JSX but for C++. Sorta.

Example

CPX render() {
  return (
    _ <html>
    _   <head>
    _     <title>"Hello"<-title>
    _   <-head>
    _   <body>
    _     <p>"Hello world!"<-p>
    _   <-body>
    _ <-html>
    _
  );
}

int main(int argc, char *argv[]) {
  std::cout << render().str() << std::endl;
  return 0;
}

FAQ

  • What's with the underscores?

    That's how you signal embedded C+X syntax to the compiler.

  • Wait a minute, doesn't an ending tag usually look like </p>?

    Correct! For technical reasons, though, we have opted for <-p> instead. Surely this minor syntactic detail shouldn't matter much?

  • Is this a joke?

    Maybe.

Related projects

  • C++ ﹤HTML﹥ -- similar goal, different approach. Inspired this project, and predates it by exactly a year!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.