PROGRAMMING LANGUAGES GIJINKAS (PART 1)

  1. HTML: Handles Internet with CSS and Javascript. Breaks the 4th wall on a daily basis. Literally a popstar. The gay is strong here.
  2. CSS: The one that does HTML’s wardrobe. Avid abstract artist. Bullies Javascript for eternity. Extremely one sided love for HTML.
  3. Javascript: Will do anything to keep HTML’s shit together. Has more than 10 toolboxes. Java’s happy sibling. Lowkey crush on Ruby.
  4. PHP: Confused 80% of the time. Oblivious to everything. ??????. No one knows she’s a great musician.
  5. SQL: Tsundere like no tomorrow. Cares a lot about PHP, but also consistently gets pissed at her. They live in the library. Robot arm because of a bookshelf accident.
  6. Python: Loves mountains and camping. Owns 2 bikes. Lowkey crush on the entire C family. Flaming bisexual.
  7. Ruby: Python’s hiking partner. Lives in a cave she renovated all on her own. Secretly wants to overthrow Python. Highkey crush on Javascript.
  8. C: Wildlife and nature. Exercises with tree trunks. The one who taught Python how to camp. Daddy.
  9. C++: The son of C. Always hangs out with Java at the arcade. Consistently wins online arguments. Has a crush on Python.
  10. Java: C++’s bestfriend. Owns 2 bookshelfs: One with video games, and one with actual books. Doesn’t know what sleep is. Absolute nerd.

As promised. Which ones should I do next?

GOLD SOURCE
A theme for fans of classic first-person shooters and those who love sharp rectangular shapes!

Well, it looks like I finally finished the overhaul. I doubt I can add anything more nor do I have any desire left.

For some reason Tumblr thinks the HTML code is invalid (searching around I found out that I’m not the only one), so I can’t submit it. This means that you have to install it manually.

To manually install the theme…

  1. download the theme from here: https://goldsrc.tumblr.com/download
  2. open the text file with a text editor of your choice
  3. select and copy all the code
  4. go to the customization page of your blog and click “Edit HTML”
  5. delete all the code there and paste the code of the Gold Source theme
  6. click “Update Preview” and after it finishes loading click “Save”

The theme features…

  • partial localization
  • rich customization options
  • sound effects
  • support of all post types

…and probably something else.

Hope you like it.

Best Posts of 2016

Earlier this year I added a sidebar for the most popular posts. So below is a list of what I think are the 5 best posts that are not in that Sidebar (as of December 2016):

1. Generators and Async Operations in JavaScript The most major criticism of asynchronous code in JavaScript is that it requires workarounds and a bunch code management to keep it clean. This new feature greatly reduces all of that.

2. Validating Object Property Types Without Setters In JavaScript A more powerful version of operator overloads which is coming to JavaScript with the Proxy API. This is one example, but Proxy could be used to create entirely new JS-like langauges without even having to compile or eval any code.

3. Lazy Objects In JavaScript In JavaScript, it is possible to have self creating objects that store their own state using themselves. This is done by applying the concepts of Lazy Functions to objects.

4. Compose in JavaScript Simplify the sequence of functions by using a function that controls function flow. The compose function is implemented using itelf.

5. Pretty Printing In JavaScript A simple and powerful, but overlooked way of doing pretty printing (Very useful for quick debugging). Built directly into the language.


Best Posts Of 2015

Constructors in JavaScript

Every object has a constructor property which refers to the function that was originally used to create the object. This can be used to get the original constructor function and name of that when the original reference to the constructor function was lost:

var runInADifferentScope = function() {
  function ObjectA() {
    this.property1 = 'test';
    this.property2 = 'test';
  }

  var objectA = new ObjectA();

  console.log('property1', objectA.property1);

  return objectA;
}

var objectA = runInADifferentScope();

console.log('objectA created by:', objectA.constructor.name);
// objectA created by: ObjectA
console.log(objectA.constructor.toString());
// function ObjectA() {
//     this.property1 = 'test';
//     this.property2 = 'test';
//   }

Which is useful for debugging or just understanding the code flow in a specific location. Using the constructor in application code is not a good idea, because like any other property, it can be assigned to anything at any time. It is also important to note that this style of Object Orientation makes the constructor function nearly useless:

var runInADifferentScope = function() {
  function ObjectA() {
    var obj = {};

    obj.property1 = 'test';
    obj.property2 = 'test';

    return obj;
  }

  return new ObjectA();
}

var objectA = runInADifferentScope();
console.log('objectA created by:', objectA.constructor.name);
// objectA created by: Object
console.log(objectA.constructor.toString());
// function Object() { [native code] }

Finally, this also applies to the ES6 Class syntax:

var runInADifferentScope = function() {
  class ObjectA {
    constructor() {
      this.property1 = 'test';
      this.property2 = 'test';
    }
  }

  return new ObjectA();
}

var objectA = runInADifferentScope();
console.log('objectA created by:', objectA.constructor.name);
// objectA created by: ObjectA
console.log(objectA.constructor.toString());
// class ObjectA {
//     constructor() {
//       this.property1 = 'test';
//       this.property2 = 'test';
//     }
//   }

Github Location: https://github.com/Jacob-Friesen/obscurejs/blob/master/2017/constructor.js

Difference between C# and Javascript
  • Me: Hold my cup of tea.
  • C#: That's not a cup of tea.
  • Me: Hold my cup of tea, with two teaspoons of sugar in it.
  • C#: That's not a cup of tea with two tea spoons of sugar in it.
  • Me: Hold my cup of tea, with two teaspoons of sugar and milk in it.
  • C#: That is not a cup of tea, with two teaspoons of sugar and milk it.
  • ...
  • Me: Hold my cup of tea.
  • Javascript: I'll hold your cup of coffee.
JavaScript by the decade

1995 - JavaScript is a joke, a temporary holdover that web browsers use until someone takes the time to invent a good language to use instead.

2005 - Everyone agrees that JavaScript is lousy, but it’s the only way to do web programming, so people grudgingly acknowledge you have to learn it to be a web developer.

2015 - JavaScript is the most popular language on GitHub, and is widely used in server-side programming. Compilers exist to turn JavaScript into almost any major language, including assembly. Many major platforms have one or more JavaScript SDKs.

2025 - Writing code in any language other than JavaScript is seen as hilariously quaint or masochistic, and would never be allowed in production.

2035 - The Illuminati One World Government has abolished all spoken and written languages other than JavaScript. Oldthinkers who unbellyfeel JavaScript are sent to Room 101 for resocialization.

Object Literals are Dictionaries are Hash Maps are Useful

friend: i dont use dictionaries ever because i never really learned them

me: maybe this is javascript specific

me: but you use “object literals” a lot, and that’s really just a dictionary

me: i can see how in a strong OOP language, you’d just use a class instead

me: since an object behaves almost identically to an instantiated class object

me: i searched around in the code from my recent projects

me: looks like i use them in 3 kinds of places

me: The first type of usage is “actually looking up things in a dictionary” behavior, where you need a 1:1 relationship between a key/value pair:

me: if i’m doing something like stripping out dangerous characters from my html

me: i can basically use an object to save a lot of if/else statements and hardcoding values

me: “does this key exist in the object? if it does, replace it. if not, do nothing”:

me: The second type of usage I find is storing or passing around data in a group, pretty much like a class:

me: they’re also very useful for returning more than one value from a function:

me: and then the third type of usage that I always forget about is

me: lots of libraries and stuff use a big object to pass into a function

me: to avoid having a million arguments

me: so instead of `function doStuff(a, b, c, d, e, f, g, h, i)` you can pass in a single settings object like `function doStuff(settingsObject)`.

me: it’s hard to see it here but `$.ajax()` accepts a settings object with values for `type`, `url`, `async`, and `success` (and probably lots of other optional stuff):

friend: I don’t think I ever really made the connection of an object functions like a dictionary

friend: Even though that’s exactly what happens

me: i think that probably makes a lot more sense for people who use languages where it’s called a dictionary

me: it’s kinda weird

me: people variously call the same structure an object, a dictionary, and a hashmap

me: if you call them objects, that makes it really easy to remember that they can contain lots of data like instantiated class objects

me: if you call them dicts it’s easy to remember that they are good for setting up 1-to-1 relationships between key/value pairs

me: and if you call them hashes it’s easy to remember that they use hash functions to store and retrieve data, which makes them much faster to search than iterating through an array with the same contents

me: so once you learn all of those they start to seem pretty cool haha

friend: Hahahahahaha

friend: Yeah

friend: That’s a really good explanation

friend: I learned about all 3 of those things in school

friend: But they were never connected to each other

friend: I think if I’d learned it like that it’d have stuck a lot easier

friend: You should make a blog post about it