Tag Archives: programming

32-bit and 64-bit, what’s the difference?

Okay. Let’s clear this up once and for all, you nerds.

Distinction discussion

’32-bit’ and ’64-bit’ are adjectives that describe computer programs that target a specific version of the x86 instruction set architecture.

Okay, some definitions, I understand.

  • An instruction set architecture is a set of commands (opcodes, if you will) that tell specifically what thing a CPU chip should do.
  • x86 is a type of ISA. It is designed by Intel and AMD.

ISAs exists so that even if, for example, Intel and AMD manufacture different types of CPU chips, the programs that target the specific ISA they support would still be able to run in all those chips.

  • x86 is a family in general of ISAs that are supported by a number of CPU chips.
  • x86-64 is a specific version of x86 that is supported by 64-bit CPU chips.

64-bit here means that the memory is made available to consumers (programs) in blocks of 64 bits. That is, when you store an integer in a 64-bit chip, it has to be 64 bits long. The same analogy applies with 32-bit chips and 16-bit chips, which you might not have heard of, is a thing.

Programming nerds, discussion ends here. English nerds, the next section is for you.

Grammar and spelling points regarding x86 architectures

  • “64-bit” and “32-bit” are compound adjectives, so they should always have a hyphen in them. “Bit” should also be singular. All of these are wrong, please don’t do these:
    • “my 64 bit program”
    • “my 64bit program”
    • “Windows XP 64 bits”
    • “64-bits”
  • x86 is commonly used together with non-64-bit applications. x86-64 or, equivalently, amd64, is used together with 64-bit applications. ‘x64′ is just a thing popularized by Microsoft so they would look cool: they won’t. Please stop referring to x86-64 as such.

Miscellaneous

  • You will see applications distributed in either x86, amd64, or ia64. “ia64” is used to refer to the 64-bit Itanium (that is, not x86) ISA.
Advertisements

Why I like node.js

Months ago I stumbled across this and though, meh, it’s just another one of those dumb programming shenanigans. Over the last few weeks, I got to try to program with it. But before we go there, let’s stop and define what node.js is really.

Node.js is a program. It exposes a framework (an API), on top of which you can program using Javascript. Other than that, it boasts of this framework having an asynchronous nature, which we all know is better than synchronous sh*t.

I have crafted this mini table for a quick comparison. NB: These are all purely my opinion.

Programming language Javascript! (No, node.js is not a programming language!) Visual Basic or C# Freaking Java!
Program (compiler or interpreter) nodejs.exe I don’t know, MSBuild? Freaking javac!
Framework I don’t know, did they give it a name? The glorious .NET Framework Freaking JRE?!
Your friendly neighborhood IDE PhpStorm, Freaking NetBeans?!??!?!, Visual Studio (!) Visual Studio Freaking NetBeans?!??!?! Or Eclipse?
Community resource pool (?) Plugins? npm Nuget ????

Now that’s done, let’s have my answers: why like node.js?

  1. It’s freaking Javascript! It’s a language we all know and love! (It’s a C-based language, which most of us know, but scare most beginners, but hey, you can always alleviate that if you’re into language transformers like CoffeeScript.) It’s the language your server tells your client user agent to do! Now, it’s the language you write your server program in! That’s right:
  2. It’s your freaking own server program! Yes, unlike Apache and PHP, which are separate web server and interpreter, node.js allows you to be free and write your own! Although this creates an issue for hosting providers that might not want to give their customers that much freedom. Although there are some who are willing to give developers a chance. Note that node.js doesn’t have a built-in web server of its own, but it has an HTTP library which can get you started. And there are always libraries that can simplify your intended task.
  3. Yes, and with npm, installing third-party tools are a breeze. Just like apt, it takes care of all the dependencies your third-party library might require.
  4. It’s based on V8, the same Javascript engine used by the awesome browser Chrome! If you’re not familiar with what V8 does, here the thing: V8 compiles Javascript code into freaking native machine code. What this means is that when it’s done compiling, your code will run blazingly fast once it starts!
  5. It’s already in the intro, but it’s based on a freaking asynchronous API! What this means is that when some code reads a file, that code can wait for that I/O operation to complete while other code consumes the precious CPU cycles! This can be really useful especially in the website hosting context where many users can connect simultaneously to your website.
  6. Write a small script and it should just work, whether it’s a simple console.log("Hello World");, a demo to show to your students (given you’re a teacher? Probably…), or just to show off your m4d w3b scr4p1ng sk1ll2. Because Javascript is a freaking scripting language!
  7. CREATE YOUR OWN GAME SERVER! THIS IS NOT POSSIBLE USING FREAKING APACHE+PHP!!!!! NO DATABASES REQUIRED!

As node has many good things, it also has some bad shortcomings. Let’s take a short look at that:

  1. This really is for JS and not node: I am really lamenting the lack of an “await” keyword for JS. It would be really useful since node has an asynchronous API. Right now the closest we have for that is Q.async + ES6′ yield.
  2. Yeah, we all know Javascript, but only because it’s an ages-old programming language. There are a couple more advanced programming languages out there, Visual Basic being my (past? :O </3 oh no!) favorite, Ruby (psssh… only Taric uses this), and Python (Who uses Python anyway? I don’t know… NASA? Freaking Google?) that addresses many of the older languages’ shortcomings. But as these are actively developed, so are the oldies. I do hope Javascript catches up one day. Fingers crossed.

And that’s it! This concludes my fanboyish post about the freakishingly awesome node.js.

Regex to eliminate double newlines

The regex is: (\s*\n)+.
The replacement is: \n.

I’m just posting this for my own reference, but why the post? Here’s the backstory: In my work I frequently encounter files supposedly uploaded by my workmates that contain redundant / double newlines. And it obviously hurts my eyes. Just my hunch, but it seems NppFtp (a Notepad++ built-in plugin) likes to connect to servers with ASCII mode and convert Windows newlines (\r\n) to nix newlines – but in this manner: \r -> \n. And this results to redundant nix newlines: \n\n.

And it’s frustrating.

This regex doesn’t just convert double newlines into a single newline, but multiple newlines. Maybe if you use something like (\s*\n){2} (this is specifically for double newlines) you can control how many multiples of newlines to convert into a single newline.

August 15, 2013 update: It turns out this is not perfect regex syntax. The right way to get rid of double newlines is (\n{2}).

PSITE Chronicles

This is a series of outtakes / quotes / whatnot that took place in the 25th of January, 2011, mainly featuring those that took place in the regional Philippine Society of Information Technology Educators competitions on De La Salle University Lipa, the exact and maybe finalized text of which are shown below. Not to be taken in all exactness, and not in any order.
Continue reading

Need small, free tools for your program?

Have you suddenly felt a need to have some bit of a certain functionality in your program but do not have time to implement them? Well, here are a couple tools to help you. These are free, and on top of that, small!

SQLite is a database library that understands your standard SQL statements while adding a mere less than 100 lines to your code. It is the most used database library in the world, and is perfect for local storage. For instance, it is implemented by the web browser Firefox and its mail counterpart Thunderbird, and the platform Adobe AIR. It can also be used in web applications, via PHP.

Lua is a light scripting language (in a few hundred kilobytes!) that claims to be fast. It is widely used in the gaming world (if you’re playing World of Warcraft, its scripting language is Lua).