4 ms·
I have done something similar with ruby, this is a great book: https://workingwithruby.com/downloads/Working%20With%20TCP%20Sockets.pdf https://workingwithruby.
by jvans 4y ago
I have done something similar with ruby, this is a great book: https://workingwithruby.com/downloads/Working%20With%20TCP%20Sockets.pdf https://workingwithruby.com/downloads/Working%20With%20TCP%2...
I would recommend doing C at some point in your career, nothing comes close in terms of forcing you to understand the hardware you are using.
- Mike_12345 4y agoThat was true in the 70's but C doesn't require that you understand much about modern hardware. https://queue.acm.org/detail.cfm?id=3212479 https://queue.acm.org/detail.cfm?id=3212479
- doodlesdev 4y agoIt still is more low level than any other language currently (that can be run on multiple architectures) which I think is what the OP was saying. If you compile C without compiler optimizations, it will generate code that is exactly what you wrote. The argument the paper makes is that the instructions available in modern processors and the way we use them to optimize code (such as instruction level parallelism) is a consequence of C being so important despite being made for much older and much simpler machines. Because if the generated binaries from any C compiler without optimizations isn't low level then you might as well say the same about x86 assembly, and then you're basically out of options.
- Mike_12345 4y agoBut it's not. It has become a high level language. The idea that C is still a low level language is no longer true. It is highly abstracted from modern hardware. Edit: I just saw your edited comment. Yeah the point is you really don't need to know much about the hardware to write C. It doesn't force you to understand what's actually going on behind the scenes.
- doodlesdev 4y agoYeah sorry about the ninja edit. Very often I reply to a comment without actually finishing and then edit it. I thought Hacker News was delaying my comments by 1 minute though according to my configs? Anyways, I agree that you don't really need a deep understanding of the hardware nowadays to write C, but my point is that it's still useful to learn because you still need more understanding of the hardware than you need to write something such as Ruby. The point the OP was making is that it still forces you to learn more about the hardware than other languages. Arguably, it also forces you to learn more about the software itself with things being much more explicit than in a modern complex language such as Rust. I'm also just not aware of _any_ language that actually maps well to what the CPU is doing nowadays since they are such complex pieces of silicon.
- Mike_12345 4y agoBut does it really force you to learn more about the hardware versus other languages? I am challenging that assumption or belief. C has memory pointers, but those are pointers in a flat memory space abstracted over the physical memory hierarchy. So yes, you do need to understand that the hardware has memory addresses and that pointers can reference memory addresses. Aside from that I don't see much difference to Java or Python in terms of requiring a deeper understanding. Even Python has bitwise operators.
- Kamq 4y ago> Aside from that I don't see much difference to Java or Python in terms of requiring a deeper understanding. The big difference would be that it requires you to understand the difference between stack vs heap allocation.
- Gibbon1 4y agoMy take is both C and the hardware are targeting the same abstract machine. It seems too that attempts shift things one direction or another haven't been successful. Itainium which tries to force the compiler to deal with instruction scheduling and parallelism, failed. Things like LISP machines also didn't do well. So thinking in terms of the abstract machine are valid for now. The exceptions mostly have to do with caching and understanding that processor can and does execute short sequences of instructions in parallel.
- _gabe_ 4y agoThis whole article seems to be picking a lot of nits. I didn't read it too deeply, so feel free to correct me if I'm wrong, but the biggest complaints highlighted in the article are: 1. Modern CPUs use instruction level parallelism (ILP) 2. Memory isn't linear (you have separate caches, L1, L2, L3 and main memory) If you've ever debugged a C or C++ program in release, you've quickly found out about ILP. The code still maps relatively close to the hardware, it just won't run in the sequential order you've provided it in. Many C and C++ programmers know this and try to make the implicit assumptions in their code explicit to allow the compiler to reorder instructions more easily/reduce memory dependency chains[0]. And I'm sure you've heard several proponents over the past few years (Mike Acton comes to mind) espousing data oriented design. This is an entire code methodology intended to help the CPU caches, and it shows an implicit understanding that memory is not linear. Heck, most C/C++ programmers realize that they're using VRAM all the time, and the memory locations they get aren't necessarily backed by physical memory until the OS sorts it out. This is especially transparent if you've ever done any sort of memmapping with files or played with virtual memory. Anyways, C doesn't necessarily map directly to the hardware, but it's a heck of a lot easier to intuit what a C program will end up doing on the CPU vs what a Python program will do. And most C/C++ programmers realize this fact, and actively write code to utilize the fact that C does not map directly to hardware. [0]: https://johnnysswlab.com/instruction-level-parallelism-in-practice-speeding-up-memory-bound-programs-with-low-ilp/ https://johnnysswlab.com/instruction-level-parallelism-in-pr...
- josephg 4y agoYeah. Also, learning C is still probably the best way to learn how raw pointers work. And pointers underpin everything - even if you spend your life in Python or Java. When I was teaching programming, it was always a rite of passage for my students to implement a linked list in C. Once it clicked for them, the world of programming opened up. C is also still the universal glue language for FFI. Wanna call Swift from Rust? You can always reach for C.
- Mike_12345 4y agoLikewise it is possible to write optimally performing Java code if you know how what what's going on behind the scenes. https://lmax-exchange.github.io/disruptor/disruptor.html https://lmax-exchange.github.io/disruptor/disruptor.html
- sitzkrieg 4y agoid recommend assembly language to really achieve this. the further away you get from x86 the more enjoyable it seems to be fore a human. skilldricks easy6502 is a really good start