Hacker News new | ask | show | jobs
by tuchsen 1109 days ago
This is great. Usually with the joke programming languages, you can get at least one person arguing that "x feature" really isn't all that bad, or could maybe be useful. DreamBerd beats them all in that regard. It is 100% terrible! I lost it at the lifetimes implementation.
10 comments

This feature is not so bad:

> In case you really need to vary a variable, the when keyword lets you check a variable each time it mutates.

  const var health = 10!
  when (health = 0) {
    print("You lose")!
  }
If it can really be triggered when the variable changes to any value it makes it a truly reactive paradigm programming language. By the way, could that be hacked to implement loops?

  const var i = 10
  when (i >= 0) {
    do_something()
    i = i  - 1
  }
Yes, when is the way to do loops in this language. From the hidden examples page

  functi fibonacci (n) => {
     const var sum = 1!
     const var i = 0!
     when (i < n) {
        sum += sum + previous sum!
        i++!
     }
  }

  when (i < 10) {
     fibonacci(i)?
     i++!
  }
And if you don't want your code to loop back by accident you can just use lifetimes! Truly an elegant language
Oh please tell me you can specify the length of your loops in lines of code executed.

  var var i<10> = 0!!
  var var i = false!
  when (i) {
    print(i)!
    i++!
  }
I think this should print 0,1,2 and then stop, assuming checking the condition is a line of code, and that lifetimes are for lines executed and not just the syntax.
Yeah honestly I was really interested in that. Kind of like a logic language?

Maybe Prolog is the perfect language.

Isn't that basically a computed COME FROM?
It's basically a syntactic sugar on an Observer pattern but I like it. You would need a way to turn off 'when' observers. And I suppose it does couple the observer to the observable pretty tightly.
Delete the observed variable?

About coupling, an implementation could send state change events to a message bus and observers could subscribe only the events they care about.

It's pretty easy to turn off the when observers, simply `delete when`.

Side-effect is that it will delete all the whens, so only use it if you need it!

This feels sort of like key-value observation in obj-c
I like this feature, but to really make it pop I would like it to be combined with comefrom control flow.
Doesn't Tcl's "trace" feature do this?
Looks a little like FRP.
But what elevates it is that it's written so confidently and buries the insane lede so well that at each feature there's a fraction of a second where it seems recoverable before sanity kicks in. After, before, and next almost, almost seem smart
This feature really isn't all that bad!

> To declare a function, you can use any letters from the word function (as long as they're in order):

> function add (a, b) => a + b!

> func multiply (a, b) => a * b!

> fun subtract (a, b) => a - b!

> fn divide (a, b) => a / b!

> functi power (a, b) => a * b!

When I first read this, I thought the function names could only include letters from the word function, and only in order!
Incidentalley this allows for

   count func (a,b) => ...
   in out (a,b) => ...
   of if (a,b) => ...
Wonderful language, wonderful.
The letters have to be in order so maybe this will not work?
That's right, "in" works, but "count" and "of" don't.

Here are some of my favorites:

union

funi

funion

fution (sounds like fussion)

fu

fuc

fucton (as noted by a fellow commenter)

You must be a fan of Subversion then. On a more serious note, I'm sure I've seen this (any unique shortenings standing in for the whole word) in an actual language at some point, and it was infuriating.
I really like the "when" keyword, actually.
Feel free to use it today in any language if your debugger supports it. Most do. It's called a data breakpoint/watch point.
Also lost it at the timed lifetimes :)

Infinite lifetime is actually useful here and there. I'll usually slap an infinite lifetime wrapper around the `requests` or `httpx` module when I'm testing out some Python web scraping code.

I honestly liked the whitespace significant operator precedence.
Nim used to have that, but unfortunately removed it because it was too controversial.
I also quite liked that idea. It would probably be a nightmare to actually use, but it's definitely a creative solution to dealing with infix operator precedence.

The only implemented language I know of with this feature is the obscure array lang I (an incrementation of the J language's name I assume) by Marshall Lochbaum:

https://github.com/mlochbaum/ILanguage

I think there's a hint of a good idea in the type that checks strings with a regex. Obviously it's comically impractical written that way.
I don't know, variable decelerations seem to me to be funny but useful.

I mean constant constants, constant variables, and variable variables seem useful.

I'm not sure how would variable constants be useful.

Also, anybody knows the difference between constant constant and immutable data (constant contact constant)?

In the normal case, Alice can write 'const const true = false' and Bob, on a second machine, can write 'const const true = 7', and there will not be an error. But if Alice writes 'const const const true = false', than Bob can't reassign or mutate 'true' without throwing an error. It's for truly global constants
Come to think of it, package registries are sort of “superglobal” in many languages. It’s not entirely far-fetched to imagine a language in which variables themselves can be super-global. Heck, MUMPS global variables are immediately persisted to disk and visible to all other processes - and that’s a real language used in real systems!
It's a rather straightforward dig at C\C++ which work exactly like this with `const` variables.
The 'previous' feature sounds like a great idea! The compiler could even decide which variables it needs to keep track of.
I think it would lead to a lot of hard to find logical bugs in a lot of projects but I think it would be a great operator in say, a scripting language for a turn based game.
I am currently working on a DSL which actually does include a "back" operator! The language is used to describe simulated circuits, so you can inquire about the value a register had during a previous clock cycle.
I dunno, the previous keyword seemed pretty neat to me.