View Poll Results: Choice of project

Voters
24. You may not vote on this poll
  • A small scripting language, possible using bytecode.

    11 45.83%
  • A C compiler.

    6 25.00%
  • An internationalization (i18n) library.

    4 16.67%
  • An implementation of the C++ STL for C.

    5 20.83%
  • An operating system.

    7 29.17%
  • A portable build system.

    9 37.50%
  • A "modern" editor (MVC pattern).

    4 16.67%
  • A game maker.

    2 8.33%
  • An RPG.

    2 8.33%
  • An IDE with integrated SVN support.

    4 16.67%
Multiple Choice Poll.

CBoard Community Project: Poll #1

This is a discussion on CBoard Community Project: Poll #1 within the Projects and Job Recruitment forums, part of the Community Boards category; Originally Posted by MK27 Could you provide a short pseudo code example of such a situation, and maybe elaborate slightly? ...

  1. #61
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,718
    Quote Originally Posted by MK27
    Could you provide a short pseudo code example of such a situation, and maybe elaborate slightly?
    Stroustrup describes a relevant example, applicable across most object oriented programming languages, in this interview: The C++ Style Sweet Spot: Designing Simple Interfaces.

    If you want further elaboration:
    How Non-Member Functions Improve Encapsulation
    Monoliths "Unstrung"
    But the code examples are in C++ only.

    Quote Originally Posted by MK27
    It seems to me you could always use a method call from a predefined base/top level class (class class or class object or something) to circumvent a more specific inheritance model.
    It is not about circumventing any model. Rather, it is about providing a minimal yet complete interface, and then providing auxiliary modules that extend this interface. In such cases, neither composition nor inheritance is ideal, but functions and static methods (e.g., of an auxiliary class with no non-static members) fit the bill.

    But if we are only designing a scripting language for a build system, these kind of design considerations might not be so important... or maybe they still are important.
    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

  2. #62
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    It seems like we're suddenly discussing a build system, when I thought we were going to start with a scripting language...

    For the build system I was going to suggest emulating some of the concepts of Jam/Boost.Build, which has a very logical way of handling the things we're talking about here.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  3. #63
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by laserlight View Post
    But the code examples are in C++ only.
    That's kind of why I asked. Stroustrup invented C++, right?

    The only OOP I know is from perl, javascript, and now ruby. There are some significant differences, IMO. So it is not clear to me that the problem to which you refer is a real problem beyond a C++ setting...a rose by any other name, you know.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  4. #64
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,718
    Quote Originally Posted by MK27
    That's kind of why I asked.
    I do not know about Perl, and I do not think Javascript really has the facilities to handle encapsulation properly anyway, but you could easily show the Date class example in Ruby.

    Quote Originally Posted by MK27
    Stroustrup invented C++, right?
    Yes.

    Quote Originally Posted by MK27
    The only OOP I know is from perl, javascript, and now ruby. There are some significant differences, IMO. So it is not clear to me that the problem to which you refer is a real problem beyond a C++ setting...a rose by any other name, you know.
    Just to check: have you read the articles? What do you understand to be the problem?
    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

  5. #65
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by laserlight View Post
    Just to check: have you read the articles?
    I was hoping you'd make a effort to explain yourself in a few short paragraphs. So I read the first one, which is a few short paragraphs. What he is saying to me does not imply at all that you must have functions, if you can have a method outside to perform the same "function":
    Quote Originally Posted by Stroupsoup
    But the function that finds the next weekday, or the next Sunday, can be put on top of it.
    is exactly
    Quote Originally Posted by mk27
    you could always use a method call from a predefined base/top level class (class class or class object or something) to circumvent a [this issue].
    My OOP vocab is shaky but I do like the paradigm. Really, a top level ruby method to me seems exactly the same as a "function" (or in perl, a "subroutine", since all functions are a "sub" of the mainline, imperative rountine). Basically, I would challenge you to present some pseudo where this is not the case. Translating the Date class example into ruby would not require a function.

    The reason I raised the issue is because in terms of parsing, etc, it will be a waste of time to include a distinct syntax for functions apart from methods if everything can be accomplished using the method syntax -- that will work if, as in ruby, everything is an object. Stroupsaid's commentary looks to me to be about C++ practices, where functions and non-object types do exist. If you replace "the function that finds" with "the exterior method" it amounts to the same thing. I totally agree with him. Why write a program composed entirely of class definitions and instantiations?
    Last edited by MK27; 05-20-2009 at 01:28 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  6. #66
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,239
    I see the decision has been implicitly made that this language will be object-oriented?
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  7. #67
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by brewbuck View Post
    I see the decision has been implicitly made that this language will be object-oriented?
    I guess that's what I'm trying to assert. Like, really really object oriented. I do not see a big need for lots of low level stuff and types, etc. although these are not quite the same issue. We don't need to go for speed here. We need muy simplicity.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #68
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,718
    Quote Originally Posted by MK27
    What he is saying to me does not imply at all that you must have functions
    Neither did I state that you must have free functions. As I noted this can be accomplished with static methods (class methods) as well. It happens even for non-static methods from other classes, since they too do not have access to the implementation of the given class, given appropriate access control.

    Quote Originally Posted by MK27
    My OOP is shaky but I do like the paradigm. Really, a top level ruby method to me seems exactly the same as a "function" (or in perl, a "subroutine", since all functions are a "sub" of the mainline, imperative rountine).
    Ah, what I did not understand was that "in Ruby, classes are never closed: you can always add methods to an existing class. This applies to the classes you write as well as the standard, built-in classes."

    Yes, I would say that it would be effectively the same as a non-member function, except with the redundant involvement of a cosmic base class. It is pretty much the same thing as just defining another class as a container of methods, except that it relies on classes (or at least the cosmic base class) being open to an extension of interface by users of the class.

    In fact, this feature of users of the class being able to extend the interface directly solves the problem of wanting to supply a minimal but complete interface and yet allowing extension without composition or inheritance. This would be so if the extensions to the interface do not have access to the implementation of the class, so the implementation can be changed independently by the class maintainer without worry of breaking compatibility with users of the class.

    But...

    Quote Originally Posted by MK27
    The reason I raised the issue is because in terms of parsing, etc, it will be a waste of time to include a distinct syntax for functions apart from methods if everything can be accomplished using a the method syntax -- that will work if, as in ruby, everything is an object.
    The benefit of a free function syntax is that the user does not have to involve a class that has nothing to do with the classes involved, whether it is a cosmic base class or not. Of course, the user might choose to extend the interface of one of the classes involved, but semantically that could indicate that the chosen class is somehow special when that may not be the case.

    EDIT:
    Quote Originally Posted by brewbuck
    I see the decision has been implicitly made that this language will be object-oriented?
    Yes, it certainly seems so. However, I would not mind a functional programming language, or a multi-paradigm one, but that may make it too complex.
    Last edited by laserlight; 05-20-2009 at 02:16 PM.
    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

  9. #69
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    I am about up to my chin in the water now!

    Quote Originally Posted by laserlight View Post
    The benefit of a free function syntax is that the user does not have to involve a class that has nothing to do with the classes involved, whether it is a cosmic base class or not.
    Hmmm...maybe an example from my first shot at ruby on the weekend:
    Code:
    def getaddon ()
            tmp = Array.new
            Dir.open($dvd) { |dir| dir.each { |entry|
                    next if entry == "." || entry == ".." || entry == "XTRA"
                    next unless File.stat($dvd+"/#{entry}").directory?
                    path = $dvd+"/#{entry}"
                    $backdup[entry].dirpath = path if $backdup.has_key?(entry)
                    $backdup[entry] = Artist.new(path) unless $backdup.has_key?(entry)
                    tmp.push(entry)
            } }
            tmp.each { |ref| recurse($backdup[ref].dirpath,$backdup[ref]) }
    end
    I conceive of that as 100% a stand alone "function", but it is 100% the method syntax (again, there are no functions in ruby). It is completely opaque to me as to what class it is associated with, I was just postulating the cosmic class. As far as I can tell, that is not relevant to the programmer.

    Hopefully you can see my point here about "saving time" -- there is no need to absorb, or define, a syntax for methods distinct from a syntax from functions. Possibly that is just "traditional"??
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  10. #70
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,718
    Quote Originally Posted by MK27
    I conceive of that as 100% a stand alone "function", but it is 100% the method syntax (again, there are no functions in ruby). It is completely opaque to me as to what class it is associated with, I was just postulating the cosmic class.
    How would you invoke the method?

    Quote Originally Posted by MK27
    Hopefully you can see my point here about "saving time" -- there is no need to absorb, or define, a syntax for methods distinct from a syntax from functions.
    Yes, that is certainly true. We are talking about syntactic sugar, after all. For example, this can be the syntax of a method call:
    Code:
    (foo obj a b)
    The method named foo is called on the object named obj, with the arguments a and b passed to the method. It so happens to be identical in form to this free function call:
    Code:
    (bar c d e)
    The triadic parameter function named bar is called with arguments c, d, and e. Presumably, the interpreter will attempt to resolve the call to a method of c, and if none exists, to a free function with parameters of the appropriate number and types.
    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

  11. #71
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by laserlight View Post
    How would you invoke the method?
    The same way you would a function, here it is in an if/else construct:
    Code:
            if tmp =~ /^a/  
                    getaddon()
            else getdata($dvd,$backdup)
            end
    Those are nested in another such global method, and again the class to which they belong is totally opaque to the programmer. It is never explicitly involved. In the programming guide I've been reading this reality is introduced slyly (by implication) so I haven't seen, or looked for, more of an explanation.

    Quote Originally Posted by laserlight View Post
    We are talking about syntactic sugar, after all.
    AFAIK yup. But if we are going to be making a language up, here is a possibility. I'm a big fan of Occam's Razor, you know, the simplest explanation is the best one. If we don't need functions, we don't need functions.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  12. #72
    Complete Beginner
    Join Date
    Feb 2009
    Posts
    312
    I see the decision has been implicitly made that this language will be object-oriented?
    This was my idea, and it was mainly meant to be syntactic sugar (it kind of saves one argument when calling a function).

    I'm trying to keep things simple, and in a language with only one definable type, it doesn't really matter whether it's OO or imperative or whatever.

    Rather than discussing whether our language will be OO or not, I would prefer to see a discussion about the purpose of the language. I implicitly made the assumption that it will be used for the build system, which was probably wrong.

    Greets,
    Philip
    All things begin as source code.
    Source code begins with an empty file.
    -- Tao Te Chip

  13. #73
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,258
    "However, I would not mind a functional programming language, or a multi-paradigm one, but that may make it too complex."

    That depends on the nature of the language. C++ isn't complex because it is multi-paradigm. It is complex because it is just extremely difficult to get all of the rules exactly right. (Look at how hard it is to get name lookup involving templates correct in all cases. No commercial compiler that I know of gets it exactly right.) Consider the case for generics/templates: if support is available for parametric polymorphisms you can get substantially easier support for generics/templates by using the available matching mechanic and using something definite to "install" a particular template as a potential match rather than using additional rules to determine which expansion/definition to employ. Alternatively, some languages are simply generic in the behavior without needing any additional mechanic.

    "If we don't need functions, we don't need functions."

    We do need functions. You can't just have syntactical sugar. It has to be syntactical sugar for expressing something.

    That said, I do like the Ruby path in general, but I'd say the group needs to shoot for something a little more regular and well defined. The variations on available syntax is a mess in my opinion.

    Speaking of "teh "OO"", are we talking polymorphism and if so what kind(s)?

    "I implicitly made the assumption that it will be used for the build system, which was probably wrong."

    I really don't see why this should be the case. If the language is reasonably complete and can be embedded in C/C++ without difficulty the library could be extended with domain specific additions without sacrificing the use in other areas.

    Soma
    Last edited by phantomotap; 05-20-2009 at 03:43 PM.

  14. #74
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by phantomotap View Post
    We do need functions.
    Why? I know c. 1975 if someone said we don't need functions everyone would laugh, but going back to what I said to brafil earlier:

    Quote Originally Posted by MK27 View Post
    My point was NO IT IS NOT A MATTER OF PERSONAL PREFERENCE. By coming up with concrete reasons related to the concrete task rather than just making it a matter of off the cuff personal preference, you will be far more likely to come up with something insightful and dynamic in context.

    Otherwise you are just saying, "every time I make a language, it will be more or less the same because of my personal preferences". If you use those preferences instead of the context, you are selling yourself short.

    [see original post, #56]

    But would probably be better seen as a set of object methods.** That said, you do not actually need functions (again: ruby is fully functional but does not use them). So yeah, I am advancing the idea that this would be a good way to go here too. Snafuist points out something similar earlier in the thread altho he may not agree with going to such an apparent extreme.
    I'm also asserting that our #1 priority here should be integration with the build concept. And that we do not need to adhere to some standardized definition of what a language is or should be; using methods instead of functions will not reduce the "functionality", it will just reduce redundancies in syntax and make the whole thing more "trim".
    Last edited by MK27; 05-20-2009 at 03:42 PM.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  15. #75
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,258
    "Why?"

    Because a method without context is a function and the details of the invocation are completely irrelevant. See Java for the ultimate argument against "everything is a method". Granted, you aren't arguing for that extreme.

    "I'm also asserting that our #1 priority here should be integration with the build concept."

    Then I see no point in discussing the language further.

    "And that we do not need [...] whole thing more "trim"."

    O_o

    And you honestly believe the Ruby statements:

    Code:
    puts "Hello, World!"
    Code:
    123456789.to_s
    Code:
    123456789.puts "Hello, World!"
    are not substantially different? (Just to be clear, the last one is a valid statement with broken logic.) How would you parse and apply all of them without implicitly parsing what is arguably a free function?

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. cboard community project
    By zacs7 in forum Projects and Job Recruitment
    Replies: 76
    Last Post: 05-16-2009, 08:30 PM
  2. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  3. CBoard Project?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 40
    Last Post: 06-21-2004, 03:15 PM
  4. POLL! What was your first C project?
    By webguy899 in forum C Programming
    Replies: 8
    Last Post: 05-02-2002, 11:15 PM

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