Showing posts with label website. Show all posts
Showing posts with label website. Show all posts

Monday, November 23, 2015

Java vs JavaScript

Yesterday wouldn't be the first time an aspiring programmer walked up to someone experienced and asked, "So what does JavaScript have to do with Java?"


The short answer is that it doesn't. They are not related at all, except by name.
However, they are both very popular and useful languages to their own merit, so we'll take an abstract look at them both.

Quick differences :

JavaJavaScript
  • Statically typed (variable datatype needs to be specified beforehand)
  • Dynamically typed (variable type is resolved directly during runtime)
  • Class based (functionality is stored in a way such that it belongs specifically to the instance from which it is accessed)
  • Prototype based (functionality is simply reduced to a property template that executes whenever required)
  • All non block statements should end with a semicolon.
  • Semicolon is optional in most circumstances.
  • Java has an implicit  this  scope, and an implicit class scope.
  • JavaScript has an implicit global scope, and during special events, an accompanying  this  scope.

If you're new to programming and the table above didn't make much sense to you, don't worry. The table just contains some technical details that'll help you to separate how one language works from another in your mind while actually writing code.
Since you're reading a blog post that's basically trying to pitch one language versus another, I'm going to assume that you might be more interested in the difference between these two languages in terms of application and use case.

Every environment has its own set of characteristic features that a programmer needs to keep in mind when developing in it, and I believe that the act of "putting yourself in the respective mindset" of that environment brings out efficient code in the end.
What I'm trying to say is that if you try to eat an orange like you would eat an apple, you might end up successful in your goal, but the overall experience will be messy and unsatisfactory. Hence, becoming thoroughly familiar with the frame of mind you need to be in for your environment first is important.

The Java mindset

A Java developer will have a concrete idea of the structure of every class in his project, like a map of properties and functions, so he knows how each instance will interact with each other. When you need to use a lot of object oriented logic, including inheriting from other classes, polymorphism, and modularization by separating functionality into their own classes, then you're going to be passing instances around a lot. That's how you know that you need a language like Java for your task.

Also useful to note is that Java has its own core set of libraries, and virtual machine platform where code is compiled.

Where to use Java :

  • For standalone apps - If you just want to create a command line or GUI application on the go, to run natively, Java is a good bet. In fact, you can't make Android apps without Java.
  • Browser Applets - Although Java applets are becoming rarer and old, sometimes they are used to extend the functionality of the limited power that web browsers have over your system.
  • Embedded devices - Java was originally written with portability in mind, such that it can easily be made to run in embedded projects due to its scalability.
  • Drivers - Java-like languages like C or C++ are often used to develop software to make hardware work, although you might want to use a language different from Java for this purpose.

The JavaScript mindset

A JavaScript developer will be aware of what's supposed to happen when. Picture a chain of events that fire off one after another. If you're developing in JavaScript, you should know the sequence of that chain and how to manipulate that sequence to get your desired result with only sufficient lines of code. You might have to juggle events by repeating, isolating, overloading, threading and doing just about anything to functionality. This will involve passing functions around a lot.
Yes, if I haven't mentioned it before, functions are treated as objects in JavaScript. You pass them around directly and play with them (along with callbacks, optionally) a lot, especially since this language has to deal with a lot of asynchronous activities. Think of anonymous/lambda functions, but on steroids.

Also useful to note is that as a scripting language, JavaScript has come a long way and has a lot of libraries to make things easier in most contexts. It is no longer limited to just a browser sandbox and is very capable for a language where code is interpreted.

Where to use JavaScript :
  • For anything web related - JavaScript is used primarily in browsers to make web pages dynamic and functional with client side scripting. There are a lot of libraries like JQuery and AngularJS that can use be used to boost its capabilities.
  • For backend or server side - With Node.js, JavaScript can also work on the server end. You can either cater to web pages with server side scripting, or just make a different desktop app altogether. Node Package Manager (npm) will help you get all sorts of libraries so you don't have to re-invent the wheel.
  • For light computation - There exist several JavaScript engines out there, so whether you're using V8, Rhino, or Spidermonkey, you can just run some code off of them in your browser console, or node terminal to quickly get some work done like basic or dynamic math.

By now you should know the difference between Java and JavaScript, not just in syntax and code, but also in usability and application. You should know which type of language to choose for your next project, and hopefully what you learnt in this post will make your project more successful.

Although it is true that a lot of points mentioned in favor of Java or JavaScript can also be applied to many other languages, they are not discussed here because this is just a general comparison post along the lines of "Java-like languages" and "JavaScript-like languages".

Thursday, May 21, 2015

Antiviruses and why they do more harm than good

It's been around four years since I've been using my current laptop and I have not had to deal with a single virus during that entire period (apart from the ones I made myself). To make that point hit you harder, I do not use an antivirus, and yes I run Windows.

I use the internet a lot, and while you might think I'm simply lucky, the truth is that there are loads of people who already do this. The idea is that there really are some foolproof methods you can apply to make viruses perpetually gone. We'll discuss those methods after I explain why antiviruses by themselves are not exactly safe.

Now you might be thinking : What's the big deal? So it's possible to avoid viruses, but I have an antivirus to keep myself on the safer side. It's not like it's doing me any harm.

Well, antiviruses can actually do a lot more harm than you think.

Antiviruses can often act bizarre and erratic. If you're trying to get some work done, this can be a bigger pain in the ass than having to deal with printers that were sent from hell.
The thing is, antiviruses try their best to keep your computer safe. Therefore by nature, it is suspicious of everything in your computer. The antivirus however doesn't know your computer as well as you do, which means that it will often target completely innocent files which can be crucial to keep your system running. As a result, the aftermath is often disastrous, or if you're lucky, just hilarious.
Which is why the really ironic part is this : The better the antivirus is, the harder it gets for the user to get his work done.

For example, this person's antivirus began to delete his system32 files.



Norton too is capable of funny fuckups.


If you've had an antivirus for long enough, you know exactly what I'm talking about. How many times did you download a harmless file for your school/work project only to have your antivirus flag it as malware and remove it from your system?
Not only does your antivirus take up memory and processing power that you could otherwise use for running your apps better, but sometimes antiviruses come with viruses bundled with them.
Pretty smart, huh? The people who make these viruses sure know what they're doing.

Fine, fine. So what do I have to do if I want to live without an antivirus?
I admit, when I first started out on the internet, I used an antivirus. Eventually, when I had to face all these problems, I realized I could do without them. I discovered the best way to avoid viruses is to use common sense.

I'm sorry if that's ambiguous (we will go a little into depth, don't worry), but rational thinking is all you need here to get you on your virus free path. Don't run files downloaded from untrustworthy sources, don't install shady plugins on your browser, don't visit sites that prompt you to install weird apps, etc.

You should pretty much already know these by now. You ignore ads that say you get a free iPad because you're the 10,000th visitor. You check reviews before downloading questionable software. You stay away from torrents that have surprisingly less seeders. All these are general ideas on how you simply have to use your intuition and be safe.

You can't get viruses from an image, or a song, so executables are the only offline resource that you need to be wary about when you download them. So if for some reason, you absolutely want to run such a file, and common sense isn't getting you far, then run the file through an online virus checker such as virustotal.com and if the site says the file is clean, then you're good. That's what I do when I download a crack or patch for a game, and I'm not sure it's safe.
You could even start a Virtual Machine and run the file in it for extreme cases. That will isolate the infection, if any, to only the Virtual Machine.

To be honest, that's all there is to it. Majority of the people I know who've complained about viruses simply missed out on the above in some instance or another. They might have visited a site with a slightly mistyped URL and downloaded something from there, or they installed a certain media player because a random online streaming site asked them to do so. Those were the most popular cases that I encountered.

Whether or not you use your antivirus beyond this point is upto you, but when people ask me what antivirus I recommend, I make sure they know that I don't, and I hope you will one day be a part of that crew, if you aren't already.

Friday, November 21, 2014

The new enkrypt.in is here

After more than a year of rigorous development, the new interface is finally out in the open.
Well I'll be honest, the reason it took me so long for this project was because I have a surprising talent for automatically procrastinating. My daily work cycle includes spending the day with the editor in the background, buried by every distraction the internet has to offer; and then pushing code after midnight at a rate that is not recommended for the healthy. I've lost count of how many sleepless nights this website now owes me, but I am indeed glad that it's finally fucking over.


Procrastination wasn't the only thing that held me back though. I did run into a dilemma halfway through the development process. My web host got taken down a couple of months ago (The host was not owned by me), and that's when I realized that I needed a permanent hosting solution instead of migrating from one free host(er) to another.
So now came the issue of retrieving backups from the expired host, painfully shelling out money to buy some new server space, and then configuring it right to host my website (If I ever somehow finished it). Of course, I did finally finish it, but I also bought a sweet VPS for myself from Digital Ocean along the way.

If you haven't noticed yet, my proudest part of enkrypt.in is the way I've made everything dynamic. Page reloads and statically loading content is for wimps. I hand coded most of what you're seeing with the use of barely any plugins. The site design is completely of my creation but I now wish that I'd used some already existing plugins to help me out and save all that work. There's a lot of PHP, a lot more of Javascript and some HTML from me that's holding this place together.
There are still possibly tons of bugs throughout the site even though I think I've smoothed out most issues, so if you're the kind of guy who likes to toy around with fragile, poorly protected webpages for vulnerabilities, then by all means go ahead. But even if you're not, please let me know if you discover a bug, glitch or error that's not supposed to be there so that I can fix it at once.

I again haven't written a blog post in more than a year because I'd promised myself not to, until I'd finished my site since my blog's being integrated into it. So now that that's done, I'll hopefully stick to my new rule: of keeping my content short. (some of my previous posts were way longer than they needed to be), and posting more often.

Well there should be a good amount of content here on this site for you to go through, and hopefully some will interest you. If you like what I've made and think this is neat, there should be some Like, Share and Plus One buttons on this page that I would really thank you for using.

Thursday, December 13, 2012

My website is back with a bang

This post is part of the "First Few Old Blog Posts" archive.
You could expect a certain lack of coherency/maturity from these posts.

Alright , let's narrate the whole event from my point of view.

Last week , during the evening , I desired to check on the Abstergo Project hosted on my website. To my surprise , I was redirected instead to some other advertisement page. Confused , I then tried the direct URL for my website. The same thing happened again. Furious , I logged in to my host's CPanel , and found out that my account was suspended.

I rewarded myself with a big giant Facepalm. I realized what an utter idiot I had been.
My host was called 0fees. It was a free host and one of the best in it's business out there. I had previously hosted several websites on it's services and I had no problem trusting it to be reliable with my website too. I trusted it so much to the point that I had kept no backups at all of my site. In fact , anything that was to be backed up , was put up on my website. And now , I realized how stupid I had acted. That day , I remembered a big lesson I had learnt in my childhood.

Never trust anything that's free. (Except Google)

So now I was stuck without a website. All my files were lost. All my database entries were gone. Why was my account suspended? Well it's obviously a marketing gimmick to get me to upgrade to paid hosting. I actually considered paying for the hosting just to recover my files back. But then I realized that the paid hosting would be on a different server , thus removing all hopes for a recovery.

The worse part is that my website meant a lot to me. Every line that I code , every line that I write on the internet , every account that I make somewhere , can be traced from my website. I use my website to organize myself. So that I can keep track of every contribution I make to the internet. This is especially required due to the fact that I have OCD. I have to sort every of my actions else I feel that all my work is useless. I have to remind myself that I have a blog , I have a twitter , I've made my own quotes etc to realize that I have done something atleast. The worse problem an organized person can face is losing his organizer. And I had lost my website.

At once , I began to rewrite my website. It was of course , a hard job. I was aided by Google's webcache and I could recover the text content in my website. But all the resources were lost and I had to make them from scratch. Luckily , I had a backup of a few of my bigger projects thus they could also be restored. Once I was done , came the question of where I would host the website now. I first considered turning my home desktop into a server since it was switched on for 20 hours a day anyway. Then I remembered of my good friend , JamezQ. He owned a server with above 99% uptime. I had hosted small Java projects on it many times and it worked great. But I was hesitant in asking to host my entire website on it. As it turned out , he was glad to have my website on his server. And so , I uploaded all my files , configured the MySQL databases , and restored the subdomains. But even then , a few projects could not be restored as I had kept the backups on my laptop which I do not have right now.

So , yeah. There you go , my website is back with a new look. There's new content and a better interface.
Check it out at http://enkrypt.in

Also , while making the website , I took to myself for making some entertaining error pages.
400 - Bad Request http://enkrypt.in/400.htm
401 - Authorization Required http://enkrypt.in/401.htm
403 - Forbidden http://enkrypt.in/403.htm
404 - Not found http://enkrypt.in/404.htm
500 - Internal Server Error http://enkrypt.in/500.htm