this post was submitted on 03 Aug 2024
1089 points (99.0% liked)

Programmer Humor

31992 readers
137 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 
top 50 comments
sorted by: hot top controversial new old
[–] JoYo@lemmy.ml 72 points 1 month ago (1 children)

I get the feeling that all of these assembly jokes are justifications to avoid learning assembly.

You can still make syscalls in assembly. Assembly isnt magic. It isn't starting from the creation of matter and energy, it's just very specific code.

[–] NocturnalMorning@lemmy.world 19 points 1 month ago (3 children)
load more comments (3 replies)
[–] davel@lemmy.ml 48 points 1 month ago (5 children)

Assembly code is for writing C compilers, and C compilers are for writing Lisp interpreters.

[–] henfredemars@infosec.pub 20 points 1 month ago (1 children)

I saw a Scheme interpreter written in assembly running a C compiler written in Scheme.

[–] wewbull@feddit.uk 15 points 1 month ago* (last edited 1 month ago) (3 children)

Only the most very basic compilers. C compilers are in C mainly.

[–] davel@lemmy.ml 11 points 1 month ago* (last edited 1 month ago)

Not the first C compiler obviously. According to this Stack Overflow post, BCPL* begat B, which begat C. Language self-hosting is pretty fascinating.

*Perhaps BCPL was originally written in assembly; I’m not certain: https://github.com/SergeGris/BCPL-compiler

[–] ulterno@lemmy.kde.social 8 points 1 month ago (1 children)

Talking about bootstrap here?

load more comments (1 replies)
load more comments (1 replies)
load more comments (2 replies)
[–] skullgiver@popplesburger.hilciferous.nl 45 points 1 month ago* (last edited 1 month ago) (4 children)

Assembly isn't that hard. It's the same imperative programming, but more verbose, more work, and more random names and patterns to remember. If you can understand "x += 3 is the same as x = x + 3", you can understand how the add instruction works.

I wouldn't be able to write Rollercoaster Tycoon in assembly because keeping track of all that code in assembly files must be hell, but people pretending like you need to be some kind of wizard to write assembly code are exaggerating.

These days, you won't be able to beat the compiler even if you wrote your code in assembly, maybe with the exception of bespoke SIMD algorithms. Writing assembly is something only kernel developers and microcontroller developers may need to do in their day to day life.

Reading assembly is still a valuable skill, though, especially if you come anywhere near native code. What you think you wrote and what the CPU is actually trying to do may not be the same, and a small bit of manual debugging work can help you get started resolving crashes that make no sense whatsoever. No need to remember thousands of instructions either, 99% of assembly code is just variations of copying memory, checking equality and jumping anyway. Look up the weird assembly instructions your disassembler spits out, they're documented very well.

[–] leisesprecher@feddit.org 19 points 1 month ago (2 children)

Assembly is hard, because you need to understand your problem on multiple levels and get absolute zero guidance by compilers.

Even C guides you a tiny bit and takes away some of the low level details, so you have more mental capacity to actually solve your problem.

Oh, and you have a standard library. Assembly seems to involve solving everything yourself. No simple function call to truncate a string or turn a char array to uppercase.

Unless you're developing an OS or something, you'll probably be using the C standard library and maybe a bunch of other libraries provided by most distros. Just because you're doing assembly doesn't mean you need to program syscalls manually.

Modern assemblers also come with plenty of macros to prevent common mistakes and provide common methods. For instance. NASM comes with things like %strcat to do string concatenation.

I suppose the lack of compiler warnings can be a challenge, but most low-level compilers don't exactly provide guidance for when you design your program wrong.

No doubt Assembly is harder than Java or Python, but compared to languages like C, I don't think it's as hard as people pretend to it to be.

[–] gens@programming.dev 7 points 1 month ago

Missing ";" on line 148.

[–] CanadaPlus@lemmy.sdf.org 6 points 1 month ago (1 children)

I wouldn’t be able to write Rollercoaster Tycoon in assembly because keeping track of all that code in assembly files must be hell, but people pretending like you need to be some kind of wizard to write assembly code are exaggerating.

Well, they've got a point for the bigger machine codes. Just the barebones specification for x86 is a doorstopper IIRC.

From what I've heard, writing big stuff in assembly comes down to play-acting the compiler yourself on paper, essentially.

[–] skullgiver@popplesburger.hilciferous.nl 10 points 1 month ago (6 children)

From what I’ve heard, writing big stuff in assembly comes down to play-acting the compiler yourself on paper, essentially.

I think that's true for just about any programming languages, though the program you're "compiling" is a human understanding of what you're trying to accomplish. Things like val bar = foo.let { it.widget?.frub() ?: FrubFactory::defaultFrub(it) } don't come naturally to the human mind, you're already working through the logic required before you start typing.

As for the x86 instruction count: you don't need to know all of them. For instance, here's a quick graph of all of the instructions in systemctl on my system:

With the top 15 or maybe to 25 of these instructions, you can probably write any program you can think of, and what's missing will probably be easily found (just search for "multiply" or "divide"). You don't need to know punpckldq to write a program.

load more comments (6 replies)
load more comments (2 replies)
[–] geekworking@lemmy.world 39 points 1 month ago (1 children)

Look at mister fancy pants with and assembler.

How about entering straight opcode, operand with only a hex keypad and two pairs of 7 segment LEDs. You can only see one set of numbers at a time. You had to write it out on paper to be able to keep track and count positions so you don't use your spot.

I had to do this as a project in school. Two 8088 units that we breadboarded to a UART that we used to drive a fiber optic link to communicate with each other with a basic protocol. All descrete components hand wired and coded.

It made you tie all of skills together into a full system of hardware and software.

[–] SidewaysHighways@lemmy.world 13 points 1 month ago

Alright you and Joe McMillan had a great weekend we get it

[–] jaybone@lemmy.world 29 points 1 month ago (7 children)

Assembly used to be a required course for CS undergrads in the 90s. Is that no longer the case?

Also we had to take something called Computer Architecture, which was like an EE class designing circuits with gates and shit.

[–] CanadaPlus@lemmy.sdf.org 14 points 1 month ago (2 children)

Which target did you use? Having to learn even a fraction of modern x86 would be ridiculous, but SPARC or something could be good to know, just to reduce the "magic box" effect.

[–] 0x0@lemmy.dbzer0.com 17 points 1 month ago (1 children)

I learned MIPS as an undergrad. Pretty neat little RISC architecture.

load more comments (1 replies)
[–] jaybone@lemmy.world 6 points 1 month ago

This was a long time ago. I’m pretty sure it was 8086.

[–] LodeMike@lemmy.today 6 points 1 month ago

Its still a thing

load more comments (5 replies)
[–] abcd@feddit.org 27 points 1 month ago* (last edited 1 month ago) (1 children)

IMHO assembly isn’t hard. When you gain enough experience you start to see „visual patterns“ in your code. For example jumping over some lines often equals to a if/else statement or jumping back is often a loop etc. Then you are able to skim code without the necessity to read each line.

The most difficult part is to keep track of the big picture because it is so verbose. Otherwise it’s a handful or two of instructions you use 90+% of the time.

I needed it often in the past in the PLC world but it is dying out slowly. Nonetheless, when I encounter 30+ year old software I’m happy to be able to get along. And your experience transitions to other architectures like changing from one higher language to another.

Nonetheless, if I’m able to choose, I’ll take Go. Please and thank you 😊

[–] wewbull@feddit.uk 9 points 1 month ago* (last edited 1 month ago)

The most difficult part is to keep track of the big picture because it is so verbose. Otherwise it’s a handful or two of instructions you use 90+% of the time.

It's a long time since I wrote any assembly in anger, but I don't remember this being an issue. Back then Id be writing 2D and 3D graphics demos. Reasonably complex things, but the challenge was always getting it fast enought to keep the frame rate up, not code structure.

As you say, I think you just establish patterns to decompose the problem.

[–] Cethin@lemmy.zip 23 points 1 month ago (2 children)

Anyone who thinks OP asking about Assembly with this meme should play the game Turing Complete. It's great. You have to design a computer all the way from the most basic logic gates (I think you only get a NAND gate to start), designing an ALU and CPU, creating your own machine language, and writing your own programs in the language you designed, and it's all simulated the whole time. Machine language is pretty advanced as far as things go.

[–] bleistift2@sopuli.xyz 13 points 1 month ago (1 children)

From your description this sounds more like a job in IBM’s R&D department than a game

[–] Cethin@lemmy.zip 11 points 1 month ago (1 children)

All the best games sound like jobs when you describe them.

[–] desktop_user@lemmy.blahaj.zone 8 points 1 month ago

factorio, satisfactory, oxygen not included, RimWorld, Stellaris, dwarf fortress, gregtech new horizons...

[–] Cavemanfreak@lemm.ee 8 points 1 month ago

We got to do something simular in uni. We modeled the CPU in VHDL and had to set up our own language, then we were to program a game for it. One of the most fun and interesting courses we got to do!

[–] darklamer@lemmy.dbzer0.com 14 points 1 month ago

It's now been 18 years since the last time an employer paid me to write assembly, but it's only been a year or so since the last time I had to read assembly at work (in order to verify what the compiler really was doing).

[–] LavenderDay3544@lemmy.world 11 points 1 month ago

OS and embedded dev here. I use assembly all the time. I've even worked on firmware that was entirely in assembly of strict requirements that couldn't be met in C.

Also even machine code hides a lot about how the underlying machine works so if you really want to do computing from scratch you really do hate to invent the universe because there's abstractions all the way up the hardware stack just like there is in software.

[–] HStone32@lemmy.world 10 points 1 month ago (1 children)

Not exactly accurate, I think. Even machine language is bound by the CPU's architecture. You can't do anything in machine language that wasn't specifically provided for by the CPU architects.

It would be more accurate to say it's like creating a new universe using all the same laws of physics, thermodynamics, cosmology, ethics, etc as our existing universe.

[–] UNY0N@lemmy.world 6 points 1 month ago

I don't think accuracy was the goal, it is a joke not a dissertation. It's more about how it feels to try a language like assembly after working with higher-level languages.

[–] mrpalmer16@lemmy.ml 10 points 1 month ago

Ha! I teach assembly and use this one every year to lighten the mood before midterms.

[–] finley@lemm.ee 9 points 1 month ago (1 children)

I remember watching assembly demos in the early-mid 90s and thinking those guys were wizards

load more comments (1 replies)
[–] JoMiran@lemmy.ml 8 points 1 month ago (1 children)

In college back in 1991. Also had to do PASCAL and FORTRAN but thankfully those two were in a single course.

[–] expatriado@lemmy.world 12 points 1 month ago (2 children)

I also took PASCAL in the 90s, but it is considered a high level language, and writes similarly to other high lvl languages, assembly has a very different syntax

load more comments (2 replies)
[–] AFKBRBChocolate@lemmy.world 8 points 1 month ago (1 children)

I had an assembly class in college. I didn't love of at all. Got my first job after graduating and it was writing space shuttle engine control software, which was in assembly. I was kind of surprised at how fast it became natural after dealing with it full time. Still, it felt luxurious when we upgraded the controller and could do the software in C.

[–] leisesprecher@feddit.org 5 points 1 month ago

"oh no, I had to do literal rocket science"

[–] TunaCowboy@lemmy.world 7 points 1 month ago* (last edited 1 month ago)

Syscalls are sitting right there, and you can always just link libc...

[–] hanrahan@slrpnk.net 7 points 1 month ago

Not since the 1980s on a Commodore 64.

SYS64738

[–] NocturnalMorning@lemmy.world 6 points 1 month ago

I learned assembly for a few weeks when I first started a new job once (didn't even have anything to do with my job), and I always felt like my brain was tired after trying to write in assembly. Just took so much more mental concentration than writing in c for example.

[–] MyNameIsRichard@lemmy.ml 6 points 1 month ago (1 children)

Only on the VIC20 and Atari STe. On the VIC20 you had to write the assembler, manually convert it to machine code and enter that into the computer. There was a cartridge with an assembler, debugger and an extra 3.5Kb memory for it but I never got one.

load more comments (1 replies)
[–] Presi300@lemmy.world 5 points 1 month ago

Nah, I don't hate myself that much.

[–] NauticalNoodle@lemmy.ml 5 points 1 month ago* (last edited 1 month ago)

I've been studying Arm Aarch32 lately. I have a software development academic background but I have always been interested in Architecture.

[–] AllOutOfBubbleGum@lemmy.world 5 points 1 month ago

I was pretty into x86 asm in my teens. Nasm was my go to. Anyone else ever play with MenuetOS?

load more comments
view more: next ›