All Projects → TehLeo → Junion

TehLeo / Junion

Licence: bsd-3-clause
Delivers struct types for Java programming language.

Programming Languages

java
68154 projects - #9 most used programming language
types
53 projects

Labels

Projects that are alternatives of or similar to Junion

goverter
Generate type-safe Go converters by simply defining an interface
Stars: ✭ 100 (-35.48%)
Mutual labels:  struct
Go Envparser
a go generator based env to go-struct decoder.
Stars: ✭ 17 (-89.03%)
Mutual labels:  struct
Faker
Go (Golang) Fake Data Generator for Struct
Stars: ✭ 1,698 (+995.48%)
Mutual labels:  struct
Defaults
Initialize structs with default values
Stars: ✭ 290 (+87.1%)
Mutual labels:  struct
Kong
Kong is a command-line parser for Go
Stars: ✭ 481 (+210.32%)
Mutual labels:  struct
Structvsclassperformance
POC for my Medium article
Stars: ✭ 11 (-92.9%)
Mutual labels:  struct
SNAP
Easy data format saving and loading for GameMaker Studio 2.3.2
Stars: ✭ 49 (-68.39%)
Mutual labels:  struct
Toml To Go
Translates TOML into a Go type in your browser instantly
Stars: ✭ 134 (-13.55%)
Mutual labels:  struct
Coolie
Coolie(苦力) helps you to create models (& their constructors) from a JSON file.
Stars: ✭ 508 (+227.74%)
Mutual labels:  struct
Structlinq
Implementation in C# of LINQ concept with struct
Stars: ✭ 106 (-31.61%)
Mutual labels:  struct
Fako
Struct Faker for Go
Stars: ✭ 329 (+112.26%)
Mutual labels:  struct
Unrealm
Unrealm is an extension on RealmCocoa, which enables Swift native types to be saved in Realm.
Stars: ✭ 425 (+174.19%)
Mutual labels:  struct
Struct
A Modern, Scalable , Graceful, Easy Use data structure validator
Stars: ✭ 20 (-87.1%)
Mutual labels:  struct
Dry Struct
Typed struct and value objects
Stars: ✭ 263 (+69.68%)
Mutual labels:  struct
Struct2ts
Generate Typescript classes/interfaces out of Go structs
Stars: ✭ 116 (-25.16%)
Mutual labels:  struct
fieldmask-utils
Protobuf Field Mask Go utils
Stars: ✭ 127 (-18.06%)
Mutual labels:  struct
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (-85.81%)
Mutual labels:  struct
Goconfig
goconfig uses a struct as input and populates the fields of this struct with parameters from command line, environment variables and configuration file.
Stars: ✭ 146 (-5.81%)
Mutual labels:  struct
Typex
[TOOL, CLI] - Filter and examine Go type structures, interfaces and their transitive dependencies and relationships. Export structural types as TypeScript value object or bare type representations.
Stars: ✭ 128 (-17.42%)
Mutual labels:  struct
Protoc Gen Gotag
Add custom struct tags to protobuf generated structs
Stars: ✭ 97 (-37.42%)
Mutual labels:  struct

(More Information available at this project's website) (Current version 1.2.2 EA (Early-Access))

Project JUnion

Gitter chat Maven Central

Class Struct Diagram

Delivers struct types to Java programming language.

When creating arrays of int, we have two main options:

int[] intArray = new int[1000];  
Integer[] intBoxedArray = new Integer[1000];

How many bytes do intArray, intBoxedArray take to store 1000 ints?

intArray 4016 bytes 4*1000 + ~16(around 16 bytes for array header)
intBoxedArray 20016 bytes (4 + ~12 + ~4)*1000 + ~16 (exact number depends on VM)

That is almost 5x more!
Well, this teaches us to prefer primitive arrays over their boxed versions.
So what is this project about?

Consider

class Point { float x,y;}
Point[] arr = new Point[500];

arr takes 14016 bytes
The data consits of 500 points, 2 floats each, thus 4000 bytes should be enough.
If Point was a struct, arr would take ~4000 bytes.

Wouldn't it be nice to be able to create struct types in Java that code like class and work like structs?

With JUnion you can do just that by marking a class with @Struct annotation!

Create struct Vec3:

@Struct
public class Vec3 {
    public float x,y,z;
}

Afterwards you can use it as:

//Create a new struct array
Vec3[] arr = new Vec3[10];
arr[5].x = 10;
Vec3 v = arr[5];
...
//
ByteBuffer a = ByteBuffer.allocateDirect(10*Mem.sizeOf(Vec3.class))
   .order(ByteOrder.nativeOrder());
//Modify Direct Native Bytebuffer as it were a struct
Vec3[] arr = Mem.wrap(a, Mem.sizeOf(Vec3.class));
arr[5].x = 10;
...

For a list of features click here.

Why use struct types?

  • Struct types use less memory.
  • Have the performance of primitive types.
  • Allow you to set data in direct native ByteBuffers with class-like syntax.

Performance Test

alt text

Download

Check out the latest release

and usage/IDE integration guide here.

Support & Donations

Would you like to support JUnion? You can report bugs or request for new features here or chat here

Or would you like to make a donation? You can do so via PayPap

News & Info

Status of JUnion 1.2.2:

JUnion 1.2.2 EA (Early-Access) is now available here

List of changes:

  • can allocate struct arrays on heap, off-heap, stack, the syntax uses annotation, eg:
Vec3[] arr = new Vec3[10]; //default currently allocates on heap
Vec3[] arr = new @Heap Vec3[10];
Vec3[] arr2 = new @Direct Vec3[10];
Vec3[] arr4 = new @DirectBuffer Vec3[10];
Vec3[] arr5 = new @Stack Vec3[10];
Vec3[] arr7 = new @Heap(ArrayType.Byte) Vec3[10]; //underlying data is Java byte[] array
  • the underlying storage can be retrieved as Java array/Buffer with Mem.getJavaArray(arr) and Mem.getJavaBuffer(arr)
  • added StructType class, which can be used to find information about a struct
  • added StructList, which serves as a resizable struct array, it stores its elements as data not as references (not yet finished)
  • Array allocation is done through ArrayAllocator interface and can be customized by the user if needed
  • Bridge interface serves as the link between the application and ram. The default bridge interface DefaultBridge uses Unsafe to read and write memory.
  • added MemInit class which stores related settings, such as setting the bridge interface, allocator interface to use, etc.

Finishing the current release/Documentation/tests are now planned to finalize 1.2.x release.

Roadmap to JUnion 1.2.x has been announced here

Wiki has been created and can be accessed here

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].