On “Looking Backward: 2000 to 1887” by Edward Bellamy

A couple of weeks ago, I posted about “The Sleeper Awakes.” At some point in that book, Graham (the protagonist) compares his situation to that described by Bellamy; and earlier in the book, when he is sound asleep and has only been asleep for a few decades at most, we see his friends talking about the same thing. Curious as I was upon reading that name I chose to google it. (I don’t quite remember exactly what I googled but it was probably something like “Bellamy Socialist Utopia Sleeper.”) I found out that there was a book by an Edward Bellamy called “Looking Backward: 2000 to 1887” in which a man sleeps for somewhere slightly above a century and, you guessed it, wakes up in a world vastly different from the one he slept in. I downloaded that book right away and made a mental note to read it after finishing “The Sleeper Awakes.”

A few hours ago, I finished reading “Looking Backward” and I thought I might as well write about it and throw in a few words about the similarities and differences between the two books. There are SPOILERS AHEAD so proceed at your own risk.  … 

 

Entropy of life

I know it’s kind of a weird title. I will promptly explain it. Have you ever been in one of those situations where you went ahead and did something without thinking twice only to later regret doing it and spend the next few days brooding over different ways to deal with all possible undesirable consequences of that course of action?

We often see situations like these in movies. I considered adding examples here from Harry Potter or The Flash or Infinity War but then I decided against it because I didn’t want to post any potential spoilers and because not everyone would be familiar with those scenes. Instead let me use a very general example: Something goes wrong and the protagonist(s) considers possible courses of action to take. In short, they form a plan that sounds completely nuts but they decide to do it anyway because it’s “the only way.” And all that while you’re just sitting there hoping that they’d see things your way because ot you there’s clearly another and better way but they can’t seem to think of it. Anyways, they go ahead and execute their plan only to screw up further and get themselves into a situation much worse than before and then the cycle starts again (or maybe not.)

Now that I am done typing that stupid example, I realize that it’s too general to be of any use. So let me use the example of time travel. Let’s say you have a regret. Years pass and you cannot get over it. Say you gain access to a time machine. You go back in time to fix it only to realize that you created a new world that’s equally undesirable. You try to figure out the point in time where this new world of yours went haywire and try to fix that. Again you screw shit up. Eventually you realized that you’ve messed it up to the point where it cannot be fixed. (There are actually movies about exactly this.)

Have you ever met someone and gotten to know them really well only to end up wishing you’d never met them in the first place and thinking about how your life would have been so much better if you hadn’t? Or maybe you’ve at some point said something that you immediately wanted to take back and so you keep on thinking about different ways to explain yourself should someone bring it up again and you can’t help fearing that someone would hold it against you. But anything you say to cover it up could only make matters worse.

In short, what I mean to say is that things always get worse with time. The more the time passes the greater the number of things in your life that went wrong, the more secrets you have and the more people there are that know your secrets, the greater the number of people in your life that you watch out for e.t.c. and every lame attempt to fix any of it only creates more problems. Life only gets messier and messier and there’s no way to clean up that mess.

 

 

On “The Sleeper Awakes” – H.G. Wells

I don’t exactly remember how I discovered this book. But at least a couple of months ago, I came across the name, looked up the synopsis and downloaded it with the intention of reading it on the first chance. Less than a month ago, on a particular midnight, I was unable to sleep and having little to no desire to take up something educational, I decided to go through my collection of fiction. The H.G. Wells folder caught my eye and I opened it to reveal this book along with a couple of others. Remembering suddenly what it was about, I decided to start reading it.

Fun Fact: The first chapter was called “INSOMNIA.” Also adding that although I mean to not talk in detail about any events in the book, depending on your perspective, there may or may not be spoilers ahead so proceed with caution. … 

 

Explaining Savitar to a noob be like

Me: Hey, Tom Felton made an appearance in the Flash.

They: Who’s that again?

Me: Malfoy.

They: What does he play?

Me: Julian Albert. A CSI working with Barry. But sometimes he gets mind-controlled and takes on the mantle of “Alchemy.”

They: Who controls him?

Me: Savitar.

They: Who’s Savitar?

Me: Barry.

They: Who’s Barry again?

Me: Flash.

… 

 

Toggl’s “Building a Horse with Programming” comic explained

If you don’t know what this is about, you should first go and check it out.

So, C++ is, for me at least, an intolerable programming language. Everything from the code to the resultant program tends to be as ugly as it gets. More than half the time it feels like it was hacked-together to include everything. However, it has been around for a very long time and you can use it to do just about anything that you could want to do with a programming language. Only, the experience and the result may not exactly be great.

Then we have Java. The main problem with Java is that for a language that aims to be useful for all sorts of applications on all platforms, it’s missing a lot of features that are commonly used by full-stack developers. Very often, when writing programs in Java, programmers end up spending more time than they need to creating new types and methods so that they can use them in the program that they actually set out to write.

Ever since npm and nodejs gained popularity, JavaScript has become one of the world’s most widely used languages and npm is probably the most used package manager of them all. And the thing about Javascript programmers is that they use a lot of external libraries and packages and every once in a while, they add their own package to the global repository just to get a kick out of it. By now there are probably more packages in npm than there are libraries for any other language out there and when you are a JavaScript developer, you really have use them if you want to get any work done. The pinked “Backbone” and “Angular” are references to Backbone.js and Angular.js, two popular JS frameworks.

NoSQL refers to database systems that don’t use SQL and are non-relational. An example is MongoDB, which stores JSON objects grouped into collections. The joke is that the non-relational model doesn’t always expose enough information for you to be able to access your objects without using the abstract api.

COBOL? Well, I guess no one entirely gets it except for its creator.

Lisp has a lot of parentheses. Just google sample codes for lisp and you’d know.

C# is a fairly complete and tolerable language. The problem? Microsoft. Windows. The thing about the costume is that C# is basically Java in a costume (it closely resembles Java in terms of syntax and semantics.) The camel is basically the windows environment. Basically, it means that C# programs don’t always work as intended if not running on Windows.

Assembly doesn’t really offer a lot of language features. There’s a basic set of operations that have to be used for everything. But coding something in such a low level language means you get control over aspects that most languages abstract over. So you can make a really efficient program, hence, the thing about running.

Everyone hates PHP. They say it’s a terrible and unsafe language and has unpredictable behavior. I personally have reasons to really like PHP but I will still go ahead and tell you that most good posts on the subject target aspects of the language that really do suck so yeah some of the hate is justified.

 

SQL Server screwups and how to fix them.

So recently I installed Visual Studio 2017 on a laptop and I installed it with only the ASP.NET and WinForms features. I was working on a webapp and initializing the database when I realized that VS was completely unable to connect to the database. I opened the “SQL Server Object Explorer” and tried to manually connect to the MSSQLLocalDB instance and I got this error.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 – Local Database Runtime error occurred. Error occurred during LocalDB instance startup: SQL Server process failed to start.) (Microsoft SQL Server)

I tried to start the service from the CMD and I kept on getting similar errors. Eventually, I concluded that the installation was corrupted and therefore tried reinstalling LocalDB. Guess what? It got me past this error but introduced me to another. It was something like this.

CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file ‘c:\Users\AnasDatabaseName-asdf5sdfasd5fs5dfs5f.mdf’.

This time, the CREATE Database command was failing because it was trying to create and MDF file in my “Users” folder. I checked the default location for the databases and it was in a sub-sub-sub-sub-folder inside AppData. A bit of Googling told me that this was actually a bug in the program itself and had been fixed in a recent update. So I just downloaded the latest Cumulative Update from the Microsoft site and it did the trick.

 

Who are you?

You’re not your face
Yet it defines you
You’re not your body
Yet it forms you
You’re not your soul
Yet it gives you life
You’re not your thoughts
Yet they drive you

You are none of them
Yet all of them
But none of them
Are all of you.

 

What would it be like to travel at the speed of light?

Imagine an infinitely long flat runway. You are running through it. At the speed of light. Let’s ignore the effects of relativity and resistance. The visible spectrum is painted on the runway, all the way from the start to the finish, meaning there’s infinitely many shades of all the 7 colors of the rainbow painted on the runway, each one easily distinguishable from the next. Yes, we are also assuming this is possible. An infinite number of trees are planted along the edges of the runway.

The speed of light is 300 000 000 m/s. Which means that any objects at a distance of 300 000 000 m from you will only be visible for a second after which you’d already have passed them. Any objects along your path relatively closer to you than the refresh-rate of your brain or your eyes or both, will not be perceptible.

You are standing at the starting point. On both sides of the runway, you can see a row of trees extending as far as the end of the runway, all of them look same age and length and appear to have the same amount of shrubbery. In short, they look identical. Your family and friends came to wish you good luck and are standing right behind you. Along with a whole crowd of people who paid to witness this miraculous feat. You got on your left another in runner, wearing red, who will start exactly one second after you and on your right is a runner, wearing violet, who will start exactly one second before you. All three of you have the same acceleration. All 3 of you are wearing heat and radiation resistant clothing.

The runner on your right has started. You see him become a red streak and disappear. The moment he disappears, you get hit by a wave of heat. Not that you should be looking at him cause after exactly one second you follow. Start running. Immediately after you start running, look at the runner behind you, you’d see him wearing violet instead of red as you get faster and depending on the shade of the red in his clothes, he may or may not completely disappear. This is due to the Doppler Effect.  You will know you’ve reached the speed of light when all you see behind you is an abyss of blackness. You might observe a flash of violet before that happens. The light from anything behind you never reaches you. Your field of vision is limited to 180deg from your immediate left to your immediate right. On your right you can see a purple streak extending all the way from slightly less than 260 000 000 m ahead of you to exactly 300 000 000 m ahead of you. That’s the runner who started before you. That streak is simply multiple images of him running.

If you look down at the painted ground, instead of seeing the colors change smoothly, you’d see them flickering into each other. Kinda like jumping straight from bright red to yellowish orange, because you are moving faster than the time it takes for the brain to “refresh” the image you see. The smaller the angle between your line of sight and the ground, the smoother the transition from one color to the next. Meaning, if you look directly at the ground and then slowly move your eyes upwards, you’d see the change between colors getting smoother, however the rate of that change would keep on getting smaller, and eventually, you’ll be able to see each shade for almost a whole second. But you will be looking at the color of the ground 300 000 000 m away from you.

Now look at the trees. They no longer look uniform and similar. The ones farthest from you still look like they did when you started running but the ones closest to you look very different. They look older and yellower and less leafier. The farther you go, the less leaves you see on the trees and more on the ground and the farther you go, the older they get. If you look at the tree farthest from you and keep on looking at it until you reach it, you’d see it smoothly lose leaves and colors and life.

I forgot to warn you to not look straight ahead. The Doppler’s effect needs to be taken into account also for objects that you’re running towards. Remember that radiation proof suit you put on? It was for a reason. The light from the objects that you are running towards has been blueshifted out of the visible spectrum. Any part of the electromagnetic spectrum travelling towards you now carries an infinite amount of energy. Not only would it be impossible for you to see it, your eyes would probably burn, if not along with the rest of your body. In truth, as soon as you approach a significant fraction of the speed of light, everything in front of you would turn blue and then eventually violet. But the other parts of the spectrum that you shouldn’t really be able to see, will now be somewhat visible. First the infrared waves would make an appearance followed by the radio waves. Yes, they’d look red at first but eventually they might get blueshifted out completely and then there really won’t be anything left for you to see.

In truth, there really won’t be much time between when you start running and when you blackout and also get obliterated as a result of the radiation but I wanted to make a post about what you could see, if you could keep on running at the speed of light for a while. That’s why I didn’t mention the blueshift until the end. There are better posts than I could ever come up with about the same concept but with relativity taken into effect. My favorite one being Relativistic Baseball. Yes I know they set the speed at 0.9c but then again, it’s because they present actual math and wanted to avoid infinities resulting from using c as the speed. An example of such an infinity would be trying to calculate the blueshift of an object approaching you at the speed of light.

The blueshift equation is as follows:

F = f * c / (c-v)

The variable v is the relative velocity of the object moving towards you. When moving at the speed of light towards a stationary object, this v is equal to c. Which means the denominator becomes zero which means we cannot determine the new frequency or as some of you would like to conclude, the frequency is infinite, meaning the wavelength becomes zero. Any photon with zero wavelength would have infinite energy which is not possible.

Sorry for wasting your time.

 

Men In Black 2 – The locker and the marble

In Men In Black, we see J and K chasing down Edgar The Bug to recover the “Arquillian Galaxy” which is a minuscle galaxy inside a glass sphere resembling a marble. As the movie ends, the camera zooms out from J’s car and keeps zooming out and eventually we zoom out of the earth, the solar system and finally the galaxy which is  revealed to be inside another glass sphere which is then picked up by some giant being and used as a playing marble alongside countless others.

In Men In Black 2, we are introduced the the C18 locker aliens, who are tiny creatures, about a few centimeters in height that live inside a locker in NYC. This was slightly different from the Arquillian Galaxy in that the beings were far bigger and their “colony” resembled a fair-sized city. Their origin is unexplained but it is safe to assume that they weren’t always there and were relocated and perhaps recolonized at some point in time prior to the events of the movie. At the end of the movie, J insists on showing telling them that there’s more to the universe than just the inside of a locker at which K proceeds to open a mysterious black door that says “Do Not Open.” As we zoom out of J, K and Frank standing in the doorway, we see a whole array of giant lockers inside a giant station and giant humanoid aliens walking around in it, which basically was meant to show that the humans themselves are living inside a giant locker.

Now what does it all mean together? Do we live inside the locker or the marble or both? Considering both concepts were boldly put forward by the movies themselves and assuming that they haven’t made any continuity errors, it is relatively safe to say that we are inside both. When we zoom out of the locker, we can still clearly see Jay and K and Frank standing in the doorway of the locker and they are scarcely smaller than the locker itself. This suggests that the locker doors are not containers but mere portals to worlds whereas the giant station is kind of an intermediary “world between worlds” just like the forest with pools from Narnia. This portal could be located in virtually any of the planets or worlds or galaxies shown or mentioned anywhere in the trilogy or it could be an extra dimensional thing that manifests itself as a station with lockers to 3D beings.

Building upon the fact that the lockers are portals, we can assume that each portal leads to a separate galaxy considering how all galaxies are supposed to be packed inside marbles and therefore don’t really allow the inhabitants to just fly out of them.

 

Angular vs React vs Vue.JS

This is the shortest and most effective comparison that aims to make the decision making process easier.

Angular: 

Pros:

  • The oldest and therefore very mature.
  • A complete framework in itself and ideal for large projects.
  • The MEAN stack remains, to date, one of the most popular stacks for web-development so finding jobs is never tough for Angular developers.
  • With NativeScript, you can use it to develop smartphone apps.

Cons:

  • If you don’t know, don’t like or don’t want to learn TypeScript, I would suggest staying away from it because the current releases are TypeScript based.
  • Packed with features, it’s a huge framework and therefore takes a fair amount of time to learn and master.

React:

Pros:

  • Been around for a fair amount of time and therefore can be said to be just as mature as Angular.
  • Smaller than Angular and therefore easier to learn.
  • Just as popular, if not more, and therefore has a well-developed community.
  • Just as many jobs out there for it as for Angular.
  • React Native allows for it to be used to make Android apps.

Cons:

  • You will have to learn JSX. Basically the idea is that in ReactJS, you try to maximize your use of JS and minimize your use of HTML. JSX kinda merges both. Obviously this adds to the learning curve.
  • Not a complete framework. React Developers almost always use Redux or some other flux implementation for state management. Code often becomes a real mess with large projects.

Vue.JS:

Pros:

  • Has just as many features as React, if not more.
  • Small enough for you to be able to learn it in a single day.
  • Great for small projects.
  • Gaining popularity real quick.
  • Resembles the original Angular.JS so if you are familiar with it, you’d love Vue.
  • Unlike React, with Vue, the goal is to maximize the use of HTML and minimize the use of JS.
  • Although not a complete framework, it comes with it’s own router and flux implementation, that, although independent projects, offer seamless integration with Vue itself.

Cons:

  • Relatively new and therefore has a small community and fewer jobs are available.
  • NativeScript has a plugin for Vue support but it not supposed to be ready for development yet. Although, it seemed pretty functional when I tried it.
 

Complimenting Complements

This post assumes familiarity with “Two’s Complement”, “One’s Complement”  and an understanding of “Positional Numeral Systems”.

Why is the Two’s Complement called the Two’s Complement?

Ever wondered why the two’s complement and the one’s complement are named as such? We were told that to calculate the two’s complement of a number, you add 1 to its one’s complement. But why? When calculating the one’s complement, we simply subtract every digit from 1, so why don’t we subtract every digit from 2 in two’s complement? And maybe, you tried to reason with yourself about how there’s no “2” in the binary system and so that mehtod would not work anyway. There is however a much better way to understand and explain it. To understand this, you need to understand the difference between the radix complement and the diminished radix complement. 

According to wiktionary:

  • The radix complement is the number which, when added to an n-digit number in radix-r, results in r^n. An alternative way of looking at it is that it is the smallest possible (n-1)-digit number in radix-r. The radix complement for radix-r is called r’s complement. We get it by adding 1 to the diminished radix complement.
  • The diminished radix complement is the number which, when added to an n-digit number in radix-r results in r^n -1. An alternative way of looking at is is that it is the largest possible n-digit number in radix-r. The diminished radix complement for radix-r is called (r-1)’s complement. We get it by subtracting every digit from (r-1)

… 

 

Sybill Trelawney

Sybill Trelawney, the Divination teacher at Hogwarts, was poorly received by her fellow staff, her students and the fans of her universe for reasons that all translate to “She was a fraud. She wasn’t a true seer and therefore not an eligible candidate for the job.” I however have always had a very different opinion about her. I believe that not only was she not a fraud but also a perfect candidate for the job, not to mention the fact that she did actually possess a gift.

We know that she was the great-granddaughter of some celebrated seer named “Cassandra Trelawney” and that Dumbledore went to meet her at the “Hog’s Head” and that no sooner than he met her, he realized that she didn’t possess her great-grandmother’s gift. Then she went into a trance and made the prophecy about Harry defeating The Dark Lord, and Dumbledore decided to hire her because he could tell that she was gonna make more of these prophecies and wanted her to be close to himself when that happened.

Now I want you to think. You are the headmaster of a school, and you want to hire a teacher for a karate class. You have to choose between a guy who is incredibly strong and can pick up and throw around the room just about anyone who picks a quarrel with him regardless of how good their karate is and a guy who spent years learning and mastering the sport and is a great fighter. Who will you choose? True that the first guy has the gift of strength and therefore has a good chance of winning most fights but he may not know anything about the sport, whereas the second guy has nothing except for a thorough knowledge of exactly what you want him to teach to your students. I don’t know about you, but if I was you I would probably hire the second guy, unless of course the first one demonstrated better karate skills than the second one.

Let’s try a different situation. You are the headmaster of Hogwarts and you want to hire a divination teacher. You have to choose between a woman who is well-versed in all the practices and techniques of divination (e.g. reading tea-leaves and making predictions from a pack of cards or dreams) or a centaur who, like all centaurs, was born with inexplicable knowledge of the cosmos and unfathomable divination skills that only require for him to look up at the sky. The woman doesn’t possess any magical powers that allow her to tap into the spirit world but she knows all that is known to man about the art of divination whereas the centaur who doesn’t have any need for those human methods probably doesn’t even know them. In fact, in the potterverse, the centaurs mainly, if not only, use the skies to predict the future and that too with seemingly minimal calculation or effort. It may be safe to assume that they aren’t even aware of the other methods used by humans. So, if it was for me to decide, I’d hire the woman, because she knows her stuff and so should be able to teach it whereas the centaur may not even know shit about the subject and is just naturally gifted at predicting the future by looking at skies.

We saw enough proof in the book of the fact that Sybill actually did know a lot about divination. She was accustomed to using all the techniques that she taught in class, and a whole lot of her predictions came true. She predicted the death of Dumbledore a few hours before it happened, predicted the order of death of certain groups of people. There are better posts about her predictions coming true so I’m not gonna list all of them here. So we know that Sybill certainly did have the knowledge, and that makes her a good candidate for the job. And we are also aware of the fact that she actually did possess a gift. That makes her a perfect candidate for the job.

One thing to note is that she herself was totally unaware of her gift. Clearly she had no control over it but given time and practice, it could be possible for her to get a handle on it. If Dumbledore wasn’t such a jerk, he’d have told her and tried to help her but he chose to not only keep her in the dark but to also make sure that she was one of the least respected members of the staff. Dumbledore and the Teachers routinely spoke ill of her and didn’t shy away from telling their students that she was a fraud and that her predictions weren’t to be taken seriously.

Let’s address the “fraud” question now. She did, at times, make predictions that sound way too ridiculous and didn’t even come true. Why? The answer is very simple. Entertainment. When you have a job like hers and everyone expects you to make cool predictions every once in a while, you have to have a mysterious air around you and you have to make predictions and you have to say stuff to make sure you have the required amount of attention. Come to think of it, she once predicted that Harry will have 12 children. Everyone knows that sounds made up including herself and so the whole point of saying it was to entertain students with some mildly humorous predictions which was a good change from the darker predictions she used to make, two of which she made in her first class and went on to become popular gossip topics.

Sybill Trelawney is underrated an underappreciated and she deserves better than to be called a fraud and better than to be insulted by her staff members.

 

The Final Sentence

I’ve been reading books, more than I’ve been reading lately, lately. Very often, I read them onscreen. A while back, I was starting with H.G. Wells’ “The Time Machine” and the PDF I found had about somewhere slightly above a hundred pages in it and it made me wonder if that was actually the whole book and not a truncated version and so I googled for the last sentence of the book to see if it matched the one in the PDF.

I ended up finding this tumblr blog called “The Final Sentence” that exists solely to serve as an archive of the final sentences of all books. I think it’s pretty cool actually and every once in a while, it makes me feel better about a crappy PDF.

 

Rewriting Legacy Code

I once wrote an answer on Quora about the improbability of a programming language to completely die out once it has gained popularity. The idea, not so original, was that there are two factors preventing a language from dying:

  1. A significant amount of code is written in it and a significant amount of people or other code depend strongly on it. An example is Linux. Now Linux has always been C and always will be. As long as Linux exists, it would be impossible for C to die out.
  2. Everyone knows about it. The problem with a programming language being popular enough for it’s existence to be common knowledge is that there will always be people who’ll be fond of it and would want it to never die out. The best example would be Richard Eng, the smalltalk evangelist who has grown more popular than the language itself and likes to call himself Mr. Smalltalk.

This post is about the first reason. C, PHP and JavaScript are three of the most popular and most hated languages that are getting closer and closer to being about as old as time itself. For my own reasons, I both like and dislike the 3 and also rely a lot on them. Let’s assume everyone agrees to killing all 3 of them. Now the problem is that C is:

  1. The language Linux is written in.
  2. The language most programmers start with. (Often this is because universities prefer to teach it in the earlier semesters.)
  3. More or less the only mature language that has the least amount of abstraction that one could ask for except for C++, which is a mess and an offspring of C itself and therefore not worth talking about in this post.

… 

 

Comparing strings with “==” operator vs “.equals” method [Java]

During lunch, I was reflecting on that day when my programming teacher asked me to come forward and teach “bitwise” operations to the whole class, and I remembered how, in my attempt to explain to them the basic difference between a regular “OR” and a bitwise “OR”, I had talked about value comparison being different from a bitwise comparison. Then I began to wonder. A bitwise operation on machine level is fairly simple to understand, but what about value comparison? What is it that happens at machine level when you check if two integer values are equal?

As I began my search for the answer, I pinged Vladislav Zorov, my mentor and friend, and asked him. He said that compilers mostly just subtract the memory addresses of the two objects being compared and returns true if the difference is zero i.e. if they are literally the same object. I couldn’t agree with this so I argued against it. I said that it is possible for two variables to point to identical objects without pointing to the same object and so I set out to prove it.

I wrote a very simple program:

import java.util.Scanner;
public class HelloWorld {
public static void main(String []args){
// Created two strings using the same literal and an array with the second index set using that literal.
String x = “abcd”;
String y = “abcd”;
String[] z = {“asafaf”,”abcd”};

// Printing addresses of all 3.
System.out.println(Integer.toHexString(x.hashCode()));
System.out.println(Integer.toHexString(y.hashCode()));
System.out.println(Integer.toHexString(z[1].hashCode()));

// Checking to see if the equality symbol works on these
if(x == z[1] && x==y && y==z[1])
System.out.println(“== works on the 3”);

// Comparing the 3 using the equals method which will, obviously, work.
if(x.equals(z[1]) && x.equals(y) && y.equals(z[1]))
System.out.println(“equals method works on the 3”);

// Creating Scanner object to read from stdin.
Scanner input = new Scanner(System.in);

// Taking two strings as input. Will test with
// 1. Two different strings
// 2. Identical strings
// 3. “abcd” for both
String j = input.next();
String k = input.next();

//printing their addresses
System.out.println(Integer.toHexString(k.hashCode()));
System.out.println(Integer.toHexString(j.hashCode()));

// Testing both comparisons
if(j==k)
System.out.println(“== working on input strings”);
if(k.equals(j))
System.out.println(“equals working on input strings”);

// Initializing a string identical to x,y,z[1] but with the new keyword
String a = new String(“abcd”);
// Printing its address
System.out.println(Integer.toHexString(a.hashCode()));
if(a==x || a==y || a== z[1])
System.out.println(“== working with new keyword”);
if(a.equals(x))
System.out.println(“equals method working with new keyword”);
}
}

If you run it, you’ll see that its output shows that all strings that have the same value point to the same address regardless of how they’re initialized. But the equality symbol only works when two strings have been created with the same literal. The fact that we’ve now proven that identical strings in Java do have the same memory address does perhaps imply that comparison is done simply by comparing addresses but then what about the equality symbol? Well, I’ll update this post when I find out.

 

David Carson on JS

The dirty little secret is that most “modern JavaScript development” is nothing to do with actually building websites – it’s building packages that can be used by people who build libraries that can be used by people who build frameworks that people who write tutorials and teach courses can teach.

I’m not sure anyone is actually building anything for actual users to interact with. – David Carson

 

Die Verwandlung

I just finished reading Franz Kafka’s “Die Verwandlung,” translated into “The Metamorphosis” by Stanley Corngold. Before I even started reading it, I’d told my classmate about how it seemed like a weird one — something I’d deduced from its synopsis — and he’d responded with “Franz Kafka’s works tend to be.”

Now that I’m done with it, I’m not quite sure how I feel about it. For one, it was incredibly short. Like I knew it was a short story but I’d still been expecting it to be longer. Then there comes the fact that (SPOILER ALERT) 
… 

 

What if logic isn’t actually all that logical?

Logic, science, reason, all of it is what? Rules that always hold true for everything that they are defined for. But who really defines them? We do. Who comes up with them? We do. And what are they based on? Observation.

I remember, as a kid, reading an article in my native language, titled “What if there was no Sun?” and it, as you can guess, was full of stupid stuff like “pitch black, ice cold, nobody would survive for any more than … e.t.c.” While I was reading it, I couldn’t help but wonder why a world without our Sun would ever have any life-forms that need the sun to survive? Or why the humans on such a world would not be used to not having a sun and thus be optimized for survival in such harsh conditions.

My point? We believe logic is absolute. Maybe it is, but only for our world. We know that if we pull at a free movable object, it would move towards us. But for all we know, there could be a world out there in which doing so would result in that very object moving away from us. That sounds illogical, stupid, and inconceivable but if it happened all the time in our world, it wouldn’t be.

We believe that we can make deductions using reasoning, but how reasonable would that be when that very art of reasoning itself is a set of deductions based on observation. What about observation? Do we even really see our world as it is? We don’t even know if we all see the world the same way. A really narrow range of the electromagnetic spectrum is sensed by our eyes and is used by the brain to form an image. This is literally akin to reading a detailed book and imagining the events and the characters. Using this analogy, we can tell that while the image can be extremely detailed, it will still be limited by the amount of information it is based on. Imagine if our ears were so trained that we could, in the absence of light, form images and see using sound. Is that inconceivable? But what really is the difference between the ear and the eyes? Both sense and interpret waves with the help of the brain. If we could see the rest of the electromagnetic spectrum, we would have a much smaller list of opaque materials than we currently do.

This does of course suggest that it doesn’t matter if the science and logic we so rely on is limited by our observation as long as it holds true for our observable world, but the idea was the very fact that it would be just limited to our observable world. This is kind of like how we wouldn’t be able to tell if there were any more-than-3-dimensional-beings out there observing us right now because we can’t perceive or observe more than 3 dimensions.