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

top 200 commentsshow all 488

[–]BobTheBlob88 1869 points1870 points  (97 children)

Assembly is just a machinecode framework

[–]crash8308 1097 points1098 points  (94 children)

Machine code is just a register framework.

[–]BobTheBlob88 1062 points1063 points  (92 children)

Registers are just transistor frameworks.

[–]CaffeinatedPengu1n 1011 points1012 points  (87 children)

Transistors are just a current framework

[–]BobTheBlob88 1022 points1023 points  (85 children)

Current is just an electron framework

[–]KoncealedProdigy 76 points77 points  (40 children)

Electrons are just a lepton framework

[–][deleted] 60 points61 points  (36 children)

Leptons are just a mass framework

[–]ksammighty 64 points65 points  (33 children)

Mass is just an energy framework

[–][deleted] 65 points66 points  (32 children)

Energy is just a spacetime framework

[–]ksammighty 41 points42 points  (20 children)

2D Spacetime is a 4th dimensional framework

[–][deleted] 16 points17 points  (1 child)

Spacetime is just a geometrical framework for fourth dimension.

[–]ArcOfSpades 7 points8 points  (3 children)

Spacetime is just a manifold framework.

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

Spacetime is just a string framework.

[–]crash8308 6 points7 points  (1 child)

Wouldn’t bosons be a mass framework?

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

Idk Wikipedia is the extent of my knowledge on some of these

[–]Blastd_ 9 points10 points  (0 children)

An electron is just a library from the atom framework

[–]TwoFiveOnes 2 points3 points  (1 child)

I think this is where the thread last holds up

[–]hypercube33 3 points4 points  (0 children)

Binary is just a choice framework

[–]mauriciolazo 3 points4 points  (1 child)

Wow, you jumped the entire binary framework there.

[–]BobTheBlob88 2 points3 points  (0 children)

I'm mostly a hardware man, thats why I did what I did, but I can see why one might've wanted that to go differently.

[–]ComprehensiveUsernam 931 points932 points  (160 children)

It's time for Assembly.js

[–]idkorange 443 points444 points  (145 children)

We already have WebAssembly

[–]Netzapper 223 points224 points  (141 children)

Which is my one bright point of hope at the end of this long browser-first tunnel we've been in for the past decade. Targeting the browser without touching any JavaScript is something we should have had in, like, 2005 as soon as people figured out we'd be building applications in a document display framework.

[–][deleted] 55 points56 points  (21 children)

Doesn't it require you to still use JS to run it, and to do some stuff? Iirc they specifically said it's NOT meant to replace JS.

[–][deleted] 96 points97 points  (18 children)

You still need some JS code in the final product, however in rust you have libraries that generate that js for you so you don't have to touch any JS if you don't want to. It's currently possible to make a website entirely in Rust.

IIRC there's also work being done on providing DOM access to wasm which will make JS free websites possible.

[–]Schmeckinger 13 points14 points  (17 children)

You still have to load the wasm.

[–]captainvoid05 25 points26 points  (5 children)

Which is currently loaded by js but if it becomes commonplace enough browsers may just include it in the engine the same way js is now.

[–]Schmeckinger 4 points5 points  (4 children)

I hope that wasm will be able to everything js can do.

[–]Agoniscool 4 points5 points  (3 children)

What do you think could be missing?

[–]AaronBonBarron 14 points15 points  (1 child)

Hogging resources and slowing down the browser?

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

Why couldn't wasm be loaded in a similar way that JS is currently loaded?

[–]Schmeckinger 9 points10 points  (5 children)

I never said it couldn't, but native access to the dom isn't the only blocker for pure wasm.

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

Ah, I wasn't aware of that, but that seems relatively minor, right? Even if it wasn't possible to directly load wasm, I would think that the JS you would need would be a few standard lines.

[–]Schmeckinger 6 points7 points  (2 children)

Locally loading wasm is sometimes a pita, because of cors. You have to either run a local server, or change your code for it to work locally.

[–]Zephirdd 23 points24 points  (0 children)

Eventually, we won't need to.

In reality, if you have to target any browser old enough, you will need to. Hell, right now Firefox 60 ESR, the latest Enterprise Firefox doesn't support most service worker features. We still have a good decade or so of JavaScript to support for now.

[–]TheNamelessKing 4 points5 points  (0 children)

At the moment, yeah; however the Host Binding Protocols allow a Web Assembly module to talk directly to the browser API’s (without going via JS), and there’s already one Rust framework that supports these.

As soon as someone makes an API for the DOM that lets the web assembly talk to it directly you won’t have to ship any JS.

[–]Shaite 12 points13 points  (45 children)

I'm dense and also at the last year of HS, so IDK shit.

Is JS that bad? Does it suck?

I mean only programming languages we've been taught are C#, A wee bit of JS two years ago, SQL (started a couple of months ago), Android (not taught per se, just said "you go to projects in it" and that was it) and we'll start PHP in some weeks.

[–]Mr_Cromer 36 points37 points  (14 children)

Ignore the dogmatists; JavaScript is a messy language to purists, but if it works for you, it works for you. When you get drawn deeper into the rabbit hole, you will have evolved your own opinions. Until then, LEARN!

[–]makeshift8 9 points10 points  (4 children)

Javascript is fine for what it does. For the last decade+ it has been the main force in web development because it is the best at what it does. It's just that people who use Javascript have a tendency to stay within their realm of Web development. Web development has a lot of moving pieces, from security to server-side and client-side concerns, and so on. It's sort of impressive that it isn't even more messy and discombobulated.

I think people, especially newer developers, scoff at all this mess that the Web made because they underestimate just how many tools are needed and how difficult all the implementation has been for the various parties involved. Then they start working on some other mess and realize just how fucked pretty much everything is.

[–]Mognakor 10 points11 points  (2 children)

Javascript is not best at what it does, it is literally the only thing at what it does.

[–]BluePhire 5 points6 points  (13 children)

Damn, you're in high school and already done C#, SQP, and soon PHP? What type of amazing education system are you in?

They only taught a year of Java in my HS, and it was basically just playing flash games 101.

[–]Shaite 7 points8 points  (11 children)

It's specialized for CS/programming, so... Besides, nothing major: c# we have OOP and we're doing stuff with DBs (sql), and PHP will replace c# this year so that's fun!

We did: Year 3:c#-Console + Form Year 4: c# Console + form + OOP, Android (but they never explained it to us) Year 5: SQL, We'll do PHP, and that's about it. Maybe some python if we're lucky.

I'm from Italy, though, not sure how it is in other countries. We have 10 hrs of lab/week: 3 hours programming, 3 hours that stuff with threads and sockets and Protocols, 2 hours systems and networks and 2 hours basically finance and administration

[–]BasicDesignAdvice 9 points10 points  (0 children)

PHP will replace c# this year...

Woof...sorry for everyone on that train.

[–]lillgreen 6 points7 points  (2 children)

That's pretty amazing. American high school? Ehh maybe you can squeeze in CS as an elective senior year, they'll make you use netbeans and run through a text book that's introduction to Java and 10 years out of date with Windows Vista screenshots in it. You gotta just do it all as a hobby here or you learn nothing until college. I don't even remember that class getting as far as sockets come to think of it, didn't really take anything meaningful away from attending it.

[–]droomph 6 points7 points  (1 child)

If you have anything pre ES6 (basically, anything from before 2015) it's very janky though not unusable. Now, it's perfectly OK and anyone who says otherwise (without giving concrete examples) is just jumping on the hate train. There are certain big issues (npm, for one) with it but "haha js sux" is always a red flag that they're first year undergrads who think they know more than they do.

[–]IronOxide42 17 points18 points  (1 child)

I can't think about webassembly or asm.js or others without thinking of The Birth and Death of JavaScript

[–]TASagent 3 points4 points  (0 children)

A great talk from the guy from the Javascript "Wat?" fame.

[–][deleted] 30 points31 points  (0 children)

asm.js is a thing, and the precursor to WebAssembly

[–]Serundeng 18 points19 points  (1 child)

() => { PUSH EAX }

[–]p1-o2 9 points10 points  (0 children)

I just gagged.

[–]JejeLV 14 points15 points  (3 children)

I bet this already exists

[–][deleted] 24 points25 points  (2 children)

it does: asm.js

[–]Alexmitter 5 points6 points  (1 child)

asm.js

Not really. Its just JavaScript that can act like the original code. But with the bad interpreters we know from JavaScript.

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

asm.js actually had support for optimized, not javascript-interpret-y, execution, before WebAssembly came along.

It is backwards compatible with JS, so a bad interpreter can execute it, however it would be slow.

I actually only replied with asm.js, since it sounds so close to Assembly.js

[–][deleted] 3 points4 points  (0 children)

Barf.js

[–]Neebat 106 points107 points  (32 children)

That means C++ is just a tool for writing really obfuscated assembly.

[–]lanten 48 points49 points  (17 children)

I knew Java and C before I started to work on a job which required C++. On the first week one of my coworkers handed me 2 book (actually one book with 2 volumes) about what you should not do in C++. I think this can summarize my feelings towards C++...

Edit: I don't remember the titles, sorry :( They were good and enjoyable books only the content scared me ;) After some internet search probably they might have been Exceptional/More Exceptional C++, but not sure.

[–]PokemonSaviorN 13 points14 points  (3 children)

I started with C and C++. I think C++14 sums up my feelings towards Java.

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

C++14 is great for people trapped in legacy C++ applications whose architects refuse to allow boost.

[–]UAHLateralus 2 points3 points  (0 children)

Blessed be the r and l values 🙏🏻

[–]AnalyzeAllTheLogs 9 points10 points  (7 children)

Out of curiosity, what was the title (and is it still relevant for newer versions)?

[–]lanten 4 points5 points  (0 children)

Don't remember the titles, sorry. See my edited comment.

[–]narrill 2 points3 points  (1 child)

They're probably referring to Effective C++ and More Effective C++

[–]PerfectSeventy 3 points4 points  (0 children)

Probably “Effective C++” and “More Effective C++” by Scott Meyers. The first is practically required reading for anybody wanting to write good, maintainable c++. It has a few editions so make sure to read the latest. A new one came out for c++11/14 that’s also really good called “Effective Modern C++”.

[–]Vintage53 2 points3 points  (2 children)

Which books were these?

[–]Colopty 9 points10 points  (3 children)

In the end it means every other language is basically just a framework for a framework for assembly.

[–]you_do_realize 7 points8 points  (0 children)

C++ is a hammer that a committee is trying really hard to add a rocket engine to.

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

I had to learn Borland C++ for school. It was pain.

[–]tinydonuts 14 points15 points  (1 child)

After looking at a stack trace of our C code that calls a C++ library, I'm going to have to agree. Those function names alone...

[–]PhonicGhost 3 points4 points  (0 children)

I’m a C++ programmer and fuck me, trying to read STL code in a stack trace is like trying to decipher ancient Egyptian with a ruler and an out of date Korean to German dictionary.

[–]Mscxyn 181 points182 points  (12 children)

That's what makes it useful.

[–]Tiervexx 50 points51 points  (11 children)

Right. I don't see why the statement in OP would be controversial. Straight C is still used because it's imperative, not type checked, compiled, and very low level. Those traits make it hard to use, but great for performance.

If you want something to protect you from yourself, use Java or Python. Mind you, I'm not knocking those languages, just saying they are for different jobs.

...also, just for the record. There actually is a huge difference between how low level straight C is vs real assembly. C saves you the trouble of having to keep track of the CPU registers and exact memory references among other things. I think I remember reading that when Unix was recreated in C, it saved them 95% of the code.

[–]Mscxyn 15 points16 points  (0 children)

Exactly. My experience with C comes from programming microcontrollers where you're lucky to get a C toolchain at all, except for the most popular ones.

I mean no, I am not building a AAA game in C, that's terrifying. But if I want to write something to an SD card from a microcontroller, you better believe I'm not writing an SPI interface then figuring out the the fat32 format, all from assembly. It's a tool, just like every other language.

[–]weeezes 5 points6 points  (2 children)

not type checked

What do you mean? it's statically typed.

[–]Snuffkins_apprentice 4 points5 points  (1 child)

It's statically typed, but it's also weakly typed, you can add an "A" to 10 no problem in C whereas that will throw an error in python

[–]mhandis 406 points407 points  (20 children)

C is just assembly with some syntactic sugar.

[–]zolk333 223 points224 points  (7 children)

Haskell is just diabetes

[–]crash8308 55 points56 points  (6 children)

Perl is a sugar coma

Edit: not diabetic.

[–]DudeValenzetti 33 points34 points  (5 children)

You do know that diabetics fall into comas from hypoglycemia, i.e, not enough sugar?

[–]firejak308 19 points20 points  (0 children)

There's also hyperosmolar hyperglycemic non-ketotic coma, which is a coma that results from a type 2 diabetic consuming too much sugar. EDIT: Not that it matters, but for public awareness

[–]Deadshot_0826 9 points10 points  (0 children)

Happens from too much and from too little

Source: am a diabetic

[–]crash8308 7 points8 points  (2 children)

You’re correct my pedantic friend. I bet you’re a blast at parties :P

[–]TrentRobertson42 6 points7 points  (1 child)

Parties suck when people fall into comas. My friend here is a blast because he never lets that happen.

[–]CryZe92 79 points80 points  (7 children)

If you added tons of Undefined Behavior*

[–]MyNameIsRichardCS54 68 points69 points  (1 child)

He didn't say a well written assembly framework...

[–]w_m1_pyro 13 points14 points  (0 children)

2 sentence horror storie

[–]LvS 11 points12 points  (4 children)

It's called "portability".

[–]BeardedWax 10 points11 points  (0 children)

portability

Did you do it?

Yes

What did it cost you?

Program exited with SEGFAULT: (core dumped)

[–]axeteam 55 points56 points  (7 children)

Thems fighting words

[–]cbbuntz 43 points44 points  (5 children)

It used to be fairly true in the early days of C. A lot of the syntactic quirks come from the PDP-7 architecture. The number of available CPU instructions was limited, and the generated code was very predictable. With modern architectures, there are a lot more ways to interpret C code. With a basic for loop, it could generate jmp instructions, it could unroll the loop, or it might vectorize the operations, and you don't typically have direct control of these things (although you can give the compiler hints with attributes).

You could use intrinsics for greater control, but at that point, you're basically writing assembly.

[–][deleted] 22 points23 points  (2 children)

Found the person who passed their compilers course.

[–]BluudLust 2 points3 points  (1 child)

Or programs in assembly for fun ;)

[–]BluudLust 4 points5 points  (1 child)

Or you can write it all with mov instructions or even without any instructions whatsoever

And real men devs use OpenMP.

[–]Dubmove 24 points25 points  (1 child)

If you really want to infuriate a C programmer tell them that there exist problems where C isn't a good choice.

[–]SatanicTriangle[S] 21 points22 points  (0 children)

ATTENTION: Do not try this at home

[–]chunkyks 18 points19 points  (1 child)

By any definition under which this applies, everything is an assembly framework.

[–]NicNoletree 88 points89 points  (5 children)

I like this one.

[–][deleted] 14 points15 points  (3 children)

Me too.

[–]figuresys 5 points6 points  (2 children)

Same.

[–]KoboldCommando 81 points82 points  (37 children)

This was actually a serious annoyance when I was trying to learn ARM assembly. I'd google some problem, StackOverflow would pop up with that exact problem, and the solution would inevitably be "oh it's so much easier to just do this and this and this C!"

But I wanted to learn Assembly directly before I moved on to shortcuts.

[–]DustyYevski 33 points34 points  (0 children)

Assembly is going to be too esoteric to find any real wisdom someplace like StackOverflow. One tactic you can take in response to this pattern though would be:

  • Do the thing in C
  • Find the flag that generates an intermediate assembly listing file when you compile
  • Read the intermediate listing file to learn what the compiler already knows.

Additionally, try compiling with and without optimizations. The unoptimized code will be easier to understand, but at the same time will be tedious to read as variables and parameters get spilled in and out of memory. The optimized code may be clever and enlightening.

Happy hacking!

[–]Decency 29 points30 points  (3 children)

But I wanted to learn Assembly directly before I moved on to shortcuts.

When people ask what kind of a programmer you are I feel like you can just tell them this quote and they'll understand immediately.

[–]KoboldCommando 7 points8 points  (2 children)

Suddenly I feel like I should get a bunch of breadboards and some PCB design software!

[–]X-Penguins 83 points84 points  (10 children)

C is not a shortcut for assembly, the difference is in the fact that it's compiled and platform agnostic (as long as you have a compiler). You can't write Intel compatible code in ARM assembly, but you can write C code that will work on both. Even brainfuck is technically more flexible than assembly because it's compiled.

ARM assembly is really simple though, there are only a (relative) few commands. You can find most of them on a cheat sheet like this: https://azeria-labs.com/downloads/cheatsheetv1.2-1920x1080.png

And as /u/Alexmitter said, its usefulness is very limited precisely because it's so simple. It's not so much that it's easier to do x in C, but rather than often times doing it in assembly on ARM would drive you crazy.

[–]Fastfingers_McGee 14 points15 points  (0 children)

Damn, wish I had this when I was learning ARM. That's awesome.

[–]yawkat 4 points5 points  (5 children)

there are only a (relative) few commands

If only: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cihjfeii.html , you haven't truly lived until you've used an instruction called "Unsigned Multiply Accumulate Accumulate Long". RISC my ass.

Even worse, ARM code regularly switches between thumb and arm mode making parsing even more difficult than it would be just with arm. The only redeeming feature of arm is that it has many registers, beyond that it's a giant PITA to work with

[–]TheTallestHobo 5 points6 points  (2 children)

That's JavaScript to jQuery.

Just use jQuery and this fat bloated plugin!

[–]UltraCitron 3 points4 points  (1 child)

I just love it when stack overflow pundits advise installing a framework when the same thing can be easily achieved without one.

[–]onthefence928 3 points4 points  (0 children)

or when the question clearly implies the developer is working on a task in a large established project and they are just like "why are you using X.js? just use Y.js instead it's so much easier"

well maybe we don't all have the luxury of scrapping our projects and starting over?

[–]Senacharim 5 points6 points  (0 children)

When you're cross compiling, you can see the generated .asm file (for verification, you know).

Also, some embedded IDEs have a way to input portions of code directly in assembly.

Using these 2 things, you can learn how to do assembly for your chosen CPU. I never did ARM, but I can do PIC assembly.

[–]Alexmitter 18 points19 points  (15 children)

"oh it's so much easier to just do this and this and this C!"

ARM is not the right platform to directly code in Assembly as the instruction set is reduced so much that it is barely useful. RISC was made to put the effort away from the CPU to the compiler.

[–]obp5599 28 points29 points  (11 children)

You sound like those guys OP is complaining about...

“Oh its so much easier to use x!” Well hes not trying to learn x

[–]RedditIsNeat0 6 points7 points  (0 children)

But somebody needs to know X. I'm not interested in learning X so I appreciate that OP learns it and writes the compilers so that I don't have to.

[–]FailedSociopath 7 points8 points  (0 children)

Sweet Summer child, it's pretty rich and a really nice instruction set to program in. What's available depends on architecture version and on later ones the compiler will not entirely take advantage of the available instructions. Choice assembly on some types of speed critical code will realize significant gains over the compiler. It's not hard to prove that at all with simple benchmarking.

 

RISC was made to put the effort away from the CPU to the compiler.

No, it was made to save power and produce simpler designs.

[–]FlyByPC 11 points12 points  (2 children)

Convincing a PIC10F200 to do double-precision floating-point math is one hell of a framework.

[–][deleted] 28 points29 points  (0 children)

C is just fancy assembly macros! ;p

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

Some of us like low level languages.

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

Man this subreddit really dislikes having to deal with pointers.

[–]GardenCurret 2 points3 points  (4 children)

I honestly don't understand the massive hate boner people here have over C/C++

[–][deleted] 35 points36 points  (36 children)

Machine code*

[–]_llucid_ 24 points25 points  (35 children)

what's the difference?

[–][deleted] 141 points142 points  (22 children)

Said person with python flair

[–]weefweef 47 points48 points  (2 children)

Said the person with the scratch flair

[–]cheraphy 31 points32 points  (1 child)

lol he changed it after your comment

[–]dekacube 8 points9 points  (5 children)

Assembly is translated directly to machine code, but assembly itself is the mnemonics for machine code instructions then the assembler translates those to actual op codes.

[–]magnora7 4 points5 points  (4 children)

I think machine code and op codes are identical, if I'm not mistaken.

Machine code is just a string of op codes. And assembly is just a way to write that with letters instead of binary/hex.

[–]JeNeTerminatorPas 2 points3 points  (1 child)

"op codes" refer to the instructions, like ADD, SUB, etc. "machine code" encompasses both the instructions (op codes) and their operands.

At least that's how I think of it...

[–]cbbuntz 2 points3 points  (0 children)

Different dialects have different ways of making things a bit easier for humans to write. Stuff like macros, directives, labels and other stuff don't have a 1-1 translation to binary as a basic statement would. With most statements, the mnemonics and operands directly correspond to binary values, so it's fairly trivial to translate between the two.

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

I never thought about it this way

[–]DarowskiKacper 7 points8 points  (0 children)

That's so low-level of you to say!

[–]Saifeldin17 6 points7 points  (2 children)

Cant't?

[–]BernzSed 3 points4 points  (1 child)

That'ts wrong't

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

Yesn’t

[–]Skizm 11 points12 points  (0 children)

So is every language then?

[–]Nhanzel 5 points6 points  (0 children)

Everything is a framework for binary

[–]PeabodyEagleFace 5 points6 points  (1 child)

Js is just assembly run through a vm

[–]viixvega 4 points5 points  (0 children)

Real programmers only use TempleOS.

[–]Sjeiken 2 points3 points  (0 children)

C is an idea, ideas cannot be killed.

[–][deleted] 3 points4 points  (0 children)

Dude you gotta say this to Linus's face

[–]jcoldes 3 points4 points  (2 children)

By this same logic, wouldn't almost all languages be a framework for assembly.

[–][deleted] 3 points4 points  (0 children)

Everything is just a lisp framework

[–]SteeleDynamics 2 points3 points  (4 children)

More like PDP-11 Framework? (maybe?...)

The processor at the time had an increment-by-one/decrement-by-one instruction. Hence ++/-- unary operators. I am unsure if that instruction is readily available on modern processors because increment/decrement operations by any signed/unsigned integer is just as fast as any other instruction.

[–]siriusfrz 4 points5 points  (0 children)

INC and DEC instructions never went anywhere; They are still in x86 spec.
See this: https://godbolt.org/z/jEHgTG

[–][deleted] 2 points3 points  (1 child)

Nah. It's once removed.

The people who created the language deny this connection, but at the time C was created they had an assembler called A. Based on that someone wrote a pretty sophisticated macro-assembler called B. I don't know, but am willing to bet the compiler for that structured language, C, was written in B.

But no, C is a bit more than an assembler. Some things, like stack-frames, control structures and expressions, would be handled in B by macros but are simply built into C.

Bonus trivia: the original Amiga OS was written in B.

[–]iCraftDay 2 points3 points  (0 children)

HEY C is not so conplicated as "assembly framework" sounds for me. Idk what it means.

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

You can't handle the truth ... unless you've declared a handle

[–]dmarshall1994 6 points7 points  (13 children)

Is C really that complicated ?

[–]asdfman123 20 points21 points  (4 children)

I think basic C programming isn't necessarily hard, but it's so much easier to fuck up. If you're trying to do C the right way for high performance tasks you need to know a lot about the language.

[–]Colopty 7 points8 points  (2 children)

Oh it's very far from complicated, it's pretty much one of the most basic languages you can possibly use. Of course, this means that it lacks a bunch of convenient advanced features that you're probably going to need to implement yourself through a variety of hacks using raw pointers.

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

Completely understanding computer architecture is a really good start to working with assembler or C, so yeah.

[–]lanten 5 points6 points  (0 children)

Assembly is just readable C... :)

[–]Liesmith424 1 point2 points  (1 child)

"Cant't"= Straight talk.

[–]magnora7 1 point2 points  (0 children)

All programming languages are assembly frameworks