Data Architect, Ph.D, Information Technologist, Gamer
5530 stories
·
25 followers

Programming a Computer with Nothing

1 Share

I don’t know why this irritates me, but it does. Several times over the last few weeks, I’ve seen memes like the one on the right, generally from programmers who think it’s cute.  As if it really was a mystery. But… if you are not a programmer, or you are a programmer who actually doesn’t know this but doesn’t want the embarrassment of having to admit it, here’s how it works:

You create a programming language with… another programming language. Another compiler / tool. They’ve got tools nowadays that can accept a new programming language in a standardized format, and will convert it to object code ready to be compiled to whatever machine you want to put it on.

Oh, but how do you build the compiler? With another programming language. 🙂

This was a required class to get my Computer Science degree back in the day. Admittedly, it was a tough course. You were strongly advised not to take the compiler course (where you developed your own language, and built a compiler for it) and the operating system course (where you built your own operating system, from more-or-less scratch) in the same semester.

Then you just put that code into a format that the new computer with a way for it to self-boot it (meaning load it up and begin executing instructions) from memory or storage. You just need a way to put a program there in the first place. The usual approach is two write code on an existing machine, and then target the compiler to compile for the new computer, and put that code on a bootable medium (like a CD-ROM, or an SD card).

Or you don’t even use a compiler, and you write it all in straight machine code. In the olden days, they had machines that were kind of like electric typewriters that would allow you to create punch-cards that a computer could read and execute. You can even write code for a machine that doesn’t even exist yet, and compile it for that target machine. In fact, if you go even further back into the 1800s, Lady Ada Lovelace wrote programs for Babbage’s Analytical Engine which was never actually produced. She was the world’s first programmer, and the machine she developed for was permanently vaporware. Sad, huh?

If you aren’t a programmer, and you have no idea what a “compiler” is or what “machine code” means, here’s what you need to know:

Computers understand numbers. Now, we always say it’s “ones and zeros” because that’s how numbers are represented in the computer. But don’t get bogged down by those bits. Just think of it as numbers. A… code. Every processor is different, and understands different sets of codes. Maybe on one machine, the value of “1” means to jump from the part of code you are currently executing to a whole different place. Maybe the value of “2” means to add two numbers together and store them somewhere.  The processor also has some registers, which designate its state and serve as temporary holding areas for values.

The position of these numbers is important, too. A number three might be an instruction, the literal value of three, or an address (the third byte of memory), or even an offset to another address stored in a register. Or… well, it depends on the processor.  To avoid confusion, we poor humans use symbols and keywords make all that slightly more readable. So if the instruction “1” means to jump to a new location in memory and resume execution, and we wanted to execute at the memory location 1, we’d probably write it as “JMP 1” instead of “1 1”. But if we’re looking at the raw values in memory, they’ll be the latter.

Now, back in the old days, you might write complete commercial software at that level.  You still can, but it’s a slow, hard way to go about it. It gets very complicated to do even a very simple operation.

Instead, we write things in a higher-level language that is a lot more readable for humans, and encapsulates a lot of complexity in a simple format. So we might write an instruction that reads, “Healthbar.SetValue(100)”, which might actually represents hundreds of instructions of machine code. We use a compiler to convert that higher-level code into machine code.

So… I hope that clears things up. There are C++ compilers actually written in… C++.  But it’s not really brain-twisting. You use compiler A to build compiler B, and compiler B may be for a totally different system. As long as compiler A understands how to convert stuff down to machine code for the new system, it’ll all work fine.

Now… what if you have no tools like that and have to do it all by hand / from scratch / etc.?  Well, the earliest PCs were that way… the rudimentary Altair interface used a bunch of switches and lights for its UI. You could program it that way. I wouldn’t want to write Skyrim that way, but it works.

I hope you feel enlightened.

Read the whole story
denubis
14 hours ago
reply
Sydney, Australia
Share this story
Delete

12/06/2016

1 Share

The best of intentions.

 

Read the whole story
denubis
1 day ago
reply
Sydney, Australia
Share this story
Delete

I quit Facebook and my life is better now

1 Share

I don’t need to hear from all you people who never got on Facebook in the first place. I know you’re already smiling your smug smile. This story is not for you.

But hey, you people who are on Facebook way too much, let me tell you my story.

It’s pretty simple. I was like you, spending more time than I was comfortable with on Facebook. The truth is, I didn’t even go there on purpose. It was more like I’d find myself there, scrolling down in what can only be described as a fetid swamp of echo-chamber-y hyper partisan news, the same old disagreements about the same old topics. So many petitions.

I wasn’t happy but I didn’t really know how to control myself.

Then, something amazing happened. Facebook told me I’d need to change my password for some reason. Maybe someone had tried to log into my account? I’m not sure, I didn’t actually read their message. In any case, it meant that when went to the Facebook landing page, again without trying to, I’d find myself presented with a “choose a new password” menu.

And you know what I did? I simply refused to choose a new password.

Over the next week, I found myself on that page like maybe 10 times, or maybe 10 times a day, I’m not sure, it all happened very subconsciously. But I never chose a new password, and over time I stopped going there, and now I simply don’t go to Facebook, and I don’t miss it, and my life is better.

That’s not to say I don’t miss anything or anyone on Facebook. Sometimes I wonder how those friends are doing. Then I remember that they’re probably all still there, wondering how they got there.




Read the whole story
denubis
2 days ago
reply
Sydney, Australia
Share this story
Delete

Immanuel Kant: the 40 Year Old Virgin

3 Shares






Earlier that night:
Read the whole story
ahmetasabanci
2 days ago
reply
İstanbul
denubis
2 days ago
reply
Sydney, Australia
Share this story
Delete

What is today’s Italian referendum about?

1 Share

From Meg Greene, here is the clearest explainer I have seen, here is one short excerpt:

There are clear reasons to vote for and against the constitutional reform. If only most Italians were actually voting with these in mind! According to one recent survey, only one in ten Italians were going to cast their ballot in response to the actual constitutional reform proposed. Because Prime Minister Renzi said he would step down in the event of a “No” vote, many Italians are casting their vote in favor of or against the establishment. Voting against the establishment means a lot of things, but given that the main opposition party, the Five Star Movement (M5S), has polled neck-and-neck with the governing Democratic Party (PD) this year it amounts to tacit support for this populist, anti-elite, anti-European party.

There is much more at the link, here is one significant point:

If the “Yes” vote wins on Sunday, Mr. Renzi will be strengthened in the short term but, given the Italicum, could be weakened in the next election. The result may be a government led by the M5S that may pursue a referendum on Italy’s membership of the Euro.

We will soon know more…

The post What is today’s Italian referendum about? appeared first on Marginal REVOLUTION.

Read the whole story
denubis
3 days ago
reply
Sydney, Australia
Share this story
Delete

Release date for STELLARIS: HORIZON SIGNAL

1 Share

I can now finally confirm that yes, the Stellaris 1.4 codename ‘Kennedy’ patch is in fact named for me and not, for instance, the airport.

It’s an interactive cosmic horror novelette; one of the inspirations is pretty obvious from the title; and it’s out on the afternoon of Monday 4th December! I’ve written more about it here, and especially here.

Read the whole story
denubis
4 days ago
reply
Sydney, Australia
Share this story
Delete
Next Page of Stories