Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
/jetPublic

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

License

NotificationsYou must be signed in to change notification settings

i2y/jet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

75 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

"I thought of objects being like biological cells and/or individualcomputers 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 theErlang virtual machine (BEAM).Jet's syntax isRuby-like syntax.Jet was inspired byReia andCelluloid.

Language features

Builtin Types

### Numbers49# integer4.9# float### Booleanstruefalse### Atoms:foo### Listslist=[2,3,4]list2=[1, *list]# => [1, 2, 3, 4][1,2,3, *rest]=list2rest# => [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 *2forninlist]# => [4, 6, 8]### Tuplestuple={1,2,3}tuple.select{|item|item >1}.map{|item|item *2}# => [4, 6]tuple.to_list# => [1, 2, 3]### Mapsdict={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)# => 49multiply=do |x,y|x *yendmultiply(7,7)# => 49### Binaries<<1,2,3>><<"abc">><<1 , 2, x>> = <<1, 2, 3>>x # => 3

Class definition

Car.jet

ModuleCarclassCar# On jet, state of an instance is immutable.# The initialize method returns initial state of an instance.definitialize(){name:"foo",speed:100}enddefdisplay()@name.display()@speed.display()endendend

Module definition

Enumerable.jet

moduleEnumerabledefselect(func)reduce([]){|item,acc|iffunc.(item)acc ++[item]elseaccend}enddeffilter(func)reduce([]){|item,acc|iffunc.(item)acc ++[item]elseaccend}enddefreject(func)reduce([]){|item,acc|iffunc.(item)accelseacc ++[item]end}enddefmap(func)reduce([]){|item,acc|acc ++[func.(item)]}enddefcollect(func)reduce([]){|item,acc|acc ++[func.(item)]}enddefmin(func)reduce(:infinity){|item,acc|matchfunc.(acc,item)case -10case00case1itemend}enddefmin()reduce(:infinity){|item,acc|ifacc <=itemaccelseitemend}enddefunique()reduce([]){|item,acc|ifacc.index_of(item)accelseacc ++[item]end}enddefeach(func)reduce([]){|item,acc|func.(item)}endend

Mixing in Modules

SampleList.jet

moduleSampleListclassSampleListincludeEnumerabledefinitialize(items){items:items}enddefreduce(acc,func)lists::foldl(func,acc,@items)endendend

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:

$ lsFoo.jet$ jet Foo.jet$ lsFoo.beam Foo.jet

Compiling and Executing:

$ cat Foo.jetmodule Foo  defself.bar()123.display()  endend$ jet -r Foo::bar Foo.jet123

Mix

mix.exs file example:

defmoduleMyApp.MixfiledouseMix.Projectdefprojectdo[app::my_app,version:"1.0.0",compilers:[:jet|Mix.compilers],deps:[{:jet,git:"https://github.com/i2y/jet.git"}]]endend

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

About

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

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp