About your programs...

This is a discussion on About your programs... within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Like I said, because a screwdriver is a bad hammer doesn't make a screwdriver bad as a screwdriver. Languages are ...

  1. #16
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Like I said, because a screwdriver is a bad hammer doesn't make a screwdriver bad as a screwdriver. Languages are tools. Use them in the correct way and they work well. Use them for the wrong purpose, and they may do something similar to the right tool, but not as well.

    --
    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.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    What Mats is saying sounds about right.

    But how do you determine whether to use Java or C++ in a project? They both seem pretty similar in terms of capabilities.

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by robwhit View Post
    What Mats is saying sounds about right.

    But how do you determine whether to use Java or C++ in a project? They both seem pretty similar in terms of capabilities.
    Sure, that's like choosing between a Phillips screw & screwdriver or a pozidrive screw & screwdriver. They are also pretty much similar (with care, you can even swap a Phillips screwdriver with a Pozidrive one, or the other way around). Likewise, most projects where Java can be used are suitable for C++ implementation and the other way around. The details of the languages and application type would determine which is better in that particular case.

    [By the way, the Phillips slot is more suitable when you have lower torque, whilst the Posidrive (and even more so more modern "star" patterns, such as torx) is more suitable for higher torque situations - this is probably why plasterboard/drywall screws are Phillips, whilst screws to hold for example floorboards are Pozidrive - http://en.wikipedia.org/wiki/Henry_F._Phillips.

    --
    Mats
    Last edited by matsp; 11-01-2008 at 07:00 PM.
    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.

  4. #19
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,062
    The truth is that professionally... at least in my experience... you don't normally have a choice in what language you program in. Perhaps when you get to a more managerial level than I am, these decisions can be made by you... but even then you'd still like either be coming into a project that's already been implemented or your company is licensing components of your system written in a specific language that you now have to adopt.

    My only professional programming experience has put me in positions where I've joined the project and they tell me what to write and in what language. Even if you look at most job applications they ask you to know several languages. So... whether or not you prefer one language over another... whatever you're programming in, you'd better make your code as efficient, reusable, and well-organized as allowable. Even if you feel the project would be done more suitably in another language.

    The only time I've found that I have a choice in what language to use is when I'm writing a small side script that is assisting myself or others but unrelated to the project... or if I'm in a job that isn't really directly related to programming (I work in Finance, as well) and I'm the only one developing some small system for them. In either of those cases, my go to language is usually either Perl or C.
    Last edited by SlyMaelstrom; 11-01-2008 at 07:18 PM.
    Sent from my iPadŽ

  5. #20
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    I agree with SlyMaelstrom - it's usually not "your" choice in a larger company. I have been the only programmer in the company when I was working for really small companies. That was great, you could do as you like. But then if it's gone wrong, it's your own fault!

    In later years, I don't think I've ever been allowed to choose the language something is implemented in. It's been determined by either the rest of the environment (it's much easier to add a few hundred or thousand lines of C code to an existing project, than it is to add the same bit of code in C++ or Java) or by the project leader(s) etc [or, most likely BOTH of those - that is, the PL's say "this has to be done in X because the rest of the code is in X"].

    --
    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.

  6. #21
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by audinue View Post
    1. A good performance, pretty fast, efficient on memory consumption but lacks of conceptual features. Just like C.
    Lacking conceptual features means you can't do some thing with it. C has no limitations, so you can do everything you could do with a higher level language with it (plus a lot more things, like self-modifying code), just in a different way. If you don't like C, try C++. And if you don't like C++ either, don't bash people who do.
    Last edited by maxorator; 11-02-2008 at 06:32 AM.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  7. #22
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,586
    [By the way, the Phillips slot is more suitable when you have lower torque, whilst the Posidrive (and even more so more modern "star" patterns, such as torx) is more suitable for higher torque situations - this is probably why plasterboard/drywall screws are Phillips, whilst screws to hold for example floorboards are Pozidrive - http://en.wikipedia.org/wiki/Henry_F._Phillips.
    Hehe. A screw's ability to hold torque has much more to do with how much torque can be exerted on the metal before it reaches elasticity and less to do with the type of 'interface' it has to become torqued.

    I've torqued large old-fashioned nuts to well over 1500 ft-lbs and they held up just fine. I've also torqued 'torx' head screws to 60 ft-lbs and had them snap right off. It really doesn't matter if it's torx, phillips, standard, hex, etc. as to how much torque they can handle. The key is to torque the fastener to a point that it maintains it's spring - which is essentially what any fastener is. The point at which it becomes elastic is the point of no return. You have stretched the metal, lost the torque, and seriously compromised the composition of the metal. It's then that I would call salvage for help to remove my fastener and they would proceed to get very angry at me and remove my fastener in whatever way possible from the component. I overtorqued one inside an engine compartment once...with the engine in and had to call salvage. They weren't happy at all. The industry I used to work in had very high torque specs and I never came across any fancy fasteners. Just good old hardened nuts and bolts.

    And now...

    As to the argument of speed or re-usability I would say first reach for re-usability. At the point it becomes necessary to optimize and it is already working then go for speed. Half the time re-usability is enough and, to me, is worth more than speed in some cases. But it doesn't have to be either or since you can do both as long as you approach them the right way.
    Last edited by VirtualAce; 11-02-2008 at 09:23 AM.

  8. #23
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Independently of the language, I always go for reusability and good organization first. If you don't have good organization, your program will be incorrect - if not at first, then after the first round of maintenance. There is simply no point in having a fast program if it doesn't do what it should.

    Or, in the words of John Ousterhout (whoever that is): "The best performance improvement is the transition from the nonworking state to the working state."
    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. #24
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    I would rather have something work first and be fast later than just it being really fast, going nowhere.

    There seems to be an extreme case of cognitive dissonance in the sense that we cannot get well performing code and good, reusable and modular abstractions. My question is: why can't we have both? :] I've found in my travels of developing with languages like Haskell, you can preserve good things like polymorphism and static typing, but still get raw performance when it's necessary which I think is fabulous (and it's true of many other languages too, do not get me wrong.)

    As a programmer, I like to think of myself as an artisan. Writing code that you know is both efficient and beautiful is a wonderful feeling - the same feeling one gets when he builds a sturdy, beautiful wood chair. But without making the right choices in things like, say, tools, your life and job can be a lot harder than it has to be, and the end result can end up less beautiful than it could or should be.
    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/

  10. #25
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Also, there is still the underlying assumption here that a program can only be written in a single language. This is not only untrue, it's also far from the reality of most large projects. Two languages (typically a high-level langauge for the boring stuff and some C or C++, possibly mixed with Assembly, for the core algorithms) is probably the most common case.
    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

  11. #26
    Disrupting the universe Mad_guy's Avatar
    Join Date
    Jun 2005
    Posts
    258
    Quote Originally Posted by CornedBee View Post
    Also, there is still the underlying assumption here that a program can only be written in a single language. This is not only untrue, it's also far from the reality of most large projects. Two languages (typically a high-level langauge for the boring stuff and some C or C++, possibly mixed with Assembly, for the core algorithms) is probably the most common case.
    This is a good point - people should keep in mind it is entirely reasonable (dare I say, encouraged?) to develop the bulk of an application in one language, with more speed-critical parts written in say, C, and bringing that fast code in through a foreign function interface (just about every language worth the cost of its own domain name can interface with C these days.) Which is a perfectly reasonable approach - you may have that gnarly 10% speed-critical part of the code, but I think that would be a reasonable price to pay for the other 90% being higher level and developed/hacked on more rapidly.

    A good example I saw recently (I think, anyway) is pycuda which allows you to interface to CUDA from python - all the power of the GPU + the rapid development of python. Delicious. :]
    Last edited by Mad_guy; 11-03-2008 at 11:02 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/

  12. #27
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    You use C++, 'cause it has a better name and Java applications never work :P
    Currently research OpenGL

  13. #28
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,532
    You're probably using an application built with Java right now.

  14. #29
    Hail to the king, baby. Akkernight's Avatar
    Join Date
    Oct 2008
    Location
    Faroe Islands
    Posts
    717
    Well, I mean applications that show the Java screen/logo in the beginning :P And I'm using Firefox, I think it's in C++...?
    Currently research OpenGL

  15. #30
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    Firefox is a perfect example of the multi-language approach. Its core is written in C++, a few low-level libraries (network, security and OS abstraction) in C, and the bulk of the UI in JavaScript, with the help of a few declarative languages (XUL and CSS, mostly).
    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

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Recommend upgrade path for C programs
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-22-2007, 06:32 AM
  2. I never Finish my programs :(
    By epidemic in forum C++ Programming
    Replies: 11
    Last Post: 04-02-2007, 12:35 PM
  3. Problem using java programs within C code
    By lemania in forum Linux Programming
    Replies: 1
    Last Post: 05-08-2005, 02:02 AM
  4. POSIX/DOS programs?
    By nickname_changed in forum C++ Programming
    Replies: 1
    Last Post: 02-28-2003, 04:42 AM
  5. executing c++ programs on the web
    By gulti01 in forum C++ Programming
    Replies: 4
    Last Post: 08-12-2002, 03:12 AM

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