bitburner-official / typescript-template

Starter repo for players who want to write bitburner scripts in typescript.
54 stars 100 forks source link

You either have a bug or a lag problem. Maybe a lag problem due to programming in JavaScript. Is Bitburner interpreted or compiled? #23

Open seannaquah opened 1 day ago

seannaquah commented 1 day ago

I got this bug telling me that I had an infinite loop and asking me if i had forgotten to use ns.sleep(n);

Now, I personally take this as an insult. I have never in my entire life programmed an infinite loop by accident. I'm an extremely particular, cautious, and meticulous programmer who didn't even have any bugs whatsoever in their assignment programs, nor in their final year project, because I personally debug every single bloody bug out of my programs as much as possible. Of course, that's impossible for larger programs, but for such tiny programs, it's a piece of cake to make it 100% bug free. And I spend tons and tons of effort and time doing so. I'm an expert at finding bugs and errors, being a gamer and having coded since I was 6 years old when PCs first came out. I used a very simple but efficient script. And I made sure there were no bugs. Plus I'm have OCD, and you should know that OCD makes you worse than a perfectionist. I've spent my whole life trying to overcome my OCD. And definitely NO infinite loops. I just ran many of them because your game requires running of many scripts and threads, etc. to earn any money at all from scripts. I find myself usually getting most of my money from the Hacknets, Isn't that defeating the purpose of the game? Aren't you supposed to learn how to optimize your scripts more and more and earn most of your money from there? Or is it just me who's thinking like a programmer? Anyway, the script had an:-

await ns.sleep(<insert your number of milliseconds of at least 20 here>);

But your game lagged because well, it's JavaScript. It's written in JavaScript, right? Anyway, the JavaScript in Bitburner, is it interpreted or compiled? Because if it's interpreted, it's going to lag like hell. Like where Abaddon lives. At the very bottom. Also, I decided to do my own troubleshooting, and unticked the "kill all scripts" and restarted. and it blanked out and jammed. So I decided to force shutdown Bitburner and give it a cold restart WITHOUT killing the scripts, just a normal cold restart. And suddenly, WALLAH! No infinite loops. And in fact, I even added on another few thousand threads of the same script and there were no problems. Your game is mistaking lag for infinite loops.

Hoekstraa commented 1 day ago

Hi there!

Let me dissect your message and answer question individually. I'm responding from my phone/e-mail, so please excuse poor formatting and any terse language.

If you're early game, this usually indicates the player being new to scripting, having invested their money poorly, needing to adjust their programming style or doing a particular 'run' where they limit themselves to certain gameplay features.Hacknet (at the beginning) has relatively low value. So it's worth focussing on optimizing scripts if you have the time and mental bandwidth. One critical thing I did wrong as a beginner was to only run the game while actively playing. This meant that half of my (short) playtime would be with scripts in organized disarray. This way earns you very little money for your efforts. So keep the game running, it's an idle game at heart.

Make sure you have an await ns.sleep(X) inside long running loops. The reason for this is a quirk that originates from using a single threaded runtime where the programs are in control of the timesharing. Think of it like an OS that isn't timeslicing, but hops between programs whenever the program is awaiting.If you don't give control back to the OS every once in a while, the game will freeze, as the GUI, game calculations, etc. all run on the same thread as your program.Due to a lack of ns.sleep() in loops in user programs usually being the culprit and this game is often played by folks new to programming, we've tried to insert as many helpful messages as we can. Albeit wrong in edge cases sometimes, but we hope you know what you're doing then.

Well, like I alluded to just now: We're running on the browser JS runtime. Meaning, it's essentially a single-threaded JIT-compiled environment. When done properly, depending on your computer specs, you can run thousands of scripts in Bitburner nowadays.That does require a little thought however, due to the restrictions the game has to deal with (and by extension, you too as it's player).

If you run into a bug, which happens often enough with such a codebase, you can report it at https://github.com/bitburner-official/bitburner-src. Make sure to include steps on how to reproduce the issue if you can. If you have troubles with that or you're not sure if it's a bug, you can ask in the official Bitburner Discord for help. I hope that answers the most pressing questions. If there's anything I missed, feel free to respond!

seannaquah commented 19 hours ago

Hi there! Let me dissect your message and answer question individually. I'm responding from my phone/e-mail, so please excuse poor formatting and any terse language. - I'm getting most of my money from Hacknet, what's up with that? If you're early game, this usually indicates the player being new to scripting, having invested their money poorly, needing to adjust their programming style or doing a particular 'run' where they limit themselves to certain gameplay features.Hacknet (at the beginning) has relatively low value. So it's worth focussing on optimizing scripts if you have the time and mental bandwidth. One critical thing I did wrong as a beginner was to only run the game while actively playing. This meant that half of my (short) playtime would be with scripts in organized disarray. This way earns you very little money for your efforts. So keep the game running, it's an idle game at heart. - The game says I have an infinite loop, but I don't. Why do I get this message? Make sure you have an await ns.sleep(X) inside long running loops. The reason for this is a quirk that originates from using a single threaded runtime where the programs are in control of the timesharing. Think of it like an OS that isn't timeslicing, but hops between programs whenever the program is awaiting.If you don't give control back to the OS every once in a while, the game will freeze, as the GUI, game calculations, etc. all run on the same thread as your program.Due to a lack of ns.sleep() in loops in user programs usually being the culprit and this game is often played by folks new to programming, we've tried to insert as many helpful messages as we can. Albeit wrong in edge cases sometimes, but we hope you know what you're doing then. - The game runs badly in terms of runtime performance (when running scripts), how come? Well, like I alluded to just now: We're running on the browser JS runtime. Meaning, it's essentially a single-threaded JIT-compiled environment. When done properly, depending on your computer specs, you can run thousands of scripts in Bitburner nowadays.That does require a little thought however, due to the restrictions the game has to deal with (and by extension, you too as it's player). - I've found an issue! What do I do now? If you run into a bug, which happens often enough with such a codebase, you can report it at https://github.com/bitburner-official/bitburner-src. Make sure to include steps on how to reproduce the issue if you can. If you have troubles with that or you're not sure if it's a bug, you can ask in the official Bitburner Discord for help. I hope that answers the most pressing questions. If there's anything I missed, feel free to respond!

Before you insult my "mental bandwidth", I'll have you know that I have full score for all IQ tests I take anytime, anywhere, including those ever increasing difficulty ones that keep going until seemingly forever, and those were so easy and repetitive that I eventually got bored after I passed 300+IQ score and quit out of boredom, even though I originally was aiming for 1000+IQ score. I've always gotten 100% for my Mathematics from kindergarten till end of college/uni and so same programming subjects and logic and abstraction subject. Anyway, enough about me. Just wanted you to know not to judge other people without first getting to know them. It's rude.

Hacknet a bad investment early game? You serious? Have you done your mathematics with that thing or not? I guess not. I'm from a heavily mathematical and scientific and scholastic family and lineage since like, Ancient China 5000 years ago? I was forced to do math drills before I could even play anything or whatever. I even had to compete in speed and accuracy with my childhood friend. Of course I won by a mile. Look, calculate the multiplicative aspects of the Hacknets. They'll earn way more than any early servers you can hack because the early game server are so darn poor. hack() is a percentage thingy as far as I can gather. Low server max money, low script income. It doesn't get any simpler to figure out than that.

Bitburner is an idle game. It calculates what you earned while you weren't actively playing the game. You're not supposed to need to actively turn on idle games 24/7. That's just ridiculous.

Invested their money poorly? I have a whole damn 4.05TB of RAM on my home computer. The first things I did was to upgrade my home computer's RAM, because 8GB just won't do when each damn function and method has an overhead of at least 0.10GB. By the way, Why even write in JavaScript, portability aside? Especially if it's interpreted, it's going to lag like hell. By the way, I'm a fully qualified computer scientist and programmer and information engineer with quite a bit of software engineering experience over the years, and a qualified engineering technician as well. I can literally put the cables together for you. Video cables, whatever. I've worked in a computer shop before, so I've assembled quite a number of high quality computers myself. We just bought an AMD because Intel messed up their processor, so yeah, it's working great.

What run? I just ran the script on my home computer 2 times and it totally used up all my memory. And yes, I calculated all that myself. I also minimized the scripts to be as efficient as possible. But what do I find when I come back to the game? I earned 0, yes you heard me, $0.0000 from my scripts after 15 hours+? How is that possible? When you have a bug, own up to it. I know I do. It's the right thing to do. And I get to fixing it ASAP. I'm no lazy programmer. I'm also not some careless programmer. In fact, I'm an extremely particular, cautious, and meticulous programmer. You're telling me I didn't put an await ns.sleep(n);? You've got to be joking. That's got to be the biggest joke or biggest insult of the century. I never miss doing this kinds of vital stuff. In fact, I found some weird quirks in the scripting language provided that misbehave and don't do what they're told to do. How can I work with code that I'm not sure will work or will not work? Imagine C, C++, C#, Java, Dart, etc. all not having a 100% guarantee of functioning the way they're supposed to. Havoc! Chaos! Even my developer sibling also said something's weird with the language provided. And he's the one who's always fixing everything.

Anyway, no real offense meant, but you really put me off by making so many assumptions about me and what I did. And I solved the problem easily by cold restarting the game without killing the scripts. I'm telling you, the game is mistaking lag for infinite loops.

Hoekstraa commented 18 hours ago

If you took offense, I'm sorry. As I don't want to presume, I minimized my examples to what I've seen before. I generally assume people are intelligent and capable of filtering out the information that is relevant to them and so can be a little verbose with my responses. If you prefer a different style of conversation, feel free to ask.

Would you please be so kind to share the scripts you have when the issue occurs again? With, if possible, steps leading up to the issue? A formal bug report would help us out here. Like I mentioned in the previous issue you raised, most of us are quite busy with our jobs/studies/....

Caldwell-74 commented 18 hours ago

this is 100% the wrong repo for this issue

seannaquah commented 15 hours ago

If you took offense, I'm sorry. As I don't want to presume, I minimized my examples to what I've seen before. I generally assume people are intelligent and capable of filtering out the information that is relevant to them and so can be a little verbose with my responses. If you prefer a different style of conversation, feel free to ask.

Would you please be so kind to share the scripts you have when the issue occurs again? With, if possible, steps leading up to the issue? A formal bug report would help us out here. Like I mentioned in the previous issue you raised, most of us are quite busy with our jobs/studies/....

It's okay. I thought about it, and I figured that it's probably just a cultural difference between you and me. I apologize for getting so upset too. You see, in my culture, we have this indirect speech thing and implying things with the most seemingly innocent statements but which have double meanings. Everything is highly contextual in my culture. And you happened to accidentally use your words in the wrong context. At least according to my culture. It's not your fault, so don't worry. I'm kind of sensitive due to having had an extremely harsh, rough and unkind childhood until I met my Engineering classmates at age 18 in college (under a UK university). I was always bullied, called names, spoken badly off, etc. so I tend to be a bit oversensitive. Sorry, it's mostly my fault, but also it's due a big difference in our cultures' way of communication. Here it's considered rude to say things directly. And insults can come in the form of implications with double meanings by context. What can I say, far eastern communication is just like that. Highly contextual. It's like walking on eggshells. So once again, I apologize for my oversensitivity. I'm actually a very open-minded, fair, friendly, warm, accepting, tolerant, and empathetic person once you get to know me well enough. However, I'm also the cold and surgically logical type, so forgive me if I don't mince my words. I hate beating around the bush, see.

Actually, all that happened was that the game suddenly lagged, and then hung and then it asked me if I forgot await ns.asleep(n); and that there was an infinite loop, so I restarted it after unticking "kill all scripts" but it went black screen on me, so I force shutdown the game, and gave it a normal cold restart without killing the scripts and WALLAH, no infinite loop message or anything and smooth running. I suspect that after playing for some time it lags, so there might be some kind of memory deallocation issue. But as I said before, JavaScript is kind of a bit cancerous. Even the creator of JavaScript said that it's outgrown its purpose.

P.S. Thumbing down or flaming a simple bug report is not a show of support for the developers. I for one wouldn't appreciate it if it were me on the receiving end. In fact, I even gave Hoekstraa some hearts for being so patient with my OCD. Remember, we all live in a very diverse world of many, many various cultures and customs. We need to be tolerant of each other. Otherwise WW3 will occur and that will be the end of human civilization, or at best, we will have to suffer through a terrible, terrible nuclear winter. And WW4 will be fought with sticks and stones.

seannaquah commented 15 hours ago

this is 100% the wrong repo for this issue

I think there should be a feedback or bug reporting feature in the game like most games, that sends the bug reports or feedback to their respective email accounts so that you people can take a look at them. Even mobile game apps have them these days. And I'm talking Indie ones. Solo developed. Because no player is going to know where to report the bugs, etc. to otherwise.

d0sboots commented 9 hours ago

So, you have typed a lot of words, but you have not done the one thing that was asked of you that would let us help you, which is to post your code.

As to Cald's comment: You filed this bug against https://github.com/bitburner-official/typescript-template, which is (as its README says) "The official template for synchronizing Typescript/Javascript from your computer to the game." Your issue is clearly with Bitburner-the-game, which lives at https://github.com/bitburner-official/bitburner-src. We'll still try to help you out anyway, but that's what he meant.

Hoekstraa commented 2 hours ago

I think there should be a feedback or bug reporting feature in the game like most games, that sends the bug reports or feedback to their respective email accounts so that you people can take a look at them. [...] Because no player is going to know where to report the bugs, etc. to otherwise.

This is a fair point. I don't think e-mail is the right way of doing this, as the flow we have on Github is very smooth and friendly in comparison. Do we link to there from within the game, to allow people to report issues?

One risk would be that if we make the bug reporting system very easy, we of course will receive more bug reports, potentially of low quality. That's not something for me to worry about, but worth noting.

Caldwell-74 commented 2 hours ago

grafik the game already has a "Report a bug" button inside the options which will bring you directly to the new Issue on the right repo grafik

Hoekstraa commented 1 hour ago

That's solved then ;)