Moving to C++ (47)

1 Name: #!/usr/bin/anonymous : 2007-05-23 00:48 ID:YkEExyXp

I’ve been studying Java for a while and I feel really comfortable with the fact that I could get the JDK and official compiler form Sun’s page, the API is easy to check and find what I need and how to use it.
I am interested in learning C++ but I’m a little bit confused on how the Standard Library works compared to the class libraries in Java. I come to you with these questions:
-> How is the Standard Library different and how does it work?
-> What’s the difference between using one compiler instead of another.
-> What are some good compilers and IDEs you would recommend to someone that’s starting?

Thanks in advance

2 Name: #!/usr/bin/anonymous : 2007-05-23 11:37 ID:Heaven

The answer to your first question would fill one or more books. Go buy one of those books. Besides, there is really no requirement to use the standard library in the first place, as your OS provides APIs that may or may not be better suited for your tasks, and may or may not use parts of the standard library.

The difference between compilers involves things such as quality of the generated code, the degree of standards-compliance in the language implementation and library implementation, the quality of error messages, and fancy stuff like debugging.

The standard compiler these days is pretty much gcc. If you're using Windows, get the mingw version. As for IDEs, I guess Dev-C++ might be useful, but I haven't tried it.

3 Name: dmpk2k!hinhT6kz2E : 2007-05-24 22:08 ID:Heaven

> How is the Standard Library different and how does it work?

Plenty of templating magic. It's also less kitchen-sink than Java's. This is a mixed blessing.

> I guess Dev-C++ might be useful, but I haven't tried it.

Dev-C++ is effectively dead. An alternative is Code::Blocks, which works fair enough.

The development practices of the Code::Blocks dev team are a bit of a joke though.

4 Name: #!/usr/bin/anonymous : 2007-05-25 04:18 ID:Uw54KCh6

[Insert obligatory recommendation to use D instead.]

5 Name: dmpk2k!hinhT6kz2E : 2007-05-25 04:50 ID:Heaven

>>4
We have a winner.

C++ is showing its age, although you still need to know it if you want a job (and hate yourself).

6 Name: #!/usr/bin/anonymous : 2007-05-25 16:13 ID:Gu66WAbT

>>4-5 Do you recommend a good book for D?

7 Name: dmpk2k!hinhT6kz2E : 2007-05-25 17:23 ID:Heaven

Unless you can read Japanese or German, there is none (and the Japanese one is massively out of date). All there are in English are online tutorials, a spec, and some mailing lists.

That's the real problem with D: great language, but it's so bleeding edge that the surrounding ecosystem is still small.

The best I can suggest is:
Summary: http://en.wikipedia.org/wiki/D_programming_language
Tutorials: http://www.dsource.org/projects/tutorials
General: http://www.digitalmars.com/d/index.html
Lists: http://lists.puremagic.com/
IRC: #d@irc.freenode.org

It's definitely not for the inexperienced or anyone adverse to constant change.

8 Name: #!/usr/bin/anonymous : 2007-05-26 14:10 ID:qEEPuu9X

I am german. :D
We had a 10hr tutorial at my university but it was full when I tried to get in. And online tutorials are generally (in my experience) not as good as a well written book. :(

9 Name: #!/usr/bin/anonymous : 2007-05-27 00:47 ID:kNVe66+7

>>8
Cool, I'm german too... so there's at least two German /code/ peoples.

So, I wonder... where exactly in Germany are you from? I'm from somewhere Baden-Württemberg-ish... who knows, we could be neighbours for all we know! ;)

(Sorry if this is a tad offtopic. And anyways, I'm interested in what >>7 would reccomend, too)

10 Name: dmpk2k!hinhT6kz2E : 2007-05-27 17:32 ID:Heaven

The German book is available online: http://www.steinmole.de/d/d_buch.pdf

The formatting leaves something to be desired, but it's fairly up to date. I'd say it's targetted at coders with prior experience in other languages; novices might have a rough time.

11 Name: #!/usr/bin/anonymous : 2007-05-30 22:58 ID:X3ZKE/ar

>>10
Thanks a lot. :)

12 Name: #!/usr/bin/anonymous : 2007-06-04 21:56 ID:Iun4RDZU

>>1

C++ is steaming pile of crap, learning it is only ever useful to know what NOT to do in a programming languages. Compared to it, even Java is good. Learn C and Python if you don't want to move too far away, C and Python and Lisp/Haskell/Prolog if you do.

13 Name: #!/usr/bin/anonymous : 2007-06-04 22:53 ID:S5pomLVt

>>9
Hehe, I am from Niedersachsen. ;)

14 Name: #!/usr/bin/anonymous : 2007-06-05 11:24 ID:8iPPlzly

>>12

No, Java is still much, much worse. C++ may have faults but you can avoid of a lot of them by simply not using those features, and C++ is far more expressive than Java will ever be.

15 Name: #!/usr/bin/anonymous : 2007-06-05 20:18 ID:UHORTx5a

Java > C++

16 Name: #!/usr/bin/anonymous : 2007-06-05 23:16 ID:Heaven

>>15 has never written a real program in his life, nor a real sentence.

17 Name: #!/usr/bin/anonymous : 2007-06-06 01:29 ID:Heaven

Vomit > Feces

18 Name: #!/usr/bin/anonymous : 2007-06-06 15:46 ID:Heaven

>>16
Ohh... weak troll.
You fail because:
1) Talking in absolutes.
2) Using shady, subjectiv definitions.
3) Assumptions.

19 Name: #!/usr/bin/anonymous : 2007-06-06 17:31 ID:Heaven

>>15,18

Are you trying to respond to someone you call a "troll" by claiming they are not making a well-supported argument? That seems just a little bit counter-productive, no?

Not to mention your three points seem to apply equally well to >>15. That was the point - if you want to make an argument, make an argument instead of trying to be a cool kid on the internet.

20 Name: 18 : 2007-06-06 17:59 ID:b2HwoTCq

>>19
14 and 15 are just posting an opinion. Both have not stated any facts. Both of them need to explain why they think so.
Whereas 16 is just a dumb troll trying to provoke 15. Next time you try to troll do it better.

21 Name: #!/usr/bin/anonymous : 2007-06-07 22:57 ID:QRD23Xq2

Here, lemme explain for retards. (Not the OP, though it's kind of retarded to ask this kinda thing here)

C is a STANDARDIZED language. Any compiler you get comes with the STANDARD libraries + any implementation quirks.

You'd wanna use GCC. Under windows you'd get MSYS+MINGW or something.

22 Name: #!/usr/bin/anonymous : 2007-06-07 23:58 ID:Heaven

>>21

Who are you talking to, again?

23 Name: #!/usr/bin/anonymous : 2007-06-08 17:47 ID:Heaven

k

24 Name: #!/usr/bin/anonymous : 2007-06-09 13:51 ID:Heaven

k

25 Name: #!/usr/bin/anonymous : 2007-06-09 17:54 ID:Heaven

k

26 Name: #!/usr/bin/anonymous : 2007-06-09 17:54 ID:Heaven

k

27 Name: #!/usr/bin/anonymous : 2007-06-14 13:13 ID:Heaven

k

28 Name: #!/usr/bin/anonymous : 2007-08-10 18:25 ID:bUWmVBy9

D seems like a really good language, but I haven't seen one thing made by an English-speaking programmer with it. The features are VERY impressive, though, especially to someone like me who programs games (some people will program whatever because they like to program- I just program because I want more games).

29 Name: dmpk2k!hinhT6kz2E : 2007-08-10 20:58 ID:Heaven

The problem with D is it seems to have veered off from being a simpler and more consistent C++ with a GC to some template metaprogramming heaven.

Now that he's playing with constness (do you know the difference between const/final/invariant?), I'm tempted to ask: why didn't he make a compiled functional language to begin with? At least there would be no runtime/compile-time dichotomy. Templates, static if, CTFE, textual mixins, tuples, constness... all those concerns would either be gone or unified.

30 Name: #!/usr/bin/anonymous : 2007-08-11 00:07 ID:YbIFRpnu

"Static if"? Is that some kind of code for "our optimizer is a piece of shit"?

31 Name: #!/usr/bin/anonymous : 2007-08-11 02:57 ID:UCW44LxJ

>>30
Yes. Also, "we have an irrational dislike of the C preprocessor".

D also seems to have a problem with string literals being mutable char arrays. Which can have three effects: a) shit blows up when one tries to change a string literal's contents; b) a string literal is duplicated into the GC heap whenever one is referenced; or c) the string literal is copied lazily on modify, which kind of breaks arrays due to changing the underlying pointer and adds "is this bit set? no? then gosub copy" logic to every last damned char array write.

Someone tried to present this as a problem to the D users in their newsgroup a few years back. The result was that some fangirl pounced on the chance to protect the tribe, saying that "D doesn't need Java's String class".

There doesn't seem to be any point to D. It's not Java, it's not C#, it's definitely not C++ and yet it brings none of the features of more advanced languages (type inference? oh no.) to the table. Also, it manages to have more horrible template syntax than C++, and a worse module system than Python.

32 Name: #!/usr/bin/anonymous : 2007-08-11 03:00 ID:Heaven

Oh, wait, D has constness now? Ha ha. Guess they came around then.

33 Name: dmpk2k!hinhT6kz2E : 2007-08-11 05:26 ID:Heaven

D's concept of constness is more nuanced. It's also harder to remember, in large part to a poor choice of keywords. No matter how many times I read the difference between const/final/invariant, I seem to have forgotten by the next week. This contrasts starkly to Walter Bright's normal philosophy of making it easy to do the right thing and more difficult to do the wrong.

Not to bash D too harshly. It's written by a master at C++ compilers (Walter Bright), played with with by a C++ guru (Andrei Alexandrescu), and used by a community of experienced C++ developers. And it shows. I feel that D really is in most ways a better C++ than C++ as a language (which ignores the critical issues of libraries, community support, and richness of toolset, which C++ obviously wins).

Of course, a better C++ that C++ isn't all that great in my opinion. Alexandrescu has argued that supporting library developers is critical, and catering to library developers with all the metaprogramming goodies does appear to be paying dividends for D. D has drawn a largely C++ crowd, so cater to them.

However, I'll argue that any language that has template metaprogramming is fundamentally flawed. It doesn't matter how similar the syntax is, you've essentially chopped the language into two very different languages. C++ has an excuse: the accidental discovery of functional programming with templates allowed the almost-frozen and very limited C++ to be extended beyond its original capabilities.

D doesn't have that excuse. So unless something changes dramatically, I don't think it'll reach much beyond an enthusiast community inhabited by a core group of former C++ developers.

34 Name: #!/usr/bin/anonymous : 2007-08-17 03:04 ID:wQqLz1a8

Not to say you're a total fucktard, but you're a total fucktard.

C++ is for mentally retarded beginner programmers.

35 Name: #!/usr/bin/anonymous : 2007-08-21 04:36 ID:liSWYG6u

Beginner programmers can't possibly understand C++.

36 Name: #!/usr/bin/anonymous : 2007-08-21 05:10 ID:l1dd/dII

>>33
Yes, I agree. Template metaprogramming is how one does "clean" (ha!) macros in C++, and duplicating it rather than doing a proper syntax-level macro system is nothing short of retarded. Doubly so when languages such as Haskell have demonstrated that most of the time resorting to explicit templates shouldn't be necessary, i.e. that most code should be implicitly typed anyway. Furthermore, the properties of types should be expressed formally in the language itself, rather than the "this model has these methods" formalized commenting styles of C++ TMP.

D is, in short, an improved and superficially rethought C++. And that doesn't go very far anymore.

37 Name: #!/usr/bin/anonymous : 2007-09-05 14:51 ID:lwTMx+N5

>>35
I started on C++.

38 Name: #!/usr/bin/anonymous : 2007-09-05 18:17 ID:NeLqBh/3

>>37
In actuality, you probably started on BASIC or LOGO, you're just repressing those traumatic memories.

39 Name: #!/usr/bin/anonymous : 2007-09-09 17:00 ID:lwTMx+N5

True enough. I started on Apple BASIC, and then did a bit of assembler for Apple ][. Then I did nothing for several years and started serious programming on C++.

40 Name: #!/usr/bin/anonymous : 2007-09-10 17:51 ID:1tS18gmd

So what does everyone think of the new specification of C++ called C++0x?

41 Name: #!/usr/bin/anonymous : 2007-09-11 01:55 ID:Heaven

>>40
I guess the new, pervy uses of template metaprogramming have to be formalized somewhere. I hope there won't be a C++1x or a C++2x.

42 Name: #!/usr/bin/anonymous : 2007-12-08 16:18 ID:99+yCZPz

Why does everyone bash C++? What's so bad about it?

43 Name: #!/usr/bin/anonymous : 2007-12-08 18:30 ID:YbIFRpnu

Mostly that there is too much of it. It doesn't have the simplicity of C, and it doesn't have the higher-level features of other languages.

44 Name: #!/usr/bin/anonymous : 2007-12-08 22:50 ID:Heaven

>>42
I dislike it because of the temptation to "library programming".

45 Name: #!/usr/bin/anonymous : 2007-12-09 00:34 ID:Heaven

>>44
Unable to google a definition for that term. "Library programming" meaning what?

Relying on libraries of already written code?

46 Name: dmpk2k!hinhT6kz2E : 2007-12-09 02:30 ID:Heaven

Maybe >>44 meant template metaprogramming.

Given the relative inflexibility of the language, it's tempting to over-engineer to be safe.

47 Name: #!/usr/bin/anonymous : 2007-12-10 12:59 ID:UCW44LxJ

>>45
Library programming refers to writing libraries for "in case I ever need them" rather than getting stuff actually done.

This thread has been closed. You cannot post in this thread any longer.