Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3
  ignore  |  Print  
  C++ standard library is really lacking - good or bad?  (Read 3267 times)
0 Members and 1 Guest are viewing this topic.
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Posted 2014-02-26 22:37:30 »

I decided to get back into C++ (this is possibly my third of fourth time trying to get past the initial learning curve of the language), and so I decided to make a small program that has to deal with reading files. The program basically opens a file, reads the lines and then compares some strings against the strings in the file. Simple really, it wasn't very hard to code, but I ran into a couple of issues. Namely:

-Next to no string operations. IE: no splitting, no trimming etc...

And that was my biggest issue. Why trimming? I accidentally saved the file containing the strings with an extra space added onto the end of one line. When the program checked to see if the two strings were a match, the stream saw a space and said that the strings didn't match, which is fine. So I looked into string operations, and look at that, C++ pretty much includes nothing besides the very basic stuff. Maybe I'm spoiled by how "complete" the Java library is, or maybe C++ tries to take a different approach to it's internal libraries, but I find it very inconvenient not to have basic functionality such as this just built in. Thoughts?

Offline The Lion King
« Reply #1 - Posted 2014-02-26 23:05:34 »

Most of these things are not that hard to add in yourself and there is always 3rd party libraries if you want. One of the things Java prides itself on is a large and powerful standard library. Java wins in that case.

C/C++ is good to learn to an extent because it brings you a little closer to the hardware and helps you understand programming a bit more, especially with optimizing java performance, understanding memory (heap/stack), etc.

C++ makes code a bit longer, but gives you more control. For example, it allows you to pass by reference or by value. Don't confuse this with more speed, in fact you first attempts at larger programs with C++ will probably be slower than your equivalent code in Java.

In conclusion, you should just stick at it, these holes in the standard lib will give you a chance to practice your C++ by filling them in. Learning C++ will be beneficial. Whether you wish to stick with it once you learn it is just a personal opinion and also depends on how much control you want/need in what you are working on.

"You have to want it more than you want to breath, then you will be successful"
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #2 - Posted 2014-02-26 23:07:52 »

I understand that C++ is much "harder" to work with, but I feel it is necessary to work with and I wanted to learn another language. I've messed around with Python and Dart also, both of which have many functions in their standard libraries. I guess it was a bit of a shock to go to C++ and find out some of this stuff wasn't included. I guess it just shows the power of the language really!

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline TeamworkGuy2

Junior Member


Medals: 10



« Reply #3 - Posted 2014-02-27 00:43:33 »

Interesting question to think about. I understand what your saying opiop, I started in C and later learned Java and the difference moving to Java felt so gooood!
I remember having to implement my own line-by-line file reading, string comparisons and array searching in C for university programming classes and I had to do the same stuff so often that I just started copy pasting it from project to project so I didn't have to redo it (kind of like the start of a library).

I remember having to implement binary searches, bubble sort, quick sort, heap sort, etc.  Build binary tree structures and searches for them  Roll Eyes.  I wouldn't discount the experience that gave me, but I am never going back.
When I compare some of the code I wrote back then to a Java library object/method for sorting, searching, binary trees, etc., my code is far worse Tongue.  Why implement something you are never going to think about twice like string comparisons when a language already provides it.  Your own implementations are likely to contain a lot more bugs than a library.

I understand what Lion King is saying about C++ or a similar lower level language giving you a chance to practice your coding and algorithm solving skills, but at some point it becomes a futile exercise in wasting time.
Similar to how most universities' CS/CE programs have at least one assembly language class in 2014.  You will probably never use it, but the exposure is good.  Once you've had a few weeks or months of practice (depending on how intense the practice is) it's not really useful to continue. Why reinvent the wheel (although I guess we, on JG, tend to do that a lot so who am I to talk Wink)
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #4 - Posted 2014-02-27 01:04:50 »

I agree that it is very much worth it to implement those low level functions! In my high school computer science class we "recreated" many of the basic Java data types including arrays, arraylists, strings, floating point numbers, linked lists and a few more I can't remember... Tongue While it wasn't the most interesting thing to learn, I now know the basics of how compilers interpret code and how memory is stored in memory blocks and then accessed.

I do agree that its also a waste of time after you have already written it! Someone on StackOverflow mentioned that its a good thing because it gives the language much more flexibility because no one person dictates how the language is set up. While this sounds good in practise, I think its only useful to a point. IE my situation. I know how trim and split works, but I seriously do not want to re-write those functions (especially because I don't know some of the more advanced C++ functions this would require!).

I still want to learn the language though because I'm sure I'll have to use it down the line, not to mention its good practice to learn different languages and their designs. Butt I can't say I'm entirely excited about the fact that I'll have to rely on a ton of third party libraries to get things done Sad

Offline jonjava
« Reply #5 - Posted 2014-02-27 01:15:27 »

(especially because I don't know some of the more advanced C++ functions this would require!).

The thing is there are no advanced functions. Especially if you look at plain old C. The easiest and simplest programming language there is. All you do is compare memory to memory (i.e., bytes).

Butt I can't say I'm entirely excited about the fact that I'll have to rely on a ton of third party libraries to get things done Sad

"Relying" on third party libraries is what 99% of programming is about.

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #6 - Posted 2014-02-27 01:20:58 »

Well let me refine my statement. I don't know much about the language yet, so its a major deterrent to me because I really don't know the functions that would be required to write a trim method yet. Its purely a problem because of how new I am to the language, but its still a problem nonetheless. I guess that's why the language has such a high learning curve, but seems really easy after you get last that initial point.

I figured out how pointers work today and why they are useful, and now the language seems so much easier to work with. It really is a damn powerful language, but that comes with its downfalls.

Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #7 - Posted 2014-02-27 04:17:56 »

You may like Rust.

Quote
Rust is a programming language with a focus on type safety, memory safety, concurrency and performance. It is intended for writing large-scale, high-performance software that is free from several classes of common errors. Rust has a sophisticated memory model that encourages efficient data structures and safe concurrency patterns, forbidding invalid memory accesses that would otherwise cause segmentation faults. It is statically typed and compiled ahead of time.

As a multi-paradigm language, Rust supports writing code in procedural, functional and object-oriented styles. Some of its pleasant high-level features include:

  • Type inference. Type annotations on local variable declarations are optional.
  • Safe task-based concurrency. Rust's lightweight tasks do not share memory, instead communicating through messages.
  • Higher-order functions. Efficient and flexible closures provide iteration and other control structures
  • Pattern matching and algebraic data types. Pattern matching on Rust's enumeration types (a more powerful version of C's enums, similar to algebraic data types in functional languages) is a compact and expressive way to encode program logic.
  • Polymorphism. Rust has type-parametric functions and types, type classes and OO-style interfaces.


Just one warning: It hasn't had a 1.0 release. Every now and then you need to change pieces of your code.

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #8 - Posted 2014-02-27 04:24:18 »

Sounds interesting, I might check it out after I learn some more C++. I have been messing around with lots of languages lately and many of them feel "flimsy" and not as powerful as C++ or Java. For example, Dart. Its a good language, but it seems the developers tried so hard to differentiate the language from say Java. I just don't want to learn another language I will only use once for a very specific purpose, I want to learn languages that encompass hundreds of uses.

Offline GoToLoop

Junior Member


Medals: 1
Exp: 1 year



« Reply #9 - Posted 2014-02-27 05:11:27 »

There's also the C++, Rust & Go rival, the D language -> http://dlang.org
Like Dart, it also implements classes & GC very Java like!   Grin  
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline aldacron

Senior Member


Medals: 9
Exp: 16 years


Java games rock!


« Reply #10 - Posted 2014-02-27 05:31:12 »

Here are some ideas on string trimming in C++.

There's also the C++, Rust & Go rival, the D language -> http://dlang.org
Like Dart, it also implements classes & GC very Java like!   Grin  

I've been involved with and using D in one form or another for 10 years, almost exclusively for the past couple. It's usually my first choice for any new code I write. It's hard for me to even touch C++ anymore, though I still have a soft spot for Java (I have a Java project I'm working on sporadically that I hope to finish eventually).
Offline PaulReeves

Senior Newbie





« Reply #11 - Posted 2014-02-27 14:00:21 »

I code in C++ at work and for years used any other language I could when at home. With the advent of C++11 and the many additions it made I now find myself fairly happy to code in C++ at home. It was a real improvement. Of course the additions mean the language is even bigger and thus harder to learn. It is crying out for a 'C++ The good parts' book to help people learning it. I imagine learning it from scratch could take a while.

I flip between Java and C++ for coding at home and find both enjoyable.

For trim functions I am sure that is covered in the boost library.
Offline Roquen
« Reply #12 - Posted 2014-02-27 15:53:41 »

For pure learning experience there's nothing really to be gained by learning C++ if you know java...they're pretty much the same.  If that's the case you should choose a language that'll teaching something new about programming.
Offline aldacron

Senior Member


Medals: 9
Exp: 16 years


Java games rock!


« Reply #13 - Posted 2014-02-27 16:27:11 »

For pure learning experience there's nothing really to be gained by learning C++ if you know java...they're pretty much the same.  If that's the case you should choose a language that'll teaching something new about programming.

I disagree. I think differently and design differently in both languages. Certain common C++ idioms are just not applicable in Java (and the other way, too). I think understanding both languages in enough detail to clearly appreciate the differences between them is a valuable undertaking.
Online junkdog
« Reply #14 - Posted 2014-02-27 16:54:52 »

Also, from a professional standpoint, the typical jobs associated with java and c++ are quite different (not even sure I've ever seen a non-enterprisey java job offer, small indie games being an exception). As a dilettante of c++ myself, I think it promotes a more low-level view of the world, whereas java in it's most immediate form emphasizes a higher level way of thinking.

artemis-odb: bugfixing and performance optimized fork of artemis ES
Offline cylab

JGO Ninja


Medals: 38



« Reply #15 - Posted 2014-02-27 17:48:24 »

IMO the only low level part of C++ is just C.

Other than that C++ requires you to very much think about what possibly could go wrong beforehand, because with C++ it will go wrong in the end and you will have a hard time to debug it.

Granted, this opinion is based on legacy experience, but I doubt it has changed too much...

Mathias - I Know What [you] Did Last Summer!
Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #16 - Posted 2014-02-27 17:50:41 »

I also disagree. The amount of knowledge I've gained from the past week of learning C++ has really helped me to understand exactly how pointer allocation works, among other things, which I think is very important to understand.

From multiple Google searches I've found that it seems many employers want you to know C++, so I decided to start learning it now! I want to learn languages that I will actually need (if I get a job related to programming) and not random ones I won't. For instance, Dart or even Rust. As good as those languages are, I doubt an employer would look for them on a resume. Sure, they would be useful and it never hurts to learn a language, but I would rather make sure I have my basic ones down before moving onto languages that are built for more specific problems and intentions.

Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #17 - Posted 2014-02-27 17:59:54 »

The thing is there are no advanced functions. Especially if you look at plain old C. The easiest and simplest programming language there is. All you do is compare memory to memory (i.e., bytes).

eh... Hey guys! What about Lisp and it's Dialects (Scheme, clojure, etc.)?
I can't imagine a language concept that is simpler than that of Lisp. I'm pretty sure.

Also, learning a functional language (instead of more imperative ones) might (or better:) WILL make you a better programmer Smiley


Sorry for being a functional language advocate in an imperative language forum.. ^^

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline GoToLoop

Junior Member


Medals: 1
Exp: 1 year



« Reply #18 - Posted 2014-02-27 18:05:42 »

Main difference between what Java/C# calls a reference & C/C++/D calls a pointer is that the latter includes memory addresses for everything that got 1.  
That is, references for variables & functions; not just objects!   Roll Eyes  
Offline Cero
« Reply #19 - Posted 2014-02-27 18:22:09 »

Other than that C++ requires you to very much think about what possibly could go wrong beforehand, because with C++ it will go wrong in the end and you will have a hard time to debug it.

Granted, this opinion is based on legacy experience, but I doubt it has changed too much...

John Carmack said this so many times, so no, its an inherent problem with C++ and only fixed by a lot of static code analysis tools

Offline The Lion King
« Reply #20 - Posted 2014-02-27 18:22:57 »

For pure learning experience there's nothing really to be gained by learning C++ if you know java...they're pretty much the same.  If that's the case you should choose a language that'll teaching something new about programming.

You've been programming for forever so for that reason Java and C++ might seem extremely similar, because they are. I commonly accidently write code in C++ while doing java or visa versa. Java if learned completely gives you all the knowledge you need to easily learn C++; however, for someone who doesn't really understand memory and has always just depended on Java's abstraction on the subject, getting that abstraction removed is a large shock and can force them to learn a lot.

I do agree though that after you learn the basics of C++, then using either C++ or Java just becomes mainly a preference thing. Though sometimes you can always go back to C to learn things you do in Java more thoroughly (like networking for example). Kinda like LWJGL and libGDX just not as different.

IMHO, people who have started in Java (and did not learn it from a CE type of perspective) should some time to learn the basics of C and spend some time to learn the basics of (as Matheus mentioned) lisp.

"You have to want it more than you want to breath, then you will be successful"
Offline Roquen
« Reply #21 - Posted 2014-02-28 09:47:52 »

I agree with pretty much everything people have said in response to my post.  But they are only pragmatic issues.  Learning one if you know the other will teach you very little new about "programming" or how you think.

WRT: Lisp likes.  It's a very good choice...but only if you go deep, which few people do.
Offline matheus23

JGO Kernel


Medals: 106
Projects: 3


You think about my Avatar right now!


« Reply #22 - Posted 2014-02-28 09:58:38 »

WRT: Lisp likes.  It's a very good choice...but only if you go deep, which few people do.

There is one thing I might want to note:

When I first started learning Lisp/Scheme/Scala I pretty much found myself writing Java in another language. That's also what will happen to you with C++ probably.

Learning another Language is not only learning the syntax. It's thinking differently.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline ctomni231

JGO Wizard


Medals: 97
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #23 - Posted 2014-03-01 02:37:23 »

Yeah, I came from c++ to java and I remember being absolutely frustrated that you couldn't do pointers, structs, or operator overloading. But it isn't a bad thing...

Learning C will make your java experience more streamlined and efficient. Java might have a thick verbose shell, but there are ways to drain the speed and flexibility out of java. Regardless, they are both very similar languages. I agree with everything else people here have said already.

My hype and hope for Java is slowly withering away... Hopefully Oracle can pull it back together or I might end up running back to c++.

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #24 - Posted 2014-03-01 04:08:23 »

I do love C++, but it definitely has shown me how lucky I feel to know Java also. With C++ I pretty much have to do everything myself, which is ok, but I like being able to just program in Java and not worry about things that I really don't need to worry about. Sure, pointers are very useful, but I've gone thus far without using them and I think I've been doing ok as a developer. I think the attractiveness from C++ comes from the fact that it is very very flexible to work with, and very powerful. As a C++ developer, you give up your safety net but gain power that you could never dream of having in Java!

Yeah, I just made C++ sound like a superhero.

Offline Agro
« Reply #25 - Posted 2014-03-01 04:10:29 »

ever since i started scala i havent touched java Tongue

Offline SwordsMiner

Senior Member


Medals: 2
Projects: 2
Exp: 1 year


Head of the Indie Developing team Revereor.


« Reply #26 - Posted 2014-03-01 21:27:59 »

I tried C, but I had quit trying to make a hello world  Undecided

- The one and only, SwordsMiner.
Offline HeroesGraveDev

JGO Kernel


Medals: 238
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #27 - Posted 2014-03-01 21:54:30 »

I tried C, but I had quit trying to make a hello world  Undecided

If you couldn't manage this:
1  
2  
3  
4  
5  
6  
7  
#include<stdio.h>

int main()
{
    printf("Hello World\n");
    return 0;
}

How on earth did you manage this:
1  
2  
3  
4  
5  
6  
7  
public class HelloWorld
{
    public static void main(String[] args)
    {
        System.out.println("Hello World");
    }
}

Offline opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #28 - Posted 2014-03-02 00:29:29 »

I tried C, but I had quit trying to make a hello world  Undecided
Have you even looked at C? Obviously not, once you get past the basic concepts it's smooth sailing. I've spent a week learning C++ and yeah, I'm by no means even decent with the language, but come on. Stop trying to be the "hip programmer" that spends his time coding in high level languages like Python or Java (not bashing those languages, but they are easy to work with) and hates anything "C" related. Jeez.

Offline SwordsMiner

Senior Member


Medals: 2
Projects: 2
Exp: 1 year


Head of the Indie Developing team Revereor.


« Reply #29 - Posted 2014-03-02 04:55:29 »

I am not trying to be a hip programmer, just knowing java and the little learning curve between it and the lack of motivation and need to learn it (thus far) made me stop quickly.

- The one and only, SwordsMiner.
Pages: [1] 2 3
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (31 views)
2014-07-18 06:55:21

Zero Volt (27 views)
2014-07-17 23:47:54

danieldean (23 views)
2014-07-17 23:41:23

MustardPeter (24 views)
2014-07-16 23:30:00

Cero (39 views)
2014-07-16 00:42:17

Riven (41 views)
2014-07-14 18:02:53

OpenGLShaders (28 views)
2014-07-14 16:23:47

Riven (28 views)
2014-07-14 11:51:35

quew8 (25 views)
2014-07-13 13:57:52

SHC (62 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!