5 ms·
Imagine what you could do with a smartphone if it were programmed entirely in assembly.
by jacquesm 3y ago
Imagine what you could do with a smartphone if it were programmed entirely in assembly.
- simulosius 3y agoWhy would anyone want to program a smartphone entirely in assembly? There is a reason (well actually there are many) that the vast majority of software development these days is done using more advanced languages.
- jacquesm 3y agoCost. Convenience. In that order.
- simulosius 3y agoCost? Please explain why writing programs in assembly is supposed to be *cheaper* than writing programs in a higher level language? The same goes for convenience: Since when is writing an application in assemlby more convenient than writing an application in a modern language?
- jacquesm 3y agoNo, it is more expensive. And less convenient. For some reason you interpreted both of these the wrong way around. I wasn't answering the question, I was giving examples of those reasons. Which are pretty obvious.
- simulosius 3y agoAh sorry, my bad! Makes a lot more sense this way ;-)
- jacquesm 3y agoIt certainly does :) I should have quoted that bit though to make it clearer.
- squeaky-clean 3y agoHow about security? I would never want an app written entirely in assembly to be allowed to take in arbitrary user input from the public internet. Cross-platform support, which you might argue just falls under convenience, but if you're writing for a different CPU architecture, you've basically written 2 separate programs now and not one.
- rep_lodsb 3y ago>How about security? I would never want an app written entirely in assembly to be allowed to take in arbitrary user input from the public internet. As opposed to one written in C, or a scripting language? When you are coding every arithmetic operation by hand, it is trivial to detect e.g. integer overflows. And even produce the mathematically correct result for operations that temporarily overflow a 32/64 bit register. (The exception is RISC-V, which seems designed exclusively as a target for C compilers and makes these operations more costly, thus guaranteeing that they won't be used even by compilers for safer languages) Assemblers also won't remove any instruction you write because of reasoning about "undefined behavior". They won't change constant-time code into something that isn't. There is a "soft limit" on the complexity of hand-written code, which encourages thinking more carefully about the design, and using data representations that are a good fit to both the problem and the machine. Yes, all of that is more work, and requires specialized knowledge. But what I don't understand is why most programmers today think that is a bad thing?
- squeaky-clean 3y ago> But what I don't understand is why most programmers today think that is a bad thing? I think it's a bad thing because I disagree with you that you'll write fewer bugs because you're coding everything by hand. In my experience how much manual work you need to do correlates 100% with how many bugs the software will have.
- johnnyworker 3y ago> Yes, all of that is more work, and requires specialized knowledge. But what I don't understand is why most programmers today think that is a bad thing? Gotta love how when someone makes an wrapper around one feature of ffmpeg weighing over 100 MB, some say that's making great tools more accessible, and is saving the original dev so much time (and the gazillion people who will maintain it forever, because that's not the vanishingly small exception but the norm, The Thing That Must Be Planned For). But when someone says the think making really tiny and bloat-free things by hand, and with 10x times the effort, the sky is falling, and people put more energy into denouncing what a human can achieve, vs. what modern compilers can do, than it would take to code the thing in brainfuck. I think it's the corporate focus. Some people think doing something for money, and to multiply money, is intrinsically more "serious" than doing it for the love of it, or just for fun, and with no more of a goal in mind than skipping stones. And I think trauma plays a role, too: Someone mentions making a vanilla whatever (and it doesn't get more vanilla than assembly... it's the opposite of using a framework to be able to make 5 apps in 3 days), and people instantly come swarming to talk about the nightmare of inheriting that "code base".
- kwhitefoot 3y agoWhy would you be able to do more, or indeed less, with it programmed in assembly rather than a higher level language? There isn't anything about assembly language that makes it inherently more effective or efficient than a high level language.
- jacquesm 3y agoYour executables will be a small fraction of the size that you expect, you will likely be able to fit the whole thing in cache and you will consume less power because you will be happy with a smaller cycles budget so you can run the cpu much slower. Of course this all comes at a price: decreased programmer efficiency.
- rafram 3y agoI don’t think that’s actually true. Compilers write machine code that’s often much more efficient than anything you could think up by hand, and the bulk of the disk space/memory used by a modern executable is for resources/strings, not instructions. Stereotypical assembly code - extremely lean routines that accept minimal user input and don’t create human-readable output - is indeed smaller than a stereotypical compiled executable, but you’d have trouble beating the compiler 1:1 on the same problem.
- jacquesm 3y agoBut you won't be writing the same code as the code that you would write in a high level language, and that is sort of the point. You're going to do your utmost not to write such code because then you might as well break out the C compiler.
- djur 3y agoAssuming that such code is suitable or even feasible for the problem you're attempting to solve. High-level languages were created specifically for the purpose of writing large, complex software systems. We don't see assembly being used for those systems. Isn't there an argument that high-level languages are simply more fit for that purpose?
- cultofmetatron 3y agoassembly? the current standard is kotlin or swift which while reasonably performant, leave a lot on the table. i'd love to have first class support for writing android and ios applications in rust. plenty fast enough for me. my day job is elixir but the memory requirements are a bit high for mobile apps (though I'm sure the guys at nerves would disagree)
- HeckFeck 3y agoDidn't we have something similar to that with the early DOS-based palmtop PCs?
- jodrellblank 3y agoYou could make a device that was slower than Window CE and go bankrupt! https://news.ycombinator.com/item?id=36570062 https://news.ycombinator.com/item?id=36570062
- wyldfire 3y agoWeird. I just tried it and it seems to be bootlooping now. Hmm. maybe there's a bug in one of the lines of someone's code. Guess I better get started investigating it. 'Cause once I'm done I've got to start porting it to RISC-V.
- xigency 3y agoI’m sure it would be very fast at booting and fast at crashing as well. However, on the Android side it’s probably what’s needed to compete with Apple hardware and software.
- petabytes 3y agoKolibri OS was written entirely in Assembly. I think the performance was pretty poor compared to C operating systems. Much easier to write optimized algorithms in high level languages. https://kolibrios.org/en/ https://kolibrios.org/en/
- ReactiveJelly 3y agoThe real problem is that I don't control all the code. If I had millions of person-hours to RE all the apps I hate, I'd just write them in Rust or something.
- kaba0 3y agoYeah, let’s leave it up to people to allocate registers, they are surely consistently good at it throughout whole code bases /s In general, writing something in assembly won’t be faster. Some expert can in certain cases come up with a better hot loop in asm, but for larger scopes we can’t be as diligent as a machine can be.