It was a complete eye opener to how computers work on a far more fundamental level than any other aspect of programming had previously revealed to me.
For anyone without a traditional CS educational background, if you don't know much about bitwise operations or binary, I highly recommend sitting down and spending a few hours exploring them - it will make you think about certain aspects of programming in a very different manner, which - at least for me - resulted in writing much better code.
Aside: While the double tilde is handy, I use the single tilde operator far more often in javascript. If you precede an indexOf statement with a tilde, it essentially turns `indexOf` into `contains`.
if(~someStringOrArray.indexOf(searchTerm))
It works because indexOf returns the index the term is found at, or -1 if it isn't found. This means 0 is actually a successful result, but Boolean(0) = false. But bitwise NOT will clear all of that up: ~(-1) = 0 (evaluates as false)
~(0) = -1 (evaluates as true)
Edit: I'm not suggesting everyone go off and use ~indexOf all the time - I was simply sharing a related javascript bitwise "trick".Do you think the person maintaining your code 2-5 years from now will understand that easily and quickly?
For maintenance, it's important to be as clear as possible, not as tricky as possible.
var exists = ~someStringOrArray.indexOf(searchTerm);
if(exists){...}
or // If exists do...
if(~someStringOrArray.indexOf(searchTerm))Things like that are only acceptable if you're optimizing a bottleneck.
> '15'
'15'
> ~~'15'
15
> '15'|0
15
> 15.99|0
15
> ~~15 * 1.3
19.5
> 15 * 1.3 | 0
19I wouldn't recommend anyone doing optimizations in especially JavaScript unless it's really needed. Remember that optimizations are the root of all evil!
So please try this on Firefox and then on Chroome and see the difference. Firefox is not yet there, sadly.
I don't need my browser to drive full-screen 3D games & demos on my current-laptop hardware. That's not what I (or anyone else) is currently using their browser for. Maybe 5 years from now things will have changed. Maybe then truly everything will be in the browser. That's fine, but by then I will have bothered buying a newer, more powerful laptop, and the browser-engines will be even more improved and everything will probably be fine.
But right now? Performance gap between browsers being put to use they're not being used for? Watch me care less.
Honestly I'd much rather have people stop writing Chrome-only websites and going back to web-standards than having a faster JS-engine in my open-source browser, because that's not where things hurt these days.
Edit: the hatred for web standards in this thread is staggering. How about a reply saying why you don't think a fragmented web is a problem instead of silently downvoting a legitimate concern?
So yes I am shocked to hear that you don't care. And I'm a bit shocked to see you rant at a person that simply suggested Firefox's JS engine may not be as performant as Chrome's.
This is serious FUD with no evidence.
Chrome is open-source Chromium plus an auto-updater and Flash.
It's also disappointing to see that nobody in this big thread arguing about JS performance has pointed out that this demo is not JavaScript-bound at all. Profiling shows 80%-90% of the time is spent in texture upload and/or CoreGraphics. JS barely even shows up in the profile.
I also remember that IE used to have far better canvas performance than Chrome or Firefox since IE9 was the first browser to hardware-accelerate 2D rendering.
From other comments in this thread, it sounds like things are improving in newer Firefox versions. There will always be worst-cases, but generally, I wouldn't say Chrome is really faster than Firefox.
Programming is a form of art, to me.
1.) people can take away a lot from the code and animation which makes it a great example of a new art form. The street scene in oarticular conjures up emotions.
2.) just because a group of the Internet does not understand or appreciate art in all its forms, doesn't mean anything at all except they are ignorant when it comes to identifying artwork.
My favorite: http://js1k.com/2014-dragons/demo/1868
for(T=[B=F=Z=D=i=0];i<600;i++)
The key here is that = is a right-associative expression operator which yields the right operand.
T=[0],B=0,F=0,Z=0,D=0,i=0The block quotes provide containment.
As a side note: I'm in college now and looking to propose an independent study on compression. Any suggested readings or algorithms I should look into?
Lossy compression (which RegPack is actually an example of), typically involves lossless compression plus a preprocessing step to discard information so that the lossless compressor can do a better job.
The techniques for discarding information vary based on application. For images and audio, the most successful techniques tend to involve working in frequency space, so you'll want to read up on the FFT and related transforms.
For code compression, you have different constraints when discarding information because you have to produce a program with identical output to the original. Simple techniques involve removing comments and renaming variables to have shorter names. More advanced techniques involve more complex transformations of the AST, including language-specific tricks like wrapping javascript in a "with(Math){}" block.
Hope some of that helps.
The human brain is a master at recognising and codifying geometric 3d shapes. The developer who created this is a master at coding geometric shapes and transitions in javascript as well.
Human memory is built precisely around remembering geographic locations, human faces and images[1]. The 'have I seen this before feeling' you get is your brain trying to match the demo location to memories ( my conjecture anyway )
// Moon
c.fillText("(",99,-99);This makes you realise how old games must have been driven by the technology.
Curious: Does any of your work survive?
http://www.pouet.net/prod.php?which=61668
Making of: http://www.ylilammi.com/webgl/highway4k/Making%20of%20Highwa...
I'd recommend watching the video instead.
It's really impressive and he posted the explanation: http://birdgames.nl/2014/04/js1k-post-mortem-minecraft/
Edit: much better in 35.0a2. I wonder what they did?