DreamBerd is a perfect programming language
June 8, 2023 5:25 AM   Subscribe

Some languages start arrays at 0, which can be unintuitive for beginners. Some languages start arrays at 1, which isn't representative of how the code actually works. DreamBerd does the best of both worlds: Arrays start at -1.
posted by MetaFilter World Peace (29 comments total) 16 users marked this as a favorite
 
God, the "arrays start at 1" thing is basically what threw me off Lua, an otherwise beautiful language.
posted by seanmpuckett at 5:50 AM on June 8, 2023 [6 favorites]


You can put a question mark at the end of a line instead. It prints debug info about that line to the console for you.

I get the joke but: a one-character state-dump for variables used on that line is a legitimately brilliant idea.
posted by mhoye at 5:52 AM on June 8, 2023 [21 favorites]


I have been trying to teach myself to code, and the fact that I find any of this funny is a sign to me of the progress I have been making.

Variable hoisting can be achieved with this neat trick. Specify a negative lifetime to make a variable exist before its creation, and disappear after its creation.

This makes me feel the same way as the gif of a tachyon on wikipedia. By the time you see it arriving, you have already watched it leaving.
posted by Probabilitics at 5:53 AM on June 8, 2023 [2 favorites]


I like how lots of these features are things that beginning programmers might logic their way into assuming were possible, but obviously can't work for reasons that are sometimes difficult to explain on the spot.

The best ones though are the kinds of things someone high on syntactic sugar and polymorphism might seriously think was a good idea in a domain-specific context: floating point array indices doing implicit interpolation? WHAT A TERRIFIC IDEA!. I think this is the reason why I've largely stayed away from Julia. I'd just be too reckless with it.
posted by RonButNotStupid at 6:04 AM on June 8, 2023 [4 favorites]


(Arrays needing to start or end at any predetermined value is an artefact of ancient hardware history that happens to cater to your muscle memory, it’s a sacred cow, not an immutable fact of computing.)
posted by mhoye at 6:05 AM on June 8, 2023 [6 favorites]


Oh god it's so silly
posted by potrzebie at 6:07 AM on June 8, 2023 [1 favorite]


Pascal, the first "real" language I learned, allows arrays to start at any index, including negative indices.
posted by tommasz at 6:17 AM on June 8, 2023 [10 favorites]


DreamBerd is the occasional reminder that computers need to be told exactly what to do in order to do anything. How? Well... your choice
posted by JoeXIII007 at 6:21 AM on June 8, 2023 [3 favorites]


This is high-quality trolling.

You can make classes, but you can only ever make one instance of them. This shouldn't affect how most object-oriented programmers work.

Technical info: Type annotations don't do anything, but they help some people to feel more comfortable.

DreamBerd is a multi-paradigm programming language, which means that you can delete the keywords and paradigms you don't like.
posted by signal at 6:23 AM on June 8, 2023 [18 favorites]


There's a Julia package which, when imported, converts the local namespace to 2-based indexing. It was written as a joke but the language does actually let you do it.
posted by biogeo at 6:39 AM on June 8, 2023 [4 favorites]


DreamBerd is a multi-paradigm programming language, which means that you can delete the keywords and paradigms you don't like.

delete RegEx<.*>!!!!!!
posted by Clever User Name at 6:40 AM on June 8, 2023 [4 favorites]


I have been a programmer for so long that I don't think it's funny. Or maybe it's just that I already saw INTERCAL and this kind of thing is a funny-once.
posted by Aardvark Cheeselog at 6:54 AM on June 8, 2023 [6 favorites]


The scolding text in examples.md was too believable to be funny. I have seen that sort of attitude in the wild.
posted by grumpybear69 at 7:01 AM on June 8, 2023 [2 favorites]


Story time! Back when Pascal was still used at university to teach algorithms, we got the assignment to solve the eight queen puzzle.

You learn to use recursion for that, but our initial solutions were pretty slow. So we one-upped each other with better and better versions that used alhorithmic shortcuts like using a new row for each queen.

When we were convinced we had the fastest version we could come up with, we found out that The Niklas Wirth himself, designer of the Pascal programming language had published a solution (his code is at bottom) that blew ours out of the waters by an order of magnitude.

It began
program eightqueen1(output);
 
var i : integer; q : boolean;
    a : array[ 1 .. 8] of boolean;
    b : array[ 2 .. 16] of boolean;
    c : array[ -7 .. 7] of boolean;
b and c are for the diagonals and you didn't even need to offset x+y or x-y to index into thosr.
posted by flamewise at 7:22 AM on June 8, 2023 [5 favorites]


I like that you can use numbers as variable names:

const const 5 = 4!
print(2 + 2 === 5)! //true


In older versions of Python, True and False were just variables, and you could reassign their values (by accident, though in fairness the language didn't make it easy to do so) and then wind up in a state where "a" == False was true.
posted by whir at 7:27 AM on June 8, 2023 [1 favorite]


I like that you can use the single-equal sign for checking equality as well as assignment, Visual Basic does that! It's a great feature when you want to check divisibility, like if(a % b = 0). Love that it does more of a loose check, this will come in handy with financial calculations, because who cares about floating point errors? Not me!
posted by mrgoat at 7:46 AM on June 8, 2023


I started in VB and moved on, but I still think starting arrays at element 1 is way more intuitive. The whole offset by 1 so that item 7 is arr[6] is … well it’s like how through and tough don’t rhyme in English. It’s just a thing ya gotta memorize.
posted by caviar2d2 at 8:45 AM on June 8, 2023 [1 favorite]


DreamBerd has significant whitespace. Use spacing to specify the order of arithmetic operations.

print(1 + 2*3)! //7
print(1+2 * 3)! //9


I found this actually quite elegant. Nested parentheses are a pain in the pemdas.
posted by cosmologinaut at 8:45 AM on June 8, 2023 [1 favorite]


Assigning intermediate values to variables is a great way to reduce the number of nested parentheses.

Now if only we had some way to always give those variables intuitive names....
posted by RonButNotStupid at 8:54 AM on June 8, 2023


Wait, this post has been up for more than four hours and nobody has quoted Stan Kelly-Bootle yet?

Should array indices start at 0 or 1? My compromise of 0.5 was rejected without, I thought, proper consideration.
posted by wachhundfisch at 9:42 AM on June 8, 2023 [14 favorites]


The whole offset by 1 so that item 7 is arr[6] is … well it’s like how through and tough don’t rhyme in English. It’s just a thing ya gotta memorize.

My opinion is that if your most difficult array programming task is to remember the index of the starting element, what you are doing is pretty easy.
posted by The_Vegetables at 9:47 AM on June 8, 2023 [2 favorites]


For simplicity, all supported regular expressions match the regular expression /Reg(ular)?[eE]x(pression|p)?/.

Simplicity.
posted by Hamusutaa at 9:54 AM on June 8, 2023 [1 favorite]


You can make classes, but you can only ever make one instance of them. This shouldn't affect how most object-oriented programmers work.

(belly laugh followed by guilty feeling)
posted by fantabulous timewaster at 10:21 AM on June 8, 2023 [9 favorites]


:sniff: if integer offsets and non-negative ordinals are properly distinct in your type system then array indexing is trivial
posted by away for regrooving at 12:52 PM on June 8, 2023 [2 favorites]


Hahaha

Please remember to use your regional currency when interpolating strings.

const const name = "world"!
print("Hello ${name}!")!
print("Hello £{name}!")!
print("Hello ¥{name}!")!

posted by wiskunde at 3:53 PM on June 8, 2023 [7 favorites]


I like how lots of these features are things that beginning programmers might logic their way into assuming were possible, but obviously can't work for reasons that are sometimes difficult to explain on the spot.

As someone who was once heavily into the esolangs scene (though in the late 1990s)... almost everything could be implemented. The resulting language wouldn't be super interesting to use, though; about the only puzzle-y aspect would be setting up loops via when, and it doesn't feel outre enough to use for artistic purposes.

For the record, I think the only "impossible" features are:

const const const obviously can't affect "everyone forever," but you could certainly get quite far. Depending on how far you wanted to take the joke, it probably wouldn't be too hard to build a "global singleton" server and force all programs to be online in order to access it, though you would have to deal with all of the content moderation nastiness, DoS attacks, abuse of space, and so on.

You wouldn't be able to use "any Unicode character or string" as a variable name, but you could get close. Several existing languages do, notably including Forth, which allows you to redefine numeric constants and language "keywords."

"Technical info: Booleans are stored as one-and-a-half bits:" tri-state values actually take a touch over 1.5849625 bits. (Well, technically you could squeeze them down to 1.5 bits assuming that you had a lot of them and they followed some patterns, but in practice you'd need at least log(3)/log(2) bits in a programming language implementation, and realistically you'd use 1.6 (8/5) bits each.)

Zero-quoted strings can't be implemented with the rest of the syntax. At least, not fully. You could do something like say that any syntax that isn't a valid expression otherwise is automatically an unquoted string.
posted by reventlov at 6:12 PM on June 8, 2023 [5 favorites]


In older versions of Python, True and False were just variables, and you could reassign their values

There were implementations of IBM FORTRAN that allowed you to redefine the values of literal constants, just by passing one as an argument to a subroutine and having the subroutine modify that argument.

Argument passing is by-reference in FORTRAN, and this particular compiler optimized the size of the static data segment by keeping only a single copy of each numeric value specified literally by the programmer.

I liked FORTRAN. It did as it was told. Definitely not a bondage and discipline language.
posted by flabdablet at 12:11 AM on June 9, 2023 [2 favorites]


There's a Julia package which, when imported, converts the local namespace to 2-based indexing.

The best Julia indexing package is StarWarsArrays.jl, which provides an array type where a[4] gives the first element, a[5] the second, a[6] the third, a[1] the fourth, a[2] the fifth, a[3] the sixth, and a[7] and onward work as usual. It also works with RomanNumerals.jl so you can index your Star Wars Arrays with "III" to get the sixth element. You know, the way God intended.

It's a bit of a joke within the Julia user community at this point that whenever the language comes up for discussion on Hacker News or wherever, the first thing someone says is some variant of "I can't get over 1-based arrays. Literally unusable language" – which is like, my guy, there are far more important things to care about in this world, and also, why are you not indexing them the one true way, which is Star Wars
posted by dashdotdot dash at 2:05 AM on June 9, 2023 [7 favorites]


The bit on indentation sent me.
posted by robotmachine at 8:44 PM on June 9, 2023 [1 favorite]


« Older I will fucking miss the shit out of everything   |   Joan Didion, the Death of R.F.K. and a Mystery... Newer »


This thread has been archived and is closed to new comments