comp-sci

Discord ID: 423219052849397773


17,577 total messages. Viewing 100 per page.
Prev | Page 3/176 | Next

2018-03-29 16:40:50 UTC

Programmers that never looked at any library, any API, don't know what the usual names of things are.

2018-03-29 16:41:10 UTC

Then they shove a bunch of generic names everywhere with no meaning.

2018-03-29 16:41:52 UTC

It's interesting to see, after you go through a lot of bad code, how important having a shared vocabulary is.

2018-03-29 16:42:33 UTC

I worked on a project where a `Connection` object was actually a tuple, and had one method, named `cleanup()` that manipulated data in another class.

2018-03-29 16:43:20 UTC

And the class that would usually be called a `Connection`, with methods analogous to `send()` and `receive()` was called `Interaction`.

2018-03-29 16:44:25 UTC

Of course, the methods weren't called that, they were called `push()` and `process()`.

2018-03-29 17:02:19 UTC

push()

2018-03-29 17:04:44 UTC

It was almost as if every name of class and method was created to mislead anyone else working with the code.

2018-03-29 17:05:24 UTC

So yeah, don't be "that guy" that doesn't know the name of things that everyone else knows.

2018-03-29 17:06:29 UTC

You should be curious to do things on your own without needing somebody to hold your hand, but also you should constantly check what other people created, to make sure you're not doing things completely wrong.

2018-03-29 17:48:47 UTC

How did you mark up the text?

2018-03-29 17:56:45 UTC

Google "Discord markdown".

2018-03-30 19:47:11 UTC

That took all too long

https://cdn.discordapp.com/attachments/423219052849397773/429366000173973525/Capture_2018-03-30-15-46-38.png

2018-03-30 19:50:07 UTC

Covered out the `http://localhost`?

2018-03-30 19:50:24 UTC

Its my public ip

2018-03-30 20:41:33 UTC

Share it

2018-03-30 20:42:03 UTC

Also, chrome? Really?
Might as well just use JS

2018-03-30 21:48:16 UTC

What do you use? Safari?

2018-03-31 00:06:41 UTC

One has to wonder, how much energy we're wasting worldwide because so many websites now offset computation and rendering to the client side.

2018-03-31 00:12:54 UTC

@Durtle02 Use firefox

2018-03-31 01:43:59 UTC

@Deleted User This is my life tonight.
```
.data

print: .asciz "%d\n\000"
scan: .asciz "%d\000"

.comm A, 32, 32
.comm B, 32, 32

.text
addr_A: .word A
addr_B: .word B
addr_scan: .word scan
addr_print: .word print

.global main

main:

stmfd sp!, {r0-r1, lr}

ldr r0, addr_scan /* r0 <- &addr_scan */
ldr r1, addr_A /* r1 <- addr_A */
bl scanf /* calls scanf */

ldr r0, addr_scan /* r0 <- &addr_scan */
ldr r1, addr_B /* r1 <- addr_B */
bl scanf /* calls scanf */

ldr r0, addr_A /* r0 <- addr_A */
ldr r0, [r0] /* r0 <- *r0 */

ldr r1, addr_B /* r1 <- addr_B */
ldr r1, [r1] /* r1 <- *r1 */

cmp r0, r1 /* compare r0 and r1 */
movgt r1, r0 /* move greater to r1 */
ldr r0, addr_print /* */
bl printf /* calls printf */

ldmfd sp!, {r0-r1, pc}

```

2018-03-31 01:45:29 UTC

@meratrix nigger is that assembly code

2018-03-31 01:45:37 UTC

arm assembly my dude

2018-03-31 01:45:41 UTC

why the fuck are you showing me that cancer

2018-03-31 01:45:48 UTC

cause it's my cancer

2018-03-31 01:46:39 UTC

two can play it that way nigger

2018-03-31 01:49:19 UTC
2018-03-31 02:25:47 UTC

``bl printf /* calls printf */`` comments could use more redundancy

2018-03-31 02:27:54 UTC

I guess it's useful for people not familiar with the mnemonics.

2018-03-31 02:28:13 UTC

But then, `cmp r0, r1 /* compare r0 and r1 */` ? That's just retarded.

2018-03-31 02:28:23 UTC

Gotta comment every line otherwise TA's give me shit

2018-03-31 02:29:33 UTC

they should be more worried the students know what their code means

2018-03-31 02:30:01 UTC

Back when I did assembly homework, I had to normalize a single-precision floating point number on a toy computer, that had only 256 bytes of RAM. And we had to write our own assembler.

2018-03-31 02:30:19 UTC

i'm learning 68k but im gonna learn ARM after that

2018-03-31 02:30:26 UTC

And whoever used the least instructions got bragging rights.

2018-03-31 02:30:37 UTC

which computer

2018-03-31 02:31:32 UTC

Oh, one that my professors used, I think it was created by a student a few years prior. Don't even remember the name.

2018-03-31 02:32:01 UTC

It was your typical two operand instructions, 4-bit instructions.

2018-03-31 02:32:03 UTC

interesting strategy. too obscure to cheat?

2018-03-31 02:32:34 UTC

I guess so.

2018-03-31 02:32:48 UTC

can i do your same assignment on 68k?

2018-03-31 02:33:17 UTC

I don't see why not.

2018-03-31 02:33:29 UTC

will it be easier then?

2018-03-31 02:33:41 UTC

Probably.

2018-03-31 02:34:02 UTC

I got bragging rights, by the way. Got my program to be even shorter than the professor's and the TAs' programs.

2018-03-31 02:34:19 UTC

By using the instructions themselves as constants.

2018-03-31 02:34:48 UTC

About 20% of the class couldn't make it fit in the 256 bytes.

2018-03-31 02:35:41 UTC

what book did they give you for assembly

2018-03-31 02:35:45 UTC

assembly is cancer

2018-03-31 02:35:58 UTC

^you probly like java

2018-03-31 02:36:05 UTC

^likes js

2018-03-31 02:36:13 UTC

Another we had to do was long division. Actually, now that I'm thinking about it, the 4-bit instructions one was to program long division. The architecture didn't have division. The normalization one was on an 8-bit instructions architecture. Same 256 bytes limit for both.

2018-03-31 02:37:10 UTC

well you've already said assembly is cancer twice. yet your computer needs it to run, js or no?

2018-03-31 02:38:22 UTC

We didn't get any book, the course was on computer architectures. We went through the design of various didactic architectures, then at the end some MIPS and IA-32.

2018-03-31 02:41:50 UTC

if i wanna play with ARM i should buy an rPi??

2018-03-31 02:42:02 UTC

There are plenty of ARM devices.

2018-03-31 02:42:39 UTC

yeah but its mainstream, deployable, versatile, so it's a good starting point?

2018-03-31 02:42:44 UTC

yee

2018-03-31 02:42:47 UTC

By all means, learn some assembly, it'll do you some good. But you don't really write programs in assembly; at least not if you want to finish coding it any time soon.

2018-03-31 02:43:04 UTC

Mainstream? Go for x86-64.

2018-03-31 02:43:50 UTC

You should know what compiled code looks like, specially if you want to have any hope of debugging code properly.

2018-03-31 02:44:11 UTC

Say, what a function call looks like.

2018-03-31 02:44:29 UTC

What an array access looks like.

2018-03-31 02:44:36 UTC

What a C string operation looks like.

2018-03-31 02:44:49 UTC

What an `if` or a `for` look like.

2018-03-31 02:46:16 UTC

But you don't really write any significant code in assembly. We have compilers for that; at which point the architecture is irrelevant - as long as the language is supported by the hardware vendor.

2018-03-31 02:47:23 UTC

well i thought ARM asm was big for embedded systems

2018-03-31 02:48:17 UTC

Dude, even NES games were made with compilers (or pseudo-compilers) back then.

2018-03-31 02:48:34 UTC

Embedded devices these days have plenty of RAM and CPU.

2018-03-31 02:49:13 UTC

When you program something for a raspberry pi, you do it in a high level language.

2018-03-31 02:49:49 UTC

well what do arm asm dudes get paid for?

2018-03-31 02:50:45 UTC

Usually people just run Linux on a raspberry pi, and thus they can use any language that runs on Linux + ARM.

2018-03-31 02:51:34 UTC

also, as far as my reasearch i was under the impression that all or most 8/16bit console games were coded in assembly. But as I'm learning I see it's all about sweettalking the Assembler with macros to let you write human-readable code

2018-03-31 02:52:56 UTC

What would often happen is, some essential routines would be written in ASM, and they would be glued with an "almost high-level language."

2018-03-31 02:53:21 UTC

sure like Doom used asm just for the column and span rendering

2018-03-31 02:53:57 UTC

Back then compilers were bad at optimizing.

2018-03-31 02:54:25 UTC

But they were perfectly fine for just calling routines that were written by hand in assembly.

2018-03-31 02:55:38 UTC

I don't want to say that you don't need assembly, it's just that it's not for software development; you need to understand it if you're doing specific tasks for optimizations, for instance.

2018-03-31 02:55:55 UTC

But you don't develop anything non-trivial in asm.

2018-03-31 02:56:13 UTC

Takes too much time, and the compiler does a better job than you overall.

2018-03-31 02:57:10 UTC

Even if you think the compiler can only do 90% of the optimizations you can do by hand... the compiler can work at 90% efficiency for the whole program, and never get tired, never make a mistake.

2018-03-31 02:58:08 UTC

So even people that enjoy working in assembly, they first profile the program to know the hotspots, and only optimize by hand the few parts that will actually make a difference.

2018-03-31 02:59:04 UTC

Even then, just because you think your code is better than the compiler's, doesn't mean it's actually faster.

2018-03-31 02:59:41 UTC

I dodnt think i'd ever be good enough at it to compete with the compiler

2018-03-31 03:00:32 UTC

This website is good, if you want to quickly play around with assembly output from various compilers.

2018-03-31 03:02:36 UTC

Simple test with ARM assembly.

2018-03-31 03:06:28 UTC

Try changing the `-Ox` argument to change the optimization level. Try `-Og`, `-O1`, `-O3`...

2018-03-31 03:07:47 UTC

Note how the compiler understands that both formulas end with `/2`, so that part of the code is common and get folded into the same code, if optimization is enabled.

2018-03-31 03:10:25 UTC

if I change -O0 it wont let me revert without reloading page

2018-03-31 03:11:39 UTC

Really? Click the compiler output at the bottom, it should open the full compiler output to the right.

2018-03-31 03:14:20 UTC

https://cdn.discordapp.com/attachments/423219052849397773/429478527474204681/godbolt-asm-test.png

2018-03-31 03:15:48 UTC

maybe it doesnt wanna play nice with Ublock Origin

https://cdn.discordapp.com/attachments/423219052849397773/429478895629107211/2018-03-30_20_12_06-Compiler_Explorer.png

2018-03-31 03:16:48 UTC

With `-fverbose-asm`, although the editor already uses colors to indicate what ASM line corresponds to what C++ line.

https://cdn.discordapp.com/attachments/423219052849397773/429479149372178435/fverbose-asm.png

2018-03-31 03:22:56 UTC

cool. kinda demotiviating to see the comparison

2018-03-31 03:35:14 UTC

the line correspondence is trippy here

2018-03-31 03:36:10 UTC

This is x86-64, so it's using the MMX/SSE registers for the floating point.

2018-03-31 03:36:34 UTC

Call convention allows the arguments to come in as registers instead of the stack.

2018-03-31 03:36:42 UTC

xmm0, xmm1, xmm2

17,577 total messages. Viewing 100 per page.
Prev | Page 3/176 | Next