Domain: cplusplus.com
Stories and comments across the archive that link to cplusplus.com.
Comments · 50
-
Re: Short sight
I'll make it easy for you: http://www.cplusplus.com/reference/vector/vector/insert/
-
Re: How many Chromebook buys are accidental?
For the benefit of others reading this, I'll summarize the top three results for Google c++ chromebook as of right now>:
- The first result, "C++ Compiler for Chromebook", was a soft redirect to "Compile C/C++ on Chrome OS", which states: "You'll probably need to build it yourself," and links to the article "Building and Testing GCC and GNU binutils". This article in turn appears to be oriented toward developing on a GNU/Linux PC and testing on a Chromebook.
- The second result, "Offline c++ editor and compiler for chromebook", has one reply stating: "No compilers will run under ChromeOS. However, there are a number of very good cloud-based programming/IDE sites that work just fine with Chrome." Use of anything "cloud-based" while riding a school bus or city bus requires a tethering subscription, and in the United States, a tethering subscription for the life of a device is more expensive than a Windows license. Another reply recommends use of developer mode, but that's fragile as I've described elsewhere.
- The third result, "Five Best Online IDE's – Making the switch to a Chromebook", mentions several web-based IDE but doesn't mention their support for offline use. This article in turn linked to "Choosing the Best Chromebook for Developers", which an article about Crouton. But Crouton requires developer mode.
So it's either a remote IDE (which fails while offline) or Crouton (which begs to be wiped). Which search terms did you use to find a third option?
Through other searches, I found Trinket, which surprisingly continued to work after I went offline, made changes to the program with Trinket still open, and ran it. But it doesn't appear to work offline after navigating from Trinket and back to it. (This would require use of a Service Worker.)
-
Re:Reason to learn C++
If I saw some really nice code, I would copy the style and start using it.
That is not how you learn a professional programming language. This is how. You learn by writing. When you have learned enough by writing to understand what it is that you are reading, then you continue your learning by reading, and more writing.
There does exist a breed of C++ programmer whose primary technique is copying. They are easily recognized because they tend to be incapable of accomplishing anything at all unless handed a class library, and then are only able to accomplish trivial things.
-
Like everything else start with the basics
I feel your confusion. This may be "old school" but I feel it's solid (or has been for me). Start with learning the basic rules.
A lot of people like Python but because most languages use certain characters to enclose blocks of code (and python only uses indents) I would suggest starting with Java or C/C++. Many here will say Python is easier (ruby is probably easiest for many), but your goal will be to have room to grow. You'll find more languages conform to the C/C++ or Java syntax style rules than Python or Ruby. I find it easier to ready than Python myself.
Do yourself a favor and skip VB.net. If you want pure Microsoft (and I would advise against that, would have saved me much grief early in my career) you can do C# and you'll be better prepared for languages with more platforms.
Java, for example you can use in many enterprise system and embedded systems, including Android. C/C++ you can use for robotic controllers, IPhones (objective-c), real-time critical applications (and gaming!!).
Some may suggest starting with scripting languages like PHP, Python or Ruby. there is faster "joy", but I'd sooner suggest starting with MIT's Scratch https://scratch.mit.edu/ (GUI language for teaching children basic of programming). It's a great teaching tool for anyone I think. Hey, it's still valid basics which converts the GUI instructs into 'C'. the reason
I'm so "hung up" on starting with C/C++ or Java is most newer languages take a lot of their cues from the concepts widely used in C/C++/Java. once you learn one of these (especially C++/Java) you can step into any other language out there with relative ease. Some good sites to start would include:
http://lifehacker.com/five-bes...
Note: These are all free or have free options
http://www.learn-c.org/
http://landofcode.com/programm...
https://ocw.mit.edu/courses/el...
https://ocw.mit.edu/courses/el...
https://www.codecademy.com/lea...
http://www.coursera.org/ (real university level courses, a little intimidating at first, but worth it)
http://www.cplusplus.com/doc/t...
For python:
https://www.python.org/
For Ruby:
https://www.ruby-lang.org/en/
the courses as udemy are a little light so I'd only go there for review.
I've given many options here although I've stated my preference. The other advantage to using C/C++ or Java is they make using these invaluable books easier to read:
Writing Solid Code: Microsoft Techniques for Developing Bug-free C. Programs (Microsoft Programming Series) by Maguire, Steve
Code Complete by Steve McConnell
Yes, these books are from MS and old, but I found them invaluable (and I wish MS had actually practice what came from their own publishing companies when writing the code for W2K and XP). Was required reading at one workplace. You'll want to learn about Object-Oriented approaches as well as syntax. It's a lot to take in and this is just the beginning, but it's fun journey. Oh, I would agree, don't bother with Basic. You are better off with Python or Ruby. :D Again, to reduce your learning curve later on, I'd start with C/C++/Java. You'll be glad you did. -
Re:Arguing over the subjective
The Slashdot forum here is broken.
ofstream myfile;
myfile.open ("example.txt");
myfile -- "Writing this to a file.\n";
myfile.close();
return 0;
http://www.cplusplus.com/doc/t... -
Re:Missing features
C++ has had concurrency since C++11 (see here). It has had RTTI (Runtime Type Info, aka. reflection) since C++98, and the RTTI feature set was expanded in C++11. Since then, they have released C++14, and are now close to releasing C++17. Your information is a bit out of date.
-
Re:Gee...
Operator overloads are there for the same reason void* is: when they actually make sense, they're a vast improvement. Complex numbers, for example, and really "+" is fine for string concatenation. Not being limited to built-in classes for that sort of thing is a feature, IMO.
C++ has few guiderails, and lets you write very unmaintainable code, much more so than C. But that's what let's you write performance-equivalent code that's much more maintainable than C.
My biggest gripe is coders who don't bother to learn the details of the 3 key library container classes: string, vector, and map. Poor coder choices causing significant (unnecessary!) performance hits was a bad enough problem that the standard had to add a fixed-sized array class, as even the simplest stuff like pre-allocating a vector when you know its size was beyond most coders. Sad, really.
And for goodness sake people, don't re-invent anything in std::algorithm! Stuff like inplace_merge or nth_element is really error prone to write yourself, as much fun as it might be to finally use that algorithms textbook from college.
-
Re:SFLC's brief explains parts of this well
An API call in programming use is something like this:
| return type | |Name of function| ( |arguments given to function| );
In general overview, an API call looks like this:
1. (Do some work / task)2. (Ask some library to do some work / task for us.) (This is the API call.)
3. (Do some more work / task possibly using the result of the API Call.)
For the in general overview, Java has not copied anything more than C++, Smalltalk, or any other language.
For the actual in programming use however it has copied somethings. This is because of the limited nature of the syntax. Put simply, although you can call a string container object "sighpghpjg234fy3r85q83", and expect people to use it when they need a string container object, that does not mean it makes sense to the programmer, is easy to remember, or maintain. Most programmers would expect a string container object to be some deviation of the word "string". As such many languages wind up coping some portion of the API of other languages with just the names of things. For example
std::string.length() in C++, has an exact copy in Java, String.length(). Both API calls do the same thing, (returns the length of the given string), and therefore is a literal copy. (See: For java and For C++)Sometimes functionality for a given API call is identical between languages, but with different names depending on the exact language in question. For example: std::string.find() in C++, has an exact copy (functionality wise) in Java's String.indexOf() call. Both calls do the same thing, (return the starting index of a search term in a given string), the only difference is the name of the function itself. (find() VS. indexOf()) (See For java and For C++)
Now of course, to a computer all of this is irrelavent. All a computer sees is some variant of:
(system-defined jump / execution branch opcode) (destination address) (result storage address)It depends on the system in question, but the overall result is always the same. The system jumps to the given address, executes the code it finds there, and when that code finishes, returns to the instruction that comes after the API call, and continues execution from that point. You could easily call an API function: "fksjfisijf" and the system will not care at all, because all it will see is: "0101010101 01011010 101010101010". The API call is just a human mnemonic for what a given function does so it's easier to remember and use for a programmer.
The only exception to this is when dynamic code is used. As that tends to require a parser at runtime, (a dynamic loader), to locate the API call's starting address in a table so that the program can use it. The program itself must know what API call to refer to, so that the loader can find it. The API library must also remain consistent (i.e. not change the API call) so that the loader can find the starting address for the API call that the program needs. If either of these is not true, the program will crash (due to an invalid address, argument, etc.), or it will not run / compile. (due to a link error.)
From a practical stand point, there is not (or rather shouldn't be) an issue. As the whole debate over coping an API call "design" or "expression" is entirely a human concept. Once again, although dynamic code can be used in a program, the computer itself does not care what you call it so long as the call does not change.
From an "Artistic" standpoint, you can't change the "expression of the idea" for an API call and expect it to work. (A computer DOES care about this.) You *could* create a new language every single time you needed to write a program, but you would have difficulty making it u
-
Re:SFLC's brief explains parts of this well
An API call in programming use is something like this:
| return type | |Name of function| ( |arguments given to function| );
In general overview, an API call looks like this:
1. (Do some work / task)2. (Ask some library to do some work / task for us.) (This is the API call.)
3. (Do some more work / task possibly using the result of the API Call.)
For the in general overview, Java has not copied anything more than C++, Smalltalk, or any other language.
For the actual in programming use however it has copied somethings. This is because of the limited nature of the syntax. Put simply, although you can call a string container object "sighpghpjg234fy3r85q83", and expect people to use it when they need a string container object, that does not mean it makes sense to the programmer, is easy to remember, or maintain. Most programmers would expect a string container object to be some deviation of the word "string". As such many languages wind up coping some portion of the API of other languages with just the names of things. For example
std::string.length() in C++, has an exact copy in Java, String.length(). Both API calls do the same thing, (returns the length of the given string), and therefore is a literal copy. (See: For java and For C++)Sometimes functionality for a given API call is identical between languages, but with different names depending on the exact language in question. For example: std::string.find() in C++, has an exact copy (functionality wise) in Java's String.indexOf() call. Both calls do the same thing, (return the starting index of a search term in a given string), the only difference is the name of the function itself. (find() VS. indexOf()) (See For java and For C++)
Now of course, to a computer all of this is irrelavent. All a computer sees is some variant of:
(system-defined jump / execution branch opcode) (destination address) (result storage address)It depends on the system in question, but the overall result is always the same. The system jumps to the given address, executes the code it finds there, and when that code finishes, returns to the instruction that comes after the API call, and continues execution from that point. You could easily call an API function: "fksjfisijf" and the system will not care at all, because all it will see is: "0101010101 01011010 101010101010". The API call is just a human mnemonic for what a given function does so it's easier to remember and use for a programmer.
The only exception to this is when dynamic code is used. As that tends to require a parser at runtime, (a dynamic loader), to locate the API call's starting address in a table so that the program can use it. The program itself must know what API call to refer to, so that the loader can find it. The API library must also remain consistent (i.e. not change the API call) so that the loader can find the starting address for the API call that the program needs. If either of these is not true, the program will crash (due to an invalid address, argument, etc.), or it will not run / compile. (due to a link error.)
From a practical stand point, there is not (or rather shouldn't be) an issue. As the whole debate over coping an API call "design" or "expression" is entirely a human concept. Once again, although dynamic code can be used in a program, the computer itself does not care what you call it so long as the call does not change.
From an "Artistic" standpoint, you can't change the "expression of the idea" for an API call and expect it to work. (A computer DOES care about this.) You *could* create a new language every single time you needed to write a program, but you would have difficulty making it u
-
Re:Problems in C++
>1) No, that's not the case. The difference between
.at and operator[] is that .at() has a const overload and operator[] is not.Are you sure about that?
http://www.cplusplus.com/refer...
>2) Most high performance apps (eg. games) turn off bounds checking in any case for performance reasons.
Which is fine.
Personally, I'd have preferred it if I could simply enable or disable bounds checking on [], so I could test my code to make sure I'm not going to fry memory, and then disable bounds checking on performance critical code for release.
>Uh, stringstreams? http://stackoverflow.com/quest...
I'm not saying that you can't write your own functions, just that the STL string class is not a drop-in replacement in functionality in string.h
-
Re:Cutting features and old syntax?
What is the compile-time-friendly subset?
constexpr. The subset was grown considerably in C++14.
Its primary remaining use is conditional compilation. That hardly counts as a language.
Well, no, it does count as its own language, because... it is. If you grant that the preprocessor is, at least. It's clearly separated from the C++ 'core' language, and it's something non-trivial that a C++ programmer needs to know about. Much like the preprocessor.
There are plenty of neat tricks to be had with the template system that aren't really just conditional compilation. Type traits, static-asserts, Boost.Function and Boost.Bind spring to mind.
-
C++ threads, Allegro, sockets, dirent.c
You have to deal with different threading, file-system, audio, controller and networking APIs
Threading I'll give you, though C++11 is supposed to take a step toward fixing this. Audio and controller appear to be handled by SDL or Allegro. Networking is why Windows copied the BSD sockets API to make Winsock in the first place. As for file system, there are plenty of thin wrappers that run on Windows and expose rough equivalents of POSIX APIs such as opendir() and the like. Could you explain in more detail?
-
Re:Finally Fixing the Date stuff
You can already do that in C++. There's also a Boost library that offers a bit more flexibility.
-
Re:Finally Fixing the Date stuff
A somewhat snarky rebuttal:
What bugs me about operator overloading is how tediously verbose it can get. For example, say you define operator functions for < and ==. You still have to do <=.
Get a better language.
For instance, in Python, functools.total_ordering will give you all six comparison operators when you give it < and ==. In C++, std::rel_ops will do the same thing. (Admittedly, in the C++ version it isn't on a per-class basis without some work because those are function templates, so you either get them for all classes or none.)
Down at the machine level, the computer does not stupidly require 2 separate comparisons to test
Get a better compiler.Given the code
bool leq_native(int a, int b) {
return a <= b;
}
bool leq_or(int a, int b) {
return a < b || a == b;
}GCC at -O1 or -Og or higher and Clang at all optimization levels all produce identical code for the two functions.
(OK, my "get a better compiler" is a bit harsh here. Interestingly, Intel's C++ compiler leaves in a jl/jne sequence at all optimization levels, as does MSVC.)
-
Re:That's just not a viable option.
cstdio : C library to perform Input/Output operations
Keyword: library. It is included by default because C would be nearly useless in normal usage without this library.
It does not matter if it is in standard libc or if it is all macros. It is a required library to do anything because without it everyone would have to constantly reinvent the wheel, poorly.
-
Academic
It's obvious that both Boost and C++ come mostly from an academic environment. In a sense it's very general, but this makes it sometimes hard to apply to practical problems. For example, try to create a random number from 0 to 1. Any other language has a function for that. Not so C++, here you have to create two objects before you can generate a random number. Which makes it more versatile, but also more cumbersome. Same goes for the reference documentation: mostly incomprehensible because of all the template arguments, and a library is only as useful as it's documentation.
-
Re:Brogramming???
-
Re:One good reason...
Lambdas are generally used to replace functors syntactically, but what I meant was STL algorithms, a set of standard templated methods that can be used on STL conforming data structures (either built in, or your own, as long as they you implement some basics such as iterators).
If used properly, you can achieve some things nearly as quickly in C++ as you can with higher level languages. However, before lambdas you had to use a lot of functors to use them, which limited their elegance.
-
Re:One good reason...
No clearly defined exception type
While use at it is not enforced the standard library contains an exception type you can and should use as base class, this normally goes unnoticed since nobody uses the throwing std::vector::at() or the iostream exceptions which inherit from std::exception.
The only reason I can think of why inheriting from std::exception is not mandatory is the anti inheritance crowd. (pre c++11 very few things in c++ required inheritance), not using it however is beyoind stupid and any programmer throwing int should be required to rewrite the code.
Exceptions should be caught before the stack unwinding process
Your use case is different, exceptions are there to be used when you don't have the information to handle them severall stackframes away, the alternative in this situation is returning an error code and checking it in each calling function and its calling function and its calling function and
...... until you are have enough information to deal with the error. For your use case you can define an error handler callback and call that which is simple enough and does not overlap in any way with the purpose of c++ exceptions - ofcourse that requires your library to actually be designed to support restart.Double exception faults
Other languages simply forget about the first exception which only barely works without causing anly trouble and just asks for memory leaks and undefined state in c++ (who will destruct the first exception if it was thrown as a pointer(bad but valid design)?).
-
Re:Doomed
The statement about std::vector is... mostly wrong.
http://www.cplusplus.com/reference/stl/vector/operator%5B%5D/
operator[] does not do a runtime check, and will result in code that potentially segfaults if you do an out of bounds array access (similar to doing the same thing with a C-style array.
It's not required to...but in theory it can
... and in reality it *does*(on Visual C++ at least you have to explicitly turn it off and I'm betting only a small percentage of people actually do because they don't even know it's doing it).
-
Re:Doomed
The statement about std::vector is... mostly wrong.
http://www.cplusplus.com/reference/stl/vector/operator%5B%5D/
operator[] does not do a runtime check, and will result in code that potentially segfaults if you do an out of bounds array access (similar to doing the same thing with a C-style array. The "at" function will throw an exception and signal an error.
This isn't to say that you shouldn't use operator[]. I use it all the time, because I often already know the size of the array (I use iterators far more often than operator[] though). The fact that there is no check is one of the advantages of C++, as in Java, there is always a check that can't be disabled (thus effecting speed).
You'll also notice this function returns a reference, not a pointer. It's impossible to pass a NULL with a reference in C++. No matter how you look at it, it's impossible for an access to a vector to return NULL. You either have "at", which throws an exception, or operator[], which gives you junk.
As C++ is a systems language, this is fine and expected. As an application level language, this is unacceptable.
The argument, "Look! I can do this and it's bad!" is because it's perfectly possible for the greatest programmer in the world to have an off-day and mess up. It's just a part of being human. It's nice when the programming language makes messing up harder to do, which C++ does not do well. That's why people say C++ is bad. The only current problem is that for the systems-level domain of highly efficient code, there aren't a whole lot of choices.
-
Re:Well, that's nice .. but
How about writing up a tutorial on how to correctly declare
c/c++ numeric variables. When I went to school many moons
ago, int and long were it.http://www.cplusplus.com/doc/tutorial/variables/
has a tutorial on declaring variables, and a table listing sizes.
They state the sizes of char, short int, int, long, etc.If this is not the correct way to do it, please help enlighten us!
Thank you. -
Re:Learn X in X hours/days
If all you need is syntax (like mwha), why not exclusively use google?
Your question is ez to answer via http://www.cplusplus.com/doc/tutorial/control/ .
The art comes in putting in the right search terms (where previous language knowledge makes this possible) and eventually you just kind of pick it up and w time you get better and better as you solve various scenarios and cases in the new programming language.
Still, at least at work, I like to have a book handy just in case I need to grasp a concept or something dumb like HQL, that you just kind of learn the rules to prior to use and google examples are very inflexible and limited due to that language's structure. SQL, any flavor of c, any flavor of vb, most other open source, have EVERYTHING documented on their parent websites as well as abundant examples and use cases floating around on places like codinghorror.
-
Re:Then learn the language better, stupid
"Finally, Python lets you write code like this:
with open('foo.txt') as inputfile: process(inputfile)
which explicitly garbage-collects inputfile as soon as it falls out of scope. If you use that pattern you'll never need to close the file (and it would in fact be a pretty dumb thing to do)."
This is actually what most (all?) C++ File I/O libraries do and certainly the standard fstream libraries. As long as you create your file stream on the stack (and I can't think of a reason not to), the file handles will be taken care of by RAII. As soon as it goes out of scope, the destructor will be called, which will close the file handle.
This Tutorial actually explicitly closes the file handle, but I wish it didn't, or at least made it explicitly clear that it isn't necessary as long as you use scope efficiently.
Instead you have to make do with this statement.
"In case that an object is destructed while still associated with an open file, the destructor automatically calls the member function close()." -
Re:Faster than C?
If you were going to do this as a one off sure you would use libc if you are going to do the same thing 10000 times in a row as you entire program and care about performance you would look for something better (this would likely be libboost in C++).
For anything to do with strings python is far more expressive than c and this case could be the more elegant and robust solution (except for memory usage). For this example i guess you 'parse' (not sure if that's the correct term in C) the text before the looping and store the result in a structure and then while looping though pass the structure as an argument this requires new libraries or you to write your own. Unless you allow on the fly editing in python I think its still equivalent function.
http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/
http://bstring.sourceforge.net/features.html
The first shows that the sprintf is bloated for the benchmarks purpose.
The second link is of library i found from google that says it has 3980% increased performance for string concatenation (other improvements are more modest) over libc if this figure is correct then a pypy has not beaten c and that sprintf is pretty bloated. I don't not check it had the equivalent functions for this problem. Its difficult to argue this as coming up with an alternative way to do nothing in C has arbitrary rules. -
Re:Heck
The internet isn't really a place to gain an informed opinion over things.
Yes, you are correct. Opinions should all be tossed out. Pure info is what the Internet is all about. Pick a language and a FOSS project, develop away, it's a great learning process that I've found much more "educational" than formal education.
Teach yourself C++: C++ Annotations, C++ Language Tutorial...
... or Perl: Perl programming documentation, or JavaScript,
or Java.Just search the web, you'll find everything that any professor will ever be able to teach you online. Need guidance, clarification, or to ask a question? There are free online forums for that too... Yes, the Internet on average, much like the FM band, has more signal than noise, but similarly you can easily tune your into the signal you need.
Consider this: My Java "professor" gave an assignment where we read in rows of data from standard input, and output the table sorted by a certain column's value. He offered extra credit for proper alignment and justification of the table's cells... "WTF? Really?", I thought.
I used the Collections framework along with Swing to provide a GUI w/ sortable & justified JTable columns instead of doing character counting and sending extra spaces with the text to the standard output. He gave me a C. Another student used the Formatter to provide printf style formatting... also got a C, WTF! Go beyond the prof's teachings & expectations to meet a requirement, get a poor grade... That's dumb and counter productive.
In the real world, you try not to re-invent the wheel, this college course was not teaching practical programming; It was so far beneath what I learned already online, on Java's own website, I dropped the course (waste of time). Sure I can write a merge sort, or programatically align console text output, but that was not what the assignment said: "Provide a tabular output sorted by the 'Name' column." We learned merge sort 2 weeks prior, but the "professor" would not move on.
Not having a "degree" myself, I frequently answer questions that "Degree" holding graduates ask in online forums... Why? Because they didn't learn what they needed to know in their courses.
You would be hard pressed to find a programmer that doesn't have some form of documentation open in another window, screen, or context menu while coding. IMO, besides learning about algorithms and complexity, the language specs & online tutorials are all you really need. I find paper books pale in comparison to down-loadable, copy&paste-able free, online resources. Also note: As a programmer you will be expected to keep up to date with the ever changing languages you learn. All of these changes are easily accessible online too.
There's a lot of noise and very little quality signal to use and without having a degree to start with it's pretty much futile in terms of knowing what is and is not reliable information.
I call bullshit. See esp. the Java link above, your arguments are ill-informed, and reek of FUD. Search google for "java tutorial", or "$any_lang tutorial" and you get some pretty damn reliable, pure "signal" information about what you searched for.
Are you really arguing that Language specs & Tutorials from IBM, Microsoft, etc, and docs from a language's main website (such as http://perldoc.perl.org/
-
Re:Poor solution
Even stranger is that leap seconds are already implemented in most system libraries. If programmers were less eager to roll their own solutions to already-solved problems, it wouldn't be that big of a deal.
-
Re:That's great and all...
I suppose 0L might be guaranteed to translate down to 0, but using it instead of 0 has no benefit; it just looks funny.
The C language never guaranteed a crash when you dereferenced a NULL pointer.
That might be because it's not part of the C language. However, the whole point of introducing the NULL macro was to provide a pointer that is always invalid.
-
Re:GUI applications
This happens sometimes when I screw up doing pointer arithmetics or when I do not check array bounds.
To cure this, I started designing a system were I will abstract pointers with my own custom library. It will also automatically free the memory from unused objects. I will call it "memory recollection".
I am also designing my own custom third party library to automatically check array bounds
;-))You mean like boost::shared_ptr and std::vector::at() ?
-
Re:C++ incomplete. C# windoz. Java slow elephant.
C++ come on it didn't even have a string class. Thus pointer math hell.
I'm not going to suggest you should use C++ but seriously, can you at least use real criticism? What is std::string then?
And no, "that was only added in 1995" doesn't count as a criticism since C++ was not defined as an ISO standard until 1998 and std::string has been there ever since.
-
Funniest part of this was this (strlen)
I was hoping that this dolt would bring up the std. string functions libs that MOST C/C++ compilers have, one function of which, is StrLen -> http://www.cplusplus.com/reference/clibrary/cstring/strlen/
(HOWEVER, because I waited on it, & he has NOT produced that? Well, his lack of putting up that simple function is merely just proving my words, that the fool I replied to is nothing more than that -> A trolling dunce who is someplace he does NOT belong in, messing w/ his betters...)
I gave it a few days, & he has not recognized that much... & instead, he gave me more really WEIRD guff trolling me instead, here -> http://it.slashdot.org/comments.pl?sid=1320775&cid=28916873
(LOL, what a freak he is, ontop of being stupid in coding & yet he had the nerve to try sound off on it here - anyhow/anways, lmao -> Hey, you read that url above, & YOU decide for yourselves, ontop of my being patient & waiting to see IF HE KNEW ABOUT STD. STRING FUNCTIONS!)
APK
P.S.=> Yes, you CAN/COULD use the method I extolled using pointer math++ operations in C++, but as I suspected (and yes, stated? The AC troll I am replying to, does indeed, not know a thing about coding, period, else he would have brought that up instead of my more "primitive method" that's doubtless behind the strlen functions in most null terminated strings C/C++ std. libs for strings (string.h file, specifically)... apk
-
Re:what does open mean?
(I should probably keep this in a text file on my desktop, it's a "batch of advice" which I frequently have to re-write, and it doesn't change much)
I mentioned the term "modern C++" above, though really it's better to call it "sane C++". By this I mean C++ that won't drive you nuts trying to figure out what went wrong, when something inevitably *will* go wrong. Practices that make programs more safe, and introspective.
If you already know C++ (the foundations, I mean), it'll be easier to shift to STL-dependent C++. If you're completely new to C++, these resources will still be very important, but you'll need to learn the lower-level stuff in parallel, so you can understand how STL containers/templates are built from the inside (which is important when you need to choose which ones to use).
A website that should very often sit in the background while you're coding/learning: C++ FAQ Lite. Following these rules will make it much easier to design and maintain your programs.
Another very useful website: cplusplus.com. It's a huge reference site, with a lot of examples.
The books I'd recommend:
Accelerated C++ -- higher-level to lower-level approach.
C++ Coding Standards -- similar to the C++ FAQ Lite in the nature of the advice, but covers more ground and is probably better organized.
C++ Common Knowledge -- This is for a few months down the line, delves into some nuances.
Software:
Windows: Visual Studio C++ Express -- You can force it to stick to ANSI C++. It's still the best IDE for C++ on windows (IMO).
Linux/Mac: Eclipse, probably Eclipse IDE for C/C++ Developers. Remember though that you can tweak Eclipse into just about anything.
If you're writing end-user applications, keep in mind two frameworks: Qt and wxWidgets.
Quick note about Boost: If you can create a structure using some combination of STL components, do that before resorting to Boost. Boost is highly abstracted, and you should only use the parts which would otherwise be extremely complicated to create from scratch (like regexp). -
Re:This is new technology to me
So you don't know about friendship and inheritance
-
Re:style
cout >> "I have no patience to program anything useful and I hate having to write code";
You're right about this one, because you got the operator wrong:
cout << "I have no patience to program anything useful and I hate having to write code";
I guess I was wrong in the first place :) -
Re:Excellent Post
Here's what I got, so far. Sorry it's not tabbed and cross-referenced...
http://ask.slashdot.org/article.pl?sid=08/09/17/224230 -- in case anyone wants this page, too
http://www.quickref.org/
http://gotapi.com/
http://www.regular-expressions.info/ -- regular expressions
http://www.perlmonks.org/
http://www.rosettacode.org/wiki/Main_Page
http://perldoc.perl.org/
http://www.perlbuzz.com/
http://java.sun.com/reference/
http://forums.sun.com/index.jspa
http://developer.mozilla.org/ -- javascript
http://www.w3.org/MarkUp/Guide/
http://www.w3.org/MarkUp/Guide/Advanced.html
http://www.w3.org/TR/html4/
http://www.w3.org/TR/xhtml1/
http://www.w3.org/Style/Examples/007/
http://www.w3.org/Style/Examples/011/firstcss
http://www.w3.org/Style/CSS/learning
http://en.wikibooks.org/wiki/Programming:Tcl
http://www.acm.uiuc.edu/webmonkeys/book/c_guide/
http://cprogramming.com/
http://www.cplusplus.com/
http://cm.bell-labs.com/cm/cs/cbook/
http://www.parashift.com/c++-faq-lite/
http://en.wikibooks.org/
http://developer.apple.com/
http://cocoadev.com/
http://www.cocoabuilder.com/ -
C++
http://www.cplusplus.com/ for APIs
http://www.codeproject.com/ for problem solving -
My experience
I started programming when I was about 12, and I am completely self taught. My parents knew nothing about computers, and still know nothing now despite my efforts. Anyway, i started with javascript, html, and php. (This was around 6 years ago). I think it was much easier to start learning the basics of this kinda stuff when you don't have to deal with all the boring (to a 12yo) details of memory management, libraries, and compilers etc. Web programming is something were you can get the instant results and action, you can just keep tweaking the source file and hitting F5 until you get something that works and looks vaguely like what you're after; this is especially useful when you don't know what you're doing.
:)I had a few books which taught me the basics, a javascript book and a html book. They only covered simple things, (I think the js book was a For Dummies..., actually), but it was enough to get me started. After that I found the php.net docs and a friend showed me loads of his php code and i picked that up fairly quickly.
Being a website, it's something easy to show off too, it was kinda cool to be like "dude, the whole world can see my webpage!". Following that theme, i got started on irc bots, eggdrops are written in C, and you can script em with tcl. Be careful tho, tcl is kinda quirky and weird (at least, that's how i remember it). But it's great for simple stuff, get the bot to parse some text and reply etc. This might also be a good time to learn some networking stuff. Also since eggdrops can also have C modules written, this is a possible path into C, although I didn't go that way so I don't know how good it is.
I eventually learned C(++) from some online tutorial, http://www.cplusplus.com/doc/tutorial/ I think. And I wrote a load of code for manipulating some large binary files (game resource files, from Halo). I certainly don't recommend letting anyone learn C solely from some tutorial, since I had rather large gaps in my knowledge at this point (that code i wrote is terrible), but it was some great experience anyway. I played around with some
.NET (ugh!) gui stuff, because I didn't know how else to make a gui program at the time (seriously, I don't know how I was meant to know about qt, gtk, or win32 etc at this point) and a program that just prints text on the command line got boring real fast.Hacking at computer games was what really drove my interest in C at that time. Reverse engineering of the file formats was fun! Even if I did kinda suck at it and just found most of the info on the web.
Looking back, I'm thinking I probably would have liked someone to show me python (and maybe perl) much earlier than when i eventually discovered them. php sucks as a general purpose scripting language and C gets tedious for those little tasks.
Sorry that was all probably a little incoherent, I spent the time I was meant to be doing english homework programming
;) -
Re:Love C++, but it still sucks...
* No standardized pragmas
Pragmas were meant to be OS and compiler specific. If your OS or compiler doesn't provide a standard then it's the language is not at fault.* Macros after-thought and not type safe
Macros weren't meant to be type safe. You should use templates if you need type safety.* No 24, and 32 bit (unicode) chars
What about std::wstring and cwchar?* Still has float / double crap, instead of being properly deprecated and f32, f64, f80 used instead * Still has short / long crap, instead of being properly deprecated, and i8, i16, i32, i64, i128, u8, etc...
Use cstdint and cfloat* No distinction between typedefs and aliases * Inconsistent left-to-right declarations
I don't have much experience with those in C++ so maybe someone else should elaborate. Could you provide examples where these two would be a problem?* Compilers still limited to ASCII source
This is true but hard-coding unicode strings is considered a no-no.* No binary constant prefix (even octal has one?!)
This is true.* No standard way to assign NaN, +Inf, -Inf to floating point constants at compile time
Standard since C99. -
Re:Use a language that checks I/O errors by defaul
Where have you learnt C++? If you use iostream you can set them to throw exceptions: Exception Mask. It isn't done by default, because a failing IO-operation is hardly a big surprise (incorrect rights, nonexisiting file, out of data). I find exceptions overrated, they make it awkward to check the state and should be reserved where you really need to unwind the stack not for simple state checks.
-
Re:The Answer
from a c++ tutorial: "we can also define a class as friend of another one, granting that second class access to the protected and private members of the first one." hmm, i should be more "friendly" http://www.cplusplus.com/doc/tutorial/inheritance
. html -
Re:No
You're also no C++ expert:
C++: ifstream in("foo.in"); -
Article
Since jero.net already seems to be
/.ed...Taking a look at PHP 6
While most web hosts are still in the PHP 4 era, the PHP developers are already planning and working on PHP 6. Lets have a look at whats been keeping them busy.
Unicode support
When youre creating a website, you hardly have to think about the character encoding. You only have to decide how you tell the user agent what encoding youre using, but with a little help of Apaches
.htaccess file, you only have to make that decision once. However, if youre building an application, the character encoding might become a problem. Thats where PHPs new Unicode support comes in handy. With its support, PHP can automatically encode and decode the in and output of the script making sure both the database and the user agent receive the encoding they need without the need of any extra functions for the encoding conversion.The big cleanup
PHP is already being used for a long time, creating a big user base, but also a lot of bad habits. Bad habits often result in slow scripts or even security holes. But these bad habits are not always the cause of the developer. Of course, he (lets just assume were dealing with a stereotype developer here for simplicity's sake) is the one whos using it in his application, but sometimes the developer is not even aware hes using it.
Im, of course, talking about the register_globals , magic_quotes and safe_mode functions. These three functions are hell for every PHP programmer so Im sure everyone will be happy to hear that these functions will disappear in PHP 6.
In other related cleanup news, register_long_arrays and the long versions of the super globals like $HTTP_COOKIE_VARS are also gone in PHP 6. Same goes for zend.ze1_compatibility_mode which dealt with the backwards compatibility of PHP 5 classes.
Alternative PHP Cache
Caching is a very good way to improve the performance of an application. Thats why there was a large demand for a good opcode cache in the default distribution of PHP. And when theres a demand, theres probably also a person or a group to meet that demand. The result is APC: Alternative PHP Cache. Of course, APC was already available a long time ago (01-07-2003), but the PHP developers have decided to include this extension in the core as the default caching framework.
OO Functionality
The improved OO model was probably the biggest improvement to PHP in version 5.0. PHP 6 tries to improve this even further by adding namespaces. If youre familiar with XMLs namespaces or maybe C++, you will probably have an idea of how namespaces work. If not: Namespaces can group variables, functions or objects under a certain name. This allows the developer to use the same name for a variable, function or object multiple times. In case youd like to learn more about the possibilities of namespaces, I find this C++ tutorial about namespaces quite useful.
Changes to the extensions
PHP is basically a collection of extensions which are all put together to form what we have now. However, these extensions change and so does the collection. Take, for instance, the XML Writer extension. A great extension to write XML files. Its brother, XML Reader, was already added and enabled in the core distribution in PHP 5.1, and now XML Writer will follow its example in PHP 6, forming a great duo to easily work with XML files.
Another change in the core distribution is the removal of the ereg regular expressions library which is going to be made an extension. ereg is currently used
-
Re:If you're going to fault them...
ANSI C++ Standard header files (also mentions the ones from ANSI C)
-
Re:Ask Slashdot: where Google Morons ask questions
The link in the above post (see parent) seems to be broken for me. I don't know if this happens to be the same book as the one above...
This is the book that my Survey of Programming Languages professor suggested for those of us who came in knowing Java but not C++.
It's nice in that it compares and contrasts many features of both languages (including quite a bit on the STL and writing templates in C++), but I found myself wishing it would have gone into more detail several times - my one gripe is that it doesn't do much more than scratch the surface in several instances.
(apparently, there's at least a couple of "C++ for Java Programmers" books on amazon alone...)
A couple of reference sites I've used in the past:
(Personally, I still shy away from C++ whenever I can...I certainly haven't gotten a comfortably firm grip on it yet.)
-
Re:Binary packages: Security suicide
Are you smoking crack?
Apparently not as much crack as the moderators. Score 4, Informative for strtok as a security risk? Give me a break. -
Re:So much...
Bawhaha... No. I don't think you've used GCJ at all.
I've used GCJ a lot and all it does is create huge-ass executables that do not run faster than any decent JIT. Plus it can't compile just anything (certain stuff from the Java runtime is not available or won't compile in GCJ).
I think part of the speed problem is just due to the bloat GCJ introduces.
GCJ sucks, Java sucks. Use something better. -
Many good C++ links + a warning or two
The problem with on-line C++ is that many people who claim to write about it don't know their subject, and consequently write superficially correct code that actually sucks. I'm sorry to name names, but the much-recommended-here CPlusPlus.com is one such site; their "Hello, world!" program at the start of their isn't even correct. I'd give sites like that a miss if you're seriously interested in learning C++.
One good source of information about C++ (and many other programming-related subjects) on-line is the related Usenet newsgroups, particularly the group specifically for learners if you're just starting out, or the moderated C++ group for more advanced subjects.
Many of these groups also have helpful FAQs, available (as usual) via the Internet FAQ Consortium. Again, for those just starting out, I'd particularly recommend the alt.comp.lang.learn.c-c++ FAQ, which has links to helpful on-line resources, free compilers, etc.
There are a few web sites of which anyone in the C++ field should be aware.
- You can get generally pretty sound book reviews for thousands of books on these and related subjects at the Association of C and C++ Users web site.
- Herb Sutter's web site has lots of informative and thought-provoking C++ articles by one of the guys who's advanced C++ programming technique a lot in recent years.
- Similarly, Scott Meyers' publications page has many worth-reading articles on C++.
- It would be remiss not to mention Boost, a collection of very good general-purpose C++ libraries. If you can't see how to do something with the standard stuff, the answer -- or a useful idea to find it -- may well be here.
There are a few decent on-line references to the standard library:
- Dinkumware make a standard library implementation, which is shipped with Visual C++ amongst other things, and provide some helpful documentation on-line. (NB: The version that shipped with VC++ 6 was flawed in many horrible ways, but that wasn't really Dinkumware's fault given the compiler limitations at the time when they wrote that library; please don't judge them by that alone.)
- SGI's implementation of the "STL" parts of the C++ standard library is excellent, and well-documented on-line.
About the only decent on-line C++ tutorial I know of the electronic version of Bruce Eckel's "Thinking in C++" books. You can find a complete copy of these, and several of his other books, at his books web site. (He also has books on Java, C#, Python amongst other things, and all of his work I've read has been reasonably good.)
-
C++ Standard Library
Since one of the major things in C++ is it's libraries, I find the two best references for that are:
1. SGI's STL Reference
2. Reference for iostreams and standard C library
And don't forget man pages in unices and msdn in windows. -
C++ sites
Two sites I refer to frequently for C++:
cpluslus.com, most notably the "standard libraries" reference link on the left there (for looking up bits and pieces of the iostreams library).
-Rob
-
can you say "Java?"
from the overview page...
features to keep:- compile/link/debug development model
- Exception handling
- Runtime Type Identification
- link compatibility with the C calling conventions
All except the last is contained in Java.
features to drop:- C source code compatibility
- Link compatibility with C++
- Multiple inheritance
- Templates
- Namespaces
- Include files
- Creating object instances on the stack. In D, all objects are by reference.
- Trigraphs and digraphs
- Preprocessor
- Operator overloading
- Object oriented gradualism
- Bit fields of arbitrary size
- Support for 16 bit computers
This seems to be precisely the parts of C++ that Java also does away with. Furthermore, the C preprocessor is not strictly part of the C language and in fact many other programming projects use cpp for simple cut and paste includes of their favorite language. When I first read about trigraphs, I couldn't wait to try them out to make some extra obfuscated code, but alas the C compiler I was using didn't support them. In fact the lack of standards compliance is one of the main drawbacks to programming in C++ and C. If my Java code compiles on sun's compiler, then I can be assured that it will also compile on any other compiler claiming to compile Java code.
The author also mentions that D will not have any bytecodes. From a strict perspective, the Java programming language and the Java VM are two different standards and just because you typically compile Java code into (confusingly named) Java byte codes, doesn't mean you can't use one without the other. For example, anyone (who is insane) can pick up a copy of the Java Virtual Machine Specification and a hex editor and make some syntactiacally correct class files. More realistically though, java bytecodes are often targets for compiler construction classes. Also, if you use the GNU Java Compiler you can compile programs written in the Java programming language directly into machine code.
While 90% of the description of this language screams Java, there seem to be some of the more useful features of C++ thrown in (typedefs, scope operator, etc.). The only way for this to be successful, is to finish standardizing the language as soon as possible and get a reference compiler for it so it leaves the realm of theoretical vaporware. Perhaps Java might have looked more like this if the language design was revisited. However, Java has lots compilers which are much much more likely to conform to the standard than the C++ equivalents.