Programming thread

  • The Kiwi Farms was targeted with a historic DDoS attack last week. Confirmed reports of 2.8Tbps on an individual provider, topping 4.8Tbps when known volumes are added together, and possibly up to 8Tbps if the attacker is believed. This is the third of fourth largest recorded.
  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
making calculator functions only using adding and subtracting
Related to something interesting I found recently: all elementary functions can be built from a single binary operator (and with the constant 1).

The binary operator in question: eml(x,y)=exp(x)-ln(y).

Here is how the elementary functions are bootstrapped:
1779905285627.png
Source
 
Related to something interesting I found recently: all elementary functions can be built from a single binary operator (and with the constant 1).

The binary operator in question: eml(x,y)=exp(x)-ln(y).

Here is how the elementary functions are bootstrapped:
View attachment 9065296
Source
This was actually one of the tricks I used while building my x64 compiler for my degree. Speed was never something thought about, so I just used three registers for the whole thing. Then stashed the outputs in memory, and pulled them when I needed them.
 
This was actually one of the tricks I used while building my x64 compiler for my degree. Speed was never something thought about, so I just used three registers for the whole thing. Then stashed the outputs in memory, and pulled them when I needed them.
good on you for building your own compiler, the closest I ever came was attempting to write my own lowering backend for a custom cpu using the same llvm version as emscripten. My sanity failed when i tried to get past the basic math operations.
 
stb is a beast not only because he made the libraries which calling them really good is a big understatement but for to this day using FUCKING VC++6 for some reason

apropos vc6, theres some kinda extension thingy with over 500 fixes for that ide - https://gitlab.com/VC6Ultimate/VC6Ultimate
its insane
 
That could be a good sign tbr, someone from the inside is against the LLM takeover and likes that your smart enough to know it's not a human.
So it might be useful to reply to those "I'm an AI recruiter :biggrin:!" emails with something about how insulting they are and how I feel for anyone who has to engage with them since they're unemployed, since it'll either go into the void or someone slightly sympathetic who needs to use it because of a managerial directive may see it?

One time I got one that said something like "your organizational skills are better than a German train schedule." I laughed and sent it to a couple friends.
 
How do I learn to write parsers? Specifically, I want to make a text adventure game engine that exports to single-page html. I want something that takes
Code:
$ boss = Character(name="Boss")
"Oh good, the Farms is up!"
boss "Nigger, are you going to do any coding today?"

menu "Go back to the cagie, wagie?":
    "Yes. Whoever does not work, does not eat.":
        $ work_done += 1
    "Nah screw this, let's laugh at some freshly butchered trannies.":
        "There's one that looks like a rotisserie chicken. You throw up."
and outputs
Code:
          Oh good, the Farms is up!
   Boss | Nigger, are you going to do any coding today?

        𝄋 Go back to the cagie, wagie?
            > Yes. Whoever does not work, does not eat.
            > Nah screw this, let's laugh at some freshly butchered trannies.
There are multiple examples of those but they're either retarded or slightly less retarded and proprietary. But more than that I just want to learn how to make parsers, there seems to be a science to it and I'm too retarded to reinvent it.
 
Last edited:
But more than that I just want to learn how to make parsers, there seems to be a science to it and I'm too retarded to reinvent it.
I recommend looking into recursive descent parsing. The parser generator thing, or whatever people do in Haskell is harder to grasp, at least it was for me as a beginner programmer. I built my first complete language with a recursive descent parser within a few hours and I could easily modify the parser with any language changes and the method allows for easily printing useful error messages on invalid input.

Wikipedia article
Jonathan Blow video
... and with Casey Muratori
 
I would recommend Rob Nystrom's Book on interpreters, which includes a section on parsers. Robert Nystrom is a great educator when it comes to this stuff.
His "Game programming patterns" book is very good as well. Has much better explanations in it than other material you might find. I bought both books (I am aware they are free online, but I think they are worth buying).
 
How do I learn to write parsers?
Lex and Yacc are classics. I think https://craftinginterpreters.com/ has been linked in this thread before, if you want to do it manually.

Roughly:
1. the raw input text is split into tokens
2. this token stream is checked for correct syntax and a syntax tree is generated
3. the tree is walked and either converted to some other representation (compilation) or directly interpreted

What language are you using? Is your input format fixed? If it is possible to write it as JSON you could probably skip a lot of work.
 
I think you meant parser combinator.
Yes I meant parser combinator for "whatever people do in Haskell", but besides that also parser generators like yacc.

It's really easy.
It is if you know Haskell and its philosophy.

The advantage of recursive descent parsing is that you can naturally do interactive debugging and print debugging (yeah I know trace exists in Haskell...). What also helps is you can combine lexing and parsing in one pass.

I think the parser combinator and parser generator approaches are more common both in practice and in academia because they are less error prone and more mathematically sound/verifiable.

That said I'm not a professional in PLT, I tried all of these methods and liked recursive descent the most.
 
What language are you using? Is your input format fixed? If it is possible to write it as JSON you could probably skip a lot of work.
I want the input format to look sort of like a subset of Ren'Py, without the Python sections and multimedia. The #1 goal is it should be very easy to write and read (have as few nondisplayable symbols getting in the way of reading as possible) and not force retarded behavior. My "competition" is
  • Choicescript: goto, no functions, horrific amounts of duplicated text and code
  • Twine: ridiculously terrible, horrific amounts of duplicated text and code, every flavor of Twine invents its own retarded syntax, woman repellent
    • there's no "source code", Twine forces a retarded GUI and saves to playable html which can't be reasonably edited by hand; the "source code" for "wtf man this is fake and gay -> whoever came up with it is a massive retard" is 141.5 kB.
  • Yarnspinner: for-profit company and I don't like their syntax
  • Ink: for-profit company and I hate their syntax
  • (there's one more that even has an open source parser, but it forces a very restrictive game format and requires every function to be in a separate file)
Features:
  • input is an arbitrary number of text files
  • output is a single html file that can be opened in a browser (no http server)
  • narration and "dialogue"
  • player choices
  • basic text formatting
  • basic variable types
  • string interpolation
  • basic math
  • loops and conditionals
  • callables (ideally functions that take arguments)
  • game saves
  • css styles
  • text input?
Why:
  1. To write and share text adventures with tech-illiterate women.
  2. A common advice for people who think themselves too retarded for Ren'Py is to "just use Twine and export to Ren'Py", and I want to provide an alternative to that, because Twine is newbie-unfriendly trannyshit.
  3. A common advice for people who want to make a storygame but can't do art is to make a story first (duh), I want these stories to be easy to write and share.
I can just write some cutely named Javascript functions and write a game in Javascript, no parser, but it won't be nice to look at. On the other hand, I don't care if the playable html is readable. So what I need to write is a compiler that takes a whitespace-sensitive screenplay and outputs a blank html page with embedded cutesyscript that contains the game. (Or I can cheat and use Ren'Py itself as a parser, and generate cutesyscript from its output.)
 
I am a bit confused as to what alternative solution you're providing here.
...have you used Twine? The only thing it's maybe good for is traditional gamebooks, and even then it's better to write the book in a text file (or several, why not), then copypaste it to Twine, because Twine "source" is not git-friendly.
Peddit link. "Harlowe" is the default Twine format. The user is asking how to implement a basic gamebook feature, and an experienced pedditor says it could "get a little more complex".

But Twine developers don't write gamebooks, they write gay "pieces" about exploring your gender, and if you download and open an award-winning "piece" from IFDB, you'll see that the text in the file is like 10x longer than it needed to be, with even such elements as continue buttons repeated in every paragraph. (For comparison, Choicescript games are typically about 3 times longer.) Twine is bad even at serving even troon interests, they use it because they have nothing else. It's a mutual masturbation toy for laundering terrible (and gay) prose.

I don't care about troons' and academics' needs. True and honest women like adventures with dialogue and choices, It's very hard to write a basic dialogue in Twine, it fights you every step of the way. The game has to be coded, with text and macros and javascript, in those gay little windows with no quality of life features. All those easy no-code links are maybe suitable for visualizing connections between scenes but good luck debugging conditions. How do you navigate code? Well, you click "Story", then click "Find and replace", type your query and see which squares on the graph light up.

This is the best Twine format, observe how (1) it's just a few formatting tags and Javascript for everything else and (2) this one page is the whole documentation, GOOD LUCK LADIES! The author is "m.c. demarco", a "she". Compare it to a women's resource, created and maintained by just one (woke) woman.

What I want is to make interactive stories as easy to write as fanfiction. The basic requirements are is that it should be possible
  • to write the game, with menus and conditionals, in one or more text files that can be edited in a normal text editor such as Notepad++
  • to play the game without installing anything, offline, cross platform, independent of graphics card drivers and shit like that.
Finally (a reminder, this is about the default Twine format):

No HTML, Javascript or CSS experience needed​

"Don't use basic web technologies! Instead, use our custom set of macros that are only sparsely documented by our tranny polycule!"

Dynamic hypertext as a focus​

I have a deep admiration for the storytelling potential of early and recent hypertext mediums, such as HyperCard, Shockwave, Flash, and early HTML fiction, and I have kept their versatility in mind when creating Harlowe. Harlowe heavily encourages you to think of a page as a dynamic interactive space, not just a sequence of prose followed by choices. Harlowe encourages you to place links and interactive elements in the midst of prose, not just at the end, and to use them to change the prose in surprising and unusual ways - inserting or removing text in a previously-read paragraph, changing the styling of words, changing just the link itself, and other such effects to reveal new meaning in the text and communicate your story in a manner unique to hypertext. If you would like to explore the storytelling potential of hypertext, it is my dear hope that you will find Harlowe satisfying.

Though, if you would prefer a more traditional, branching style of interactive prose writing, you may wish to use Chapbook or a non-Twine language like Ink instead.
I want a sequence of prose followed by choices, and don't want anything else littering up the source code. The guy just comes out and tells you, "Use something else if you're straight". But Chapbook has the same problems, Ink is overthought and unreadable (and their sample html game has an interface bug), and Choicescript is brain-damaged.
 
It is a problem in all of academia right now. I can't speak to the US, but in Europe, I know for a fact that three are many research efforts that get directly sponsored on the condition that they use and prominently mention AI in their research. The "move fast break things" ethos seems to have seeped well into PhD and postdoctoral projects. I have no idea how anyone in their right mind can find these studies trustworthy, except maybe they just don't, and are either ideologically or monetarily captured to pump out slop.
I have actually not been hearing how Europe is handling this anti-intellectual crisis/AI crisis in academia. I see some articles come out here and there from Japan, so I appreciate your perspective! That's unfortunate, but also good to know. That's how some of our professors are feeling and some don't understand why we're now having the discussion on AI and "ethical use" of it in intro courses. I'm learning more towards no one finds these studies trustworthy, and they're riding the money train.
My tinfoil theory is that the professors who are doing research in AI/VR are struggling to find participants because I've seen them come into group chats with students, advertise on campus, etc that they need people for some related experiment they're doing. What better way to get guinea pigs than to force AI slop in our intro courses.

This made me look at all the grants my department has recently gotten. Anything hitting the range of 500k - $1mill+ is related to AI and for some reason Virtual Reality? I did not know there was any interest in this still, but reading more into it and seeing things like "eye movement tracking, brain activity" and how its easier to incite empathy in people due to "donor fatigue" ?? Makes more sense to my pessimistic self. I have been focused on school so much that I've been living under a rock. Didn't even know about the cheating epidemic with ChatGPT until 2 years ago.
 
Back
Top Bottom