Monday, November 14, 2011

Javascript: The language everyone wishes it wasn't

Having just gotten to watching the Crockford videos (well, 2 of 5 so far) due to the video's intimidating length (~7.5 hours in total), I'll say its definitely interesting and worth viewing. If you haven't yet seen them, they are easy to find on youtube (yahoo theater versions seem to have been moved or taken down).

The first part about the history of programing was quite interesting, but fairly inconsequential and can be skipped if you want to save yourself an hour and a half of time. It can be found here.

The second part really starts getting into the workings of javascript and its relationship to the browser. Crockford outlines many advantages and disadvantages to javascript, almost all of which I already knew, but he also outlined the ES5 standard, which had many awesome things that I think javascript sorely needed. The video can be found here.

Of the pros he discussed, the only thing that particularly sticks out is the sheer dynamism of the language, mostly given to it through its use of prototypical inheritance. This dynamism allows for a program to undergo a drastic change in structure or scope with less tedious refactoring involved when compared to other languages.

Of the cons he discussed, they all seem to stem from a simple lack of forethought on the part of the language's developers. Many of the issues came from the developers trying to make the language accessible to beginners, while they did manage to succeed in this, it resulted in many pitfalls that still plague the language today. One that stuck out to me was the NaN variable, as I didn't know that NaN does not equal NaN and that NaN is subsequently toxic to all numeric operations there after that use the NaN. Seems like a fairly useless implementation; I recall Objective C (terrible language btw...) having a similar situation with NaN, but I am unsure if NaN didn't equal NaN in that language.

The part I found most interesting was the new things that were being introduced in the ES5 standard. I was unaware of this functionality, but much of it seems very useful and would address many of the problems I have with javascript. A short document on the ES5 changes can be found here. These changes seem to primarily introduce ways to give greater control over the objects you create and use in javascript, giving you the ability to more rigidly and accurately structure your objects which in turn allows you to more accurately structure your scripts. I am not sure as of right now how widely supported these are across all the browsers out there, but I would hope that it is a fully supported standard by now, as I would like make use of these features in my future scripts.

I'm gonna finish this out by expressing an opinion I've had about javascript for sometime now... What holds javascript back is its attempt to be accessible and easy to learn. This is great for beginners but will seriously hold back the development of a more complex and intricate system that requires a large complicated infrastructure and mass resources to work. I think it may be in the interest of developers to create a new language, keep javascript around for compatibility and for beginners to code on, but give us the option of a cleaner, more robust language that we can work on for larger, more complicated systems that run in the browser. If the browser really is the future platform, the thing we are heading towards for all of our entertainment and media like some suggest, then a better implemented language is a must, because it will take far too long to improve and restructure javascript as to where it is the language we all need it to be.

Saturday, November 12, 2011

Using git and setting up my git server

Having used git for a few months now, I seem to have become fairly comfortable with it and have started implementing it into other projects that I have on the run. Really, with the exception of some initial start-up processes it can really be used as nothing more than a simply SVN server, so people familiar with SVN shouldn't have much of a problem operating git at a basic level. From this basic level, the users can slowly start unwrapping the layers of functionality within git. It doesn't seem to be too different from mercurial, I've heard some argue that git has a better branching system but I have heard opposing arguments that git lacks some of the utility that mercurial offers.

One con of git that I have noticed is that due to the way git works, simply making copies and copies of data as it branches and whatnot, it makes it inviable to keep binary resources(images, models, etc) grouped in with source code. If a project were to ever become large are well distributed, the sheer disk space usage that these resources would incur would very quickly spin out of control. I suppose this isn't too much of an issue, as it is probably good practice to keep your resources separate from your repo system anyways, instead using a more specialized solution to distribute a program's binary resources.

I recently got a git server running on my own personal server using gitosis. It was surprisingly difficult to get running, but this likely has a lot more to do with the fact that git server software are not usually built to run on Windows Server 2008 and are instead meant to run on Linux based system. Though through the use of cygwin and a few hours of tweaking I got a private git server running. If anyone is interested in having a place to privately store your code (as opposed to github which public unless you wanna drop like $8/month), you could set up your own git server running on your desktop or, once I get the security tightened up and tested on my server, I may be willing to give people accounts on my server so they may have access to a git repo that is unaccessible by the public.

Friday, November 11, 2011

Building Firefox in debug

So, I have recently attempted to build firefox in debug mode on windows. Having follow the instructions posted here after having downloaded all files from the git repository. Things were moving smoothly until I attempted to execute the make process, in which case it displayed the following error:
client.mk:121: *** This source tree appears to have Windows-style line endings. To convert it to Unix-style line endings, run "python mozilla/build/win32/mozilla-dos2unix.py". Stop.

I ran the python script it suggested, and after processing it, I re-ran the make process, but it continued to fail with the same error. I have looked up some in information on this problem, some have indicated that I have to set a option when I pull from the repository... I have yet to test this but I will update this when I have successfully completed the make process and share my findings.

**UPDATE** - So, found out why those errors were coming up, funny because I believe David Humphrey mentioned this in class (or someone did) but I didn't understand the context of what he was talking about. The problem is that git wasn't configured to deal with windows line endings correctly, so by entering the following command:
git config –global core.autocrlf false

and re-cloning the repo, this issue should be fixed.

**UPDATE** - So, took a while but it finally finished building. When I go to run it, for some reason it opens up my normal firefox application instead of the nightly build, but I'll figure that out tomorrow.

Sunday, October 30, 2011

CubicVR Issue 30 - 0.2 Tester

So I finished the first run through of the material tester. I decided to develop more of a testing platform instead of a simple tester for materials, allowing the user to use and tweak the settings of the tester on the fly. I only managed to incorporate three basic material types into the tester, but the basic lighting and and dynamic object creation component seems to work. I plan on hopefully having this tester finished by 0.3, working with all materials and all lights, as well as other things that may end up conflicting in the system. It can be accessed here https://github.com/CloudScorpion/CubicVR.js/blob/issue30-dev/tests/material%20regen/Material%20Test.html

The other issue I am working on is the dirty material issue. I couldn't figure out much else to do other than simply adding the dirty flag variable to the materials and incorporating it with my previous changes. It can be accessed here https://github.com/CloudScorpion/CubicVR.js/blob/issue30-dev/source/CubicVR.Material.js

So that will hopefully suffice for 0.2. Hopefully I will have more time to sink into 0.3 than I did into 0.2 but only time will tell. I'm still unsure if I am supposed to submit this 0.2 somewhere, I haven't found anything about it on the wiki, hopefully I can contact David Humphry today to find where I can submit this stuff, if I even have to...

Friday, October 28, 2011

Getting back to things....

I've been working on a material testing system for the last while, in a hope to make a system with enough utility to do more than simply test one or two things at a time. I've also added the "dirty material" flag to all materials to my original bug, but I'm a bit confused on where else I can go with that bug, thus I have been concentrating on the test system.

My time has been strung quite thin lately, dealing with tests and assignments from other classes and dealing with details pertaining to my other jobs, I haven't gotten to blog much lately, mostly because I haven't had time to dabble in OSD work at all, thus I'd have nothing to blog about. Hoping to finish this 0.2 tonight since I have another assignment due in a few days for another class.

Thursday, September 29, 2011

CubicVR Issue #23 version 0.1 release

It took me some time to figure out how CubicVR works, but now I have a basic understanding of its workings and was able to create a 0.1 release that isn't completely worthless. The issue was that when a material was initialized with an opacity of 1.0, it could not because changed because the shader was already setup not to do alpha blending for performance reasons. Subsequently, material that started opaque could never change.

My development proceeded in three steps. First, I created a tester page to recreate the bug so that I could test to see if my solutions had fixed it or not. This tester can be found here. I simply displayed two boxes on screen with the camera spinning around it with controls at the top to adjust one of the box's material's opacity, which started at 1.0. This tester was partially based off of the Normal Mapping render tester that was already on the repo.

The second step was a very simple fix by forcing all opaque objects to having blending on them. This fixed the issue but at a needless cost, so I had no intention of considering it an actual fix.

The final step was the development of the fix submitted as the 0.1 release. This fix kept track of whether or not the material had blending enabled on it, while the system was rendering the materials if it came across a material with blending not enable and an opacity below 1.0, the shader would be cast aside and a new one generated on the spot. Its obviously not the best solution, but it seems to work well enough for the time being.

CubicVR Material Bug

I have been suited with a material transparency bug for the CubicVR 3D graphics system. The problem seems to be that when a material is initialized with an opacity of 1.0, that it cannot be changed afterwards. It was mentioned that the material system might just as well benefit from some form of dirty flag that will force the material to be regenerated during the next cycle so that inconsistencies like this should not be an issue any longer. I had a fair bit of experience in 3D graphics (for about a year now) so I was also asked to look into another issue, which is to create an automated test suite for the all of the commonly used material types. If no one else ends up wanting to grab that one, I might take it on board as well.

I have just recently completed a small test page that replicates this issue so it should make it easier to identify the state of my bug fix as I am developing it. It is a simple pair of boxes with the camera spinning around it and a control at the top of the page to allow you to change the transparency of one of the boxes, using the other box as a reference point. Its nothing spiffy but with it complete I am hoping I can have a rough bug fix ready before mid-night.