Skip to content

a little bit of javascript, rust and python syntax wrapped in a toy language

Notifications You must be signed in to change notification settings

panzerstadt/babyjs

Repository files navigation

BabyJS

excerpts from the hundred-year language

What programmers in a hundred years will be looking for, most of all, is a language where you can throw together an unbelievably inefficient version 1 of a program with the least possible effort.

I don't predict the demise of object-oriented programming, by the way. Though I don't think it has much to offer good programmers, except in certain specialized domains, it is irresistible to large organizations. Object-oriented programming offers a sustainable way to write spaghetti code. It lets you accrete programs as a series of patches. Large organizations always tend to develop software this way, and I expect this to be as true in a hundred years as it is today.

Will the future ever catch up with it? People have been talking about parallel computation as something imminent for at least 20 years, and it hasn't affected programming practice much so far. Or hasn't it? Already chip designers have to think about it, and so must people trying to write systems software on multi-cpu computers.

The real question is, how far up the ladder of abstraction will parallelism go? In a hundred years will it affect even application programmers? Or will it be something that compiler writers think about, but which is usually invisible in the source code of applications?

Site: BabyJS

This is an ongoing project to build a programming language by following along with the amazing book Crafting Interpreters.

As I'm most comfortable in Typescript + React + Nextjs, and the focus is on mulling over the nuances of designing a programming language, This the programming language in question will be basically a rehash of Javascript, but only the parts that like and that don't give me too many footguns.

BabyJS is also integrated into my blog site with the hopes that I could find a way to turn it into my search interface in the near future.

wishlist

  • in functions, can i haz a: array.swapIndex(idxOne, idxTwo)
  • can i make it easier to clarify off-by-one issues?
    • maybe in functions, descriptions indicate whether its inclusive or exclusive?
      • also explain what inclusive and exclusive means?
  • an we always create a function graph during interpretation, so that when an error stack happens, we show the graph?
  • in recursive functions, can we have a visualization? just boxes pointing to other boxes (linkedlist-like)

how to deal with nulls

ref: https://medium.com/free-code-camp/a-quick-and-thorough-guide-to-null-what-it-is-and-how-you-should-use-it-d170cea62840#:~:text=Note%3A%20Some%20programming%20languages%20(mostly,value'%20case%20is%20handled%20explicitly.

const SENTINEL_VALUES = ['uninitialized', 'empty_function_return']
// unitialized
emailaddress = null; // you mean you don't know the emailaddress yet. -> uninitialized

// its not giving me back anything
function() {}; // you mean your function is just side effects, you're not returning anything from the function to pass in

function procedure() { print "don't return anything"; }
var result = procedure(); // -> should throw error here
print result;

// TODO: what about functions with early returns?
fn early(num) {
  if (num != 1) return;
  return num;
}

// allowed
let one = early(1);
print one;

// this is allowed
early(2);

// not allowed
let two = early(2);
print two;

// closures
fn makeCounter() {
  let i = 0;
  fn count() {
    i = i + 1;
    print i;
  }

  return count;
}

let counter = makeCounter();
counter(); // "1".
counter(); // "2".


// TODO: explore this
// In data structures like trees, linked lists, or optional fields in structures/classes, the absence of a value is traditionally represented by null. Alternative representations might be less efficient or intuitive.

NextJS setup

This is a Next.js project bootstrapped with create-next-app.

Getting Started

First, run the development server:

npm run dev
# or
yarn dev
# or
pnpm dev
# or
bun dev

Open http://localhost:3000 with your browser to see the result.

You can start editing the page by modifying pages/index.tsx. The page auto-updates as you edit the file.

API routes can be accessed on http://localhost:3000/api/hello. This endpoint can be edited in pages/api/hello.ts.

The pages/api directory is mapped to /api/*. Files in this directory are treated as API routes instead of React pages.

This project uses next/font to automatically optimize and load Inter, a custom Google Font.

Learn More

To learn more about Next.js, take a look at the following resources:

You can check out the Next.js GitHub repository - your feedback and contributions are welcome!

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

About

a little bit of javascript, rust and python syntax wrapped in a toy language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages