All Projects → i2y → jet

i2y / jet

Licence: MIT license
Jet is a simple OOP, dynamically typed, functional language that runs on the Erlang virtual machine (BEAM). Jet's syntax is Ruby-like syntax.

Programming Languages

elixir
2628 projects
erlang
1774 projects

Projects that are alternatives of or similar to jet

Pycos
Concurrent, Asynchronous, Distributed, Communicating Tasks with Python
Stars: ✭ 30 (+36.36%)
Mutual labels:  distributed-computing, concurrent-programming
asyncoro
Python framework for asynchronous, concurrent, distributed, network programming with coroutines
Stars: ✭ 50 (+127.27%)
Mutual labels:  distributed-computing, concurrent-programming
E4vm
A small portable virtual machine that would run Erlang on embedded systems
Stars: ✭ 124 (+463.64%)
Mutual labels:  beam
LuaKit
Lua核心工具包,包含对面向对象,组件系统(灵活的绑定解绑模式),mvc分模块加载,事件分发系统等常用模式的封装。同时提供打印,内存泄漏检测,性能分析等常用工具类。
Stars: ✭ 112 (+409.09%)
Mutual labels:  oop
Beam
Beam: the open source Reddit client for iOS
Stars: ✭ 217 (+886.36%)
Mutual labels:  beam
Codec Beam
Generate Erlang VM byte code from Haskell
Stars: ✭ 152 (+590.91%)
Mutual labels:  beam
java-concurrent
OpenTracing-aware helpers related to java.util.concurrent
Stars: ✭ 36 (+63.64%)
Mutual labels:  concurrent-programming
Beamcommunity.github.com
From distributed systems, to robust servers and language design on the Erlang VM
Stars: ✭ 107 (+386.36%)
Mutual labels:  beam
DistributedCompute-Series
分布式计算:分布式数据处理(流计算/批处理)、消息队列、数据仓库
Stars: ✭ 24 (+9.09%)
Mutual labels:  distributed-computing
Lumen
An alternative BEAM implementation, designed for WebAssembly
Stars: ✭ 2,742 (+12363.64%)
Mutual labels:  beam
taskinator
A simple orchestration library for running complex processes or workflows in Ruby
Stars: ✭ 25 (+13.64%)
Mutual labels:  distributed-computing
Pytorch Beam Search Decoding
PyTorch implementation of beam search decoding for seq2seq models
Stars: ✭ 204 (+827.27%)
Mutual labels:  beam
Mad
⚡ MAD: Manage Dependencies
Stars: ✭ 175 (+695.45%)
Mutual labels:  beam
Design-Patterns
Project for learning and discuss about design patterns
Stars: ✭ 16 (-27.27%)
Mutual labels:  oop
Prom ex
An Elixir Prometheus metrics collection library built on top of Telemetry with accompanying Grafana dashboards
Stars: ✭ 149 (+577.27%)
Mutual labels:  beam
cactoos-crypto
Crypto extensions for Cactoos library
Stars: ✭ 15 (-31.82%)
Mutual labels:  oop
Hulaaki
DEPRECATED : An Elixir library (driver) for clients communicating with MQTT brokers(via the MQTT 3.1.1 protocol).
Stars: ✭ 115 (+422.73%)
Mutual labels:  beam
Scio
A Scala API for Apache Beam and Google Cloud Dataflow.
Stars: ✭ 2,247 (+10113.64%)
Mutual labels:  beam
awesome-software-architecture
A curated list of awesome articles, videos, and other resources to learn and practice software architecture, patterns, and principles.
Stars: ✭ 1,594 (+7145.45%)
Mutual labels:  oop
cactoos-matchers
Elegant object-oriented hamcrest matchers
Stars: ✭ 30 (+36.36%)
Mutual labels:  oop

"I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages" --Alan Kay, creator of Smalltalk, on the meaning of "object oriented programming"

Jet is a simple OOP, dynamically typed, functional language that runs on the Erlang virtual machine (BEAM). Jet's syntax is Ruby-like syntax. Jet was inspired by Reia and Celluloid.

Language features

Builtin Types

### Numbers

49  # integer
4.9 # float

### Booleans

true
false

### Atoms

:foo

### Lists

list = [2, 3, 4]
list2 = [1, *list] # => [1, 2, 3, 4]
[1, 2, 3, *rest] = list2
rest # => [4]

list.append(5) # => [2, 3, 4, 5]
list # => [2, 3, 4]


list.select {|item| item > 2}
    .map {|item| item * 2} # => [6, 8]
list # => [2, 3, 4]

# list comprehensions
[n * 2 for n in list] # => [4, 6, 8]

### Tuples

tuple = {1, 2, 3}
tuple.select {|item| item > 1}
     .map {|item| item * 2} # => [4, 6]

tuple.to_list # => [1, 2, 3]


### Maps

dict = {foo: 1, bar: 2}
dict2 = dict.put(:baz, 3) # => {foo: 1, bar: 2, baz: 3}
dict # => {foo: 1, bar: 2}
dict.get(:baz, 100) # => 100

### Strings (Lists)

"Abc"


### Anonymous functions (Blocks)

add = {|x, y| x + y}
add(40, 9) # => 49

multiply = do |x, y|
  x * y
end

multiply(7, 7) # => 49


### Binaries

<<1, 2, 3>>
<<"abc">>
<<1 , 2, x>> = <<1, 2, 3>>
x # => 3

Class definition

Car.jet

Module Car
  class Car
    # On jet, state of an instance is immutable.
    # The initialize method returns initial state of an instance.
    def initialize()
      {name: "foo",
       speed: 100}
    end
  
    def display()
      @name.display()
      @speed.display()
    end
 end
end

Module definition

Enumerable.jet

module Enumerable
  def select(func)
    reduce([]) {|item, acc|
      if func.(item)
        acc ++ [item]
      else
        acc
      end
    }
  end

  def filter(func)
    reduce([]) {|item, acc|
      if func.(item)
        acc ++ [item]
      else
        acc
      end
    }
  end

  def reject(func)
    reduce([]) {|item, acc|
      if func.(item)
        acc
      else
        acc ++ [item]
      end
    }
  end

  def map(func)
    reduce([]) {|item, acc|
      acc ++ [func.(item)]
    }
  end

  def collect(func)
    reduce([]) {|item, acc|
      acc ++ [func.(item)]
    }
  end

  def min(func)
    reduce(:infinity) {|item, acc|
      match func.(acc, item)
        case -1
          0
        case 0
          0
        case 1
          item
      end
    }
  end

  def min()
    reduce(:infinity) {|item, acc|
      if acc <= item
        acc
      else
        item
      end
    }
  end

  def unique()
    reduce([]) {|item, acc|
      if acc.index_of(item)
        acc
      else
        acc ++ [item]
      end
    }
  end

  def each(func)
    reduce([]) {|item, acc|
      func.(item)
    }
  end
end

Mixing in Modules

SampleList.jet

module SampleList
  class SampleList
    include Enumerable
  
    def initialize(items)
      {items: items}
    end
  
    def reduce(acc, func)
      lists::foldl(func, acc, @items)
    end
  end
end

Trailing closures (Trailing blocks)

sample_list = SampleList::SampleList.new([1, 2, 3])
sample_list.select {|item| item > 1}
           .map {|item| item * 2}
           # => [4, 6]

Other supported features

  • Tail recursion optimization
  • Pattern matching

Currently unsupported features

  • Class inheritance
  • Macro definition

Requirements

  • Erlang/OTP >= 18.0
  • Elixir >= 1.1

Installation

$ git clone https://github.com/i2y/jet.git
$ cd jet
$ mix archive.build
$ mix archive.install
$ mix escript.build
$ cp jet <any path>

Usage

Command

Compiling:

$ ls
Foo.jet
$ jet Foo.jet
$ ls
Foo.beam Foo.jet

Compiling and Executing:

$ cat Foo.jet
module Foo
  def self.bar()
    123.display()
  end
end
$ jet -r Foo::bar Foo.jet
123

Mix

mix.exs file example:

defmodule MyApp.Mixfile do
  use Mix.Project

  def project do
    [app: :my_app,
     version: "1.0.0",
     compilers: [:jet|Mix.compilers],
     deps: [{:jet, git: "https://github.com/i2y/jet.git"}]]
  end
end

".jet" files in source directory(src) is automatically compiled by mix command.

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].