What's in a language that makes you like it

Started by
63 comments, last by cr88192 10 years, 1 month ago

The few things about c++ i don't understand why it's there is the ';', the '<<' in front of cout, the '>>' in front of cin

Those are overloaded operators. More details here.

and why you have to use a template/tuple/whatever else there is to return more than one variable from a function.

C++ functions are designed to return a single value. If you want or need to return more than one value, there are ways around it.

Advertisement

Intuitive and clean.

Obviously those are all relative to the programmer. People find ObjectiveC to be intuitive, and I find it to be quite the opposite, a gross hack with ugly syntax.

By clean I mean, works the way you expect it to, when you expect it to, how you expect it to. This is where Java falls on it's face. C# is just so much more... clean. If it werent for the pre-generic datatypes, it would be perhaps the cleanest general purpose programming language out there. Java on the other hand has lots of warts, the class libraries are schizophrenic and the language itself is confused with an odd ball type system and many later features hacked on with less elegance than C# managed. Of course, that is only to be expected, as C# learned from Java which learned from C++.

Oh, and on to C++... if Java has lots of warts, C++ *IS* a wart. Or possibly a wart on a wart on a wart. That's the joy of being a real world, non-trivial programming language 30 years of evolution behind you. You are bound to pick up a bit of cruft, and C++ certainly has. It's basically 4 programming languages smushed together, with an entire turing complete language ( templates ) bolted on top! That said, what C++ gives me is native integration and decent portability. It certainly doesnt give me productivity though.

This applies to scripting languages too... JavaScript is a horrendously successful language, there are probably more lines of JavaScript code being written than C++, C# and Java combined. Considering the language was designed in 13 days, that is pretty damned impressive. That said, it certainly isn't a clean language. Some of the design decisions are downright awful for that language ( read JavaScript: The Good Parts, if you want a better idea ). Like C++ though, it is a compromise language of actual working programmers, so its bound to pick up some cruft and warts along the way.

On the other hand Lua is simplicity defined. It's a beautiful language on the level of simplicity and expressiveness.

Increasingly though, it's the libraries that draw me to a language more than the language anymore. I am currently working in Java because of LibGDX, not because I love Java. When working in the browser, TypeScript is a thing of beauty, a true pragmatic programmers language. If I was working on a tool or productivity application, or when I wrote Flexamail, C# was the language of choice more so because of the .NET libraries than the language itself.

So, at the end of the day, what draws me to a language, more so than anything else, are the libraries and tools and the nature of the problem I am trying to solve.

I love programming and all languages so I can't objectively answer this question. I use languages according to what I'm needing done at the time. I like to play with the languages a lot and try doing different projects. A few months back I was doing a test project using C++, MySQL, PHP, CSS, and XML.

I love programming and all languages so I can't objectively answer this question. I use languages according to what I'm needing done at the time. I like to play with the languages a lot and try doing different projects. A few months back I was doing a test project using C++, MySQL, PHP, CSS, and XML.

No offence, but I have to question the sanity of anyone that loves PHP. :)

I like haskell and scheme, they force you to program in a very different way. Scheme hurts my pinky though.

@geoger: i do believe there's a simpler clearer language in c++ waiting to get out but it seems there is no need to bring it out since it and it's father are still really popular.
C is an '...f' (scanf etc.) and '%' language while c++ is a '...stream' (ofstream) and 'c' (cstdlib) language even though not as frequent as ';'

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy

Do you prefer {} over begin .. end or just indentation to break up code like in if statements and loops.

UNREAL ENGINE 4:
Total LOC: ~3M Lines
Total Languages: ~32

--
GREAT QUOTES:
I can do ALL things through Christ - Jesus Christ
--
Logic will get you from A-Z, imagination gets you everywhere - Albert Einstein
--
The problems of the world cannot be solved by skeptics or cynics whose horizons are limited by the obvious realities. - John F. Kennedy

@geoger: i do believe there's a simpler clearer language in c++ waiting to get out but it seems there is no need to bring it out since it and it's father are still really popular.

Of course there is a need, and C++11 and C++14 introduce elements that allow you to write code that is cleaner, simpler, more elegant and more robust than you could with C++98. But there are aspects of the language that simply can't be changed, e.g. the declaration syntax. I'd LOVE to see C++ incorporate Go's declaration syntax, but some parts of the design are set in stone, and changing them would probably break backward compatibility in a way that you effectively have a new language.

You should also bear in mind that C and C++ are popular for a number of reasons other than their simplicity and clarity (both of which C has, C++ not so much). Let's name a few: they are multiplatform, have rich libraries, and robust toolchains.

You don't have to use C++ if you don't want to; in many cases it is not only possible, but better (even *MUCH* better) to use something else, like C#. Which many game developers have been doing. You can even mix and match, e.g. call Lua scripts from C++ code.

C is an '...f' (scanf etc.) and '%' language while c++ is a '...stream' (ofstream) and 'c' (cstdlib) language even though not as frequent as ';'

I don't quite understand this bit.

Do you prefer {} over begin .. end or just indentation to break up code like in if statements and loops.

I like curly braces. They are explicit, clear and concise:


#include <iostream>
using namespace std;

int main()
{
    bool ehDivisivel = false;

    for ( int i = 0; i != 100; )
    {
        ++i;

        if ( ( ( i % 3 ) == 0 ) && ( ehDivisivel = true ) )
            cout << "Fizz";

        if ( ( ( i % 5 ) == 0 ) && ( ehDivisivel = true ) )
            cout << "Buzz";

        if ( ehDivisivel )
            cout << endl;
        else
            cout << i << endl;

        ehDivisivel = false;
    }

    return 0;
}


No offence, but I have to question the sanity of anyone that loves PHP.

From my experience, a question of sanity comes for all programmers as only programmers understand why we love doing this while the rest think we are off our rocker.

This topic is closed to new replies.

Advertisement