Rashakil Fol 978 Super Senior Demiposter Team Colleague

It depends on the new file, and how the text layout is defined. Does RTF have a defined algorithm for kerning and paragraph layout? If not, then the behavior is specific to the particular RTF-reading application. If so, then, well, there's a spec somewhere.

In general, how fonts work and how they're sized in different media is specific to those media, there's no general answer to be given here.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

One could consider this part of the syntax.

Then one'd be wrong, because it's not part of the syntax.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Go's syntax doesn't really cater to compilation times, in any particularly special way. Its compilation time wins come from other aspects of the language design, like its lacking generics and cyclic module imports.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Of course it will eventually parse the whole file, unless an error happens, in which case it could stop, or a user-friendly compiler might try to find some more errors.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Some programming languages are designed so that the parser and compiler can work from top down -- that is, the meaning and compilation of a particular function depends only on the code that comes before it. C, C++, and probably Pascal work this way. Thus, the compiler doesn't need to parse or read the whole file, before generating output. A long time ago you could take advantage of this to compile files on low-memory systems. It would be a bad idea nowadays, though, for all sorts of reasons related to compilation speed, optimizations, and user friendliness.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Has Lisp ever really been anything more than an academic language with very little real-life applicability?

Yes.

Common Lisp and a subset of its ancestors are not academic languages at all. A few people even made money with it.

Scheme is (in particular) the academic lisp.

There are some corner markets (like early AI) that favored Lisp or Lisp-like languages, but they are pretty small and don't really have a mountain of legacy Lisp code to maintain.

I think the real reason "early AI" and such used Lisp was because it was a nice-to-use language the way Python/Perl/Ruby later were in comparison to C/C++03/Java. They just didn't have needs such as distributing software on floppies to Windows 3.1 users and running ultra-fast, and when other people ended up not needing the same thing (e.g. server-side environments), the same thing happened. Of course, I wasn't there.

Also, Haskell isn't obsolete in any sense, but C is obsolete for some set of things it used to be a premier choice for.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yep, it's C++. It gives you better ability to make and use abstractions than almost any other language and better ability to micromanage the low level than any other language (and that includes C).

Tcll commented: at least you're trying :) -1
Rashakil Fol 978 Super Senior Demiposter Team Colleague

I think a good place to start is the book by Koenig & Moo, Accelerated C++, if you think your class is easy. Maybe you'll still think it's easy and useless, because it's designed to teach the language and not e.g. how to use libraries to build certain kinds of applications.

Your problem might be that you can't find a way to use C++. I mean, how do you go out and start writing real software with it? Or with any other programming language, for that matter? This is one of the problems I had when starting out. I'd end up clinging to whatever gave me a simple handle to the "real world" that would let me do user interaction in a dynamic way. If you want to create a normal application with C++ one way might be to get QtCreator and do some tutorials. I'm not saying this is the best way -- I don't know -- as a developer experienced in using C++ to write server software that didn't have to do much GUI interaction, it seems pretty good for the things I've been toying around with the past few weeks. Its downside is probably that it's complicated and powerful. But you should be able to follow a tutorial, look at the examples (there's a ton in the qt/examples directory if you download qt) and tweak things to do what you want.

A different direction might be to go down the OpenGL route and go straight to 3D …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

There is no difference in behavior between the two. Both declare a variable "a" and give it the value 10.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If only you had the ability to come up with ideas!

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you want to master data structures, a few good first baby steps would be to get good at basic data structures in C or C++ (graphs, trees, etc, using a common first text like CLRS or some other), then learn a bit about functional data structures by reading Okasaki and doing some practical functional programming, then watch the Advanced Data Structures lectures on MIT Open Courseware (and do the homeworks). It's probably a good idea at some point to make some relatively data-structure-intensive projects, such as a 3D graphics engine, optimizing compiler for a statically typed language (ideally one that uses unification at some point in type checking), and a database engine (especially if it doesn't rely on kernel page caching).

You're not really a master at that point but those are some good first steps. Then you'll probably have an idea of what to learn next.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Yeah, on most systems nowadays you can get away with modulus. But I've been burned by that kind of assumption when porting between different systems before, so personally I would rather divide. Or just use <random> now.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Operator overloading isn't bad. The worst case scenario is that you have a badly named function. It is completely sensible and necessary for many things in C++ that are good, like smart pointer types, generic programing over iterators, and collections. Not to mention assignment.

That you even stop to gasp about operator overloading as if it had any real negative impact on C++ development shows what shallow understanding you have.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The reason is that the language is simpler to understand if every case clause has fall-through behavior. If default: sections didn't have full-through behavior (on entry), that would be surprising to people because that's different behavior than what you get with all the other clauses.

Also, if such was the behavior of C++, code that relied on that behavior would be fragile. Adding a new enumeration value and a new case clause just before the default: case would require the programmer to remember to insert a break; statement at the end of the previous case clause.

That would lead to lots of bugs.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You should look for interviews with and documents written by the designers of these languages.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

OP, I think you might enjoy the series of challenges at http://microcorruption.com/ . It is a good introduction to this sort of thing.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The actual information you learn won't be particularly important. I think the artificial intelligence specialization will affect you in ways that make you a better all-around programmer. Data science takes you outside of tough programming and throws you into some statistics, that isn't really particularly interesting, and is the sort of thing that's easy to forget. Also, I think as a professional specialty, data science is a bad place to pigeonhole yourself, looking 20, 40 years down the line. So you should look at them based on how they'll improve your programming ability and CS ability overall. AI has more crossover benefits.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Scorpiono I tihnk you missed the entire point of the article. This article is trying to talk about cracking password hashes after the password database has already been compromised.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

That's actually not true.

Irrelevant, actually. The vast majority of my posts, including all the interesting ones, were made before the terms of service included any such clauses.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Instructions for proper password digestion:

http://codahale.com/how-to-safely-store-a-password/

happygeek commented: good piece, thanks for the share +11
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Unfortunately your problem is not solved, you'll have to rewrite everything, your code is illegal for you to use. By posting your code, you have granted DaniWeb an exclusive copyright license to your code according to DaniWeb's terms of service. You may no longer use it and have no rights to you code. Please delete your code from your computer. As the Terms of Service say:

Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

Further transmission of your source code material, such as in a personal project or in handing in an assignment, may be prosecutable as criminal copyright infringement.

happygeek commented: sigh... +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hello Qonquest, unfortunately you no longer have the legal right to use the code you have written. By posting your code, you have granted DaniWeb an exclusive copyright license to your code according to DaniWeb's terms of service. You may no longer use it and have no rights to you code. Please delete your code from your computer. As the Terms of Service say:

Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

Further transmission of your source code material, such as in a personal project or in handing in an assignment, may be prosecutable as criminal copyright infringement.

happygeek commented: yawn +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hello Sean Fuoco. You are now prohibited from using your timer class. By posting your code, you have granted DaniWeb an exclusive copyright license to your code according to DaniWeb's terms of service. You may no longer use it and have no rights to you code. Please delete your code from your computer. As the Terms of Service say:

Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

Further transmission of your source code material, such as in a personal project or in handing in an assignment, may be prosecutable as criminal copyright infringement.

happygeek commented: pack it in +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hello Christopher Welborn. Thanks for posting your code. By posting your code, you have granted DaniWeb an exclusive copyright license to your code according to DaniWeb's terms of service. You may no longer use it and have no rights to you code. Please delete your code from your computer. As the Terms of Service say:

Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

Further transmission of your source code material, such as in a personal project or in handing in an assignment, may be prosecutable as criminal copyright infringement.

happygeek commented: yawn +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hello lostelf and speakon. Thanks for posting your code. By posting your code, you have granted DaniWeb an exclusive copyright license to your code according to DaniWeb's terms of service. You may no longer use it and have no rights to you code. Please delete your code from your computer. As the Terms of Service say:

Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

Further transmission of your source code material, such as in a personal project or in handing in an assignment, may be prosecutable as criminal copyright infringement.

Reverend Jim commented: Fudding -2
Ancient Dragon commented: that's all wrong -3
happygeek commented: more childish knee jerk over-reaction, sigh -2
Nick Evan commented: You'd think that at some point in time, you would grow up -3
almostbob commented: peanut -3
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Hello silvercats. Thanks for posting your code. By posting your code, you have granted DaniWeb an exclusive copyright license to your code according to DaniWeb's terms of service. You may no longer use it and have no rights to you code. Please delete your code from your computer. As the Terms of Service say:

Any and all information posted on DaniWeb may not be copied or used elsewhere, in any way, shape, or form, either on the Internet or in print, without prior written permission from Dani Horowitz.

Further transmission of your source code material, such as in a personal project or in handing in an assignment, is prosecutable as criminal copyright infringement.

happygeek commented: troll +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

Therefore, if someone posts an article or tutorial on DaniWeb, we require full copyrights to that content, because we need to make sure that it doesn't get published elsewhere, therefore damaging us with the search engines. By having these rights, we are able to go after other publications that duplicate content on DaniWeb in whole or scrape our content. (If a member posts an article or tutorial on DaniWeb that already exists elsewhere, it is a rule violation and will be deleted as soon as we notice it, which is usually quite quickly.)

Transfer of exclusive copyright rights must be in writing and signed. DaniWeb does not have an exclusive license to any of my posts.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

One reason why being a const reference can kill you is that somebody could easily unknowingly initialize another const reference that escapes the lifetime of the locked_ptr object. One person might write locked_ptr<std::string::type u = s;, the next person sees that and thinks locked_ptr uses a shared lock, because that's what it looks like. And then they write something like f = new foo(s) and you get a possibly unnoticeable memory corruption bug.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In such a small example where it is not hard to see the context, and within a "detail" class that shouldn't be looked at by users, I don't think it's that bad. But, yeah, it's a bad example to give.

It's bad because it's l which looks like 1, in particular, not just because it's a single letter.

The alternatives are worse.

I don't quite understand you because you then said that naming it lock would be better. It doesn't matter, the function really should not exist at all.

The reason for having locked_ptr and detail::locked_ptr_impl is because it uses the "scope-guard" technique. Look at it again, and you will see that those two need to be separate, because locked_ptr is not just a typedef for detail::locked_ptr_impl, it is a typedef for const detail::locked_ptr_impl& and that makes all the difference in the world.

Nobody expects a typedef to be a reference type, so you should never ever do that. For example, I didn't know that it was a reference type. As you can see, the code is confusing to the reader and too subtle. Abandoning the practice of having this method on lockable which obtains the locked pointer, and instead having a constructor on locked_ptr which takes a lockable<T>& argument, is more clear and more ordinary. That's why, for example, std::unique_lock<T> works that way, and why std::mutex::lock is a dumb method that returns void.

Also, even if we wanted to keep the interface the …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Also locked_ptr_impl(std::mutex& aMut, T* aPtr) is unnecessarily marked explicit.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Another problem with lockable::operator&, in addition to the fact that it's the most confusing possible name for such a function, is that it encourages broken use in expressions.

std::string foo = *(&my_str) + *(&my_str);

There's one example of a relatively innocuous-looking expression that will deadlock.

Instead, locked_ptr should have a public constructor that takes a lockable (or a pointer to lockable) as its argument.

If the code is forced to have locked_ptr<std::string> written out when a lock is acquired, this sort of mistake and confusing syntax is avoidable.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Also, I think that std::forward(arg) needs to be std::forward<Args>(arg), if you actually try to instantiate a lockable with constructor arguments. This might be only necessary in gcc 4.6.3.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Another problem with swap is that it contains implicit behavior that lhs and rhs's mutexes are locked in a particular order. This makes the object prone to deadlock or fragile with respect to changes in code. Instead, swap should not be implemented, and a separately named function acquire_locks_left_to_right_and_swap (or something) may be implemented. That might seem bad, if you want to use some algorithm that expects a swap to exist, but, um, that's exactly what you want to avoid.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

swap(lockable<T>&, lockable<T>&) is broken.

It doesn't work properly when lhs and rhs are the same object. It tries to lock the mut field twice, but std::mutex is not recursively lockable.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Defining the type as detail::locked_ptr_impl for no reason is another, it could have just been locked_ptr and you wouldn't have compatibility problems.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Putting semicolons after function definitions is an idiosyncracy that you'll abandon someday.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Having a variable named l is a bad idea.

Overloading the address-of operator is a terrible idea.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Note that I fixed a few other issues as well... :-)

Oh really? Now Valgrind can't catch uninitialized value errors when somebody forgets to initialize the object with setvolume.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

A master's in computer science is basically worthless when it comes to causing increased future life earnings. Actually, it has negative value, because of the lost year or two. It might be correlated with higher earnings (or might not) but don't be fooled into thinking that's a causative effect.

but it will give me more experience

No? A master's does not give you more experience. Having a job gives you more experience.

If you want to improve your job prospects, you need to get better at programming, and have better evidence that you're good at programming. A master's is not that, not at all.

There are good reasons to get a master's. One is indeed, simply to avoid having to have a job for another year or two! Maybe you like being in college better, or are afraid of being an adult with daily responsibilities. That was my reason for spending an extra semester in college to get a dual major.

Another reason might be if you want to learn specific things in the computer science field, if you've looked at the courses available in the master's program and find yourself saying, "Yes, I want to learn about that!"

Reverend Jim commented: Excellent points +0
Rashakil Fol 978 Super Senior Demiposter Team Colleague

What is MVC really?

A design pattern.

Is "model-view-controller" basically the way all ASP.NET programs in Visual Studio are made?

No. Certainly not. Programs using the ASP.NET MVC framework, on the other hand, might use the design pattern. Unless ASP.NET MVC framework actually is designed for a different design pattern that is close to but not exactly the same as MVC. That's likely. And people can use ASP.NET MVC and still not do something that is MVC (or whatever exactly ASP.NET MVC espouses).

Is it the default way WPF applications are arranged?

What do you mean "default"?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Probably you were expected to assume the name didn't have any spaces in it, and do

char name[100]; scanf("%99s\n", name);

The way the code in your post works is that it matches a sequence of characters that are not \n. The %[^\n] format specifier works a bit like a regex character class. For example, %[ac-e] would match one or more characters that are a, c, d, or e. %[^ac-e] would match one or more characters that are not a, c, d, or e. Then the line involving dump should supposedly eat the \n at the end of the stream. That of course assumes the user inputs less than 40 characters, otherwise it writes past the end of the array and makes your program crash in interesting ways.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Did you change your BIOS settings back?

Also, unplug your monitor cable and plug it back in, at both ends. Also, unplug your monitor power cable and plug it back in, at both ends (sorry, I know you know I'm assuming you're a bit retarded here, just do it). Unplug the USB device, too.

Can you confirm that other computers work with the monitor?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

You don't have to define a _SIZE macro to initialize the size of the vector to zero...

If anything you should use const ints instead of #defines, but in this case just put a 0 in the code.

Also _SIZE is a reserved word under POSIX, since it begins with an underscore followed by a capital letter.

Why would anybody expect a resize() call to exist, and why would they expect it to double the size? Nobody would expect that.

Why would a resize(n) call where n is less than the current size be a no-op?

The resize function is completely broken, it assigns arr to the value of temp_array and then deletes temp_array which is the memory address arr now points to!!!

And it deletes it with the wrong delete operator! It must use delete[]!

Also push_back is broken because it writes past the end of the array.

pop_back unnecessarily copies the value before returning it.

operator[] could return the value by reference but it doesn't.

~vector uses the wrong delete operator too.

So this code is completely broken, unless you want to construct empty vectors, call size() on them, and crash the process before the vector gets destructed.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The website will be developed with PHP, MySQL, and several other established open source languages + technologies. The reason I list the two above technologies is because I remember hearing some stuff about a MySQL license that prohibits people from using it publically for profit, or selling software that uses MySQL. Is this true?

Partly. MySQL is distributed under the GPL (with the linking exception which gives you more rights when redistributing it). You have to obey certain rules when redistributing MySQL, but there are no rules to follow when you're hosting a website that uses MySQL internally.

I'm hoping to use the social website as a business in the far off future, any legal repercussions?

There is the question of whether you need to get a business license in your local jurisdiction, if you have the goal of it being a business in the far-off future. If you make any kind of income your activities certainly constitute business activities and need a business license. It may be the case if you're just developing the product too. You haven't specified your local legal jurisdiction, so you should look at the relevant laws, for starters.

I wouldn't like this idea/brand to be copied by someone, how's this done?

Read about trademark law (regarding brands) to understand the issues around that. Read about patent law (regarding ideas) to understand the issues around that -- but your "idea" is almost certainly not patentable and probably going to …

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Look up "random shuffle" algorithms.

The way it works is that you fill the array with N values, and then you pick which value should go last, picking a number from 0 to N-1. Then swap that value with the one in the last position. Then pick a value which should go second-last (choosing a number from 0 to N-2). Then swap that value with the one in the second-last position. Then pick... and so on.

This gives each possible permutation an equal probability of being chosen. (In particular, there are N! permutations of N elements, and there are N! combinations of random numbers you picked, which makes sense.)

Specifically that picks permutations randomly [i]and[/i] uniformly.

Another technique, which is broken, is "for i = 0 to N-1, pick a random element from a position chosen from 0 to N-1 and swap it with the i'th element." That would give some permutations a better chance of being chosen than others.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

Okay...

What part do you need help with?

Rashakil Fol 978 Super Senior Demiposter Team Colleague

If you don't have data to store, you wouldn't use a database system.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

What you actually want to do is return a pointer to a function.

(Or, perhaps you really want to return a std::function<void(YType, ZType)>, which is different, but the first thing to learn is how function pointers work.)

Search for "function pointers" and learn how they work, they'll do what you want.

They'll do it without involving strings, by the way. There's no table of function names available at run-time, so that couldn't work. A function pointer is just the memory address of the first instruction in the function.

Edit: Interpreting your question less literally, it's also possible that you actually want runtime polymorphism, involving virtual functions and class inheritance. You should make sure you learn how these work, they could also be used to accomplish the goal, albeit less directly and more generally. And it's a very important part of C++.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

The Python documentation on the website provides a suitable introduction.

Rashakil Fol 978 Super Senior Demiposter Team Colleague

In python you don't have to declare types and you don't have to declare interfaces, the way you do in certain other languages, and it has certain constructs like list comprehensions and general "functional" features that let you avoid having to write things in terms of declaring local variables and writing loops that manipulate them. Also it has generators.

The downside for certain applications and upside for others is that the language has a particularly dynamic nature.