Wednesday, May 28, 2014

Java !== JavaScript: return true;

Surprisingly, everyone seems to get the two languages Java and JavaScript for being the same thing. It's like a virus that can't be erased unless you find out the solution or difference, which in my opinion, can be quite simple if you just search the web (no kidding!). But it's mainly because someone named the programming language JavaScript after Java, so whoever did this managed to successfully manipulate people drastically. But this article is going to be about the differences between the two languages, and how they're not the same thing. So hopefully you won't be like the ones who are confused after reading this!

Java



Java is coffee. You brew it to your personal taste and add sugar if wanted, then sip with milk or either by it's perfect original taste. Where do the beans come from? No one knows. Only the computer produces such a magnificent, flavorful..

No really, let's cut to the chase. Java is not coffee (in the programming world!). Java is a powerful and common object-oriented language that actual developers use to create devastating mobile apps and games that you see (without realizing it) to this day. The popularity of Java is increasing, because more people are looking towards it's simplicity unlike other high-level programming languages (like C, C++ or maybe even Objective-C). I honestly wouldn't know much about C or C++ being complex, but I do know that Java does seem simple from my own personal experience. Take note that the fundamentals of Java came from  C++, but the creators improved the syntax of Java so that it could be more simple for programmers to use. And so far, they done a great deal to society by doing so.

Aside question: Why did they use coffee as their logo for Java?

This is kind of a general question, but no one really knows. I actually did my own research (across the web) and I haven't found a good solution yet, so I'm not sure. The creator probably just came up with the name while sipping actual Java. Besides, from what I heard, programmers run on coffee. But I don't..


JavaScript

JavaScript is a popular, object oriented, web-based programming language used by Web Developers. People use this language to make websites created out of HTML and CSS interactive. Without doubt, you probably seen JavaScript in action, because it's nearly everywhere across the web browser. Input boxes, check boxes, radio buttons - all of that stuff is powered by JavaScript. The power of this language is great, but it isn't as great as Java. You definitely wouldn't use this programming language to create mobile apps or games unless they're web-based. This is not a language to look into if you aren't interested in web development, because that's basically where that direction is heading.

The good thing about this language is that everyone is learning it across the world, so finding open-source projects or tutorials is very easy with just a simple search (unlike Java). You wouldn't have much trouble learning this language either because JavaScript is more simpler to get into and less complex. The only part of JavaScript that might confuse is the object-oriented part, because it takes a lot of effort to utilize the code and remember it's methods. But other than that, you're definitely good to go. This was actually my first language that I had gotten into thinking it was for mobile development, but I realized it wasn't through my brother and by research. It was kind of disappointing on my part, but I'm glad that I learned this language as a first - I'll talk about that in another article, perhaps.


Listing The Difference Between The Two


I probably don't have to list the difference for you guys, but just in case you're unsure - and for the sake of this post - I'll break it down for you. Once you're finished reading the difference, you should probably look exactly like that meme above. Jussayin'.

JavaScript

  • Popular web-based programming language
  • Used to make websites interactive
  • Can be used freely on your browser, with no download needed
  • Object oriented 
  • Less complex syntax than Java
  • Leads to Web Development as a career
  • Easier to learn on the web due to popularity
Java 
  • Very powerful, common programming language
  • High-level programming language
  • Used to make mobile apps and games
  • Cannot be freely used on your browser - you need to download an IDE
  • Object-oriented
  • More complex syntax than JavaScript, but simpler than C++
  • Leads to Software Development as a career
  • Not easy to learn using the web as a source, but popular among the web

Wow, look at the difference! If you aren't amazed or even the slightest astonished, you have to be crazy. It's quite easy to say that Java isn't JavaScript now because they have NO similarities at all. And I'm not saying this to belittle our web-based language JavaScript, but it is absolutely nothing compared to Java. The only reason this topic is ever brought up in the programming community is because people can't distinguish the difference between the two due to the similar names. But trust me, the concept and design is totally different.

That's it! Feel free to comment if you have any questions or just want to throw out your opinion. It's fun to have active people willing to spread their knowledge, so don't be afraid not to.

See ya!




Thursday, May 22, 2014

Where to Code First


Whether it's being apart of an open-source project, soloing or partnering with friends, it's important that you know where to start first. Coding naturally starts anywhere, but it's best that you don't hop to different languages every time instead of focusing on one. This saying goes for all of the above that I just listed.


Open-source projects

Whenever you participate in open-source projects, you see each person (in that group) in a certain field; JavaScript Developers, Web Designers, Story Editors, etc. Everyone plays their part and doesn't worry about others unless it affects their area (For example, incorrect name of characters implemented by JavaScript Developers). This kind of process usually leads to success, because everyone informs the project leader whenever ideas come up or when confusion is put into play. The responsibility as a project leader is heavy, because you're expected to have some knowledge in at least one language or the other, especially if you don't have a co-leader to back you up. But you usually see Lead JavaScript Developer and such for a reason, because their job is to obtain the project leader's information and convert his/her words into coding-terms for other programmers (in that field) to understand. So let's say (as a project leader) you wanted random numbers to be generated and added each time it was displayed on screen - the Lead JavaScript Developer would have to take your information and explain to other programmers in a more programmable-sense. It's like converting one language into another. 

I suggest just a few tips for you when you enter open-source projects:

  1. If you're really good in a particular language, try to keep your complex code at a lower level for people to understand. This is called consideration and team work.
  2. Don't judge nor question the project leader's orders unless you intend to support his idea. The Lead JavaScript Developer usually does that.
  3.  Look over your code before posting for others to see, because bugs will occur in the program if you don't. Tiny mistakes like miss of semicolons or wrong boo leans can cause major problems. 
  4. If you can't participate, don't participate. It's a open-source project, not your lifetime career.

So, this leads back to the question: "Where do you code first?"

 For open-source projects - whatever field you're good in. 

Soloing on a project

                     photo is not me.

When you're by yourself, it's probably a good idea to be fully aware of what you do. The difference between being apart of an open-source project and soloing is that, you're the leader of the project. So you know what you want instead of being given orders by someone else. Acknowledging this fact is precisely a good idea when soloing on a project, so don't let that deprive you from coding what you please.

Tips that I suggest when soloing are:

  1. Don't be afraid to talk to yourself when trying to solve some difficult problems. (troll) 
  2. Take a break sometimes. Soloing is a lot for someone with one brain.
  3. Never give up on a project you started. That's a major fault with programmers.
  4. Ask for help. Having someone assist you won't lose the title as being a "solo project". Erase that pride.

Where should I code first? In my opinion, the HTML file. Designing the layout of your program is better than completing some code and then putting use to it afterwards. You want to see the result of your code fast, not slow. On top of that, creating a nice webpage/design is pretty hard, so it's best that you focus on that first. But make sure you utilize CSS - HTML doesn't look good without it.

Partnering with Friends

What could I possibly say to this? Take your time! You guys are friends. Of course, you want to have some kind of day picked out to work on the project with each other - but take your time. This topic is similar to open-source projects, so reading what I wrote above should be enough to understand what you should/not.

I have two tips that I'd like to suggest:

  1. Drink Mountain Dew or Monster (Energy Drink)
  2. Have fun and laugh

Where should you code first? Wherever your friends decide on. :)


I hope you guys enjoyed reading this - I had fun writing it! Learning one of the greatest importance is phenomenal in the programming world, so make sure you take this as a valuable lesson! Thanks again, and comment if you may! 



Monday, May 19, 2014

jQuery IS JavaScript

Every time I come across a programmer (who is just learning how to code), they always ask me these questions:


  1. What is jQuery?
  2. Why do we program jQuery inside of a JavaScript file?
  3. jQuery isn't JavaScript, right?

I'll admit, I'm not really good at explaining things, so bear with me. The last time I tried explaining to my sister what a (JavaScript) Object method was it turned out to be an disaster. You can say I'm one of those people who learn something from my own point of view and then  have trouble explaining from that point of view. I eventually worked it out with my sister, but it took me some time to explain it as simply as I could. But everyone learns things differently, so it's only natural if others can't comprehend you from your own understanding. You just have to find a way to provide an understanding for them to comprehend what you learned in an easier-term. Everyone thinks alike in a sense, but not really. Keep that in mind.

Why am I telling you this (you didn't ask this question, I know)? Because I'm warning you that you might not be able to understand me, but just let me know in the comment section. I'll find a way to make it even more simpler for you. :)

What is jQuery?

jQuery is awesome, that's what it is! No seriously, jQuery is a JavaScript library that makes manipulating the DOM (in other words, the HTML document) much easier and funner. It was created by thousands of coders who are experts at JavaScript and ran on either Mountain Dew or coffee (you gotta know your history, kid). They even have their own website which is called jquery.com 

If I were you, I would keep this website bookmarked. They have nearly everything listed in their documentation about methods that you could use and choose from. I believe they also provide several demonstrations as to how each method works too, so don't hesitate to "Write less, do more".

Why do we program jQuery inside of a JavaScript file?


You program jQuery in a JavaScript file because you wouldn't be able to program it elsewhere, unless it's put in <script> tags in the HTML document. But other than that, you're outta luck. Not satisfied with your answer? Good. Read the next question below - it's related.


                      jQuery isn't JavaScript, right?

No, no. jQuery is JavaScript. You can't let that confuse you, my friend. That's why I said you only program jQuery in a JavaScript file (or HTML document with <script> tags) because it's JavaScript itself. The purpose of jQuery is to make creating interactive websites more simpler, that's all. With the help of jQuery, websites all over the world have been becoming better and better each day. And the best part about jQuery is that it's still growing, so you'll always be able to find something new once it's added. Keep an eye out, coder!



I hope this fixes all misunderstandings that some of you people might have. Like I had mentioned before, I'm speaking from my understanding about this topic. So if I added any misleading information, please feel free to clarify. Whatever the case, the most important thing that I didn't mix up is the fact that jQuery is JavaScript. That's honestly all you really need to know. :)

Sunday, May 18, 2014

(How-to make) jQuery Alphabets for Kids

I'm going to show you how to create a simple program that contains the alphabets (A through Z) in HTML while making it interactive with the power of jQuery. The code is simple, repetitive and most importantly, fun for everyone to learn from.

I found this to be a good program to start with if you're a beginner who knows jQuery but doesn't know how to utilize it. The key of this post is to show you that jQuery is a powerful library (made out of JavaScript) and you can do just about anything with it. If you want to view the code in action, here is the link.

Some of the audio I implemented inside of that program are different from the rest - did you notice? I only did that because of my hilarious, sick humor, so my baby sister says (not really). But it's true, because I didn't want to do something if it didn't please me. What fun is that? None at all. So, do whatever you want to your program, but make sure it still has it's kid-friendly kick to it.


Step 1. Using JSBin

To begin, we're going to pull up JSBin. JSBin is a free website that allows you to program JavaScript, jQuery and HTML/CSS all together. If you look at the tabs above, you can see "HTML", "CSS", "JavaScript", "Console" and "Output". We honestly have no concern for the console tab, so close it if it appears to be highlighted on your page. The "Output", however, is going to be needed. If you click on it, you'll see a few options in the display menu saying "run JS" and a checkbox saying "Auto-run JS" - you can leave those settings alone. There should be an arrow though on the right-side of those two options, and it will open up your code in a HTML file. This is going to be useful because we're going to want to view our code for correct positioning (for the letters and such) and provide test-runs, so keep this in mind.

Step 2. Providing jQuery



We're using jQuery, so it's important that we provide the link for it. Luckily, JSBin has all this, so you can just click the "Add Library" button and select the "jQuery 2.1.0". It will automatically insert the jQuery link for you inside of your HTML file - what a breeze!

Step 3. Getting Started


First, let's provide an image for our little program. You want your background to be catchy and appealing to kids, not some boring plain white-background. Kids would be so displeased with you, trust me. So, find an image (Mine is already chosen)! Make sure you copy the url image link.


After you picked an image (and copied it's URL link! Important!) You're going to want to place it somewhere.. Luckily we have <img> tags! In our HTML file, we're going to want to create one and then close it with a self-closing backslash. After we do that, we're going to want to provide two attributes to the tag; the ID attribute (that allows us to do CSS code) and the source attribute. If the image I provided is too small to see, I'll demonstrate below:

<img id="background" src="whereourimagelinkgoes"/>


Remember, all of this goes in the HTML file. If you noticed in the picture above, I circled two code pieces. The one on the right is CSS and the one on the left (you guessed perfectly) is HTML. In the CSS file, I took the ID that is connected to the <img> tag and provided it with code. The code fills the entire HTML document with that background image you chose. Pretty cool, huh? I also included another property for that element (that's what all tags in HTML are called, by the way) which is called position. It allows you to lock an image to the page (using the "fixed" value) or move freely (using the "absolute" feature). I'm not the best teacher out there, so I'm only speaking from my own understanding. Your code should look like this in the CSS file:

#background {
   width:100%;
    height:100%;
  top:0px;
    left:0px;
  position:fixed;

}

You can view to see if your code is working properly by clicking on the black arrow like I had mentioned in the "Output" button. Your image should cover the entire HTML document.

Step 4. Creating the letters




Finally, the fun part! We're going to want to create our first letter on our HTML document - the letter "A". Starting with the HTML file first, we're going to want to make a <div>. In this div, we're going to need an attribute ID and call it "letterA".  This helps us distinguish our elements if we ever get caught up in something by accident, so it's important that you name your IDs' carefully. Make sure you put the actually letter "A" in the div so that it'll show in the HTML document.

In the CSS file, give your letter "A" a color using the "color" attribute. After you do that, give your text a font, a size and a position set to "fixed". We don't need to move this letter, so it can remain in it's place.

Step 5. Second letter and the use of jQuery


Repeat the same method as last time (in step 4) for the second letter. But we're going to need to use the "margin" property in the CSS file this time to move your second letter from the first.



I created another <div> with a similar ID name to identify the letter and then embedded some CSS code.
The difference in the CSS file is the "margin" property, which I set to a hundred pixels. This allows it to avoid conflict between the two objects by separating them instead of being on each other. The second letter will rest aside on the right-hand side next to the first letter.

Here comes the jQuery part! We want our letters to expand when we hover over them. But when we leave from that letter, we want it to go back to it's regular size. The code "mouseenter" stands for when the mouse hovers over an object, while "mouseleave" stands for when the mouse leaves an object - kind of makes sense, doesn't it?
 In the mouseenter function, I expanded the letter using the .css method. It's literally just another way to edit an element instead of doing it within the CSS file itself, making it easier for programmers to change how something looks and appears. Your outcome should look like this in your output, and moving your cursor across the letters should expand then go back to it's regular size when left:




Step 6. Getting Audio (soundfxcenter)

Now, finding audio for your games and stuff is really difficult. Really difficult. In fact, it took me nearly days to get good audio for those letters! But my determined self never gave up, so I landed upon Soundfxcenter.

It's a really good website that provides nearly every audio and sound effect for you. I definitely recommend that you get your audio from here. It lags kind of bit, but there aren't any pop-ups nor viruses on there. So don't be shy.

If you search up "Letter sounds", you should be able to find the exact same audio that I have. Try to find the "A" letter sound first, then "B", "C" and so on. But here comes the tricky part:

You don't want to download the actual file - you want to copy it's link location instead. So, to do this, left-click on the "Download MP3" link and drag it into your URL box at the top. The link should have ".mp3" at the end of it, indicating that it's an MP3 file. Copy the link and move onto the next step!


Step 7. Making Use of the Audio

Now that you got your audio link, let's put it to use.

This part of code involves the use of actual JavaScript this time, so if you know JavaScript and at least one DOM method, you're good to go.


  1. We created an variable called "letterA" and then turned it into an "Audio Object" by using the new keyword. 
  2. After we did that, we put out link inside of quotations, closing off the piece of code with a semicolon. 
  3. Then, we called upon that Object, using the method .play() to activate the sound we provided.
Now you have your sound working! High five-- I mean, air five! Feel free to test it out in the "Output" section. But just to note, if the sound doesn't work right away, give it time. Loading your code is a lot of work for your HTML document.


Step 8. Repeat, Repeat, Repeat. You're On Your Own

Create another <div> tag with a letter inside of it, give it an ID, utilize some CSS code, margin it (to the correct spot aside the other letters) and then use the same jQuery code demonstrated in Step 5. Basically, repeat yourself.  Your code should look very similar to mine after a while, except the fact that I used the <span> tags for no reason in my code..

Once you're done with your program, please submit it for viewing in the comment section! I'd love to see your creativity, work and skills. Thanks for reading this and I hope you learned a great deal from it. :)

- Yazid