« first day (410 days earlier)      last day (4539 days later) » 

3:02 AM
WHY CANT I GET SOMETHING THIS STUPIDLY EASY RIGHT!/
THIS SHOULD NOT TAKE ME 4 HOURS
 
@AlfPSteinbach What tutorial/book are you using?
 
I'm having trouble writing an array of wchar_t's to a file
I try to write it, but then the output is corrupted (only writes the first 2 characters, and the rest is garbled)
I read the newbie hints by the way, and it says to use "backticks" to format code. Are those '?
 
Backticks are `
 
So:
void FileStream::Write(Array<byte> data, int offset, int count) {

int dbg = fwrite(data.internarray+(size_t)offset,(size_t)1,(size_t)count,fpointer);
ipos +=count;
if(ipos>flen) {
flen = ipos;
}
}
Hmm..
 
Multiline messages act weird.
 
3:14 AM
Yeah... I tried the four-space and fixed-font thing
 
That's "normal".
 
int dbg is so I can set a debug breakpoint there by the way
In case there's a write error of some kind
I also wrote an Array class
Quite a long Array class, but I have an out-of-date Git repo for it. Perhaps I should update that and link the source
GIT is often quite slow... especially on a VM.
Probably read/write from the host HDD that I mounted in it
Here's the Array class
Here's the program I wrote that writes to the file (UChar in GCC maps to wchar_t)
Looking at the library, and my application, what am I doing wrong?
I use C-style casts by the way, to preserve the value of the data, as I simply need the data to be interpreted by the compiler as a different type
I could probably use reinterpret_cast in some of these cases too.... Would that be more correct?
Any ideas?
Sorry if the code looks too C#y. I program primarily in .NET languages, and decided to work on a few C++ projects for a change.
 
I can write char* to a file just fine, but not wchar_t*
 
3:29 AM
you're not supposed to, really
the external format should really best be UTF-8
how to do that easiest depends on the compiler's support for C++11
 
I'm using GCC as the compiler
 
which version?
 
The one that comes with Eclipse
It has "experimental" C++11 support
I'm trying to not rely too much on the new features though
 
well, the thing is C++11 has a number of standard library functions that convert wchar_t to UTF-8, and vice versa
 
I'm using ICU
 
3:32 AM
oh then you're set
:-)
 
So; when I call getTerminatedBuffer() on the UnicodeString, it returns wchar_t*....
At least in GCC
Is there a better way to do it?
I want an array of something which I can write to either a file or a virtual device
 
I'm not that familiar with ICU
i would just google it
 
Tried that....
 
or check the documentation
 
Tried that as well. I think I'm calling the right function...
And I can use the wchar_t* fine as long as its in memory
but it becomes corrupted as soon as I write it to a file
I convert it to an Array<byte> then write to a file (or other type of stream) using the following logic
 
3:36 AM
You need to use binary mode file if you're on Windows
 
` Array<byte> mray = Array<byte>((byte*)testring.cstr(),testring.Length()*sizeof(UChar));
I am using Binary mode
r+b
Right?
In fopen?
 
Then to write to the file: mstr->Write(mray,0,testring.Length()*sizeof(UChar));
 
@AlfPSteinbach What's your opinion on that book? I've been reading "Real world" and "a gentle introduction" but haven't been thrilled with either of them.
 
byte is defined as
`unsigned char
cstr returns a wchar_t*
Length returns the number of characters in the string
 
3:39 AM
@Pubby u mean the tutorial? well it's ok so far but it did skip very lightly over a few issues that i think an ordinary user would have trouble with. like, that most examples are meant to be typed into an editor and not in the interactive command line
 
The program I wrote and all resources it uses are in source form here: github.com/IDWMaster/C--.NET/blob/master/SampleApplication/…
All in the same project
Again; I apologize for some C# style stuff. That's my primary language
However, as I understand it, a C-style cast is supposed to:
Tell the compiler: This section of memory should be processed as this type
But it doesn't actually DO any conversions, or type-safety checks
Which in my case are not desirable
I could use a reinterprate_caste to do the same thing
 
Since all that stuff is .NET, I think it would be easier and more clear to just do it in C#
I was assuming that you were talking standard C++
I think that's C++/CLI, which is just another language (a Microsoft language)
 
@Pubby have you tried learn you a haskell too? Or just the two you've mentioned?
@AlfPSteinbach how far you into that book?
 
i'm into those higher order functions
i'm talking it Real Easy(TM)
:-)
 
It's not C++/CLI
It's standard C++ which can compile under GCC
 
3:46 AM
@keithlayne Just the two. I decided against the "learn you a haskell" due to the illustrations on the cover. The other one has a scarab beetle!
 
@AlfPSteinbach I'm surprised you didn't type the Unicode for TM :)
 
#include <CLRHeader.h>
#include <FileStream.h>
using namespace System;
using namespace System::IO;
hello
 
@Pubby if you have a sense of humor like mine, the illustrations are pretty funny throughout
 
They're C++ classes, not actual managed classes
They're written in .NET style
Look at the code for the whole library. It's a BCL without the .NET framework
 
←â„¢
 
3:49 AM
@AlfPSteinbach I assume you have some FP background...the only thing I worry about is that I tend to read for a while before I play with it, and the concepts (embarrasingly) get a little harder for me to grasp
@AlfPSteinbach that's better sir :)
 
thanks
The Base Class Library (BCL) is a standard library available to all languages using the .NET Framework. .NET includes the BCL in order to encapsulate a large number of common functions, such as file reading and writing, graphic rendering, database interaction, and XML document manipulation, which makes the programmer's job easier. It is much larger in scope than standard libraries for most other languages, including C++, and is comparable in scope to the standard libraries of Java. The BCL is sometimes incorrectly referred to as the Framework Class Library (FCL), which is a superset includi...
ah
 
argh, I wish my math was better...I know a lot of you guys will discuss stuff like category theory and such...maybe I should read a math book instead.
 
@keithlayne It's humorous? I thought the artwork was for the kids. Although I must say, I strongly hate that style. Besides the art, how's the content?
 
ok so far
 
@Pubby he's just silly like me...I had the same basic question for @RMartinhoFernandes when he recommended the book, it gets deep enough I think. I think a combination of all three would be a good thing to try.
@Pubby I think (unless I'm just the dumbest person in the world) that the kids are gonna have difficulty grasping monads, etc. He does spend a lot of time going over syntax. I'm in the stage of playing with concepts now in order to really get it before moving on.
The syntax chapters help as a reference when I go back. I've played a little with Haskell before, so I've looked some at the other two tutorials, but not lately.
 
3:55 AM
The book I'm reading now has monads as almost the very last chapter. It teaches how to write an entire json parser before even mentioning them :S
 
I like the direct style, like "making a lambda in this case is stupid since using partial application is much more readable" :-)
 
It's nice to be able to write functions point-free
 
By the way (sorry for code formatting, still can't get the four-space thing to work):
//This works; but it's politically incorrect
	char* mt = (char*)"Hello world!";
	mstr->Write(Array<byte>((byte*)mt,sizeof(char)*12),0,sizeof(char*)*12);
Meant sizeof(char)
Not sizeof(char*)
 
However, I don't know how to compose a function when the return type can't be deduced without defining essentially a function alias or using a lambda
 
what is it with that Write function that it needs such silly arguments
what are the formal arguments?
 
3:58 AM
Write(Array<byte> data,int offset,int count);
 
Where offset is the offset in the array at which to begin writing, and count is the number of bytes to write
 
well if you just remove sizeof(char*)* it should work?
 
That sample works
 
Remove sizeof(char) too? I don't see how it adds anything
 
3:59 AM
But if I use wchar_t it's a whole different story
 
yes, it's just 1
 
My first formal programming education was Scheme, which I like probably better than any other Lisp, but Haskell's features (automatic currying, etc.) put it to shame
 
Does char very based on platform?
Updated Array class on github
 
Lisp doesn't have currying?
 
4:00 AM
@IDWMaster is Java a platform :)
 
@keithlayne Yes
 
@Pubby: i think maybe the typo at the end there has been making all the trouble
 
Updated char* sample: //This works; but it's politically incorrect
char* mt = (char*)"Hello world!";
mstr->Write(Array<byte>((byte*)mt,12),0,12);
 
@IDWMaster yes, but sizeof(char) is 1 by definition. you can get the bitsize from CHAR_BIT from <limits.h>, or std::numeric_limits<char>::digits() from <limits>
 
So the above will also work
 
4:01 AM
sizeof(char*) * 12
 
= 12
= 48
But sizeof(char)*12 = 12
 
@Pubby yes...works better with Scheme IMHO, but not as smooth as Haskell I think
 
Now, switching to Unicode.....
 
@IDWMaster did the hello work then?
 
@AlfPSteinbach did you post part 2 of your blog entry on the UTF stuff yet?
 
4:05 AM
IT WORKS! FileStream* mstr = new FileStream("hi.txt");



StdString testring = StdString("Hello world!").cstr();
UChar* mt = testring.cstr();
mstr->Write(Array<byte>((byte*)mt,testring.Length()*sizeof(UChar)),0,testring.Length()*sizeof(UChar));
return 0;
Finally!
UChar* is an ICU type, which actually maps to wchar_t* on Windows GCC
 
@keithlayne no, i haven't looked at it since the Request For Comments
 
Updated GIT repo
 
Hm, does char always correspond to a byte? Or can it be multiple bytes even though its size is 1?
 
char is always one byte
 
But what if the byte can't hold characters set?
 
4:07 AM
the feed guy here will post it here when i post
 
@Pubby That's why Unicode was invented
Supported properly in C# and newer languages, now FINALLY supported properly in C++!
In GCC at least...
MSVCC choked on ICU
 
Surprisingly most schools that I know of still use MSVCC and REFUSE to allow the use of GCC in their classrooms
I'm ironically still in 12th grade in high school, not even college yet, and I'm trying to learn multiple languages by myself. I've heard from people who've went to college they don't allow GCC though...
I personally think GCC is a lot better than MSVCC, but I have used both for different purposes.
I use MSVCC whenever I need DirectX stuff
GCC for everything cross-platform
 
It depends on what you're judging by. GCC is free and correct. MSVCC is fast and microsoft related
 
Yes. I don't like Microsoft-only stuff
Meaning I also don't like what they did with Windows 8
 
4:11 AM
I doubt colleges prohibit GCC, I bet they just don't install it
 
@IDWMaster where are you that won't allow GCC?
 
USSR?
 
@Pubby that sounds like a party
 
@keithlayne That's just where the party is at! CCCP is the party!
 
4:13 AM
@IDWMaster what I've seen a lot is that schools have a "partnership" with Microsoft. The upshot is that you can get a lot of software for free (Windows, VS, etc.) but the teachers are pressured to use BS stuff like VB. It's smart from their perspective, but lame.
 
@IDWMaster That looks like an inverse of this.
 
Where I first went there were nothing but Sparc stations, NeXT terms, and a few Macs in some labs (circa 1996-2000).
However, I would not push Sun's cc on anybody either, it sucks.
 
The reason I'm so focused on Unicode by the way is because I'm creating a BCL for C++, that can run on any platform without the need for porting a bulky Mono
I'd like Android support without having to pay the outrageous fee for Mono support
 
...or you could just say Team America, Fuck Yeah!!! and use only ASCII...EVER.
 
@keithlayne ASCII = Civil rights lawsuits
 
4:17 AM
@IDWMaster that's no fun, wouldn't happen in the USSR! CCCP == no civil rights!
 
@keithlayne Combined Community Codec Pack?
 
it's okay to joke about something that doesn't exist, right?
@IDWMaster I will assume you're kidding.
 
@keithlayne Yeah. But what IS the CCCP?
 
USSR in Cyrillic, I believe
 
Oh
Soviet Russia
 
4:19 AM
or the equivalent
 
In Soviet Russia, C++ programs YOU!
 
I know, it was gone before you were born.
 
Wish .cccp was the C++ extension
 
Modify GCC a little. It could be
 
4:22 AM
@IDWMaster you're probably going to be just as disappointed when you go college with what you learn there...just suck it up for a few years and then find an interesting job.
 
@keithlayne Yeah. I've heard stories, watched Harvard lectures (at least they ENCOURAGE gcc there!)
But even Harvard was kinda boring
 
lecture == boring, everywhere
 
I gave a lecture at the University of Minnesota once - youtube.com/watch?v=U85l1AOuxtg&feature=channel_video_title
On cross-platform .NET stuff
And 3D graphics programming
Only part of the lecture was recorded - battery died
 
and you're now in last year in high school?
that's impressive
 
Source code pertaining to the lecture is also on GitHub (C#) github.com/IDWMaster/3DAPI
 
4:25 AM
I think you'll find that if you find some decent CS faculty you can find something interesting to work on. Professors are having such a tough time finding work (schools moving away from tenure) that you find a surprising number of smart teachers all over the place, even when students are dumb.
 
I was their youngest speaker
That they'd ever had speak at that event
 
People are so enamored with 3d graphics stuff....I don't really get it. I don't like math that much
 
@keithlayne You don't need to be a math expert to understand 3D graphics, or programming in general. It's still mainly a "logical" understanding that you need.
 
@IDWMaster that is outstanding, but don't get too cocky or I'll crush your soul and steal your brains.
 
You need to know how 3D graphs and matrices work and stuff
but that's pretty simple
 
4:27 AM
i can't say i understand quaternions or rotation/shear matrices and all that stuff
i would have to read up on it
 
@IDWMaster I agree it's not so hard to use, but hard to fully understand, especially without more schooling than you have (for most)
 
@AlfPSteinbach My library on GitHub will abstract a lot of that for you
 
Quaternions are one too many dimensions for me :(
 
@IDWMaster that's kind of my point...there will always be guys like you willing to do that, it's just not as interesting to me. But good for you if you enjoy it, that's what really matters.
 
i remember we did Laplace transformations in high school (and at college). but if you threw one at me today it would just bounce off without making any impact whatsoever
sort of
 
4:29 AM
Like FFT libraries abound, and I can use them, but I hate Fourier math.
 
not that that has anything to do with graphics, just math
 
@AlfPSteinbach it's a good thing you have your Laplace shields up :)
 
The reason I made a new library, instead of using an existing one was because there was no existing .NET library which supported DirectX, OpenGL, and XNA (Windows Phone) in a single package.
 
ah, to be young with a bright future...
@IDWMaster didn't that get bulky?
 
4:32 AM
@keithlayne 45MB
Compressed
 
ugh
 
277MB uncompressed
Oh, and I made a new version
Should upload that now....
 
how well does that fit on a Windows phone? :)
 
Funny that Ubuntu warns "You have the num lock key on"
The binary size is significantly smaller
as it only needs to contain the XNA binaries
 
yeah, I get it, I'm just a smartass.
 
4:34 AM
I'm in a bit of a tricky situation here now: I want support on Windows, Linux, Mac, Windows Phone, and Android
Problem:
Windows phone doesn't support native code (for 3rd party devs)
Android doesn't support .NET (without paying a huge fine)
So; what to do?
I'm pretty sure Android supports GCC
 
something else instead? :)
 
So I can compile my native BCL for Android using Eclipse
 
haven't messed with native android, but 3d would probably be a place for it
 
Then I can make my own IL bytecode reader
Then I can run my 3D stuff on Android using my own implementation of the BCL
Without any need for re-compilation of the actual 3D program I want to run
Depending on your definition of compilation (is COMPILING to IL considered compilation?)
 
sure
 
4:37 AM
So then no re-compilation is necessary, because it can read the same bytecode with a different runtime
 
you could create a machine that runs it natively
 
Similar to how Mono works
@keithlayne In other words, a bytecode interpreter
 
well, like I said, a JVM is a bytecode interpreter, but the bytecode is compiled nonetheless
 
@IDWMaster Looking at your github, array.h is bugged censored
 
@Pubby be gentle
you mean the government is spying on it?
 
4:39 AM
@Pubby What's the bug?
 
i'm not sure i understand this one:
map ($ 3) [(4+), (10*), (^2), sqrt]
 
@AlfPSteinbach back to Haskell?
 
i'm thinking $ 3 produces a function that, uh, what?
yes
 
@IDWMas realloc doesn't work for non-pod data. Was discussing this a few days ago and apparently there isn't a solution
 
:t ($ 3)
($ 3) :: Num a => (a -> b) -> b
 
4:41 AM
oh, $ is infix
right
 
@Pubby What should I do then?
Malloc a new array, memcpy it, and delete the old one?
Isn't that what realloc is supposed to do?
 
@AlfPSteinbach huh? I don't really get it
 
@IDWMaster memcpy can invalidate your data since it doesn't call copy constructor/assignment op
 
the expression $ 3 sort of fills in the right argument of $, if you think of $ as a function with two arguments
 
@Pubby Oh.....
 
4:43 AM
it fills in the right arg because $ is infix, normally invoked like func $ arg
so it "curries" the $ function, binding the right argument, yielding a function with one argument (which argument is a function that it will apply to the bound arg)
 
What should I do?
 
@IDWMaster Best solution is to use std::vector. cccp committee decided that std::vector is the only portable way to do this. It really bothers me that they rejected hinnant's proposal to fix it.
 
On line 25 by the way, should I use delete[] or delete
 
@IDWMaster why doesn't std::vector work?
 
@AlfPSteinbach I suppose I can modify it to use std::vector, I've heard that it can hurt performance vs raw arrays though
 
4:45 AM
std::vector is masterful at reallocating buffers as necessary.
 
@AlfPSteinbach I've used $ before, but I didn't pick up on that usage, seems really useful.
 
@AlfPSteinbach Will I get an inherit performance hit by using it?
 
@IDWMaster no. but you can get a performance hit for debug builds. and a marginal one for release, but nothing to worry about.
 
@AlfPSteinbach Which operations cause the "marginal" performance hit, and why is it different between Release and Debug?
 
it's about bounds checking for indexing
 
4:47 AM
@IDWMaster release builds are optimized, debug builds are not.
 
in a debug build operator[] will typically check for range error
 
I've got a Haskell question for any who can help...
 
@AlfPSteinbach Oh.. I see. So it shouldn't really be that bad
 
in a release build it doesn't, it just sends you to UB land if you have range error
 
Changing my Array<T> class to use Vector underneath...
 
4:48 AM
Can I rewrite this point-free?
children p = zipWith delete p $ repeat p
 
@IDWMas You also have the overhead of a few extra variables since vector is resized on the fly
 
@IDWMaster I missed the start of the discussion, but why not just use a std::vector?
 
@keithlayne i don't know what fixed point is yet ;-)
i'm learning
 
@AlfPSteinbach just means removing the arg from the function definition, essentially
 
@EtiennedeMartel He's making a generic class that's simpler than std::vector. Doesn't it seem silly that he is forced to do it the more complex way?
 
4:50 AM
fg = f . g instead of fg x = f . g x as a stupid example
 
@EtiennedeMartel Making a native BCL. The point is to have the functions be similar to .NET BCL functions
Why is memcpy declared in string.h by the way?
 
@keithlayne well as of this time it's over my head. perhaps tomorrow.
 
"taking it easy". Yeah right. I wish I were so smart. :)
when you come to all those applicative functors and monads and such I will harass you for understanding.
 
he he
ok
 
Speaking of std::vector, is there a way to create an std::vector<T> from a T*?
Without using push_back
 
4:56 AM
@IDWMaster yes. there are two forms: v( start, end ) and v( start, n ) if i recall correctly. but at least the first.
 
@AlfPSteinbach Only the first one.
@IDWMaster std::vector v(p, p + size);
 
Array<T>(T* existingarray, long len) {
Length = len;
std::vector<T>(existingarray,existingarray+len);
Like that?
 

« first day (410 days earlier)      last day (4539 days later) »