Skip to content

rhysd/Dachs

Repository files navigation

Dachs Programming Language

Now new version is being developed in 'next' directory. It will replace current C++ implementation.

Dachs is a general-purpose programming language designed to be enjoyable, statically-typed and dog-friendly. Dachs is intended to be used for efficient applications and tools development, not for system programming.

Goals 🐕

  • Light to write (inspired by Ruby)
  • Strongly and statically typed
  • Native code efficiency
  • OOP
  • Immutability-aware
  • Familiar with functional features
  • Dog-friendly
# If 'var' is specified, the argument is copied and passed by value
# then mutable.  Otherwise, the argument is passed by reference then
# immutable. Variable definition has the same rule as this.
# Type of arguments and returned value are deduced automatically.

# If you want to specify the type of argument, you can use ':'.
# e.g.
#   func step_to(var first : float, last : float, block) : ()

func step_to(var first, last, block)
    for first <= last
        block(first)
        first += 1
    end
end

# UFCS is implemented.
# '1.step_to n' is equivalent to 'step_to(1, n)'

# Dachs has a block inspired from Ruby.
# do-end block is passed to the last argument of callee as lambda object.
# Here, 'block' variable is captured into do-end block.

func fizzbuzz(n, block)
    1.step_to n do |i|
        case
        when i % 15 == 0
            block("fizzbuzz")
        when i %  3 == 0
            block("fizz")
        when i %  5 == 0
            block("buzz")
        else
            block(i)
        end
    end
end

func main
    fizzbuzz 100 do |i|
        println(i)
    end
end

# Array and tuple are available as container.
# (dictionary will come.)

Progress Report

  • Basic literals
  • Basic expressions
  • Basic statements
  • Basic strong type check
  • Functions
  • Operator functions
  • Overload resolution
  • Simple return type and variable type deduction
  • Type inference
  • UFCS
  • Class
  • Lambda
  • Block
  • Variadic arguments
  • Module
  • GC
  • Tests
  • CMakeLists.txt
  • Travis-CI
  • Option parser
  • Allocator customization
  • Introduce OvenToBoost

This software is disributed under The MIT License if not specified in a source file.

Copyright (c) 2014-2015 rhysd

This software uses Boost C++ Libraries, which is licensed by The Boost License.

Boost Software License - Version 1.0 - August 17th, 2003

This software uses LLVM, which is licensed by University of Illinois/NCSA Open Source License.

Copyright (c) 2003-2014 University of Illinois at Urbana-Champaign