6 ms·
Look at the code guys [1]. I love it. This is simple. There is not a single line of bullshit. I hope he gonna become a great programmer and continue to make bea
by quadcore 8y ago
Look at the code guys [1]. I love it. This is simple. There is not a single line of bullshit. I hope he gonna become a great programmer and continue to make beautiful code like that.
[1] https://github.com/S-poony/Ultra-Square-Catcher-USC-/blob/master/jeuvideo.html https://github.com/S-poony/Ultra-Square-Catcher-USC-/blob/ma...
- jeena 8y ago> There is not a single line of bullshit. Don't want to be the killjoy here but isn't line 77-79 the same as 85-87? With the rest I can agree.
- lucisferre 8y agoI'm going to guess that isn't intentional.
- userbinator 8y agoAgreed. There are so many JS projects these days composed of a dozen abstraction layers and barely-used libraries all mixed together and spread out across multiple files with an insanely complex "build system" on top, that it's very refreshing to see simple, self-contained JS.
- beatgammit 8y agoYou don't need complexity until you do. Our company needed an internal tool, and they wanted remote access to it, but it was basically just a tool to generate a file based on a few inputs. We already had a command line program for it, so I wrapped it up in a web server and had it take input as a form input without any JS. It worked great for years, and then someone got tasked with updating it (mostly just combining it with other tools). He couldn't figure out how it worked, so he rewrote it to use a ton of JS, using Angular and other stuff. And guess what? He took longer to rewrite it than I spent the first time and made no functional changes besides some CSS and a ton of JS. With all these fancy new frameworks and browser features, it seems that many developers have forgotten (or never learned) how to do things simply. Frameworks and browser features have their place (I built an interactive HTML5 app as my first project at that company), but they're often completely unnecessary.
- jb3689 8y agoTo be fair, in my experience rewrites always take longer regardless of technology choices. You are often reverse engineering requirements which is really consuming both in time and energy. That said, I agree with the point you're trying to make though (I strongly prefer software with less dependencies/frameworks)
- akuji1993 8y agoAlso, he apparently had to update / upgrade the application, so it's kinda to be expected that he will take longer for this.
- kennybomber 8y agoYes one should assume most frameworks will be dead 2 years from now. Dependencies problems suck. And create security holes. When development starts going into the cloud get ready for a lot of pain the world has never seen before.
- jianzong 8y agoMy brain hurts just imagining this.
- croh 8y agoMine too
- tracker1 8y agoIt depends on your needs... Are you building a complex application with several developers. You probably want a build system and module based JS. I prefer react + redux + material-ui. Some of the new stuff around hooks and context could displace redux for smaller apps easily. If you need a one-off page that does a little dynamic stuff? Drop in jquery+bootstrap and a little wiring js and be done with it. Not a huge fan of the size of jquery + bootstrap, but it's a fast path to done depending on your one-off needs.
- natecavanaugh 8y agoAs far as logic goes, I totally agree, but personal preference nit pick, from a code writer and reader perspective, I think all subproperty access (`hero.acceleration.x`) could be cached to a variable, or just operate on plain variables and assign property access after mutations and only manipulate objects as needed. It makes the code easier to write and read, IMHO, and I believe older engines had infinitesimal changes in performance with updating objects, so it's more of a habit and code clarity thing for me. Of course, that's far less important than the fact that the logic is clear and concise, especially after learning JS in a week :)
- tmdroid 8y agoHe did the game in a week, not learn JS from what I understand from the title
- natecavanaugh 8y agoAhh thanks for the clarification :)
- 11235813213455 8y agoThe mix between French and English variable names or comments is a bit irritating, even for as a French guy
- deleted 8y ago[deleted]
- HighSaysBob 8y agoFrom the source, Shift = Brake
- Imagenuity 8y agoYou would never know this unless you read the source. It's unlikely that you'd stumble across it.
- finaliteration 8y agoMy only complaint is the global scope pollution with the top-level variables and lack of ‘var’ for those. But other than that, I agree.
- etatoby 8y agoThat's a complaint about the JS language itself, that variables are global unless otherwise specified.
- finaliteration 8y agoI do agree it’s a complaint about the language. However, I think it does ultimately fall on the developer to know how to work with the language including the bad/ugly/awful parts. I also think not polluting the global scope is a pretty foundational thing to know or be aware of. It’s really easy to shoot yourself in the foot or have naming collisions/overwrites happen if you aren’t careful. Another example would be memory allocation/freeing in a non-GC language. Sure, it’s a pain that I have to deal with it, but it’s still on me to make sure my application works in the language I’ve chosen and doesn’t leak memory all over the place.
- deleted 8y ago[deleted]
- klyrs 8y ago> However, I think it does ultimately fall on the developer to know... This person has been programming for a week. I think we can let this slide
- sbov 8y agoBut what if he wanted to turn it into a AAA FPS game with RTS elements in a persistent online world that supports millions of simultaneous users?
- cududa 8y agoIf you're not joking and actually making that statement seriously you need to close your computer and go take a few hour walk.
- MetalGuru 8y agoHe’s joking.
- deleted 8y ago[deleted]
- nurettin 8y agoThat was the next logical step during the early 2000s. Every bright-eyed college freshman on IRC was "recruiting" for his next awesome MMORPG idea.
- skocznymroczny 8y agoIt's still a thing. On gamedev forums and subreddits you still have people assembling a team. Of course he can't do any programming, he's only an idea guy and needs 5 programmers, 3 writers, 7 artists etc.
- kungtotte 8y agoNo he can't pay you anything, you'll get shares in the company which eventually will be worth gazillions because the idea is so good.
- baud147258 8y agoNo, right now it's the RPG elements that are trendy, RTS is soooo 2000.
- apo 8y agoReally well done and I like the brevity. Here are some ideas for revising the code: 1. There are two functions called "distance" and they're identical. Only the outermost appears to be needed. 2. As written, the game places variable and function names into the global scope. It doesn't matter for this game, but will be a problem for larger games. One idea would be to use the Immediately Invoked Function Expression (IIFE) pattern [1]. Another would be to take advantage of ES6 modules[2] (<script type="module">) to limit variable scope. [1] https://developer.mozilla.org/en-US/docs/Glossary/IIFE https://developer.mozilla.org/en-US/docs/Glossary/IIFE [2] https://www.contentful.com/blog/2017/04/04/es6-modules-support-lands-in-browsers-is-it-time-to-rethink-bundling/ https://www.contentful.com/blog/2017/04/04/es6-modules-suppo...
- tim1994 8y agoAlso never use Math.pow for squaring numbers (used in the distance function) because it is significantly slower as it is designed for abitrary real exponents, not just integer ones. Cannot be learned soon enough IMO :) Still a very good job for just a week of coding though.
- therein 8y agoDefinitely great job. Reminds me of when I taught my physicist friend C and he wrote a raytracer and a game to demo it the next day. I had never witnessed so many trig functions used on a global context.
- Sean1708 8y agoDoes the JS JIT not handle this? Seems like it would be incredibly trivial...
- fenomas 8y ago> Also never use Math.pow for squaring numbers (used in the distance function) because it is significantly slower... Modern JS engines optimize hot functions at runtime - advice like this won't affect actual performance.
- ghusbands 8y ago
- Satsana 8y agoSure, with a duplicate distance function and one 100-line function? For me that in itself is horrible lol. But as a new programmer he should still be commended but bro, give credit only to where its due. And here its the fact that he's new, not that the code is "beautiful". (You're making me doubt what you think of beautiful code, but i guess since he's your brother you're definitely biased.)