nope it does not. it's the opposite of C-based languages, which require parantheses and not curly braces, as Rust requires curly braces but not parantheses
did you use the airbnb configuration as a starter? that's what i use. definitely a hate-at-first, love-at-last thing.
every time i don't like something it makes me do, i realize that the reason i want to do the thing it's telling me not to is because i am trying to rush something or do something sloppy, "for a quick test" or "to just get it done." but that ends up being the wrong thing in the end.
It counts as a syntax error, because this restriction on style (and others) serve a cool purpose: it makes the parser much more efficient to not require the token lookahead that a traditional whitespace-ignoring lexer has to do in order to disambiguate {'s different potential meanings.
And what if fps is already 60? You would then set fps to 60 redundantly, which would be an O(log(n)) operation, since the CPU needs to flip log(n) bits. Quite wasteful and unoptimized
Which most JS engines try to avoid relying on the interpreter if possible. They compile your JS down whererver possible. It's only if you've written some truly garbage JS that it goes through an interpreter.
JS is strictly an interpreted language (okay, fine, it’s a JIT-compiled language running in a feature-rich VM, buuut it doesn’t have any bytecode stage, so it’s not too big a deal to call it “interpreted”).
There is no way to avoid an interpreter. Now, the system does try to compile it down, but it can only do that to a limited extent. Even WebAssembly is still preformance-limited in that respect.
This is the sort of thing AI would do if its instructions were to improve fps but it measured fps by reading the fps counter on the screen.
This reminded me of the videos by Robert Miles on Youtube about AI safety and how AI will inevitably optimize against the metrics you score it by rather than the task you actually wanted it to do. Kind of like students cheating on tests. The point of the test was to measure how smart the student is, but the student isn't incentivized to be smart, they're incentivized to score well on tests. Learning is much more difficult than cheating, and so [some] students cheat on tests.
Lmao I actually tried this when I was a kid in Gamemaker. I did a check if the FPS dropped below 30 and set the target room speed even higher to compensate since I had no concept of delta time and everything I coded back then was frame rate locked. The result was an even more unstable laggy mess that would crash occasionally
662
u/Nipatiitti Dec 05 '20
Cursed formatting
298
u/botle Dec 05 '20
Yup, that's bad code. It can obviously be simplified to
fps = 60
235
u/A_Sad_Shoe Dec 05 '20
damn, why didn't yandere dev think about this when implementing his fps counter
93
u/ITSOPBTW Dec 05 '20
I wonder how performance friendly would be a Python based game engine.
69
u/[deleted] Dec 05 '20
obviously should have been written in HTML to be better at fast.
24
u/nikstick22 Dec 06 '20
This is the sort of thing AI would do if its instructions were to improve fps but it measured fps by reading the fps counter on the screen.
This reminded me of the videos by Robert Miles on Youtube about AI safety and how AI will inevitably optimize against the metrics you score it by rather than the task you actually wanted it to do. Kind of like students cheating on tests. The point of the test was to measure how smart the student is, but the student isn't incentivized to be smart, they're incentivized to score well on tests. Learning is much more difficult than cheating, and so [some] students cheat on tests.
54
u/Galse22 Dec 05 '20
Well, If FPS was 300 it'd be set to 60... So yeah... That's be a downgrade.
19
u/xmartissxs Dec 05 '20
while(true) fps++;
27
u/healplease Dec 05 '20
unnessesary equality check here, it can make your game's FPS drop
7
u/Gonzo345 Dec 05 '20
Damn b0i
7
u/[deleted] Dec 06 '20
It is always 60fps, it just shows the same picture 4 frames in a row
13
u/ce-walalang Dec 06 '20
Image Transcription: Text Messages
[Screenshot from Discord.]
Logan: I solved our optimization problem
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
5
u/chronicideas Dec 06 '20
QA here.
There’s a potential bug here where if FPS is higher than 60 it would get decreased to 60.
I think it should be refactored to
3
u/veskoyyy Dec 06 '20
Modern problems. Modern solutions. Well played. Now go fix that COVID thing!
3
u/TrigamYT Dec 06 '20 edited Jun 05 '22
if (fps < 60) { fps = 60 }
3
u/sdriyaz712 Dec 06 '20
Python kids trying to use JavaScript
3
u/wktr_t Dec 06 '20
Whoever indents code like this can also kill.
3
u/ReduceHyperlinks Dec 06 '20
if fps > 60{ if fps != null { if true && false != true { var fpsdiff = 60 - fps; while fpsdiff > 0 { fps = fps + 1; fpsdiff = fpsdiff - 1; } } } }2
u/[deleted] Dec 06 '20
What language is this even
2
u/cyberspacedweller Dec 06 '20
That’s just VSync. You’ll be capped at 60 even if you’re over with that logic.
2
u/evanlinjin Dec 06 '20
// I optimized it.
if fps < 60 { fps = 60 }
2
u/n3wsw3 Dec 06 '20
It should clearly be max(fps, 60) so if the fps was over 60 it doesn't get lowered.
2
u/ImpDoomlord Dec 06 '20
Lmao I actually tried this when I was a kid in Gamemaker. I did a check if the FPS dropped below 30 and set the target room speed even higher to compensate since I had no concept of delta time and everything I coded back then was frame rate locked. The result was an even more unstable laggy mess that would crash occasionally
2
u/[deleted] Dec 06 '20
My god this is revolutionary
1
u/Rudxain let let.let = 'let' Dec 10 '20
for (fps = 30; fps < Infinity; fps++){fps *= fps}1
u/[deleted] Dec 26 '20
Holy grail number for fps
1
u/[deleted] Mar 09 '21
but somehow my screen's default latency setting is like 59.randomgibberish
1
u/cheesycheese24 Feb 03 '22
o p t i m i z a t i o n