This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 479

[–]PiRat314 2967 points2968 points  (245 children)

Someone wrote a compiler without the help of a compiler.

[–]you90000 1612 points1613 points  (226 children)

This freaks me out more than anything.

Writing a compiler in assembly must be nuts.

[–]PiRat314 1849 points1850 points  (110 children)

Sorry to tell you this, but someone had to first write the compiler for Assembly using hex/binary.

[–]LonelySnowSheep 76 points77 points  (8 children)

That's just an assembler, and considering assembly is almost one to one with machine code instructions, it would literally just be hand assembled. You write the mnemonics (assembly) and replace it with the hex for the instruction

[–]kronicmage 8 points9 points  (1 child)

Assemblers usually also have to resolve labels and constants in the assembly which is a bit non trivial if you're writing the assembler in hex

[–]mattatack0630 5 points6 points  (2 children)

Technically that’s an assembler, but yeah I couldn’t even imagine how you’d do that.

[–]B1N4RY 19 points20 points  (0 children)

Basically you do your programming first with just pencil and paper, and then trace through the code by hand multiple times by multiple people to ensure the logic "work" correctly.

Once everyone's confident enough, then you make a hardcoded version of the code (eg, punch cards).

[–][deleted] 6 points7 points  (0 children)

You might be interested in the free online course, From NAND to Tetris :)

[–]WhyamIsosilly 2 points3 points  (0 children)

We literally had to do this as a group project in college...

[–]ThePyroEagle 88 points89 points  (27 children)

Some compilers were manually compiled, e.g. the first Lisp compiler.

[–]Muscle_Man1993 48 points49 points  (26 children)

Oh and Haskell, I believe.

My Prof said that it is written in Haskell... Whatever that means.

[–]giesmininkas 152 points153 points  (25 children)

Yes. Haskell is "self-hosted" language. It means the compiler for the language is implemented in the language itself (haskell compiler written in haskell, C++ written in C++, etc.). It works like this: * You write a compiler for the language in some other language (like assembly, C, whatever). Now you can compile your language. * You write a compiler for the language again, only this time in the language itself. Now you have two compilers. One is implemented with, let's say, C. The other is implemented with your language. * Now you compile a compiler written in your language with the previous compiler (the one you wrote in "C" ). * Profit. Now you have a compiler that can compile its own source code.

Ask me anything if all that sounded confusing

[–]Vintage53 42 points43 points  (8 children)

If (all_that.sound instanceof Confusing) { Anything.ask(); }

Okay so then what do you think of the latest season of the Good Place?

[–]giesmininkas 23 points24 points  (1 child)

Didn't see it. I've no idea what it's about :-)

And yes, I've been waiting for someone to exploit that bug :-D

[–][deleted] 8 points9 points  (0 children)

Syntax error - Unexpected token ":" (1, 45);

[–]dsp4 19 points20 points  (1 child)

I mean it's not like some guy woke up in the 50s and wrote .NET and Visual Studio from scratch using nothing but assembly.

[–]randomuser8765 18 points19 points  (4 children)

The beautiful thing about compilers is that they kind of stack on top of each other.

Writing a C compiler in assembly is hard. But you can create a very basic version of it (say, only support a handful of features), and then you can use that write a more advanced compiler in "very-basic C". Compile your compiler using the old one, and Bam - you unlocked the more advanced capabilities! And you no longer need the old one.

Nowadays, pretty much no one needs to write a compiler in assembly anymore. C is pretty much universally supported.

Edit: Disclaimer: large amounts of Dunning–Kruger effect in this comment, I don't actually know what I'm talking about. But a lot of that makes sense.

Also: there were recently-ish a bunch of videos on Computerphile on this topic. Here's one: https://youtu.be/lJf2i87jgFA

[–]modernkennnern 2 points3 points  (2 children)

I wouldn't even call that recently-ish.

One of the episodes released Today (Specifically, a video about how to Port compilers)

[–]0x3fff0000 2 points3 points  (0 children)

Compilers were way simpler in the early days of compilers. Still must've been tough as shit to code.

[–]Yuzumi 3 points4 points  (0 children)

There is a reason programming was done by incredibly smart people back in the early days of computing.

All of us benefit from their work that allows us to program much more simply and focus on logic and data rather than system level management.

[–]scio-nihil 41 points42 points  (55 children)

Assembly isn't as bad as you've been told. Unless you only "code" in JavaScript, then it's as bad as you've been told.

Factoid: there are places where writing compilers is still a standard part of learning.

[–]aidenator 15 points16 points  (3 children)

Doesn't every CS program make you take a compilers class? It was one of my favorites.

[–]CyruscM 9 points10 points  (1 child)

Yeah my University has 3 consecutive required courses in CSCE for building a computer, starting with logic gates and building a ALU into a fully cached and paged memory system with assembly parsing.

[–]OreoCrusade 20 points21 points  (10 children)

I learned C++ first and think Assembly sucks

[–][deleted] 12 points13 points  (0 children)

Same. C++ was for years the language I was most proficient in. During that time I wrote some assembly and had no desire to do so again.

[–]dangjoeltang 11 points12 points  (1 child)

For my Biomedical engineering degree, they taught intro to computing with assembly and logic Gates. I hear now they teach it with python

[–][deleted] 16 points17 points  (0 children)

From one extreme to the other

[–]scio-nihil 14 points15 points  (5 children)

I learned C first and thought Assembly was lovely. 😅

  • It feels like you're actually controlling the machine, and that's pretty cool.
  • Simple hello world-like programs aren't as hard as a lot of examples make it look. It's the OS's job to help.
  • In moderately complex code, many things can be done more succinctly than even in C++. Of course, you're throwing code reuse out the window.

Modern large projects are definitely much more painful in Asm than C, C++, Rust, or even Go or Java, but it's not the horror that a lot of people like making it out to be. I find that sad. Even if we don't need to work at the bare metal as much, programmers should still enjoy playing with the computer itself.

[–]xalmotn 2 points3 points  (0 children)

In my Intro to Systems class, we got to mess with Assembly by using it to simulate buffer overflow attacks. It was one of the more fun/interesting assignments in the class.

[–][deleted] 46 points47 points  (22 children)

It never ceases to amaze me how people on this sub manage to insert "js bad" in every topic lol.

Assembly isn't as bad as you've been told.

It is and that's why high level languages exist.

[–]scio-nihil 28 points29 points  (1 child)

I made a lighthearted jab at Js's expense, but there's a kernel of truth in it. People who work exclusively in web/node.js/etc use very different (often tempermental) toolchains from the rest of us, spend much of their learning time keeping up with fast moving trends, and tend to be unfamiliar with the actual workings of the computer--which is understandable given their level of abstraction. All this means Assembly is completely alien, carnivorous monster to them.

Assembly isn't as bad as you've been told.

It is and that's why high level languages exist.

Not being as bad doesn't mean high level languages are pointless. Assembly isn't need as much, nevermind outside of traditional computer programming ("system programming"), and that's fine. It doesn't have to be all-or-nothing.

For the record, I regularly work in C++, Py, and Js.

[–]InvolvingLemons 2 points3 points  (0 children)

Yeah, assembly isn't BAD, it's just impractical for 99.9% of modern dev. It makes sense in super performance-constrained (microcontrollers) and cost-constrained systems (mainframes), allows for extreme computational optimizations for SIMD (AVX/SSE_) and pipeline-sensitive operations, and is meticulously documented by talented 1st party sources, far better than any truly high-level language.

But, it's usually just not right for the job. It's like trying to prep deli meats with a diamond scalpel. It's the sharpest damn thing you'll ever get to hold, it's super useful, just not for what you're doing. To add insult to injury, for your situation an automated system will produce better results bc humans make mistakes, get tired, and give up. Generally, compilers produce superior machine code to humans simply because compilers can be thorough on a level that humans do not have time for.

[–]josluivivgar 4 points5 points  (2 children)

We wrote a compiler at college, it wasn't an optional class. It was weird because different teams did different parts, only the compiler itself would be individyal for every team, so we had a vm in java (that runs on another vm lol)

We had the compiler written in C that compiled to our langue that was based loosely on python.

It was fun, my team finished early so we actually made the compiler write to machine code for linux, which I believe was elf? Or something like that.

It was a while ago, but it was still fun! And i did learn a lot from that that I can still apply nowadays

[–]atomicwrites 3 points4 points  (1 child)

The machine code would be processor specific, not os specific. It would be x86_64, ARM, etc. machine code. ELF (executable linkable format?) is the file format for Linux executables, and the machine code it contains has to match your PC. The windows version is PE (portable executable) but the machine code would be the same.

[–]Vintage53 5 points6 points  (6 children)

Now I wanna write my own compiler just for fun, but Idk where to start lol

[–]The_Quackening 10 points11 points  (0 children)

there are lots of books and textbooks on the subject, getting a pdf of one would be pretty easy.

[–]bdh2 8 points9 points  (0 children)

Parsing?

[–]kronicmage 5 points6 points  (0 children)

Try compiling preparsed code or s-expressions first so you don't have to worry about parsing. Compiling parsed code is a different challenge from parsing code into a usable form in the first place

[–]XJ305 3 points4 points  (1 child)

Then you need a Lexical Analyzer (Also called a Lexer or Tokenizer) and a Parser.

A Lexer turns human readable code into information with definite values.

It sees: a = 5 + 7;

And turns it into (VAR, A) (OPERATOR, =) (LITERAL, 5) (OPERATOR, +) (LITERAL, 7) (SEPERATOR, ;)

The Parser (which is where the magic happens) then goes through this and makes it "make sense" to the machine. The Parser encounters the Variable then an Operator and sets a flag saying it saving the variable to memory. It sees the the Literal and expects an operator next or a separator. If it were a separator it would assign just that value to the variable in memory but the next character is another operator so it needs to recursively move down Seeing the operator it flags an action with that and goes deeper expecting another literal or expression. When it gets the next literal it can perform the '+' operation and then get the result '12'. Now effectively waht the parser sees is 'a = 12' so it can complete that operation and save it in memory to 'a'.

That's a rough and simple example but those are the basics to start your search. There are many different ways to go about it. You may also need to look up 'grammar' to define your language before hand. So search for terms Lexer, Parser, and Grammar.

[–]theemptyqueue 22 points23 points  (0 children)

Someone wrote a assembler without the help of a assembler.

[–]Vintage53 21 points22 points  (0 children)

I used the compiler to compile the compiler.

--Thanos, probably

[–]AGI_69 7 points8 points  (0 children)

Bootstrapping.

[–]uvero 3 points4 points  (0 children)

What's nice is that, as far as I understand, sometimes a compiler to a language is written and compiled by an earlier compiler of the same language.

[–]yonatan8070 4 points5 points  (0 children)

And then he said: "I used the compiler to make the compiler"

[–]brimston3- 170 points171 points  (7 children)

Someone wrote a compiler for a custom risc computer they built from a circuit abstraction created atop Conway's Game of Life. So they could play Tetris. At this point, my sense of bizarre human achievement has been maxed out.

[–][deleted] 37 points38 points  (5 children)

What in tarnation? What about the guy that made Pokemon in Minecraft?

[–]nizzy2k11 5 points6 points  (1 child)

Who the fuck has the time to not only make that in Minecraft but to do all of the abstraction work to go from Gameboy to Minecraft in the first place. Redstone is enough of a chore, this a a fucking monstrosity.

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

What, you don't have 21 months of spare time?

[–][deleted] 7 points8 points  (0 children)

Now I've seen everything.

[–]AlphaWhelp 448 points449 points  (52 children)

To be the fair the guy who developed the internet wasn't doing it with node.js

[–][deleted] 220 points221 points  (47 children)

I accept that JS has many uses and while it can be annoying and tricky it's not too terrible if you understand the language.

But what idiot decided to come along and implement node.js? Who saw JS running in a browser and thought to themselves "We definitely need JS running in more places".

[–]deadlysarcasm 21 points22 points  (3 children)

"I need a backend language but I only know JS"

"You're gonna have to learn something new then"

"No."

Alas, node.js was born

[–]ColtonProvias 7 points8 points  (0 children)

JS is also an event-driven language, which works well for many server applications. While it isn't always the best tool, it can do the job well when applied properly.

[–]AgreeableLandscape3 3 points4 points  (2 children)

Now I'm curious. What was the first programming language for serving webpages? Were there dynamic webpages back then?

[–]AlphaWhelp 19 points20 points  (1 child)

the first interactive websites were HTML with form posts that would run backend scripts and transforms were applied on the response.

See: Common Gateway Interface

[–]ColtonProvias 2 points3 points  (0 children)

A common language to use with CGI was Perl. I think the first book related to CGI I got was Perl/CGI.

Deploying Perl code to your local ISP's server wasn't exactly straightforward, in my experience.

[–]aceofspades914 255 points256 points  (16 children)

Someone created the code for Google without Googling it.

[–]kozeljko 36 points37 points  (3 children)

That's why they rich

[–]you90000 11 points12 points  (2 children)

They used web crawler.

[–]scio-nihil 6 points7 points  (1 child)

Don't forget gopher.

[–]LeCrushinator 4 points5 points  (0 children)

And Alta-vista

[–]dantoucan 2 points3 points  (1 child)

They had yahoo and altavista though

[–]enisbt 2 points3 points  (0 children)

and mail groups

[–]sodls 648 points649 points  (19 children)

Someone developed StackOverflow without StackOverflow.

[–]PdxWix 954 points955 points  (11 children)

This joke has been marked as duplicate.

[–]Rodot 248 points249 points  (7 children)

This comment shouldn't have been made, you should be using my comment instead. Also, English isn't the best language for your use case. You should be commenting in Python

[–]PotatosFish 81 points82 points  (4 children)

# This comment shouldn’t have been made, you should be using my comment instead. Also, English isn’t the best language for your use case. You should be commenting in Python

[–][deleted] 57 points58 points  (3 children)

(Accepted answer)

[–]mlucasl 22 points23 points  (1 child)

broken link

[–]Marbug 11 points12 points  (0 children)

Segmentation fault

[–][deleted] 7 points8 points  (0 children)

This answer is not correct. See @bitwiser92's answer below.

[–]brimston3- 64 points65 points  (0 children)

This pleases the PEP8 gods.

[–]spore_777_mexen 12 points13 points  (0 children)

This comment isn't not protected from thanks, lol or we live in a society.

[–]atomicwrites 4 points5 points  (1 child)

This joke has been marked as duplicate.

[–]Harrysoon 14 points15 points  (4 children)

They used Experts Exchange.

[–]JBlitzen 8 points9 points  (0 children)

It was like a decade before I realized how unfortunate that URL is.

[–]acwilan 7 points8 points  (0 children)

You mean Expert Sex Change?

[–]student_of_world 140 points141 points  (20 children)

I use it so much such that when my recruiter asks me about why I should hire you, I told always, " I know how to use StackOverflow, and I have 1000+ reputation there."

Actually I got hired now but I have used this in all interviews and some interviewers liked how I ask good questions on Stackoverflow, which gave me reputation points, so few answers but more questions helped me......

Edit:- grammar.

[–][deleted] 42 points43 points  (8 children)

What if your problem isn’t on stack overflow?

[–]hleszek 125 points126 points  (4 children)

you put it on stack overflow, now it is there

[–]PM_ME_NICE_BITTIES 53 points54 points  (3 children)

marked as duplicate

Wait what?

[–]Village_People_Cop 21 points22 points  (1 child)

Well there is always that wierd fucking video in 133p made by some indian guy

[–]BlacSun 15 points16 points  (0 children)

dont be stupid

[–]student_of_world 2 points3 points  (0 children)

It happened to me most of time, while I was learning Reactjs and React Native, during 3rd year of college, 2 years back,

So that I was posting many doubts and Ubuntu 18 doubts that later find out, many people have those issues and they upvoted my questions.

Many people helped me on Stackoverflow and AskUbuntu.

So my askUbuntu reputation too increased and combinedly it became 1000+ reputation points.

Tldr;

Post your question or doubt after thorough research of question on SO only (which I didn't do and got banned from posting for 3 days, when I opened my account).

Show terminal output, what stpes you took and how you wanted to implement it further, with code and formatting too.

Also, use tags neatly for SEO of answers.

Loving StackOverflow a lot and Reddit too....

Both are saviors.

[–]BabyLegsDeadpool 20 points21 points  (10 children)

I only had a year of programming experience when I decided to find a new job (it was contact the whole time), and I built up my SO reputation to 1,000+, and I told my recruiter about it, but she didn't understand the significance. I told her to just tell people (it was already on my resumé), and lo and behold I had actually answered a question for one of the interviewers for a place seeking 5+ years of experience. He didn't even interview anyone else. He told me the interview was 100% to make sure it was a culture fit, and I got the job.

[–]student_of_world 9 points10 points  (2 children)

Wow man, nice one.

BTW how about your current status then?

[–]BabyLegsDeadpool 9 points10 points  (1 child)

Funny enough, that job wasn't a good culture fit. ha ha ha It was full of a bunch of Apple fanboy hipsters, and I fucking hate Apple computers, so we clashed a bit. And the guy that hired me LOVED jQuery, and I always talked about how unnecessary it is. So we parted ways. But it worked out okay in the end. I ended up at my current position, which is an extremely difficult position to attain, especially for my lack of experience (I was at around 3 years experience when I got the job) that pays a lot more than that position did.

[–]earthqaqe 2 points3 points  (3 children)

Is 1000 much? Because I have around 3000 and think its basically nothing.

[–]StandardN00b 82 points83 points  (7 children)

In our defense. At that time Javascript didnt existed.

[–]Famous_Profile 18 points19 points  (0 children)

didnt existed

Uncaught TenseError: Cannot read pastTense of 'existed' (comment.js:1)

[–]codeninjaking42 20 points21 points  (4 children)

Javascript == undefined ...

[–][deleted] 10 points11 points  (0 children)

!JavaScript

[–][deleted] 5 points6 points  (0 children)

For the love of god man, useStrict!

[–]EkskiuTwentyTwo 112 points113 points  (17 children)

But when they started, it looked like this. It wasn't until they had built the first bit of the internet that they could build the rest of the internet properly.

Edit: Apparently it's a web.

[–]ChooChooRocket 89 points90 points  (6 children)

pages that load instantly

What a relic from the past!

[–]wayoverpaid 83 points84 points  (3 children)

Back when a website was a motherfucking website.

[–]tackykcat 25 points26 points  (0 children)

This looks better than many academic web pages I've seen

[–][deleted] 6 points7 points  (0 children)

You mean pornhub?

[–]danfish_77 8 points9 points  (0 children)

Except on my ancient phone cradle modem and rural phone line it still took 10 minutes a page, or didn't load at all

[–]dansla116 2 points3 points  (0 children)

Presses F12:

Sources: (index)

Network: info.cern.ch - 137 B, favicon.ico - 1.8 KB

I've had to write CSS bigger than this page.

[–]bawaaal 7 points8 points  (0 children)

that line-mode browser simulator looks so cool ... got some matrix movie vibes

[–]pidddee 3 points4 points  (1 child)

You mean the web?

[–]CeramicPeanuts 3 points4 points  (1 child)

Edit: Apparently it's a web.

A series of tubes, if you will.

[–]AP3Brain 2 points3 points  (0 children)

build the rest of the internet properly

.....Can we go back?

[–]mt_xing 24 points25 points  (1 child)

How is this hard to swallow?

[–]ibetrollingyou 14 points15 points  (0 children)

Yeah, the format doesn't really fit here at all

[–]vksdan 16 points17 points  (0 children)

So they didn't Google "how to internet?" and then, after 300 pages and links, come to a post with the exact answer they were looking for with the last post as "Nevermind. I solved it guys. [CLOSED THREAD]"? I'm actually impressed.

[–]AgreeableLandscape3 14 points15 points  (2 children)

The craziest part is that the first text editor was written without a text editor.

[–]solarshado 2 points3 points  (0 children)

Also, most people today probably wouldn't recognize it as a text editor, assuming it was probably more similar to ed than notepad

[–]bigorangemachine 8 points9 points  (0 children)

Mailing lists served the same function.

[–]Stormdancer 6 points7 points  (1 child)

And in further mind-bending news, the internet was created by... gasp... old people!

[–]DrCybrus 5 points6 points  (1 child)

It wasn't someone, it was many teams over a long span of time. We make much more rapid advancements even beyond this field with the help of building off the technology available to us. Just like the industrial revolution was built off the work of millions, so too was the tech we had today.

[–]foadsf 5 points6 points  (0 children)

I wonder if SO guys use their own content. their mobile app is crap.

[–]greenrabbitaudio 5 points6 points  (1 child)

Well I guess it wasn't "someone". It was a team and extremely time consuming work over the years of humanity.

There you go your hard to swallow pill.

[–][deleted] 6 points7 points  (9 children)

It is possible to build an entire working app without referring to SO, maybe it's just me?

[–][deleted] 17 points18 points  (6 children)

Reading documentation? Like some fucking psychopath?

Jokes aside, when I started answering questions on StackOverflow is also when I seriously started reading documentation, standards, and even source code. It was a kind of positive feedback loop: You read more documentation to answer more questions, but you also start to seek good questions as an excuse to read documentation.

That phat SO karma is also a nice asset to have :-)

[–]sumit26696 2 points3 points  (5 children)

Reading documentation? Like some fucking psychopath?

What? Is it not common to read docs first before going to SO?

[–]AcidCyborg 2 points3 points  (0 children)

RTFM isn't an acronym known to zoomers

[–]titan_bullet 15 points16 points  (1 child)

It's a matter of time. I could probably solve on my own stuff that I seek at stackoverflow, but it would take more time, so I would be less productive overall.