DulLabs / bhai-lang

A toy programming language written in Typescript
https://bhailang.js.org/
MIT License
3.97k stars 499 forks source link

Make It an ACTUAL programming language. #170

Open electrolyte-orb opened 2 years ago

electrolyte-orb commented 2 years ago

Description

To make it a serious programming language, we'll need to add atleast barebones for a lang.

  1. Static types bhai ye hai a = 0 to bhai ye shabd hai a = "strings"
  2. Runtime features dekh $PATH for getting current PATH.
  3. Add more data types.
Type Syntax
String shabd
Number ginti
Array dhara
Object Could be determined by the class
  1. Object oriented features like class(for very least) and inheritance(for mainstream langs)

Domain

Bhai Lang

Type of Contribution

Enhancement

Code of Conduct

thecodacus commented 2 years ago

mai ispe contribute karu bhai??

electrolyte-orb commented 2 years ago

mai ispe contribute karu bhai??

If you are sure in every way(like optimization, size, complexity) then just go ahead 😋

thecodacus commented 2 years ago

added a PR for Funda, it will introduce functional programming

you can check it in preview build https://6234ac37ec8e100008f579b5--bhailang-preview.netlify.app/#playground

electrolyte-orb commented 2 years ago

added a PR for Funda, it will introduce functional programming

you can check it in preview build https://6234ac37ec8e100008f579b5--bhailang-preview.netlify.app/#playground

bhai you are awesome!

Lekin homepage me bhi toh funda daal do.

electrolyte-orb commented 2 years ago

Should I close this issue now?

Edit: although less than 10% of my issue is resolved.

thecodacus commented 2 years ago

I am working on adding class

thecodacus commented 2 years ago

How does this look?? these features are built on top of the changes in the last PR, I can add a PR once the last PR is accepted

image
electrolyte-orb commented 2 years ago

You are just awesome!

electrolyte-orb commented 2 years ago

How does this look?? these features are built on top of the changes in the last PR, I can add a PR once the last PR is accepted

image

Hey wait. 😐 Where is new keyword implementation?

What you have implemented is just same as getting output of a function. I think just refactor and everything will be just fine.🥲

samajh le bhai janwar {
}

samajh le bhai kutiya jo ki ek janwar hai {
// Same
}

Bhai ye hai Alice = bana kutiya()

kutiya.bhouk()

I'm using bana as new but you can use a better keyword

thecodacus commented 2 years ago

new is not necessary for this (take python for example), by default it creates a new object, and it's different than a function, functions will not have methods of it's own or it's own data members,

see the example below:

image
electrolyte-orb commented 2 years ago

new is not necessary for this (take python for example), by default it creates a new object, and it's different than a function, functions will not have methods of it's own or it's own data members,

see the example below:

image

I've only worked with JS/TS and C#. Both of them use new so I thought same for bhailang. But python's implementation is also good.

PositiveUser commented 2 years ago

naya keyword can be used

electrolyte-orb commented 2 years ago

No need for unintended naya if @thecodacus has already implemented it(python like syntax).

thecodacus commented 2 years ago

257 Added a pr for class feature