is C appropriate for intro to computers?

This is a discussion on is C appropriate for intro to computers? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; To me it makes languages like C# a little more ambiguous since you just have to infer that everything is ...

  1. #181
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    To me it makes languages like C# a little more ambiguous since you just have to infer that everything is a reference while logicially assuming it may not always be one. So I don't think that was the world's finest example of your point C_ntua. I would rather explicitly know what is what.

  2. #182
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,622
    I don't think this is a very good example, though.
    Are you talking about practically as a language (ie, it falls short of other languages) or in terms of newbie friendliness?
    Btw, there's a bug in the code (both Java and C++). Can you spot it?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #183
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Quote Originally Posted by Elysia View Post
    I don't think this is a very good example, though.
    Are you talking about practically as a language (ie, it falls short of other languages) or in terms of newbie friendliness?
    Btw, there's a bug in the code (both Java and C++). Can you spot it?
    Two bugs. One return; and the other didn't put { for else.

    I am talking about newbie friendliness! On the contrast, if you are not a newbie I agree with what master5001 said.
    But the topic is about "intro".

    EDIT: To elaborate more. You tell the newbie "See, you can pass objects as you can pass variables in functions using Java". In C++ you tell them "See, you pass a pointer/reference of the object since you don't want to create a copy of the object. The same as you do with variables". Why would the creators of C# have the default pass (no extra symbols or key words) be by reference and why would the creators of C++ have the default pass be by value? Because one is more focused on OOP the other is C with OOP features.
    Effectively there is just syntax differences. But the syntax of a language makes it more or less easy to understand some basic programming ideas.
    Last edited by C_ntua; 10-14-2008 at 02:02 PM.

  4. #184
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,622
    I don't think it matters, though, because they still need to know about the whole thing with variables and references in the first place. And if they learn that, they can learn to append &.
    Next example, please?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  5. #185
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,749
    Quote Originally Posted by C_ntua
    You tell the newbie "See, you can pass objects as you can pass variables in functions using Java". In C++ you tell them "See, you pass a pointer/reference of the object since you don't want to create a copy of the object. The same as you do with variables".
    If you wish, you can ignore the cost of the copy for pedagogy reasons, and introduce it later when you want to teach about pass by reference. It is a matter of approach. Consider that Java is not immune to the difference either: eventually, you have to explain that although Java only has pass by value, you do not actually pass objects, but "references" to objects. I have witnessed this difference tripping up beginners to Java.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  6. #186
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    Just to second what laserlight said - that's been a legitimate problem with some "noobs" I work with. A fairly inexperienced programmer was working with a multi-threaded application and didn't understand why his code was causing problems. He was passing by reference, and changes were being made to the same object twice, and it ended up causing unpredictable results - he thought new copies of the object were being created every time - he didn't even know the first thing about addresses.

  7. #187
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,622
    That is seriously disturbing...
    (Although I still fail to see how he was able to "pass by reference", this being C [unless you're talking about C++?] )
    You should probably have that guy fired in one way or another. He seriously needs to get back to studying the language.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  8. #188
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Although I still fail to see how he was able to "pass by reference", this being C
    This being C, a language without references, you can talk about byref passing without tripping over the ambiguity.
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  9. #189
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,622
    I still don't buy it, though. In C, it's pass by pointer, nothing more, nothing less
    Although that's just a formed opinion...
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #190
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,472
    And If my sources are correct, the term "passing by reference", predates C++ and was always used to describe pointer arguments in C
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  11. #191
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,622
    Hey now, no need to get hung up on an opinion.
    You've already mentioned this more than once.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  12. #192
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,472
    What opinion?
    I'm sure you know you were not born yet, and C was already saving lifes in Nuclear Power Stations.

    EDIT: Which means... who are you to have an opinion?
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  13. #193
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    My apologies - let me clarify - that was a programmer who had only learned Java in school, and was using a language so similar to Java, that for the purposes of this conversation, let's call it Java. (Flex / ActionScript)

    My school uses Java in it's classes a lot - and I see it as a major drawback that he had gone so far in programming, and didn't understand some of the fundamental building blocks like that.

  14. #194
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > I still don't buy it, though. In C, it's pass by pointer, nothing more, nothing less
    Huh? Don't think of it like that, think of it as pass by value, nothing more, nothing less

    The pointers are still passed by value... . That being said, everyone will know what you mean when you say "passing by reference" in C -- so it's not wrong IMO.

    > Which means... who are you to have an opinion?
    That is moronic...
    Last edited by zacs7; 10-14-2008 at 03:56 PM.

  15. #195
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    Not all languages have "pass by reference". The compiler or interpreter may do so unbeknownst to the programmer in the interest of speed... if it is safe to do so.

    One language I used did have it, but the syntactical difference was only in the function's header (prepend a '.' to argument names) - but there was NO syntactical requirement to use anything different within the code or the call. No equivalent of dereferencing or "address of". The compiler simply knew what to do.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Numeric addresses for computers
    By great in forum C Programming
    Replies: 4
    Last Post: 08-23-2010, 11:53 AM
  2. Computers as authors
    By hk_mp5kpdw in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 11-22-2004, 07:55 PM
  3. Industrial vs home computers
    By nbo10 in forum Tech Board
    Replies: 10
    Last Post: 09-01-2004, 02:04 AM
  4. Matrix and vector operations on computers
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 11
    Last Post: 05-11-2004, 06:36 AM
  5. Love programming, hate computers
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 12-14-2002, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21