Viewing 40 posts - 121 through 160 (of 160 total)
  • What is it about C++?
  • mmannerr
    Full Member

    stumbled across a bit of code (in the middle of a trivial function to do with multiple currency support) which I’d commented as “I don’t know what this does but if I take it out nothing works”.

    Been there done that, got the t-shirt and trip to Cebit 🙂

    It’s been a while but I do recall that C++ macros by certain gents of eastern origin were quite mindbending, all this while dealing with big endian to little endian changes and simulators.

    I recall guys in my project found something like this couple of months ago:
    // there should be error handling logic around here
    It was commercial US product which claims to be “developer-friendly solution” but failed at random times.

    IanMunro
    Free Member

    That’s 3 MISRA rule violations in that slight difference. (MISRA != fun).

    A hardcopy of the MISRA C and C++ rules along with pc-lint turned up on my desk this week. My cup runneth over 🙂

    GrahamS
    Full Member

    The good news is Lint can enforce most of the MISRA rules for you.

    People moan about it – but code the lints cleanly and is MISRA compliant is notably less buggy IME.

    jonnouk
    Free Member

    People moan about it – but code the lints cleanly and is MISRA compliant is notably less buggy IME.

    If you start a project with a good pc-lint setup I’d imagine it’s fine. If you suddenly apply it to a massive codebase 18mths into development (my only experience of applying it) – Oh sweet baby Jesus.

    MrsToast
    Free Member

    http://crashworks.org/if_programming_languages_were_vehicles/

    As a designer, I tend to stick to scripting languages like Lua and C#. My efforts often make proper coders (such as my husband) weep, generally due to iffy indentation.

    T’husband has to use C++, C# and Java in his day job, and soon he’ll be adding objective C to the list. Poor bastard.

    aracer
    Free Member

    <learns to code in Haskell>

    IA
    Full Member

    Oh god, such truths….

    <learns to code in Haskell>

    Haskell? Not nearly niche enough…. 😉

    I did some development work on a language where the compiler for it was written in Haskell… trendy in limited circles, you probably haven’t heard of it … 😉

    Very high level languages, especially functional languages can be way more mind bending than C/C++, just obscure in a different way.

    andytherocketeer
    Full Member

    Occam is probably the most obscure I’ve programmed in.
    or perhaps BCPL (really have no idea why we did that at uni).

    Ada is one I never learned to code in, but have had to debug fairly often in the past.

    Contemplated Erlang and Haskell at times, but then changed my mind.

    IA
    Full Member

    Do you have a massive beard? In which case you should crack right into Erlang. For some reason all Erlang programmers I’ve met have massive beards, it seems to be in some way necessary.

    Haskell (and other functional languages) are fun, they let you be properly clever (for good and bad!). Progol maybe takes this a bit too far though (literally the best description of how the language works, and coincidentally how it’s spelt, is “ass backwards prolog” which pleases me)

    aracer
    Free Member

    Go Forth and multiply (provided you’ve already put the variables you want to multiply on the stack). I think that’s my most obscure language.

    andytherocketeer
    Full Member

    No massive beard, so Erlang is crossed off the list.

    molgrips
    Free Member

    Alternatively if you’re clever and careful

    Yeah well done and all, but we just needed a washing line.

    Written many device drivers in Java?

    Don’t be a smartarse*. I was comparing problem domains where both languages can be used.

    * oh wait.. you’re a geek, it’s what you do 🙂

    TurnerGuy
    Free Member

    Don’t be a smartarse*. I was comparing problem domains where both languages can be used.

    A mate (at CSFB) reckons that traders at CSFB can arbitrage prices off a internal system they know can be triggered into falling behind the ‘market’ with its price updates if they flood it with activity – and caus\e it to go into a gc cycle.

    You need a managed language for that…

    TurnerGuy
    Free Member

    Also a Fix engine we use is based on the C++ ACE engine – I asked if they had a pure .NET version – they said no as there is no way they could get it to go fast enough.

    We use the .NET interface and they provide tips on how to use it in a performant way – like reusing objects so as not to trigger the GC.

    aracer
    Free Member

    (re i = i++)

    Well how strange – that doesn’t result in i incrementing, despite being gcc which did increment i under raspbian. Can’t be bothered to work out what the difference is.

    molgrips
    Free Member

    A mate (at CSFB) reckons that traders at CSFB can arbitrage prices off a internal system they know can be triggered into falling behind the ‘market’ with its price updates if they flood it with activity – and caus\e it to go into a gc cycle.

    Poorly designed system then isn’t it? Stop the world gc in a critical time sensitive app is a bit daft.

    Tool for jobs. I wonder how long that market price app would have taken to develop using C++ vs Java? I wonder if they had the C++ skills available?

    oldnpastit
    Full Member

    Well how strange – that doesn’t result in i incrementing, despite being gcc which did increment i under raspbian. Can’t be bothered to work out what the difference is.

    That code is is undefined. If you turn on -Wall you’ll get a warning about it (sequence points).

    timb34
    Free Member

    That reminds me of certain things I once had to do to avoid compiler optimisations – basically splitting up C increments/decrements into seperate lines of code with pointless assignments in between them to actually make the required increments/decrements work.

    Reading the comments thread on stackoverflow has also reminded me that one of the UKs larger sports retailers is currently using systems that contain a number of comments along the lines of
    //TBtodo – check that this works 😳

    TurnerGuy
    Free Member

    Poorly designed system then isn’t it? Stop the world gc in a critical time sensitive app is a bit daft.

    it is normally not the programer that stops an app to perform gc, it is the managed environment.

    Unless you program in a non-idiomatic style in those languages then the gc will fire of its own accord.

    Tool for jobs. I wonder how long that market price app would have taken to develop using C++ vs Java? I wonder if they had the C++ skills available?

    yes, tools for the job for anything dealing with market prices is generally not a managed language…

    dudeofdoom
    Full Member

    @Beej – I only ever managed to get about a million quid stuck in limbo, that was pretty cool also managed to buy 20 grands worth of shares but that ws fine as they made a profit selling those so no bollcking.

    mogrim
    Full Member

    it is normally not the programer that stops an app to perform gc, it is the managed environment.

    Unless you program in a non-idiomatic style in those languages then the gc will fire of its own accord.

    Yes and no – you can certainly anticipate the memory usage, configure the server accordingly, etc. You’re not 100% at the mercy of the runtime.

    molgrips
    Free Member

    it is normally not the programer that stops an app to perform gc, it is the managed environment

    And who configures the environment? GC tuning is an important and detailed job.

    It is possible to write very good low latency trading applications in Java if you know what you are doing. But why would you choose to do that when you know what you’re doing? Good question 🙂

    llama
    Full Member

    …. the managed vs unmanaged geek debate continues this morning …

    embracing my inner nerd:

    If a system is adversely effected by GC it does point to poor design, for example, not using object pooling, or heap allocation where stack allocation would be better. As someone who used to regularly hunt down memory leaks in C++, I would rather put up with this design gotcha than go back there.

    Really you are arguing on a horses for courses basis. Of course in performance critical, or low level applications, managed environments are usually not the best. However, on a like-for-like basis, speaking about design paradigms, C++ is not more powerful than the managed world.

    OK there are some neat things you can do with templates in C++ that are not possible to realize elsewhere, but not really any that cannot be done in a managed way without a bit of fiddling. In practical terms, the same is true of multiple inheritance.

    Purely talking about design paradigms, look through the C++ in the Go4 book. Then think how much less code it would be to do it managed. Then think of that scaled up 100 times. Then bless the garbage collector.

    rusty90
    Free Member

    Never come across a situation in Java where I couldn’t do something.

    [quote] I was comparing problem domains where both languages can be used.[/quote]So in the domain where Java can be used, Java can be used.
    Fair play, if you had a choice between Java and C++, choosing Java would make sense (or C# if, like us, you’re a Windows shop). Just pointing out that sometimes your problem is a 6″ nail, and a screwdriver just ain’t gonna work.

    oh wait.. you’re a geek

    Ouch! Being called a geek by a Java adherent 😯

    TurnerGuy
    Free Member

    Then think how much less code it would be to do it managed.

    that is not particularly true – if you write modern C++ then it looks very like a managed language, except you might not have as many finally statements…

    But it is the frameworks in these managed environments where the huge productivity gains exist – even the modern Microsoft frameworks which are very good when compared to things like MFC.

    klumpy
    Free Member

    I’ve been doing this programming thing for about 16-17 years, mostly C++ but a fair amount of all sorts thrown in.

    C++ has the ‘issue’ of having to manage your own heap memory combined with the opportunity to use OO badly. As such when you use OO badly you get in a mess pretty quickly. In a managed environment you take longer to get in a mess, and if the project is small enough maybe you never will.

    For four years a little while ago I worked in a department renowned for on time delivery of working bug free code, and we used C++ pretty much exclusively. It’s not about the language, it’s the people – a culture of excellence, curiosity, and the balls to send working code back to be done again, better. Turns out that actually saves time.

    A worrying trend that seems to be emerging is for people used to managed environments thinking that in C++ smart pointers manage memory for you – in fact they just help you manage your memory.

    And I’ve seen managed code leak. A tangled mess of circular and mutual references means the GC simply can’t figure out what should be released so it just keeps devouring memory.

    If you find you can’t write decent C++ code, you probably shouldn’t code at all.

    mogrim
    Full Member

    If you find you can’t write decent C++ code, you probably shouldn’t code at all.

    Not even… php?

    🙂

    lemonysam
    Free Member

    If you find you can’t write decent C++ code, you probably shouldn’t code at all.

    Well that’s it, I’m hanging up my pocket protector.

    llama
    Full Member

    But it is the frameworks in these managed environments where the huge productivity gains exist – even the modern Microsoft frameworks which are very good when compared to things like MFC.

    Yes well that reinforces my point. The frameworks are more productive not just due to their standardization and size, but also due to a large extent that the language allows a greater range of design paradigms. For example if we are talking msoft, Linq which is able to convert C# expression trees at runtime into an underlying form (this being subtly different to what is possible with STL); or Entity Framework which can represent class graph in a relational database with next to no code being written. Both these things enable high productivity and make heavy use of design paradigms that are impossible to realize in C++.

    IA
    Full Member

    All this talk of Java and C++ and no-one’s yet mentioned the option of creating unholy unions by means of dark rituals such as JNI etc…

    And that’s before we even get to embedding script interpreters etc.

    A favourite horror of mine was doing something with Beanshell*

    *that’s an interpreter for Java (not Javascript, Java) that’s written in Java itself. I’ll leave the dark rituals that require such a thing up to the imagination of the reader…

    GrahamS
    Full Member

    If you find you can’t write decent C++ code, you probably shouldn’t code at all.

    That rather depends on your definition of “decent”. 😀

    To me “decent code” is code that is obvious, easy to understand and test, regardless of the language.
    Which is the main reason I normally steer well clear of most of the more advanced or esoteric features available in C++ that others might consider “clever”.

    (I’ve likewise been coding professionally for 17 odd years in C, C++, C#, Java and others)

    TurnerGuy
    Free Member

    Of course Scala aficionados would berate Java for being unproductive…

    molgrips
    Free Member

    Fair play, if you had a choice between Java and C++, choosing Java would make sense (or C# if, like us, you’re a Windows shop).

    Absoultely, and that’s why my argument is indeed horses for courses.

    Who the hell needs all this complex geekery you can do in C++? There’s a lot of smart-arse questions about Java I’d probably get wrong – why? Because I don’t code like that, and nor should anyone else.

    I make a point of breaking the problem down into the simplest possible code I can write, and that’s always pretty simple. My rule of thumb is that if the code gets difficult and complicated, you need to go back and re-think it until it’s not.

    aracer
    Free Member

    Well even I had to select C++ when I used VS earlier in this thread as my default for Windows stuff is C# (can we have a Java vs. C# debate now? 😈 ) However the majority of my coding isn’t Windows stuff and doesn’t have Java available either (I can code in that, but wouldn’t generally choose to due to my relative level of expertise).

    Which is kind of the point.

    Not most of the people who have to use C++ for reasons mentioned above. Generally we’d all be happy in C

    molgrips
    Free Member

    I’m not sure I could bring myself to use C unless I was doing something really fundamental.

    I think what this highlights is that there’s code and there’s code. Some of us are writing device drivers or embedded code, some of us are integrating systems for enterprise applications. Pretty different worlds!

    oldnpastit
    Full Member

    Of course Scala aficionados would berate Java for being unproductive…

    Apparently, Scala is doing it all wrong, and this is the guy that should know:

    [video]https://www.youtube.com/watch?v=TS1lpKBMkgg[/video]

    If it isn’t straightforward to modify it will never be any good!

    TurnerGuy
    Free Member

    I was thinking of learning Go as that is Ken Thompson, which makes it sound interesting.

    rusty90
    Free Member

    Who the hell needs all this complex geekery you can do in C++?

    In my case (thankfully for only one fairly unique project) because it allows a combination of low-level stuff that can most easily be done in C and assembler and a complex UI with multiple windows and an embedded web browser control using MFC. C++ happens to be the sweetspot.

    I’m doing it because I’m the only one in the company old enough to not run away screaming when they see the source code. And as soon as I finish breathing new life into its decaying corpse I’ve got a sexy new project waiting using HTML5, SignalR and MongoDB.

    can we have a Java vs. C# debate now?

    Nothing wrong with a good programming language religious war. Bit like a wheel size debate 🙂

    molgrips
    Free Member

    a combination of low-level stuff that can most easily be done in C and assembler and a complex UI with multiple windows and an embedded web browser control using MFC.

    Could it be done with say, Java and JNI? Or C# and whatever the equivalent is?

    can we have a Java vs. C# debate now?

    That’s a more useful debate (or not!) because they are much more closely aligned.

    rusty90
    Free Member

    Could it be done with say, Java and JNI? Or C# and whatever the equivalent is?

    Probably. C# plus P/Invoke or COM Interop, or Java plus JNI. But as the JNI wiki says “Basically, anything that Java code can do can be done using JNIEnv, albeit with considerably less ease.”

    That’s a more useful debate (or not!) because they are much more closely aligned.

    Yes, and add Node.js while your at it. But although the language syntaxes are becoming more similar, it’s the frameworks and dev tools that really make the difference, and that’s where it really is horses for courses.

Viewing 40 posts - 121 through 160 (of 160 total)

The topic ‘What is it about C++?’ is closed to new replies.