What is it about C+...
 

MegaSack DRAW - This year's winner is user - rgwb
We will be in touch

[Closed] What is it about C++?

159 Posts
46 Users
0 Reactions
417 Views
Posts: 31206
Full Member
 

Pfffft... all you really need is [url= http://en.wikipedia.org/wiki/Ed_%28text_editor%29 ]ed[/url] 😉

[url= http://xkcd.com/378/ ]Also xkcd[/url]


 
Posted : 06/11/2014 1:09 pm
Posts: 7060
Free Member
 

seems to use the form i++ instead of ++i even

better than "i = i++"

which I have seen used in anger, once.


 
Posted : 06/11/2014 1:18 pm
Posts: 1460
Full Member
 

better than "i = i++"

Isn't that undefined?


 
Posted : 06/11/2014 1:21 pm
Posts: 0
Free Member
 

[quote=GrahamS ]Also xkcd

😀 Started off using emacs (actually umacs, but it's close enough to count) and was once fluent in that - then I did a lot of work on minimalist systems where that wasn't installed, so ended up having to learn how to use vi(m) which I loathe, but will defend to the death to anybody who dares criticise it. Though I've not recently come across a system which doesn't include nano - the main advantage of which is it's better than vi 😉


 
Posted : 06/11/2014 1:22 pm
Posts: 0
Free Member
 

[quote=chambord ]better than "i = i++"
Isn't that undefined?

I'm fairly sure it results in i++ as that's a postincrement operator so the assignation should happen first. I'm not sure I'd want to rely on it though. Let's test...

Edit: Yep - using gcc in the latest raspbian it works as I suggest.


 
Posted : 06/11/2014 1:25 pm
Posts: 1460
Full Member
 

Well the result will depend on your compiler.


 
Posted : 06/11/2014 1:29 pm
Posts: 31206
Full Member
 

I've not recently come across a system which doesn't include nano

You need to work on embedded systems more 😀
I've had the pleasure of creating (small) text files using cat or echo because that was all we had room for on the install.

Yes please Mike

And by "Mike" I mean "aracer"

#readingfail


 
Posted : 06/11/2014 1:30 pm
Posts: 5755
Full Member
 

And there we were thinking all this forum was middle management in IT, but this suggests we still have some technical people around!


 
Posted : 06/11/2014 1:41 pm
Posts: 0
Free Member
 

[quote=GrahamS ]You need to work on embedded systems more

I think it's that the ones I've worked on are either at a similar level to RPi where you have stuff like that, or far smaller and not running on OS at all.

Oh, and the code also works as I suggested in VS2008 which is the other platform I have immediate access to, so I've covered the two most widely used C(++) compilers. Don't think I CBA to start a VM to prove it also works in a different flavour of Linux.

Edit: oh what the heck <fires up Atmel Studio>


 
Posted : 06/11/2014 1:42 pm
Posts: 0
Free Member
 

Here you go, Graham:

Ok, here is a snipet of code that is much cleaner with the GOTO than
without (BTW it's the only goto in several thousand lines of code
belonging to the same project).

[code]// direct_declarator:
// identifier
// | '(' declarator ')'
// | direct_declarator '[' constant_expression ']'
// | direct_declarator '[' ']'
// | direct_declarator '(' parameter_type_list ')'
// | direct_declarator '(' identifier_list ')'
// | direct_declarator '(' ')'
// ;

p1 = parse_identifier();

if (p1 == NULL)
{
p1 = parse_lparen();

if (p1 != NULL)
{
ITEM *p2;

p2 = parse_declarator();

if (p2 != NULL)
{
ITEM *p3;

p3 = parse_rparen();

if (p3 != NULL)
{ p1 = p2;
goto lab1;
}

push_item(p2);

p2 = NULL;
}

push_item(p1);

p1 = NULL;
}
}

lab1:

[/code]


 
Posted : 06/11/2014 1:55 pm
Posts: 0
Free Member
 

yes but that is goto in effectively C, not C++, where its use is even more unwise.

I arranged a code review of some guys code once as it was leaking resources all over the place because it was using a goto to handle errors, then I found the MSDN code examples it was modelled on and they had the same leaks in.


 
Posted : 06/11/2014 2:13 pm
 IA
Posts: 563
Free Member
 

So, as there's a bunch of C++ aficionados in one place here, any recommendations for an IDE to deal with a series of gnarly unix/linux C++ projects that's better than the CDT in Eclipse?

The only thing drowning out the wails of despair fading into tears when the indexer decides to run is the sound of my laptop's fans...


 
Posted : 06/11/2014 2:18 pm
Posts: 1460
Full Member
 

Every time I google this I read that QtCreator is your best bet in Linux (It does normal c++ as well as Qtey stuff).

Otherwise people recommend code::blocks


 
Posted : 06/11/2014 2:30 pm
Posts: 0
Free Member
 

@IA: Qt Creator is very popular for std C++ as well as Qt projects.

Edit: Snap chambord!


 
Posted : 06/11/2014 2:31 pm
Posts: 17371
Full Member
 

oldnpastit - Member
It's late. I'd like to be at home. But instead I'm reading through mountains of poorly written jumbled up and incomprehensible C++ (looking at you, Qt).

What is it about this language that encourages people to write utterly opaque code?...

Simple. Guarantees future employment, probably as an extortionately paid consultant to fix it about 3-4 years after your original employer sacked you for writing incomprehensible garbage.


 
Posted : 06/11/2014 2:50 pm
 IA
Posts: 563
Free Member
 

Cheers, will check out what Qt Creator is like these days then, not tried it for years.


 
Posted : 06/11/2014 2:53 pm
Posts: 31206
Full Member
 

Here you go, Graham

Blimey! See that right there is a great example of code that is a tangled mess of logic paths, mostly by the way it is structured and by the use of goto.

Okay give me a minute and I'll see if I can make sense of it.


 
Posted : 06/11/2014 2:58 pm
Posts: 31206
Full Member
 

Yeesh that was horrible, okay aracer how is this:

[code]ITEM* p1 = parse_identifier();
 
if (p1 == NULL)
{
    ITEM* plparen = parse_lparen();
    
    if (plparen != NULL)
    {
        ITEM* pdecl = parse_declarator();
        
        if (pdecl != NULL)
        {
            if (parse_rparen() != NULL)
            {
                p1 = pdecl;
            }
            else
            {
                push_item(pdecl);
                push_item(plparen);
            }
        }
        else
        {
            push_item(plparen);
        }
    }
}
 
// whatever the code at lab1 was going to do...[/code]

(Note: in a real situation I'd refactor that completely and slap whoever wrote the original)


 
Posted : 06/11/2014 3:25 pm
Posts: 12079
Full Member
 

if (p1 == NULL)

Why the == NULL?

if (!p1)


 
Posted : 06/11/2014 3:37 pm
Posts: 0
Free Member
 

and too many braces...


 
Posted : 06/11/2014 3:42 pm
Posts: 31206
Full Member
 

Why the == NULL?

I just kept it the same as the original for clarity.

Also some strict standards forbid logical operations on anything other than booleans.

and too many braces...

Again some strict standards (rightly IMO) forbid the use of single line expression blocks - we always put braces for every block.

Avoids nasty stuff like this:

[code]if(a)
  if(b) x=y;
else x=z;[/code]


 
Posted : 06/11/2014 3:44 pm
Posts: 0
Free Member
 

the problem is rarley the langauge and much more likely the eejit that wrote it in the first place, often trying to be too clever... I've even seen someone rewrite the .net framework because they could...


 
Posted : 06/11/2014 3:45 pm
Posts: 91097
Free Member
 

C++ is the programming equivalent of lots of rope. You may hang yourself with it if you want, or just get it all horribly tangled up.

Java is an attempt to prevent you from doing this. It's a lot nicer imo.


 
Posted : 06/11/2014 4:00 pm
Posts: 31206
Full Member
 

C++ is the programming equivalent of lots of rope. You may hang yourself with it if you want, or just get it all horribly tangled up.

C gives you enough rope to hang yourself.

C++ gives you enough rope to shoot yourself in the foot.


 
Posted : 06/11/2014 4:05 pm
Posts: 0
Free Member
 

Java is an attempt to prevent you from doing this. It's a lot nicer imo.

it is like C++ with stabilizers you mean.

It is worth learning to program idiomatic Java as it can improve your C++ style, but there are lots of design/programming paradigms you can do in C++ which you can't do in Java or C#, mostly to do with generics.


 
Posted : 06/11/2014 4:09 pm
Posts: 3293
Full Member
 

there are lots of design/programming paradigms you can do in C++ which you can't do in Java or C#

Such as?

I'd say rather that the reverse is true


 
Posted : 06/11/2014 4:18 pm
Posts: 91097
Free Member
 

Yes, but do you really need to do those things?

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


 
Posted : 06/11/2014 4:18 pm
Posts: 0
Free Member
 

Never come across a situation in Java where I couldn't do something.
Written many device drivers in Java? 🙂
We have a desktop app that does some very low level stuff, to the degree that it includes inline assembler and direct kernel calls. C++ is still the tool of choice for such stuff.


 
Posted : 06/11/2014 4:34 pm
 beej
Posts: 4148
Full Member
 

I once wrote a date conversion routine that ended up stopping all new connections to a UK mobile network for the month of December.

Converting from 01, 02, 03... to JAN, FEB, MAR.

In Fortran (comments indicated by a "!"), something along the lines of

If 01 then month=JAN
ELSEIF 02 then month=FEB
..
..
ELSEIF 12 then month=DEC
ELSE
! Something bad as the month isn't 01-12, bomb out
Throw fatal error

All well and good(ish), however... I'd left a "!" in front of the final ELSE, turning it into a comment.

I was late into the office 1st Dec, to be greeted by s****s and "uh-oh, you're in trouble" head shaking. We fixed it by about 11am. My one saving grace was I had the signed-off code review proving my mate had missed the extra "!" as well.


 
Posted : 06/11/2014 4:39 pm
Posts: 0
Free Member
 

I'd say rather that the reverse is true

only if you look at reflection and the support that gives.

But you can do loads more in terms of generic programming and template metaprogramming in C++ which you wouldn't be able to do in Java, or C#.

But they are not comparible languages - you wouldn't even consider writing an operating system in Java, for example...


 
Posted : 06/11/2014 4:41 pm
Posts: 31206
Full Member
 

beej: An obvious question would be "Why did your unit tests miss that?" - but given you were writing in Fortran I suspect the answer is equally obvious 😀


 
Posted : 06/11/2014 4:42 pm
Posts: 42
Free Member
 

if (p1 == NULL)

Why the == NULL?

if (!p1)

The second form, while it most likely compiles the same, is an implicit conversion from pointer to bool which could cause readability issues without a consistent naming scheme. That's 3 MISRA rule violations in that slight difference. (MISRA != fun).


 
Posted : 06/11/2014 4:47 pm
Posts: 0
Free Member
 

Well done Graham. By that point in [url= http://www.piclist.com/techref/postbot.asp?by=thread&id=%5BPIC%5D+List+of+C+Questions&w=body&tgt=post ]the thread[/url] I couldn't be bothered to work out the control flow, so just put it in a function with a return in place of the goto 😉

I thought it interesting the comments suggesting removing the NULL and a set of braces - doing that is exactly the sort of thing which gets C++ a bad name, and coding standards tend to require you to write it just as Graham has for very good reasons. Personally I would never test for a null variable by using it directly as a boolean in the way suggested in code I expected anybody else to ever have to maintain, and I've been so brainwashed that I always use full sets of braces even in my own scratch code (unless I'm deliberately trying to minimise, confuse or obfuscate).

[quote=molgrips ]C++ is the programming equivalent of lots of rope. You may hang yourself with it if you want, or just get it all horribly tangled up.

Alternatively if you're clever and careful
[img] [/img]


 
Posted : 06/11/2014 4:48 pm
Posts: 349
Free Member
 

and I've been so brainwashed that I always use full sets of braces even in my own scratch code (unless I'm deliberately trying to minimise, confuse or obfuscate).

I know a guy who uses them in python, he comments them out along with semi-colons!


 
Posted : 06/11/2014 4:50 pm
Posts: 0
Free Member
 

Ah yes - I'm sure I've seen commented out semi-colons in VB!


 
Posted : 06/11/2014 4:53 pm
Posts: 0
Free Member
 

I know a guy who uses them in python, he comments them out along with semi-colons!

I do that when I'm struggling to understand someone else's code (only the brackets, not the semicolons, that's weird) 😳


 
Posted : 06/11/2014 4:54 pm
Posts: 31206
Full Member
 

More accurately:

[img] [/img]


 
Posted : 06/11/2014 5:04 pm
Posts: 0
Free Member
 

Alternatively if you're clever and careful ...
Unfortunately I tend to get to work with stuff like this 🙁
[img] [/img]


 
Posted : 06/11/2014 5:05 pm
 beej
Posts: 4148
Full Member
 

@GrahamS - We tested in November. Never bothered changing the system date.

I was a) not massively experienced and b) never planning to write code for a living.

That was about 1994-95. Scarily, some of my code is still running.


 
Posted : 06/11/2014 5:14 pm
Posts: 17
Free Member
 

Ah crap I'm now reading the rest of this at the bar and trying not to laugh out loud


 
Posted : 06/11/2014 5:21 pm
Posts: 1004
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.


 
Posted : 06/11/2014 5:31 pm
Posts: 0
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 🙂


 
Posted : 06/11/2014 6:09 pm
Posts: 31206
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.


 
Posted : 06/11/2014 6:13 pm
Posts: 42
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.


 
Posted : 06/11/2014 7:40 pm
Posts: 0
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.


 
Posted : 06/11/2014 8:05 pm
Posts: 0
Free Member
 

<learns to code in Haskell>


 
Posted : 06/11/2014 8:15 pm
 IA
Posts: 563
Free Member
 

http://crashworks.org/if_programming_languages_were_vehicles/

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.


 
Posted : 06/11/2014 8:32 pm
Posts: 6208
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.


 
Posted : 06/11/2014 9:11 pm
 IA
Posts: 563
Free 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)


 
Posted : 06/11/2014 10:09 pm
Posts: 0
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.


 
Posted : 06/11/2014 10:33 pm
Posts: 6208
Full Member
 

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


 
Posted : 06/11/2014 10:35 pm
Posts: 91097
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 🙂


 
Posted : 06/11/2014 10:43 pm
Posts: 0
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...


 
Posted : 06/11/2014 10:54 pm
Posts: 0
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.


 
Posted : 06/11/2014 10:57 pm
Posts: 0
Free Member
 

[quote=aracer ]Edit: oh what the heck <fires up Atmel Studio>

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


 
Posted : 06/11/2014 11:49 pm
Posts: 91097
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 7:25 am
Posts: 7090
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 7: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 8: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 8:33 am
Posts: 5593
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 8:52 am
Posts: 12079
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 8:57 am
Posts: 91097
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 9:29 am
Posts: 3293
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 9: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 9: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 10: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 10:16 am
Posts: 12079
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 10: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 10:18 am
Posts: 3293
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 10: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 10: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 11:06 am
Posts: 0
Free Member
 

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


 
Posted : 07/11/2014 11:29 am
Posts: 91097
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 11:34 am
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 11:51 am
Posts: 91097
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 12:03 pm
Posts: 7090
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 12: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 1: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 2:13 pm
Posts: 91097
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 2: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 3:21 pm
Page 2 / 2