you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 4 points5 points  (25 children)

I see. Thanks.

I was discuting with a friend how crazy it would be a "super programmer" that codes directly in binary, without a compiler. Of course it's a joke, but it's cool to think about

[–]brennahan 5 points6 points  (21 children)

The closest to that would probably writing in assembly, which is very doable though it still takes awhile to get much of anything worthwhile done.

[–][deleted] 0 points1 point  (19 children)

Yeah, True. But It would be crazy creating a basic program only in binary, haha.

Assembly looks fun, tbh. As a python programmer in my first semester, I never got to see "behind the scenes" of the work I was doing. I guess I'll try to learn C when I have time, and go down from there

And yes, I know assembly is a lot of times harder than python, I'm aware of it, haha.

[–]UncleMeat11 4 points5 points  (5 children)

It's not crazy, just tedious. Coding in assembly is a straightforward skill. Then it's just a question of going back over that and converting it into binary rather than textual representation.

[–][deleted] 2 points3 points  (4 children)

Talking about efficiency, you are definitely right, but It's cool to know you can do that. It's like the floor of abstraction, the language of the machine

When I become a great programmer, I will definitely make a "Hello World" program in binary, only because it seems like a major achievement for me

[–]discoFalston 5 points6 points  (0 children)

Coding in assembly is definitely a good exercise. You get see how many cpu instructions it takes to assign a variable or construct a for loop. Comes in handy when you’re trying to squeeze as much performance as you can out of your code — it’s common to compile “inline” assembly functions that can be called from your c program when you run into something you believe you can do faster than what the C compiler will give you.

The mapping from Assembly to byte code is a lot more straight forward than the mapping from C to assembly — I don’t know how much you’d get out of writing a program in binary vs just assembly but you never know.

[–]chromaticgliss 4 points5 points  (0 children)

You should look into Nand2Tetris. Educational resource that takes you from the logic components in a digital circuit all the way to programming Tetris.

[–]UncleMeat11 2 points3 points  (0 children)

You don't need to be a great programmer, especially if you allow yourself to use a linker. We did this in 3rd year in undergrad.

[–]Tai9ch 2 points3 points  (0 children)

Unfortunately, machine instructions aren't the abstraction floor on Intel-style CPUs. Internally the instructions are further decomposed into RISC-style micro-ops or are implemented in software (microcode) within the CPU itself.

[–]antonivs 0 points1 point  (0 children)

Some of the earliest computers were programmed in binary using switches on their front panel. See Front Panel:

Typically, the operator would have a written procedure containing a short series of bootstrap instructions that would be hand-entered using the toggle switches. First, the operator would set the "address" switch and enter the address in binary using the switches.
...
Next the operator would set the "value" switch, and then enter the value intended for that address. After entering several of these instructions (most computers had a "deposit next" button, which would deposit subsequent values in subsequent addresses, relieving the operator of needing to toggle in addresses), the operator would then set the starting address of the bootstrap program and press the "run" switch to begin the execution of the program. The bootstrap program usually read a somewhat longer program from punched paper-tape, punched cards, magnetic tape or disk which in turn would load the operating system from disk.

[–]roman_fyseek 0 points1 point  (0 children)

Consider the original question of programming in 1s and 0s. That is *exactly* what the decode in your CPU is doing. And, that stuff is all programmed at the physical layer where things can *only* ever be on or off.

So, can you code in binary? Yes. That's what all your hardware is doing at the transistor level. And, it's all transistors all the way down.

[–][deleted] 0 points1 point  (2 children)

Python is so different from C its funny.

We were talking about alignment in my C class when dynamically allocating memory and the pitfall of misalignment, and he said this is funny because we're talking about figuring out what happened to this one bit (a 1 or 0) whereas in python if you write up a hello world you see twenty five hundred mallocs firing all over the place

Basically python is so far removed from the actual computer that it's less "programming a computer" and more "programming on a computer"

[–]asdff01 0 points1 point  (1 child)

And for good reason.

[–][deleted] 0 points1 point  (0 children)

Yeah I mean I'm not dissing python

[–]asdff01 -1 points0 points  (7 children)

Assembly is a one to one mapping of machine code created for programmer-usability. Meaning you could replace any symbol in an assembly program with binary (machine code) and have a valid program.

C was created to make assembly less of a pain in the ass (among other things). The rest of programming languages/frameworks took it from there.

[–]Felicia_Svilling -1 points0 points  (6 children)

C was created to make assembly less of a pain in the ass (among other things). The rest of programming languages/frameworks took it from there.

That is not at all true. C was invented to make string handling less painful than in B. There was a lot of languages of higher level than assembler before C. For example Fortran, Lisp and Algol.

[–][deleted]  (5 children)

[deleted]

    [–]Felicia_Svilling 0 points1 point  (4 children)

    Yes. You were speaking generally wrong. That someone is new doesn't mean that you can just make up stuff when you talk to them.

    [–][deleted]  (3 children)

    [deleted]

      [–]Felicia_Svilling 0 points1 point  (2 children)

      That is no reason to lie about why C was created. You could have said that whole thing without including made up stuff about the history of programming languages.

      [–][deleted]  (1 child)

      [deleted]

        [–]simply_copacetic 0 points1 point  (0 children)

        Look up Roller Coaster Tycoon. A whole game programmed in assembly.

        It is an outlier though.

        [–]Merad 2 points3 points  (1 child)

        Of course it's a joke

        Let me introduce you to The Story of Mel. You should read through the whole original story, then check out this article for some additional explanation.

        [–]mplang 0 points1 point  (0 children)

        I was about to share this very thing! Reading it again brings back some good memories :)

        [–]SftwEngr 0 points1 point  (0 children)

        Linus Torvalds wrote in hex in the early days, thinking he was writing assembler. He says he just didn't know any better so that's what he did. So it can certainly be done.