C++ warning in function
posted to Ask by LoveFromSkyy

Currently, you are using C++'s comma operator, which is... practicially useless.

(x, y) evaluates to y, therefore, (XP, coins) == coins; you're just returning coins, not XP.

Also, XP and coins are only mutated within the scope of the function, maybe you wanted to pass by reference?

I'd suggest using a std::pair to return XP and coins at once.


// If player wins the Level
auto LvlWin(int const experience, int const coins) {
	return std::make_pair(experience + 100, coins + 100);

void foo() {
    Player player1 = { ... };

    auto const [ new_experience, new_coins ] = LvlWin(player1.experience, player1.coins);

But more likely, you'd want a global player struct, and you'd mutate experience and coins as globals instead.

How did Repl.it help you this year?
posted to Ask by amasad

Okay, legit answer this time:

I am a school student, and I don't have a PC, what I do have is a school-administrated, Google Chromebook.
These laptops are completely useless while administrated.
It's not I don't like the hassle of setting up a compiler and build system, it's that I literally can't, even if I wanted to!

Repl allows access to a VM that almost feels just like a normal machine. Yes, it has plenty of restrictions, and plenty of arbitrary decisions have been made, but it's a machine, one that I can install software on, and execute code on.

Repl has provided salvation to anyone in this situation, especially during the recent pandemic.

How did Repl.it help you this year?
posted to Ask by amasad

If it weren't for Repl providing a free sandbox to execute malicious code in, I would've never learned how to develop malware, and I would've destroyed my own computer's software! But, thanks to Repl.it, I could safely execute any virus I got my hands on, knowing that it would be perfectly safe.

Remaking IOS from scratch
posted to Share by rafrafraf

Now make the OS execute iOS native code, so we can install apps on the phone :)

Error: Can only get response body on requests captured after headers received
posted to Ask by realTronsi

Whoa, what a coincidence? I had this same problem earlier, came to post and found you already asked about it.

[2] C++ Made EZ!!!
posted to Tutorials by Bookie0

@Bookie0 @DynamicSquid Personal suggestion: how about doing the one thing that no C++ tutorials seem to ever do on Repl.it: explain the difference between statements and expressions, actually explaining where and why semi-colons are needed? It's up to the two of you, of course, but no other C++ tutorial seems to do it, and there's a lot of exceptions if you explain it poorly.

Computer Prank - Send Link to Your Friends!
posted to Share by DanielBrown9

@systemctl I'm confident that one could create a buffer overrun by exploiting a browser bug, writing an entire executable file into memory, and attempting to execute it.

But this is definitely not how it's done.

No If Statements
posted to Share by SixBeeps

I mean, sure, they are useful, but what if they weren't?


I mean, sure, they are useful, but what for(;they weren't?;) { break; }

Seems about right :D

Full HTML Tutorial
posted to Tutorials by Kookiez

... HTML is also one of the easiest "programming languages" to learn!

HTML stands for
HyperText Markup Language

Markup Language


The <!DOCTYPE html> is very important in HTML. It may look like a tag, but it's actually a statement informing the browser that this code is HTML, and it is also stating what version of HTML it is. This is so the web browser can handle it correctly.


...but it's actually a statement informing the browser that this code is HTML

Looks like someone needs to read up on MIMEs:

NOTE: All of this code is written in the <body> section. Do NOT write your code below the <script src="script.js"></script> or it will NOT work.

100%... wrong.

At this point, I want to stop, because the author has no clue what they're talking about :(

You touch upon b vs strong and i vs em, but you don't explain the differences between semantic markup at all.

The <strong> tag is used to make text bold.

No, the <b> tag is used for that, the <strong> coincidentally displays as such in a browser, but it is intended to emphasize a sentence or word.

Oh, I actually stuck around till the end, and I saw this:

If we made any typos, wrong information, or bad explanations, feel free to correct us in the comments section! We will credit you.

... I guess this falls under that?

coming back
posted to Ask by heavyduck

You're on Repl, 99% of the people are going to be biased into telling you to learn HTML, CSS, JavaScript, and Python.

These arguably aren't the simplest languages that you could learn, but regardless, anyone could make anything out of them; just think of a project to make, and make it.

Free Cycles
posted to Share by Coder100

That's a ridiculous amount of work for such a simple project. Good job, you should end up getting get some free cycles.

Navigation Bar
posted to Ask by JoshuaBrown31

@JoshuaBrown31 You should learn to do it yourself, not ask for direct source code...

live chatroom one liner! (1 line series)[no5]
posted to Share by rafrafraf

Wow, and I heard that Python was a white-space sensitive language that forced perfect formatting on code...

Last problem, and its a simple one.
posted to Ask by Brendan23

Just use a code formatter, problem solved,

Actually no, just stop using Python, problem solved.

My online countdown
posted to Share by Cooolcoder

Now, as you did say you were young and not great at web development, I'd suggest learning more.

To start, MDN has a full course/tutorial:

If you're insistent in using HTML and CSS, it doesn't hurt to know more:

I see plenty of new JS users use .innerHTML; I have no clue where it comes from, and I doubt anyone using it knows what they're doing at all.
Please, avoid it like the plague.

MDN's documentation on Element#innerHTML:

After reading it yourself, you'll probably understand why I would suggest one of these instead:

Now, I'm not hating on you specifically, as I believe that anyone could learn if they are taught well.
That JavaScript seems to have come straight from the depths of hell W3Schools, I'd recommend looking elsewhere:

@RayhanADev, you helped me out with styling https://repl.it/@xxpertHacker/XHTML-Intro.

I had made a joke, only HTML goes:


And it happened here, I'm dying. (btw the article is almost done, you'll be pinged in the credits for helping)

posted to Ask by WilliamXing

To create a button, make a button element <button />, to color it, use CSS, to make something happen, use a CSS pseudo-class.


    Buttons are things that you click, so... how about you click me?


button {
    color: green;

button:active {
    color: red;

Now seriously, why do you need to know? Maybe you just need some documentation instead?


Can we make a new Programming Language
posted to Ask

It is very possible, as we wouldn't have anything but binary right now. I'm pretty sure this message was sent using JavaScript, and it was made by someone (or more, most likely), wasn't it? Of course, it was! But the real question is "WHY"? Why should we make a whole new language when there are thousands? Why is yours better than what's available? Are you trying to make a better version of C++? It's still being updated, and there's D anyway. Are you trying to make a stricter version of JavaScript? There's TypeScript already. Are you trying to make a language specifically for graphing? Too late, already done, I think that'd be R. What's it run context? Will it be executed in a browser, on a computer? Is it fast, optimized, efficient? Will it work on a Mac, Linux, or a Windows system... or all of them?

Lastly, and most importantly... making a new language is EXTREMELY hard, okay that's not necessarily true, but making a good + useful language is anything but easy.

Is F# OO?
posted to Ask by KennethAnderso1

OO is unrelated to OS, one can write an OS with or without OOP.

Rust Web Development
posted to Ask by asemnada991

@asemnada991 o_o oh, well, one can setup an HTTP server in a Rust Repl; technically Repl doesn't support webdev for language, so it's equally easy for any language.

Then one can setup rustc to emit Wasm and load it in a frontend document.

A template would be nice; I'll see if I can try to make one myself, it wouldn't be too easy.

what is the language rust for
posted to Ask by 2plus2is4hoi

Rust is a systems programming language; at the lowest-level, it is used for anything else that low-level programming languages are used for: creating system drivers, managing memory, reinterpreting memory, etc.

Rust has been used for a lot of projects, Firefox and Chromium are partially built in it, Servo browser engine is written in Rust, plenty of modern HTTPS 2.0 servers have been written in Rust (in fact the Rust tutorial has you make one), multiple programming languages have been made in Rust, websites have been made in Rust (yes, the frontend, not just the backend), games have been made in Rust, plenty of miscellaneous things have been written in Rust (here's a gameboy emulator in Rust)... everything you can make in any other language, has been made in Rust ;)

But, at that point, it's just like any other language, right?

The lower-level a programming language is, the more inheritly dangerous it is to use.

The more power one has, the more one can do something wrong or malicious; with power comes responsibility.

Now, here's the crucial difference between Rust and most other low-level languages, Rust is geared toward making secure, reliable, robust software. Rust has no "undefined behavor," which is common in C or C++.

Doing anything wrong will usually make the compiler stop you, and tell you that you're doing something wrong.

Contrast that with C or C++, if you do something wrong, the compiler will let it clear past and you might not even notice; it could keep happening until your computer blows up, and you still wouldn't know what went wrong!

And, if anything makes it though the compiler, at runtime the program will abort if something bad is about to happen.

Example C++:

#include <iostream>

int main() {
	int const x[3] = { 1, 2, 3 };

	std::wcout << x[3]; // undefined behavior: out of bounds access

Try it in a Repl: https://repl.it/@xxpertHacker/OOB

C++ acts like a child's toy; who cares about responsibility? C++ just does whatever.

Equivalent Rust:

fn main() {
    const x: [i32; 3] = [ 1, 2, 3 ];

    print!("{}", x[3]); // ha ha, this won't even compile

Check it out yourself: https://repl.it/@xxpertHacker/No-OOB

Furthermore, it has no implicit behavior, while C has plenty of implicit type casts, because C has a weak type system, on the other hand Rust is strongly and staticially typed. This usually means that code is more readable and explicit.

posted to Ask by JustinWu

Dynamicially casting from child -> parent sounds incredibly unsafe, as the child may not be the parent at all, or it may have inherited differently.

struct A {
    char a;

struct B : A {
    unsigned int b;

struct C : A {
    unsigned short c;

int main() {
        auto const var = A { .a = 'a' };

        dynamic_cast<C const&>(var).b; // OOB access, undefined behavior

        auto const parent = C { .a = 'a', .c = 0xFFFFu };

        auto const child = dynamic_cast<A const&>(parent);

        auto const var = dynamic_cast<B const&>(child);

        var.b; // reads u32, not u16

(^ this code won't compile, but serves as a nonsensical example)

I'd suggest reworking your hierarchy into something more sensible.

Rust Web Development
posted to Ask by asemnada991

Can you elaborate? Frontend or backend? Both are already possible on Repl.

What are you asking for? A template for one of these?

How to use Unsized arrays or VLAs in Rust?
posted to Ask by xxpertHacker

@Jakman I was joking, you just hadn't been on for a long time.

Good to hear that you're back on Repl though.

And I have to say that life has been hell for me over the last year, nothing is easy.

NodeJS Express Error: Failed to lookup view
posted to Ask by lightningrock

The folder name is "blogpages" not "blogpage".

Just add or remove the 's'.

Is it correct that I took and copied someone else's code?
posted to Ask by DeepGreen

Plenty of times, code is associated with a license, for example, an M.I.T. license. Each one is different and has different rules, so you could be, say, heavily fined for breaking one license, but nothing could happen for another.

But legalities aside, if you do copy someone else's code, don't go around posting it as your own, that's just plagiarism at that point. At least credit the author.

And what the code is being used for matters a lot too; if this is, say, a school assignment, obviously don't copy code that you don't even understand.

Python to Javascript
posted to Ask by DavidSafro

Doesn't answer your question, but you can just use Python on the web if you're more comfortable with it:

Ask Me Anything
posted to Ask by amasad

@ridark Wow, trolling the CEO like that.

Free Cycles
posted to Share by Coder100

@Coder100 On top of that, this is a pretty good April 1st joke.

But looking at the code, are you sure you didn't want to use a function callback for the replace value?

Share your Always On repls
posted to Ask by amasad

@Codemonkey51 They should add something to tell you what Repls are "always on," I believe that was mentioned from the very beginning.

How to make a compiler ( Python ) in a Python compiler?
posted to Ask by Lockk

You don't make compilers in compilers, your question makes no sense.