a C++ library of mine.

This is a discussion on a C++ library of mine. within the A Brief History of Cprogramming.com forums, part of the Community Boards category; I'd rather think of it as "slow down." I fail to believe dynamic recompilation can beat native....

  1. #46
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,820
    I'd rather think of it as "slow down."
    I fail to believe dynamic recompilation can beat native.
    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.

  2. #47
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Quote Originally Posted by Elysia View Post
    It's a trade-off. It's good, but it removes too much flexibility.
    Give me one example of something you might want to do that you can't under the VM. (Destructors aside.)

    Say what you want, but I don't like it and though it's not much of an argument, it's an opinion that's important to me and another reason I stay away from it.
    But why is this opinion so important to you? You have absolutely nothing to back it up with, so it only makes you appear unreasonable.

    If Microsoft were to start building library components and enhancing C++ with safe things, then I'd probably start using them directly (they have implemented a safe C library, and I do use it when I tend to use C stuff), but not C#.
    They have "enhanced" C++ with their checked standard library. Which causes a factor 10 slowdown in one STL benchmark and is binary incompatible.
    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

  3. #48
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,820
    Quote Originally Posted by CornedBee View Post
    Give me one example of something you might want to do that you can't under the VM. (Destructors aside.)
    Well, I might think that the following might not work:
    MyManagedObj* pObj; // Assume it points to something
    BYTE* pRaw = (BYTE*)pObj;
    Now do whatever you want with pRaw. Dump it to a file for all I care.
    Also, due to the blasphemous GC, you can't really move memory around without sticking it first. I believe there was an example somewhere about how that caused problems, but I can't remember where or how.

    But why is this opinion so important to you? You have absolutely nothing to back it up with, so it only makes you appear unreasonable.
    It's what makes me tick. That's why it's an opinion.
    I like fast, responsive, powerful, non-cpu intensive applications.
    I will give credit to the Framework, however. I've always wanted something like that in C++, separated in namespaces and all.

    They have "enhanced" C++ with their checked standard library. Which causes a factor 10 slowdown in one STL benchmark and is binary incompatible.
    And it's a darn shame no one else has attempted to implement one, says I.
    I'm sure it could actually be optimized, as well.
    I've always echoed it and will do so again. I really don't like iterators because they are unsafe, as in you can easily walk past the end. Microsoft's checked iterators will alert you if you do and I love that.
    C++ needs more of things like that. It can become a modern, safe 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.

  4. #49
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Both STLPort and GNU libstdc++ have debug versions that are checked.
    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

  5. #50
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    > I'd rather think of it as "slow down."
    So you'd want to write a website in a pre-compiled language? And what if the environment changes, such as the server OS, etc?

    Sometimes it's not all about speed, but productivity. Very well you may be able to write a program that is faster, but in terms of some VM/interpreted languages I can port mine without even recompiling, and it took less time to write . Of course there are cases that would blow this argument out of the water (but I'll ignore them for now).

  6. #51
    The larch
    Join Date
    May 2006
    Posts
    3,573
    MyManagedObj* pObj; // Assume it points to something
    BYTE* pRaw = (BYTE*)pObj;
    Now do whatever you want with pRaw. Dump it to a file for all I care.
    And if MyManagedObj is a non-POD? And what about endianness and such?

    As to the original topic, may-be it's just me but I find it useful to have Get... and Set... in function names. It seems to make it a lot easier to locate functionality to ... set and get things in references, especially if you have no idea what the property might be called (is it caption, or label, or text?). These prefixes nicely group similar functions together alphabetically. If your libraries have a reference, it will probably be easier for me to find set_caption(), rather than just caption().
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  7. #52
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,514
    Quote Originally Posted by zacs7 View Post
    Very well you may be able to write a program that is faster.
    Or not... The London Stock Exchange (which was in the news just recently for the wrong reasons) runs on a C# platform and still allows for a performance level that is among the most critical requirements one can think of. That didn't stop the minds -- which I'm sure are more than qualified -- behind the LSE to adopt a solution based on managed code, dynamic compilation and all the other demons from hell we like to think of when tagging programming languages as "bad".

    Performance is perhaps one of the least understood requirements by many programmers. I wished Elysia reviewed her concept of it. Meanwhile liking or disliking the programming language has nothing to do with it, as Elysia will soon learn when the time comes for her to join the masses of other programmers waiting for a job in the industry.

    Finally, the notion of a safe C++ ticks me. C++ is not meat to be safe. If that is a requirement (and I see plenty of reasons why it can be) one either implements safety or uses libraries that do. That's what's libraries are for. The language itself must remain as much general-purpose as it can be.
    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.

  8. #53
    The superhaterodyne twomers's Avatar
    Join Date
    Dec 2005
    Location
    Ireland
    Posts
    2,262
    >> The language itself must remain as much general-purpose as it can be.
    I agree. But that's not to say the language should throw if you, for example, try to divide by zero, or allocate a string of the size -1, or model the LHC, etc. [I've ignored the first 51 posts... so this might be a little off track...]

  9. #54
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Mario,

    your point about performance is good. 90% (or more in large systems) of code is not factoring in the performance of most applications. The relatively small portion of code that is performance critical can often be optimized on a algorithmic level to a larger degree than the optimizations that you get from the difference between one language to another (or variant of language to another). And if all else fails, most languages support calling C or assembler.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  10. #55
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    It's good, but it removes too much flexibility.
    I completely fail to understand what this means or attempts to imply. What types of 'flexibility' do you lose?

    Actually, forget that - the more important question is what types of flexibility do you gain by moving to other languages?

    Note that I say 'types of flexibility' because the whole point varies from language to language. Ruby for example has a very flexible object model - you can add individual methods to classes for example. Combined with meta-programming you can have your objects and classes become even more powerful and you don't have to repeat yourself as much.

    Another good example is Io. Io is an incredibly dynamic and flexible language that is built on message passing and objects (smalltalk-style.) It is possible for example to completely change code in situ by passing messages to objects and thus their behavior can change. This makes it completely feasible for example to write a self-optimizing optimizer in Io which could take your code and eliminate redundant or dead code if necessary.

    Factor (or really Forth for that matter) is also an excellent example. Because it is a stack-based language, it tends to be very easy to refactor (pun intended) pieces of code. The underlying philosophy is that the factor words you write (think of words as functions basically) should be short and composed. It is extremely easy to get out of hand with it if you go with words that are too long.

    Factor - like Forth - is a very 'high ceiling' language. It is completely feasible to write extremely DSL-like syntax to describe things like, for example, parsing grammars. Here's an example:

    Code:
    EBNF: balanced?
    parens = "(" term ")"
    brackets = "[" term "]"
    braces = "{" term "}"
    term = (parens | brackets | braces)? => [[ >boolean ]]
    ;EBNF
    If you've got any sort of basic computer science education (or simply worked with BNF-grammars) then most of that should make sense to you immediately. It is extremely DSL-like, so it is entirely feasible to build very abstract and complicated programs in this manner. Doing it in C++ is, to say the least, not this easy (and yes, I'm completely aware of flex/yacc.)

    Erlang is another example. Very very flexible concurrency model and because of it, it is extremely easy to take erlang programs and parallelize them across hundreds of computers and CPU cores. The underlying model of the system is what allows this to happen so easily and with so little hassle.

    Does C have its place? Absolutely. C is essentially just portable assembler - you can basically get C anywhere within reason, and it is exceptionally good when it comes to things like hard constraints on memory or speed (e.g. real-time systems.) In some cases, it is absolutely the best tool for your job and I have never ever denied that.

    I can go on and on, if you want.

    The point is, if you just keep thinking in terms of losses you're completely limiting yourself because that connotation is likely to have a negative impression on your brain and thoughts - "oh, I lose pointers," "oh, I lose templates." It's a half-full vs. half-empty type of thing. It is better to think of what you may gain - reduced development time, better scalability, more security and soundness in your programs, more modular, refactorable code - and weigh it out overall than to just think of what you lose.

    Being opinionated is fine - I think it is a wonderful thing - but if you let it get in the way of cold, hard fact and reality then it's useless and you're simply hindering yourself.

    Say what you want, but I don't like it and though it's not much of an argument, it's an opinion that's important to me and another reason I stay away from it.
    That's fine. Just be aware in the real world, nobody gives a damn about that.

    (Addendum: I am almost completely ignoring efficiency in this post because I have been down that road so many times and so few people understand it, I've found bringing it up to be almost worthless in practice because nobody gets the point. Programming - simply put - is about more than how blazingly super-fast your programs can be.)
    Last edited by Mad_guy; 09-11-2008 at 09:23 AM.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  11. #56
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,893
    Doing it in C++ is, to say the least, not this easy (and yes, I'm completely aware of flex/yacc.)
    Are you aware of Boost.Spirit?
    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

  12. #57
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,820
    The biggest complaint seem to be around that opinions are evil or the real world doesn't care about them.
    Yes, I know, in the real world, you just have to bite it and do it.
    I'm fully aware of this and if it would indeed some day be a requirement in a job, then yes, I would do it. Not willingly or happily but because the job required it.

    Thankfully, programming is a hobby rather than a job for me, so I can freely ignore it (for now).

    The other argument seem to be about A VS B - the advantages and disadvantages of the both. I agree. You have to use the right tool for the job. Especially in jobs.
    And while I do agree on the topic, this is also why I like C++ - it can borrow and create strengths from other programming languages due to its flexibility. It doesn't support properties natively, but with some knowledge, I can emulate it.
    Being a hobby as it is, I try to bend C++ around to the way I like things. Even if it costs some performance or if it's awkward. It's a hobby and a challenge and it allows me to stay with C++ instead of moving on to other languages.

    Again, if I were in a job, I wouldn't try this if it's a waste of time or resources. If I'm given a NO, then I wouldn't do it. But for a hobby, I would definitely pursue it.

    Quote Originally Posted by zacs7 View Post
    > I'd rather think of it as "slow down."
    So you'd want to write a website in a pre-compiled language? And what if the environment changes, such as the server OS, etc?

    Sometimes it's not all about speed, but productivity. Very well you may be able to write a program that is faster, but in terms of some VM/interpreted languages I can port mine without even recompiling, and it took less time to write . Of course there are cases that would blow this argument out of the water (but I'll ignore them for now).
    But the problem with the web is that it's a data format understood by browsers. And data formats aren't exactly executable code... if it were, then there'd be no need for browsers.
    But if I would choose speed over portability, in my own opinion, it would be a yes.

    Quote Originally Posted by anon View Post
    And if MyManagedObj is a non-POD? And what about endianness and such?
    Actually, I would like a library that handles endianess. Abstraction, without losing the flexibility-
    This may have been a poor example, but I would like to be able to do it nevertheless. It makes me feel more control and grip over how things work.

    Quote Originally Posted by anon View Post
    As to the original topic, may-be it's just me but I find it useful to have Get... and Set... in function names. It seems to make it a lot easier to locate functionality to ... set and get things in references, especially if you have no idea what the property might be called (is it caption, or label, or text?). These prefixes nicely group similar functions together alphabetically. If your libraries have a reference, it will probably be easier for me to find set_caption(), rather than just caption().
    Hmmm. I'd rather there was just some documentation instead.

    Quote Originally Posted by Mario F. View Post
    Finally, the notion of a safe C++ ticks me. C++ is not meat to be safe. If that is a requirement (and I see plenty of reasons why it can be) one either implements safety or uses libraries that do. That's what's libraries are for. The language itself must remain as much general-purpose as it can be.
    Now I do agree with that. A language should not be safe out of the box (like C#), because it would put too much restriction on what you can do.
    As we have seen, C++ can be safe, and that's why I like it. It can be safe, it can be fast, and it doesn't put restrictions on what I can do.
    If I know what I'm doing, then I should be allowed to do it. Hurray for C++.

    Quote Originally Posted by Mad_guy View Post
    I completely fail to understand what this means or attempts to imply. What types of 'flexibility' do you lose?
    Btw, a good question to this might be - what do I lose due to the strict security in place?
    Due to the strict security, there is so much that I cannot do. That's probably the features that I "miss".
    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.

  13. #58
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Quote Originally Posted by CornedBee View Post
    Are you aware of Boost.Spirit?
    No (I don't really do C++ that much and by association Boost) - could you provide me with a code example? If it can accomplish the same thing as succinctly and clearly I would be very impressed and interested in it (and I will retract my earlier point about not being able to do it as easily.)

    Due to the strict security, there is so much that I cannot do. That's probably the features that I "miss".
    That doesn't exactly answer my question, you're just saying "there's a lot I can't do, trust me."

    What does this 'security' a VM (or similar) introduces inhibit you from doing, exactly? More importantly - why is this feature/idiom not expressible in another manner?
    Last edited by Mad_guy; 09-11-2008 at 12:54 PM.
    operating systems: mac os 10.6, debian 5.0, windows 7
    editor: back to emacs because it's more awesomer!!
    version control: git

    website: http://0xff.ath.cx/~as/

  14. #59
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,744
    But the problem with the web is that it's a data format understood by browsers. And data formats aren't exactly executable code... if it were, then there'd be no need for browsers.
    But if I would choose speed over portability, in my own opinion, it would be a yes.
    Pardon me for speculating, but do you know what CGI is and what it does? Some types of web sites will require interaction with the user -- if you so much as utilize form data -- and as Google wants to prove with Chrome, the web is becoming more and more like an application platform. It's not cute to ignore the possibility that you would need to write some perl or something for a website.

    And I really hope that you would choose an interpreted language for the web since it is much easier to use perl or php to interpret form data and draw pages on the fly.

    I believe that was the point zacs was trying to make. But you did admit that every job has a tool ...
    Last edited by whiteflags; 09-11-2008 at 01:15 PM.

  15. #60
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    CGI scripts run on the server, so portabilty is not as much a concern as with client-side applications. Java has platform-independent (I know... JVM dependent) bytecode so that it can have multi-platform capability for client-side web applications, which is what I think was being implied.

    Also, C and C++ can do CGI.

Page 4 of 5 FirstFirst 12345 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What's an import library?
    By chiefmonkey in forum C++ Programming
    Replies: 1
    Last Post: 06-19-2009, 05:00 PM
  2. Property Set Library (PSL) - Announcement
    By vultur_gryphus in forum Projects and Job Recruitment
    Replies: 0
    Last Post: 05-29-2008, 06:04 AM
  3. Makefile for a library
    By sirmoreno in forum Linux Programming
    Replies: 5
    Last Post: 06-04-2006, 04:52 AM
  4. very weird .h problem
    By royuco77 in forum C++ Programming
    Replies: 1
    Last Post: 09-11-2005, 07:55 AM
  5. better c string functions
    By samps005 in forum C Programming
    Replies: 8
    Last Post: 11-04-2003, 12:28 PM

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