GithubHelp home page GithubHelp logo

zaidharoon001 / sunlight-lang Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 0.0 820 KB

Sunlight lang is a dynamic, lazy, and functional programming language that compiles to Lua and JS

License: MIT License

Lua 23.23% Haskell 58.38% Nim 0.37% TypeScript 14.68% JavaScript 3.34%
functional-programming algebraic-data-types dynamic-programming language lua polymorphism polymorphic-functions polymorphic-variants functional-languages dynamic-typing

sunlight-lang's Introduction

What is Sunlight-Lang?

Sunlight-Lang is a purely functional, declarative, dynamically typed programming language. It is designed with functional programming beginners in mind, especially the ones who come from imperative/object-oriented and dynamically typed programming languages such as Python and JavaScript. it's extremely easy to transition from one of the aforementioned languages to Sunlight-Lang while learning actual functional programming concepts. Many people use a language like Scala, FSharp, and OCaml to transition from OO to functional, because they offer mutability, free side-effects, and sometimes even loops but some of those people, just continue programming imperatively, except in a functional language. This language is designed to avoid such pitfalls by not providing conveniences like the aforementioned ones while still being very beginner-friendly.

It does that by being extremely expressive like Haskell while providing intuitive constructs like dynamic dispatch based on arbitrary predicates, similar to that of Clojure. This language allows you to be concise and on the point while solving an arbitrary problem, by the use of a great many abstractions this language provides, for example even map in this language is an abstract and extendable function.

But enough talk, let's see some code.

out <- "Hello World"

Ok, but what about something less trivial? Like an actual function. Here come Fibonacci.

fib: n <- if n < 2 then 1 else (fib: n-1) + (fib: n-2)

Fine, what about an actual program? Maybe output the lyrics of 99 bottles of beer

lib "*std"
lib "*IO"

class unlessZero: n
n = 0 -> []
true -> [n] .. unlessZero: n-1

bottles: i <- s .. " bottles of beer on the wall,\n" .. s .. " bottles of beer.\nTake one pass it around,\n" .. (stringify: i-1) .. " bottles of beer on the wall.\n" where
   s <- stringify: i
end

bottle <- "1 bottle of beer on the wall,\n1 bottle of beer.\nTake one down, pass it around,\nNo bottles of beer on the wall."

out <- mapM: (\if x = 1 then bottle else bottles: x) lcmp println, &World, unlessZero: 99

That was oddly specific but ok. So, to learn more definetly visit this page. Do definitely note that this project is still in it's pre-alpha stages so don't use it in a serious or large project.

Editor Support

The only editor support for now is this VSCode syntax highlighter plugin, but there's definitely more to come.

sunlight-lang's People

Contributors

zaidharoon001 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 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.