Bad Lang - esoteric and useless programming language

I made this around midnight and I still don’t know why but, …

Bad Lang is a 100 line long interpreter (Also inspiried by bf)
It uses character <>{?}.,: and numbers to work

Small explaination on what they do:

How to use:
	Example:

		local BadLang = require(game.ReplicatedStorage.BadLang)

		local input = [[
		{?97>}.,
		{?97>}{?97<}:,
		]]

		BadLang.run(input) -- Runs the input
	Syntax:
		> add 1 to pointer value
		< subtract 1 from pointer value
		. print out as ascii char
		{ start of loop
		} end of loop
		? keyword for how long to loop should go (Example {?2>.} - Runs 2 times)
		, reset pointer value to 0
		: print out pointer value

You can test it right now:

Or edit it:

Src
--[[
How to use:

	Example:

		local BadLang = require(game.ReplicatedStorage.BadLang)

		local input = ""
		{?97>}.,
		{?97>}{?97<}:,
		""

		BadLang.run(input) -- Runs the input
		
	Syntax:
		> add 1 to pointer value
		< subtract 1 from pointer value
		. print out as ascii char
		{ start of loop
		} end of loop
		? keyword for how long to loop should go (Example {?2>.} - Runs 2 times)
		, reset pointer value to 0
		: print out pointer value

]]--

local vm = {}

local function addToTable(v, t)
	t[#t + 1] = v
end

function vm.run(text: string)
	local out = vm.lex(text)
	
	local p = 0
	
	vm.parse(out, p)
end

function vm.lex(text): {string}
	local split = string.split(text, "")
	
	local out = {}
	
	for index, token in pairs(split) do
		if (token == ">") then addToTable("add", out) end
		if (token == "<") then addToTable("sub", out) end
		if (token == ".") then addToTable("print", out) end
		if (token == "{") then addToTable("loop-begin", out) end
		if (token == "}") then addToTable("loop-stop", out) end
		if (token == "?") then addToTable("loop-end-when", out) end
		if (token == ",") then addToTable("reset", out) end
		if (token == ":") then addToTable("print-raw", out) end
		
		
		if (out[index] == nil) then addToTable(token, out) end
	end
	
	return out
end

function vm.parse(out, p): number
	local pointer = p
	
	for index, token in pairs(out) do
		if (token == "add") then pointer += 1 end
		if (token == "sub") then pointer -= 1 end
		if (token == "reset") then pointer = 0 end
		if (token == "print") then print(string.char(pointer)) end
		if (token == "print-raw") then print(pointer) end
		
		if (token == "loop-begin") then
			local maxThrough = 0
			
			if (out[index + 1] == "loop-end-when") then
				local num_string = ""
				
				for i, t in pairs(out) do
					if (i >= index + 2) then
						if (tonumber(out[i]) ~= nil) then num_string ..= t else
							break
						end
					end 
				end
				
				num_string = string.gsub(num_string, " ", "")
				
				local num = tonumber(num_string)
				local success = num ~= nil
				
				if (success) then
					maxThrough = num
				else
					error("No number after '?'.")
				end
			else
				maxThrough = math.huge
			end
			
			local loop_out = {}
			
			local begin_add = false
			
			for i, t in pairs(out) do
				if (i == index + 3) then
					begin_add = true
				end
				
				if (t == "loop-stop") then break end
				
				if (begin_add == true) then
					addToTable(t, loop_out)
				end
			end
			
			-- Loop through
			local through = 0
			
			while (through < maxThrough - 1) do
				pointer = vm.parse(loop_out, pointer)
				
				through += 1
			end
		end
	end
	
	return pointer
end

return vm
26 Likes

who needs another programming language when they know lua???

1 Like

Thats why it says useless in the title genius.

34 Likes

If it’s useless then it’s not a resource surely

4 Likes

Your probably right, but I think it can still be allowed to be shared.

11 Likes

{?72>}., {?5>>>}: outputs H3 even though the pointer should be 15. For some reason it does not respect the number of loops after the first loop. This truly is a “Bad Lang”.

7 Likes

vietnam flashbacks

4 Likes

what if i want to make my developing experience worse? surely this would come in handy in that scenario

3 Likes

There are already many other resources that will produce the exact same outcome such as:

  • put fork(s) in your eyes
  • have a cat and or dog claw your eyes
  • insert vinegar into your wounds
  • claim to the ambulance you have no idea how this happened
  • be told you are going to the hospital but actually be sent to a psychiatric ward
  • continue to repeat steps 1 and 2 while you think no one else is watching but infact there is cctv
  • beat up the guard who comes in to check on you
  • steal his phone
  • post this on a random forum on the internet
11 Likes

I have been summoned to this monstrosity

5 Likes

This is a must-use for Roblox development. It will help you speed up your development and have fun in the process.

sarcasm but this project is actually cool, reminds me of brainfuck
4 Likes

almost as if it was inspired by the thing you mentioned :scream::scream::scream:

NO WAY :scream::scream::scream::scream::scream::scream::scream::scream::scream::scream::scream:

3_0 chars

Basically lmao, that language is legit the most annoying thing I’ve tried, second to rust.
Though, it seems pretty cool that someone even made something close to it for roblox studio

2 Likes

no way they imported brainfuck compiler to roblox
first python now brainfuck

1 Like

This is an esoteric language, I’d recommend you update the title accordingly instead of “useless”.

1 Like

Don’t be hating on Rust. It’s a godsend if you use C.

BrainFuck is useless. Yet it counts as a resource

3 Likes

I can’t believe this didn’t get deleted 20 hours ago.

rust is annoying? wait until you see assembly or C/C++.