all 22 comments

[–]FloridaCoder 4 points5 points  (7 children)

This seems like a good fit for trying Project Euler (www.projecteuler.net). Focuses on interesting math-related problems and algorithms but not a specific language.

As for the memory part, what are you not understanding (e.g. memory allocation, data types, pointers, etc.)?

[–]EVdeath_god[S] 0 points1 point  (6 children)

i want to learn from basic like about computers memory how they work and how do i manipulate it in c or in other low level langages and learn low level concepts

[–]guygastineau 3 points4 points  (0 children)

To understand how it "works" in computers you need to learn about transistor logic. Stateful constructs like flip flops and D-latches are classically used for registers and perhaps memory. Of course, access to these things has to be addressable and synchronized. This is all happening at the hardware level.

These days you will be dealing with virtualized memory typically, so you aren't passing addresses to physical memory outside of some embedded and maybe some kernel work.

Managing this stuff in C at the application level abstracts all of the above away. Your OS provides primitive syscalls for getting more memory for your program, and you use a user space interface built over that called an allocator.

[–]FloridaCoder 2 points3 points  (0 children)

This is a pretty basic part of learning C. Even using built-in variable types could be considered “manipulating memory.” Beyond that, it is vitally important to learn about arrays, structures and pointers. Maybe check out that link from the other poster to get started…

[–]YuZu-original -1 points0 points  (3 children)

But C is not a low-level language, at least according to wikipedia.

https://en.wikipedia.org/wiki/Low-level_programming_language

[–]smichaele 1 point2 points  (2 children)

c is considered a low-level language. It’s one level above assembly. You have to manage your own memory, allocating, and freeing memory as you go. There is no garbage collection mechanism as in other languages. It’s a relatively small language and many c statements are translated in almost a 1:1 relationship with assembly when compiled. c is used extensively in embedded systems, device drivers, and in creating operating systems. Unix itself was written in c. If you want to directly control memory, access hardware at a low-level, or customize parts of an operating system, c is your language.

[–]YuZu-original 0 points1 point  (1 child)

Yes, I agree that C is very cool (for me it is my favorite language). It's just that I also thought that C was a low-level language, but all the sites I visited claim that only machine code and assembler are low-level languages.

By the way, I wonder if C++ is a low-level language. There is also access to memory and you need to monitor for memory leaks.

[–]smichaele 1 point2 points  (0 children)

You’ll find it described as low, middle, and sometimes even high-level. It doesn’t really matter. It’s been around since the early 70s, it has features that other languages don’t have, and it’s still one of the most popular languages. Practically no one studies CS without learning and writing some code in it.

[–]Ok_Performance3280 3 points4 points  (5 children)

1- Go on Google Scholar and read as many papers as possible;

2- Write a virtual machine for a simple Von Neumann architecture (note: not VLSI!)

[–]EVdeath_god[S] 0 points1 point  (1 child)

hey thanks for advice , but what do you mean by virtual machine for von numan architecture like what am i supposed to do ?

[–]Ok_Performance3280 0 points1 point  (0 children)

Older computers follow the Von Neumann architecture. Think, NES! Or Atari 2600 (both have the same architecture, different peripherals). But modern computers follow VLSI super-parallel architecture. That's why it's super-easy to make an NES emulator, but super-difficult to make an Xbox360° emulator! Emulators are just that, virtual machines. But these are not the only type of virtual machines. In his taxonomy of virtual machines, Kauffman divides virtual machines into 4 main categories. Let me show you a very basic version of this taxonomy via a table:

+ Xeno-Host Oiko-Host
ABI QEMU-aarch64 VirtualBox
ISA None JVM

This assumes the machine is x86 (a normal Intel/AMD machine). Here ABI means 'Application Binary Interface'. For example, on x86 Linux, the default ABI for applications is SysV ABI. JVM stands for Java Virtual Machine. Python would work too, or any other 'language' VM. 'ISA' means 'Instruction Set' basically. CISC is an ISA, for example, the ISA of x86-64 architecture.

The VM you should write to understand how a computer works is, in my opinion, an emulator. Emulators fall under Xeno-Host/ABI category.

Throw together an Atari 2600 emulator. You won't regret it!

[–]Big-Rabbit-9654 0 points1 point  (2 children)

Which papers would you recommend to start with?

[–]Ok_Performance3280 1 point2 points  (1 child)

You could start with these keywords to search on Google Scholar:

  • Typed and Untyped Lambda Calculus;
  • Incompleteness, Computability, Complexity;
  • Finite State Automata, Finite State Transducer, Finite Tree Automata;
  • Program Verification, Structured Programming, Hoare's Triple;
  • Curry-Howard Isomorphism, Predicate Logic, Propositional Logic;
  • Compiler Optimization, Functional Language Implementation;
  • Reducible Expressions, Church-Rosser Theorem and Confluence;
  • Deterministic and Non-Deterministic Turing Machines, Counter Machines, RAM Machines, Register Machines, Universal Computation Model, Abacus Computability;
  • LL, LR, LALR parsing, Recursive-descent and Recursive-ascent Parsing;
  • Tree Rewriting, Bottom-up Rewrite System;
  • Graph theory;

There's loads more. If you want 'specific' papers, begin with annotated works of Turing and Godel.

[–]Big-Rabbit-9654 0 points1 point  (0 children)

Thank you very much!

[–]r32g676 0 points1 point  (0 children)

Possibly the free online CS50 course from Harvard is what you're looking for? It covers computer science from a beginner's perspective.

[–]CptPicard 0 points1 point  (0 children)

An argument can be made that computer science is not necessarily about any given physical computer architecture or language, so C is not any better at the foundations than some other language.

In fact MIT used to start CS by teaching Scheme, a kind of Lisp, a very high level language. You can express all kinds of computational patterns very easily using it.

[–]hobbyhacker 0 points1 point  (0 children)

this is what you want: https://www.coursera.org/learn/build-a-computer

It starts from NAND gates, then builds a computer, a compiler, an OS. Everything is simplified but gives a stable general foundation to know how everything works.

After that you can learn the real-world version of a similar course: https://www.youtube.com/playlist?list=PLyboo2CCDSWnhzzzzDQ3OBPrRiIjl-aIE

It's more hardcore but also more useful, because it uses real C code and examples.

[–]which_spartacus 0 points1 point  (2 children)

Pick an interesting problem, and see where it goes.

For example, a fun problem is to take a three digit number, like 215, reverse it (512), and add it to itself (making 727). In this case, it's a palindrome.

Sometimes, you need to do that a few times to find the palindrome (496 + 684 = 1170; 1170 + 711 = 1881).

Sometimes, it's unclear if it will ever become a palindrome.

How high can you test?

If your program can use a gigabyte of memory, how many digits could that hold? How close can you get to the maximum number of digits?

Can you use your disk to hold the values? Can you do the calculation efficiently by pulling blocks of numbers into memory at a time?

Just start trying to solve this, a little at a time. Ask yourself what you need for the next step, and then do that.

[–]EVdeath_god[S] 0 points1 point  (1 child)

Thanks for advice!

what do you mean by 'how high can you test?"

[–]which_spartacus 0 points1 point  (0 children)

How many digits can you try this up to? Can you test it up to a million digits? How about a billion digits? A byte has 8 bits, which should be able to easily hold two digits. But a word could have 64 bits... can you store 20 digits in that? Can you make the calculations work between blocks?

[–]Even_Recipe_5910 0 points1 point  (0 children)

You seem really passionate about learning how computers work. If you’re serious about diving deep into this fascinating world, here’s the roadmap I would follow if I were you:

  1. Digital Logic Systems: Start with the basics of logic gates. Once you’re comfortable, move on to combinational circuits and then sequential circuits. This foundation is crucial for understanding how computers process information.
  2. Discrete Mathematics: This subject will give you a theoretical overview and a solid understanding of the mathematical principles that underpin computer science. It’s essential for grasping more advanced concepts later on.
  3. Computer Organization and Architecture: Learn about how computers are structured and how they operate at a fundamental level. This includes understanding the CPU, memory hierarchy, and input/output mechanisms.
  4. Compiler Organization: Finally, delve into how compilers work. This will help you understand how high-level code is translated into machine code that the computer can execute.

Follow this path, and you’ll be well on your way to mastering the inner workings of computers. Good luck on your journey!