Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Technically it ends up as machine code (assembler is a more human-readable version of that), but in any case you're not actually writing assembler, you're writing C, Swift, Cobol. It doesn't count as "using assembler".

--Eric
 
Any compiled language - C, Swift, COBOL - ends up as assembler.

But some languages allow the compiler to do more optimizations, and/or allow syntax that can directly hint at some near hand-coded assembly language optimizations (NEON intrinsics from the C subset of Objective C, etc.)
 
Java is verbose, but unless your issue is with OO in general then it's a pretty decent C-Style language with a ton of open source frameworks and libs. It's understandable though, 'Java is terrible' was what I thought when I first started out.

It's not that I don't know how to write Java (I do) and the language being verbose isn't a major factor (Objective-C has some of that as well), but, in my opinion at least, it "feels" heavier than other languages that I prefer. (Mainly Swift and C#. I'm not too fond of Objective-C, either, but I'm used to it because I have to for iOS development.) It's why I haven't stopped learning about Android development (and I refuse to make Java an excuse not learn it). It's just not that fun to learn with Java and if Google were to add another language to use instead like Apple has done with Swift, I would be okay with it.

If someone hired me to make something in Java, I'll do it with the best of my ability. I don't have to like it, though.
 
  • Like
Reactions: JoshDoug and John.B
But some languages allow the compiler to do more optimizations, and/or allow syntax that can directly hint at some near hand-coded assembly language optimizations (NEON intrinsics from the C subset of Objective C, etc.)

Indeed. With modern CPUs with branch prediction and pipelines, a modern compiler can create code to take advantage of these feature that you might miss if hand-coding. See this article http://www.tachyonsoft.com/s8192db.pdf (ok, it for IBM mainframes, but the principles are the same).

I like this example:

5 cycles per iteration

LA R2,STRING .R2 points to start of 'STRING'
LHI R3,L'STRING .R3 = length of 'STRING'
FIND1 CLI 0(R2),0 .Compare what R2 points to to x'00'?
JE FOUND .If equal, branch to FOUND (end of 'STRING' found)
LA R2,1(,R2) .Unequal - point R2 to next character of 'STRING'
BRCT R3,FIND1 .Decrement R3 and if not 0, branch back to FIND1

-vs

4 cycles per iteration

LA R2,STRING
LHI R3,L'STRING
FIND2 CLI 0(R2),0
LA R2,1(,R2)
JE FOUND
BRCT R3,FIND2


where the 'logical' order of instructions i.e. doing the branch immediately after the compare and then checking if you should loop immediately before doing the loop is slower than doing these things in the 'wrong' order:

compare
update pointer (not needed if equal)
branch if equal
loop if not


Of course, you can argument that one CPU cycle is not worth the loss of readability.


But a hand-written assembler program will usually beat a compiled one for performance, even if some bits are slightly slower.
 
Last edited:
It's not that I don't know how to write Java (I do) and the language being verbose isn't a major factor (Objective-C has some of that as well), but, in my opinion at least, it "feels" heavier than other languages that I prefer. (Mainly Swift and C#. I'm not too fond of Objective-C, either, but I'm used to it because I have to for iOS development.) It's why I haven't stopped learning about Android development (and I refuse to make Java an excuse not learn it). It's just not that fun to learn with Java and if Google were to add another language to use instead like Apple has done with Swift, I would be okay with it.

If someone hired me to make something in Java, I'll do it with the best of my ability. I don't have to like it, though.

I kind of get that you find it "feels" heavy, sort of (writing groovy unit tests can be a nice change of pace tbh), and I can totally get on board with it not being particularly enjoyable to learn, the culture and community around it just isn't exciting either. It's a serious language that's big in the enterprise. Although I'd personally much rather be using Rust, Swift, or heaven forbid.. Go.
 
  • Like
Reactions: Junior117
With modern CPUs with branch prediction and pipelines, a modern compiler can create code to take advantage of these feature that you might miss if hand-coding.

A good assembly language programmer has the advantage that they can look at the output of one or more optimizing compilers, profile the resulting code on the target processors, and see what all those compilers missed (e.g. unneeded dependencies, or opcode sequences that the compiler writers didn't know about or found too complicated to safely include in the general case, etc.).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.