Announcement

Collapse
No announcement yet.

Richard Stallman Announces GNU C Language Reference Manual

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • coder
    replied
    Originally posted by DavidBrown View Post
    I think you'll find people can create memory leaks in pretty much any programming language - whether memory management is manual like C, handled by RAII like C++, or automatic with garbage collection.
    I was going to say something to this effect, but it hinges on what we consider a memory "leak".

    Garbage-collected languages can't leak memory by completely losing track of it, but you can write programs that hold onto memory longer than necessary, thereby becoming bloated over time.

    Perhaps more dangerous are pseudo-garbage collected languages that simply rely on refcounting, like old Python or people getting carried away with C++'s shared_ptr<>. In those cases, the hazards are indirect cyclic references. In C++, you can use weak_ptr<> to break the cycles, but it means you need to pay attention to what you're doing and not just use shared_ptr<> with abandon. I'm reading that Python can now detect & handle indirect cyclic references, which is good news.

    Leave a comment:


  • coder
    replied
    Originally posted by DavidBrown View Post
    in Forth, you must manually control your data stack.
    Really? I wrote a bunch of Postscript, at one point, and I seem to recall that all the stack stuff was automatic. I'm not sure it had any heap memory, but it seemed like Forth was entirely stack-based. At least the version used in Postscript.

    Leave a comment:


  • coder
    replied
    Originally posted by kylew77 View Post
    Many students started to struggle when we got to pointers. I had people that excelled right up through standard arrays but when we got to dynamic arrays they couldn't keep up.
    Was it pointers or heap allocation that people really struggled with?

    When I told her I was teaching myself C, I remember a high-school teacher once warned that pointers would give me trouble. However, I'd already started using them and I remember thinking: "no, they're just like glorified index variables". I'm not sure I'd fully gotten my head around everything you could do with them, at the time. Probably my very first thought about pointers was: "neat, now I don't have to keep a separate array + index".

    Originally posted by kylew77 View Post
    our first language was python and I've since wondered would the world be a better place if we taught python first then C or is C needed because like they say it is better to learn stick first then automatic cars?
    Eh, I'd venture as far as to say that C is good starting point for understanding computers and how they work. If you really just want to learn about algorithms and data structures, then C is probably too low level. I feel like there's been pretty broad consensus on this, for a while now.

    Leave a comment:


  • DavidBrown
    replied
    Originally posted by baka0815 View Post
    DavidBrown
    I like type-safe compile languages. I hate debugging Python and running into run-time problems that could have been detected by a compiler. But maybe I'm not deep enough into Python to know how those things should be done.
    There are pros and cons of all aspects of programming languages. Dynamic typing gives you a lot of freedom and flexibility, but reduces the scope for compile-time or static checking. (There are optional type annotations in Python, and you can certainly do some static checking.) Python is a good language for some tasks, and a poor choice for others - just like anything else.

    In languages where you have to manually keep track of your memory and free it the moment you don't need it any longer you have to be aware of that very much. But if you are using languages with auto gc (Java, C# etc.) then you might already be spoiled and create one memory leak after the next...
    I think you'll find people can create memory leaks in pretty much any programming language - whether memory management is manual like C, handled by RAII like C++, or automatic with garbage collection.

    Leave a comment:


  • DavidBrown
    replied
    Originally posted by baka0815 View Post
    Is it a good idea to promote languages with automatic garbage collection first?
    I know the intention behind it (I think), but once you comfortable with automatic gc you may forget to manually free your memory with languages that don't have auto gc.
    Every high level language automates things for you. Even C, one of the lowest level of all high level languages, automates lots for you. It handles function calling, stack management, register allocation, variable lifetimes, and many other aspects. You can go lower - in Forth, you must manually control your data stack. Or you can go higher. For each language, some aspects are handled automatically by the language so that you can concentrate on the issues that are important to you, as the programmer. And when you move to a different language, there are different things you need to pay attention to yourself.

    IMHO, the most important aspect of learning your first language, is that you should enjoy it. And that means having results quickly - it means being able to write a program that does something, knowing only a small part of the language.

    Leave a comment:


  • kylew77
    replied
    Funny he mentions C shouldn't be one's first language. The undergrad school I went to taught C as the first language. When I graduated I became a GTA at a big state school and we taught C to all first year engineering students. Many students started to struggle when we got to pointers. I had people that excelled right up through standard arrays but when we got to dynamic arrays they couldn't keep up. I didn't complete my PhD at that school instead deciding to be a system admin someday and get a masters degree in ITM, our first language was python and I've since wondered would the world be a better place if we taught python first then C or is C needed because like they say it is better to learn stick first then automatic cars?

    Leave a comment:


  • baka0815
    replied
    DavidBrown
    I like type-safe compile languages. I hate debugging Python and running into run-time problems that could have been detected by a compiler. But maybe I'm not deep enough into Python to know how those things should be done.

    In languages where you have to manually keep track of your memory and free it the moment you don't need it any longer you have to be aware of that very much. But if you are using languages with auto gc (Java, C# etc.) then you might already be spoiled and create one memory leak after the next...

    Leave a comment:


  • coder
    replied
    Originally posted by DavidBrown View Post
    Scheme will teach you the importance of counting dozens of close parentheses in a row.
    🤣

    Originally posted by DavidBrown View Post
    To be a good programmer, you should work with a range of languages. But you don't want to be caught up in too many details at the start - a higher level language such as Python is a good choice for starters.
    Agreed... except that I remain uneasy about pushing Python as a beginners language. There's something about the way it handles mutability, on a per-type basis, that doesn't sit right with me and definitely seems like it should mess with programming newbies.

    Leave a comment:


  • DavidBrown
    replied
    Originally posted by baka0815 View Post
    Is it a good idea to promote languages with automatic garbage collection first?
    I know the intention behind it (I think), but once you comfortable with automatic gc you may forget to manually free your memory with languages that don't have auto gc.
    It is certainly a good idea to work first with a language that has a different balance between programmer efficiency and runtime efficiency. You get a lot more done, a lot faster, with Python than with C - at the cost of a lot more runtime memory and processing time. Working in different languages lets you learn different things. Python will let you get fast results for your efforts. C will teach you about getting the details right and working manually. Assembly will teach about what is really going on under the hood. Haskell will teach you about coding in a way that you can be sure is correct. Scheme will teach you the importance of counting dozens of close parentheses in a row.

    To be a good programmer, you should work with a range of languages. But you don't want to be caught up in too many details at the start - a higher level language such as Python is a good choice for starters.

    Leave a comment:


  • coder
    replied
    Originally posted by Developer12 View Post
    The FSF can and will use the "or any later version" clause to unilaterally relicence your work without your consent, should it suit their purposes. Do not include it.
    Yup. However, I think the downsides of taking liberties with the license is that they might not go to bat for you, if you find a violation and lack the resources to litigate it, yourself.

    Originally posted by Developer12 View Post
    This is to say *nothing* of the absolute absurdity of transferring the copyright of your work to them, which they demand for many GNU projects.
    Eh. This is simply pragmatic. If you want your project under the GNU umbrella and to use their resources and imprimatur, then it seems like reasonable demand. Nobody is making you contribute your project to GNU.

    If I'm reading this correctly, the Apache Foundation has a similar requirement: https://www.apache.org/legal/src-headers.html

    Originally posted by Developer12 View Post
    The bottom line: Don't trust the FSF to do what's right,
    Yeah, the re-licensing thing does cross a line, for me.

    Originally posted by Developer12 View Post
    They are not incorruptible
    Yes, but you haven't given an example of what I'd consider "corruption". IMO, the re-licensing thing is just them being overzealous in their mission. Still not great, if you're on the other side of it.

    Originally posted by Developer12 View Post
    concentrating all power over free software in one place was a Bad Fucking Idea from the start.
    Well, it's not. There are multitudes of options. They get credit for playing a central role in getting the ball rolling, but they aren't the sole guardians of the free software movement.

    Leave a comment:

Working...
X