These kind of people exist btw. Sorry or ruining you're night.

These kind of people exist btw. Sorry or ruining you're night.

Not even good looking either. You can clearly see the barrier at which it cuts off from the original & decays into random patterns, whereas the original has a structure.

Genuinely I can't possibly see myself finding a dead artist's unfinished piece, going "oh thats sad" then having a robot "finish" it for them, and at the end of the day think "yeah, I'm a good person". Unbelievable.

(Note: this image is from another Reddit post I came across, just wanted to share my thoughts on it here since I thought it was fitting)

u/PhosXD — 4 days ago

Another day another delusional shitpost

"Art is only accessible to rich kids & the elite!! But AI makes it accessible to everyone, why would you be against that!!!!"

What is this logic bro. You don't need to be rich to be an artist, everybody knows that. Image generation only dilutes the pool of real art & devalues the appreciation of all art AI or not.

u/PhosXD — 1 month ago

(Feedback) What do you think the weakest aspect of this song is?

I used to make a lot of simple tracks last year as a learning process, only recently (by recently I mean since December last year to now on/off) have I tried actually making something I'm really proud of. I have been working on this specific track for almost a week now but something is off, I can't pinpoint it. Is it too repetitive? Not interesting enough? Too flat or messy?

I spent all this time learning & experimenting but I feel like a fraud. Everything I make it seems amature-ish & I desperately need advice

u/PhosXD — 1 month ago
▲ 1 r/bash

I'm going crazy over this shit.

Dear Bash, I just want to fucking iterate over each line in a text file, why do you make it so hard?

First off I just want to say, this is trivial in modern Bash, my function works just fine.

readarray_compat() {
	local file_path=$1
	local var_name=$2
	eval "$var_name=()"
	while IFS= read -r line; do
		eval "$var_name+=(\"\$line\")"
	done < "$file_path"
}

Where I'm having problems though is on MacOS where for some reason we're still using 3.2, and oh boy let me tell you, trying to read lines from a file on 3.2 is a form of torture I wouldn't wish on my worst enemies. I tried countless variations of the same function that should do the same exact thing. BUT NO. No matter what I do, one thing remains constant. Bash just *cannot* for some unknowable reason just be fricking normal about escaped characters. I tried replacing backslashes with escaped backslashes, I tried printf, echo, and other various commands to maybe try to pass the text through something that wont interpret the escape characters, I TRIED EVERYTHING, if it's a string & it has escape characters, too bad bitch it's getting formatted. I even tried putting ts in single quotes & it still finds a way to fuck me over.

All the world's problems would be solved if Mac just updated their Bash.

If anyone knows how to read lines from a file in Bash 3.2, please give me your wisdom, I've been at this for 3 hours.

reddit.com
u/PhosXD — 1 month ago

Ity: a tiny but powerful scripting language.

I made a programming language from scratch in C++ for the purpose of being small, heavily modular, multi-platform, & simple to use. There are a TON of example scripts to look at, including a full Conway's Game of Life simulation. The repo also includes in-depth documentation (markdown) on structure, syntax, types, operators, functions, & standard modules.

I/O, time, file-system, & math modules are all built-in. With additional script-based modules in development!

Ity can be used as a library in your project & provides convenient APIs for parsing & execution. Everything is state-based so you can keep multiple instances.

There is a lot of work to be done as this is still a new project, anybody is welcome to contribute!

https://github.com/phosxd/Ity

u/PhosXD — 1 month ago

People have a misconception about AI *just* being a tool.

When people say (or at least when I do) say that AI is not a tool, I don't think it's meant in a literal sense. Yes obviously it is a tool for people to use in whichever way they choose, but it's not the same as other tools. A digital brush for example, is just a more convenient or more accessible way to paint, it unlocks features like undo redo without having to start over or paint over portions, & some people cant afford painting supplies so they have no choice but to use a digital alternative.

AI is different. It doesn't make anything better nor does it unlock new capability. Everything that's ever been done, has been done without AI, & can continue to be done without AI. It's just an unnecessary complication that destroys trust, opens the gate to a flood of scammers, pedophiles, & all around bad people to take over the hobbies & jobs of actually hard working & passionate people.
The only thing GenAI may be good at is making your process go faster which in most cases is not a good thing, it takes away from the creative process. Good art is often not rushed, nor should it be.

To be clear I'm not saying that EVERYONE who uses AI is a bad person, maybe they're just lazy or don't care about the craft. I'm just saying it gives already bad people an easy way to pull off more of their scams or schemes or whatever. Whether it be selling AI "art" without disclosure, scamming old or desperate people with chatbots, or pedos generating CP then uploading to the internet, which is disgusting, not everyone is a freak not everyone wants to see that shit.

I also want to clarify, that I am not talking about specialized AI, the kind of AI that is actually useful like AlphaFold & other technical models. I'm exclusively talking about shit like image generators, text generators, audio generators, & others of the same class.

reddit.com
u/PhosXD — 2 months ago

Youtubers putting fake progress bars on videos?

I've experienced this some times before, this is just my most recent encounter. I genuinely can't tell if people are putting these in the thumbnails or if youtube is just having a stroke thinking I watched videos that I know I never did...

u/PhosXD — 2 months ago

GOL simulation in custom CLI-focused language

Tiny high-level programming language built in less than a month as my first ever C++ project at 17.

- No dependencies
- Close to Python/NodeJS performance, in some cases faster (see benchmark)
- Tiny memory footprint
- Tiny executable size
- Incredibly modular. Pick & choose everything.
- Nones, Bools, Ints, Floats, Strings, Arrays, Maps (dict), & user defineable types*
- I/O, Math, File Managment, Time, Str/Arr Util, & full ANSI modules all included, most are embedded into the executable itself.

Why make this? I wanted a portable & embeddable language that was fully sandboxed, very memory efficient, & has all the essential high-level language features, all while being under 200KB in size. I have looked all over, the language I was looking for just didn't exist, so I made it myself.

I want to keep working on it & improving this because I know this is something a lot of people beside me would find useful, giving a star really helps

https://github.com/PhosXD/Ity

Everything is open source & free to use!

reddit.com
u/PhosXD — 2 months ago
▲ 62 r/teenagersbutcode+4 crossposts

GOL simulation in hand-made CLI-focused language

Tiny high-level programming language built in less than a month *without* any AI assistance as my first ever C++ project at 17.

- No dependencies
- Close to Python/NodeJS performance, in some cases faster (see benchmark)
- Tiny memory footprint
- Tiny executable size
- Incredibly modular. Pick & choose everything.
- Nones, Bools, Ints, Floats, Strings, Arrays, Maps (dict), & user defineable types*
- I/O, Math, File Managment, Time, Str/Arr Util, & full ANSI modules all included, most are embedded into the executable itself.

Why make this? I wanted a portable & embeddable language that was fully sandboxed, very memory efficient, & has all the essential high-level language features, all while being under 200KB in size. I have looked all over, the language I was looking for just didn't exist, so I made it myself.

I want to keep working on it & improving this because I know this is something a lot of people beside me would find useful, giving a star really helps

https://github.com/PhosXD/Ity

Everything is open source & free to use!

u/PhosXD — 2 months ago

std::filesystem::exists throwing `std::bad_alloc`?

Any reason? Cant find anything online about this. But I cant check whether or not a file exists, no matter what path I give it. I am using C++ 26 compiled with GCC.

This is literally all I am calling: const bool exists = std::filesystem::exists("file.txt")

This is the exact error: terminate called after throwing an instance of 'std::bad_alloc'
 what():  std::bad_alloc

No it's not coming from anywhere else in my code. Minimal reproduction code, include "filesystem" call the line above. I am on Fedora Linux if that matters at all

EDIT: moving the include into my main file instead of the only file it's being used in somehow fixed it. Literally all I do is move "#include <filesystem>" from "do_things_with_filesystem.hpp" to "Main.cpp". No compilation errors when it was in the first file, why does it rely on this?? Is there some weird declarations in my codebase or something, i dont know but it works now so why should I care.

reddit.com
u/PhosXD — 2 months ago
▲ 16 r/gameoflife+2 crossposts

Implemented game of life in terminal as a test for my language lol

The script & interpreter are both open source at github/phosxd/Ity

I just thought I'd share a fun little 2 hour terminal project

u/PhosXD — 2 months ago

How do you solve the problem of dangling pointers?

I store some data in an unordered map, create a pointer to an item in that map, then say I want to delete the item but I still have the pointer. How would I know that the item is no longer there without going and manually searching the map for the name of the item we pointed to?

I'm new to C++ & especially pointers, so forgive me for this stupid question...

EDIT: A lot of good solutions suggested, I really appreciate it! I ended up going with key lookup instead of storing pointers. The reason I didn't want to do this in the first place is because it increases complexity & I didn't want to overcomplicate

reddit.com
u/PhosXD — 2 months ago

Made a programming language in &lt; 1 month (no ai), looking for feedback

I'm 17 & have been programming for roughly 5 years now, so I thought it was about time to get low-level & start learning C & C++. I gave myself a goal to implement a fully functional, high-level interpreted programming language in C++, in 1 month without using AI, reference material, or any help other than simple google searches for when I have questions about the syntax of C++.

I started this challenge exactly on July 1st, & now that the month is coming to an end I want to show off my progress so far!

Here is the source code if you want to to take a look, see my approach to things, or to just try it out: https://github.com/phosxd/Ity

Enough of all that though, what is the language actually capable of? Well, I think the best way to explain, is to just show you a snippet of code, so here is a little script that calculates & prints prime numbers:

merge IO; merge Time;


func INT isqrt; arg INT n;
	if n &lt; 0; throw "'n' cannot be negative."; /;
	var INT x = n;
	var INT y = ((x+1) / 2); while y &lt; x;
		x = y;
		y = ( ((n/x) + x) / 2);
	/; return x;
/;


func BOOL is_prime; arg INT n;
	if n%2 == 0; return n == 2; /;
	var INT r = isqrt:[n];
	var INT i = 3; while i &lt;= r;
		if n%i == 0; return false; /;
		i += 2;
	/;
	return true;
/;


const * count = prompt:['Count: '] -&gt; INT;
const INT start = now:['us'];


var INT p = 2; while p &lt;= count;
	if is_prime:[p]; print:[p]; /;
	p += 1;
/;


print:['\nDone in ', (now:['us']-start / 1_000_000.0), 's.'];

So in this script we do a various number of things.

First we import the modules we are going to be using. The `merge` instruction particularly imports a module then merges all it's members into the current scope, so you don't have to access by name. So for example usually when importing say the `IO` module, we would have to call a function like so `IO.print:[]`, but if it's merged we can just ignore the "IO" & just do `print:[]`.

Secondly we declare a couple of functions, these functions have explicit return & argument types. You may notice that we don't use curly braces to wrap the code we want inside of the function, instead we use `/;`. Well what does that mean exactly? `/` is the instruction, `;` is the instruction delimiter (end of instruction). `func` is something called a "composite instruction" in Ity, composite instructions basically contain every instruction after it until the final end instruction (`/`). So that's how things like functions & loops contain code.

Arguments are another thing to note, in Ity they aren't something you define as part of the function, rather they are ambiguous until execution. This means a function can be called with any number of arguments of any type, & it is not the function's job to verify the argument count or the argument types, that would all be handled inside of the function code. How you grab an argument is by using the `arg` instruction to assign the next argument to a variable of whatever type you set, if the type doesn't match or there is no next argument, then an error would be thrown.

Now that I have explained composite instructions, functions, arguments, & importing behavior, let's move on to the final part of this script that I feel needs explaining, & that is this little section here:

const * count = prompt:['Count: '] -> INT;

What is happening exactly? So we use the `const` instruction (which is like `var`, but the data is immutable) & assign it the type of... star? Ok so "*" represents an "inferred" type, meaning if you set the variable to an integer, then the variable type will be integer, if you set it to a string or whatever, then it will be a string & you cant change the type after declaration.

So in this case, we are setting the variable's type to the result of the call to `prompt`. What is "prompt"? This is a function that asks for user input through the terminal, & returns a string of whatever was typed in. But we want count to be a number! So the final part of this line is the type cast, which is expressed through an arrow symbol ("->") pointing to the type you want it to be (in this case "INT" for integer). So in the end the type of the `count` variable is integer, & the value is the integer representation of the string the user entered in the terminal.

Wow, okay that was a lot of explaining, but hopefully now you have a better understanding of how the language works & you will be more prepared if / when you try it out yourself.

I am very interested in all of your thoughts on this little project & if you have any tips for me as a C++ beginner. Also I am open to contributions, if this project is something you're interested in definitely let me know! Just be aware that I won't accept any AI assisted PRs or issues.

Thanks for sparing your time, reading through my ramblings, I really appreciate it! Have a great day! 👋

u/PhosXD — 3 months ago

Looking for feedback on my first project (programming language)!

So over the past 20 days I have been working on a project to get familiar with C++, I didn't want to use AI, references, or pre-made snippets of code. Only standard google for basic questions about the workings of C++ & it's syntax.

I think I picked up most of the language rather quickly because I'm already used to programming in Python, TypeScript, & GDScript. But it was still difficult understanding the differences between references, pointers, shared pointers & such..

Anyway, as a challenge to hopefully get fluent in C++, I decided to do something not-so-simple like creating my own programming language from scratch, no third-party libraries, pure C++. After 20 days here is the result: https://github.com/phosxd/Ity

So what are the capabilities? Well I think it's best explained through code, here is an example script that calculates the fibonacci sequence:

#!/usr/local/bin/ity
import IO;

const * n = IO.prompt:['Number: '] -&gt; INT;

var INT a = 0;
var INT b = 1;

var INT i = 0; while i &lt; n;
    var INT c = a;
    a = b;
    b = (c+b);

    IO.print:[a];
    i += 1;
/;

We can also do functions, complex math expressions, type-casting, arrays, hash maps, & objects (without inheritence). Some features have been purposefully omitted due to personal preference in the way I like to code, such as lambdas & try-except.

The performance is also something to note, it's not blazing fast, but it's not the slowest out there either.

I took some simple benchmark tests on my system to compare with other languages:

https://preview.redd.it/6km2w3j8lleh1.png?width=651&format=png&auto=webp&s=f9e5236a9e1e1f52aba6dd77fce4561cc19c4a9e

Note: every language is running the same exact script with the same exact logic, just with changes to suit each one's syntax. is-prime & square root functions have been written into the code instead of being off-loaded to a library.

If you know of other interpreted languages I can test against, let me know!

Now finally, I am new at this stuff, but I am very passionate about programming in general,I've made countless projects & met good people along the way. Usually I drop a project like a month or two after I start it, but I don't want that to be the case for this. I want to continue polishing, improving, & actually trying to make this into something usable/practical.

If you are knowledgeable in C++, I ask of you if you have the time to spare, take a look at the codebase, give me suggestions, show me where I messed up because I know I probably did in multiple places. If you made it to the end & actually read all this, thank you so much for giving me a chance 🙃

reddit.com
u/PhosXD — 3 months ago
▲ 70 r/teenagersbutcode+5 crossposts

Built an interpreted programming language from scratch in 19 days without AI

I built a functional interpreted programming language from scratch in 19 days **without** AI, reference material, or borrowed code, as my first ever project in C++. It is platform agnostic, faster than Bash by a long shot (not that it was meant to be a replacement), & is only 104kb with IO, time, & math modules.

Despite the time frame & the small size, the syntax is more modern than you'd expect but is definitely different. However, you will be lacking advanced language features such as lambdas, variadic arguments, & inheritence.

https://github.com/phosxd/Ity

I plan on working on this continuously, adding more functionality, making it more performant, & making the code as readable & understandable as possible so that hopefully a beginner can take a look, & maybe use this as a guide for their first project too!

Any & all feedback is encouraged, I would really like to know your thoughts, if you have any tips!

u/PhosXD — 1 month ago

std::move overwrites the contents of the original variable?

Imagine this scenario: You have an unordered map which you take a value from as a reference. If I were to then pass that reference under a new name the reference is still in tact & the original item in the map stays the same, nothing happened, which is expected.

However, I have a case where I need to move the renamed reference to yet another name, so that it can be accessed in a higher scope. You cant do this with references, not by assigning it. The way you would do this is with the `std::move` function which performs some kind of conversion from what I can tell, it works great in my case except for the fact that now the original item in my map has been set to an undefined value.

How would I go about moving my reference without `std::move` since it kills the original item?
I would use a pointer to store the reference itself (which does work somewhat surprisingly), however in my case I do 2 things. First is the storing of the reference, the second is storing just a raw value, but whether something is a safe reference or just a normal value is not differentiated (I dont know how to) so I cant be sure that the reference wont be invalidated after the scope has exited for normal values.

I hope I explained my scenario well enough, it is quite a specific case that I am not sure how to work around. Due to how my project is set up I cant just make every value I work with a shared pointer (so that I wouldnt have to worry about references) because firstly the codebase is already a bit too large for that kind of refactor, & secondly my project does millions of iterations which it needs to do quickly (sub 200ms), making everything a shared pointer would slow that down to an unacceptable level.

reddit.com
u/PhosXD — 3 months ago

I'm sorry? I thought we knew basic moral principles!

https://preview.redd.it/0w4qx0u24ach1.png?width=672&format=png&auto=webp&s=d86f57dff68d1d57bbd044bb3303c142bd868081

Context: this is under a comment claiming I was guilt tripping because I was comparing thieves to idle spectators of thieves. The reason "rapist" is coming up is because the commenter lumped my depiction of who I was describing (the thieves) in with rapists/killers/terrorists, even though the words or the like never came up in my comment. So even though the replier was exaggerating my words in attempt to frame me as someone calling everyone I don't like the worst of the worst, I ignored it & just replied with the top comment you see in the image now, to try & correct them but apparently I'm the one who needs corrected

reddit.com
u/PhosXD — 3 months ago