Forum search & shortcuts

What is it about C+...
 

[Closed] What is it about C++?

Posts: 91169
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?


 
Posted : 07/11/2014 8:25 am
Posts: 7127
Full Member
Topic starter
 

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


 
Posted : 07/11/2014 8:47 am
Posts: 0
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 😳


 
Posted : 07/11/2014 9:16 am
Posts: 0
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...


 
Posted : 07/11/2014 9:33 am
Posts: 5859
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.


 
Posted : 07/11/2014 9:52 am
Posts: 12089
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.


 
Posted : 07/11/2014 9:57 am
Posts: 91169
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 🙂


 
Posted : 07/11/2014 10:29 am
Posts: 3323
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.


 
Posted : 07/11/2014 10:46 am
Posts: 0
Free Member
 

Never come across a situation in Java where I couldn't do something.
I was comparing problem domains where both languages can be used.
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 😯


 
Posted : 07/11/2014 10:47 am
Posts: 0
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.


 
Posted : 07/11/2014 11:02 am
Posts: 0
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 [b]you[/b] 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.


 
Posted : 07/11/2014 11:16 am
Posts: 12089
Full Member
 

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

Not even... php?

🙂


 
Posted : 07/11/2014 11:18 am
Posts: 0
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.


 
Posted : 07/11/2014 11:18 am
Posts: 3323
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++.


 
Posted : 07/11/2014 11:27 am
 IA
Posts: 563
Free 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...


 
Posted : 07/11/2014 11:44 am
Posts: 31206
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)


 
Posted : 07/11/2014 12:06 pm
Posts: 0
Free Member
 

Of course Scala aficionados would berate Java for being unproductive...


 
Posted : 07/11/2014 12:29 pm
Posts: 91169
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.


 
Posted : 07/11/2014 12:34 pm
Posts: 0
Free Member
 

[quote=rusty90 ]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).

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.

[quote=molgrips] Who the hell needs all this complex geekery you can do in C++?

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


 
Posted : 07/11/2014 12:51 pm
Posts: 91169
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!


 
Posted : 07/11/2014 1:03 pm
Posts: 7127
Full Member
Topic starter
 

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:

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


 
Posted : 07/11/2014 1:36 pm
Posts: 0
Free Member
 

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


 
Posted : 07/11/2014 2:09 pm
Posts: 0
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 🙂


 
Posted : 07/11/2014 3:13 pm
Posts: 91169
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.


 
Posted : 07/11/2014 3:46 pm
Posts: 0
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.


 
Posted : 07/11/2014 4:21 pm
Page 4 / 4