Code Monkey home page Code Monkey logo

native's Introduction

Native Library

Build status Build Status Coverage status Support Platform

Native Library brings productivity and maintainability for your C/C++ application as a Java program.

  • Blazing fast, small footprint with no dependency required
  • Provide rich Java Core classes beside C++ Standard Library
  • Prevents nearly all memory leak and segfaults via automatic storage
  • Classes are strictly tested with unit tests, clean with Valgrind and follow Oracle documentation
  • Feel free to use in your commercial products and welcome for contributions

This project is also useful for new developers in practical programming.

Getting started

Docker

$ docker pull foodtiny/native:latest

Installation

$ git clone https://github.com/foodtiny/native.git
$ ./configure && make native -j4 && sudo make install

Benchmarking with C++/STL

Google Benchmark is required for benchmarking if you're using Linux or Mac please use ./misc/benchmark.sh to install

$ ./configure && make native -j4 && make native_benchmark
$ ./native_benchmark

Examples

#include <native/library.hpp>

class MainApplication {
public:
    static void main(Array<String> arguments) {
        HashMap<String, String> hashMap;
        int counter = 0;
        for (String argument : arguments) {
            hashMap.put("argument " + String::valueOf(counter), argument);
            counter++;
        }
        System::out::println("We have 4 pairs:");
        String pairs = "Pairs: \n";
        for (Map<String, String>::Entry entry : hashMap.entrySet()) {
            pairs += entry.getKey() + String(" - ") + entry.getValue() + String("\n");
        }
        System::out::println(pairs);
        ArrayList<HashMap<String, String>> arrayList;
        arrayList.add(hashMap);
        System::out::println(arrayList.toString());
    }
};

int main(int argc, char **argv) {
    return Application(MainApplication::main, argc, argv);
}

Compile your source and link with native library

$ g++ -c -o main.o HelloWorld.cpp
$ g++ -o main main.o -lnative
$ ./main one two three

Output:

We have 4 pairs:
argument 3 is three
argument 2 is two
argument 1 is one
argument 0 is ./main

[{"argument 0": "./main", "argument 1": "one", "argument 2": "two", "argument 3": "three"}]

More examples can be found here

Contributors

  • This library must be followed Oracle Java 8 Documentation for standardization
  • Make sure your commits must be passed with check before you create pull request
  • At least one contributor in this project reviews your commits (except you) before merging
  • Best practices guidelines in CONTRIBUTION.md

Documentation

Documentation

Differences

This library provides Java classes in C++ so its syntax are friendly for both programming languages:

  • Namespace - Package
// Java
System.out.println("Java");
// C++
System::out::println("C++");
  • Array
// Java
byte[] byes = {};
// C++
Array<byte> bytes = {};

Data Types

All data types are implemented and ready to use in C++ Application

  • char - Java.Lang.Character
  • byte - Java.Lang.Byte
  • string - Java.Lang.String
  • unicode - java.lang.Character
  • short - Java.Lang.Short
  • int - Java.Lang.Integer
  • long - Java.Lang.Long
  • float - Java.Lang.Float
  • double - Java.Lang.Double
  • boolean - Java.Lang.Boolean
  • enum - Java.Lang.Enum

native's People

Contributors

dquangit avatar dthongvl avatar frangte avatar huuphuoc0196 avatar lamtronn avatar loint avatar minh1302 avatar neacao avatar nploi avatar sonda2208 avatar thuydunq avatar truongchauhien avatar tuananhnguyen69 avatar xdeploy avatar

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.