I'm not a C engineer, but I think I have an interesting recommendation to consider. Since you are already familiar with other languages, you obviously don't need to know the basics of C. The basics are the same everywhere. Instead, you'd likely want to build that mindset on how to build good software with C. I suggest you read other people's code and try to deep dive into the whys. I heard Redis is a well-written sof…
Ask HN: Learn C in 2023?
151–160 of 220 posts
Re: Ask HN: Learn C in 2023?
#152Re: Ask HN: Learn C in 2023?
#153I like firearms as an analogy here. Rust is like a modern rifle, unloaded, with six safeties and three locked triggers in a gun safe. The ammunition will harmlessly self-destruct if you don’t focus properly before firing. C is sort of like Rust except the rifle is on the couch, loaded, one in the chamber, all the safeties are off, the numerous open triggers are held by RNGs, and the business end is pointed right at y…
Ha. Confession time: I came to this thread to Ctrl-F for "Rust" to find the Rust-C fisticuffs. And this answer is like what I would expect if I said "ChatGPT, write me a reddit-style Rust defense that would rustle some jimmies." I'm about equally capable at both Rust and C - I could pass a 1st year undergrad CS course using either, but I'm no better than that. I know C has its place - its marketshare of embedded devi…
Re: Ask HN: Learn C in 2023?
#154Earlier quoted context omitted.
If you're just beginning with C, it doesn't matter. If anything, it's better to be exposed to these unsafe practices and make mistakes with them in the very safe environment of your own home, where absolutely no one cares what you're doing. K&R C is an excellent learning resource primarily because it's extremely strong pedagogically. Read K&R and then move onto something else later when you're done with it. If you ev…
C is one of those things that unless you have proper testing, tooling and linting you don't know if you code is incorrect. It may have subtle memory bugs, rely on undefined behavior or crumple in exploitable ways under bad input. Having a feedback loop is really important in learning and improving. Undefined behavior helps subvert it. For the exact example of above, how would a developer learn not to use gets? The be…
If you continue using C, then you should eventually learn this stuff, but to overburden someone with a list of 100 things they must do right is the surest way to frustrate them to the point where they give up.
If OP eventually writes C code that goes into production for a company, it is the company's responsibility to have procedures and safeguards which ensure that OP writes reasonable code. Ideally, one such safeguard will be a senior colleague to introduce them to the thornier parts of C.
To expect a beginner to learn all of the finer points of a topic from the start is bad pedagogy.
On the other hand, K&R provides a set of exercises which are fun, graded, interesting, and challenging. By the time you finish them, you have a working knowledge of a large and useful subset of C. You can then proceed to reading another book (or consulting some other reference). Invariably, you will find that they disagree with K&R to some extent. Learning to spot these differences and begin to understand how C has evolved is itself an important lesson.
Re: Ask HN: Learn C in 2023?
#155I'm not a C engineer, but I think I have an interesting recommendation to consider. Since you are already familiar with other languages, you obviously don't need to know the basics of C. The basics are the same everywhere. Instead, you'd likely want to build that mindset on how to build good software with C. I suggest you read other people's code and try to deep dive into the whys. I heard Redis is a well-written sof…
Fully agree with the principle but maybe let's not call Redis "well-written" :) Redis is a great piece of software because of how much it impacted the "evolution" of Internet not because of the code quality, Redis's code resemble spaghetti code, a lot. I will push myself and say that nowadays people would get fired for writing code like that! And before someone start to throw stones (just for the sake of it), here a…
Re: Ask HN: Learn C in 2023?
#156One thing I always loved about C was how easily you could slip in and out of x86 assembler with the __asm__ tag. There is no ceremony & it seems like magic. Like if you have 3 C int's a,b & c, and you want to add a & b and store the result in c, you would do: __asm__ ( "addl %%ebx, %%eax;" : "=a" (c) : "a" (a) , "b" (b) ); Then you could just continue in C as if nothing had happened, and a printf("%d",c) would give y…
Man, that is one complex, interconnected and interesting System! I would love to work on something like that even if it is just maintaining a legacy product. Seriously, let me know (contact in my profile). On similar lines, I have been thinking of using Erlang/Elixir for distributed programming over the Web (even in the browser if possible) and dropping down to C/C++ and J programming languages as required on individ…
Re: Ask HN: Learn C in 2023?
#157I'm not a C engineer, but I think I have an interesting recommendation to consider. Since you are already familiar with other languages, you obviously don't need to know the basics of C. The basics are the same everywhere. Instead, you'd likely want to build that mindset on how to build good software with C. I suggest you read other people's code and try to deep dive into the whys. I heard Redis is a well-written sof…
Fully agree with the principle but maybe let's not call Redis "well-written" :) Redis is a great piece of software because of how much it impacted the "evolution" of Internet not because of the code quality, Redis's code resemble spaghetti code, a lot. I will push myself and say that nowadays people would get fired for writing code like that! And before someone start to throw stones (just for the sake of it), here a…
Re: Ask HN: Learn C in 2023?
#158I'm not a C engineer, but I think I have an interesting recommendation to consider. Since you are already familiar with other languages, you obviously don't need to know the basics of C. The basics are the same everywhere. Instead, you'd likely want to build that mindset on how to build good software with C. I suggest you read other people's code and try to deep dive into the whys. I heard Redis is a well-written sof…
It's funny because I would never think that this is a good way to learn a codebase. Code changes completely through time, and early phases where nothing is set can be extremely messy and filled with constant refactorings. Commit messages are rarely good. I would rather try to learn a codebase looking at the latest state and the docs.
It is NOT for learning the codebase.
It is for learning how to program in C.
Re: Ask HN: Learn C in 2023?
#159Earlier quoted context omitted.
If you're just beginning with C, it doesn't matter. If anything, it's better to be exposed to these unsafe practices and make mistakes with them in the very safe environment of your own home, where absolutely no one cares what you're doing. K&R C is an excellent learning resource primarily because it's extremely strong pedagogically. Read K&R and then move onto something else later when you're done with it. If you ev…
I've taught C at university level, and used to give crash courses to new college grads and interns in industry. The one thing I impart the most from the beginning is to develop good instincts for secure interfaces. You should be able to look at function signatures and see alarm bells for unsafe practices. For someone skilled at C this is second nature, you can see bad practices from a distance, often at the function…
Re: Ask HN: Learn C in 2023?
#160Earlier quoted context omitted.
Fully agree with the principle but maybe let's not call Redis "well-written" :) Redis is a great piece of software because of how much it impacted the "evolution" of Internet not because of the code quality, Redis's code resemble spaghetti code, a lot. I will push myself and say that nowadays people would get fired for writing code like that! And before someone start to throw stones (just for the sake of it), here a…
Here's one example of when to commit auto-generated code: if you use a tool like Cython and want to distribute sources to an end user, it is frequently recommended to distribute the C sources generated by Cython instead of the Cython code itself. The given reason is that the end user may not have access to Cython, but will likely have access to a C compiler. (This is frequently the case on scientific clusters where u…
The fact that "can be done" doesn't necessarely mean that "it's the right way" to do it.
Going back to embedding auto-generated code, focusing on this specific case, are you telling me that a line in the requirements.txt, on a machine where the user is expected to have access to a compiler, is the reason to keep auto generated code in the repository? Sorry, personally it seems a flaky reason.
Also, the very fact that you mention that users don't have superuser privileges should be even more of a reason to use virtual environments, where you don't need super privileges, or if you can't or want to use virtual environments you can still have multiple paths in the PYTHONPATH env variable and you can install packages in a specific paths leveraging the --target of pip or the PYTHONUSERBASE env variable, solving the issue as well.
I would prefer to suggest my users to improve their runtime environment than enable them to improve the chaos.