Coding: Fleeting Thoughts

A place to discuss the implementation and style of computer programs.

Moderators: phlip, Moderators General, Prelates

User avatar
Rium
Posts: 70
Joined: Sat Feb 04, 2012 12:57 am UTC

Re: Coding: Fleeting Thoughts

Postby Rium » Wed Jun 06, 2012 11:41 pm UTC

Xanthir wrote:Woohoo! Every web dev rejoice, today my Flexbox Layout CSS spec was approved to go to Last Call! It'll be published on Tuesday, so on July 3rd it'll move to Candidate Rec, and all the browsers can unprefix it!

Right now, only Chrome has a public implementation of the new draft, and we're about to change to match the naming changes that have happened in the past month, which will break pretty much everything currently using Flexbox. Once we do that, though, we'll be stable and unprefixed in a mere few weeks! All the other browsers have implementations ready to go as well - FF and Opera were basically just waiting for the spec to stabilize, so should release unprefixed support in a month or two as well. Even IE10 will support it, though right now the plan is to do so under the -ms- prefix (who knows if that'll change, though).

By the end of this year, you'll be able to use Flexbox in every major browser! Wooooooo!

Congrats! That looks like it will save a lot of hassle.

troyp
Posts: 557
Joined: Thu May 22, 2008 9:20 pm UTC
Location: Lismore, NSW

Re: Coding: Fleeting Thoughts

Postby troyp » Wed Jun 06, 2012 11:49 pm UTC

Xanthir, why is it you seem to be always an editor of "should have happened years ago" specs, like CSS variables and more intuitive layout? Are you somehow managing to advocate this stuff or push it through? If so, someone needs to give you a medal...

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Coding: Fleeting Thoughts

Postby Steax » Thu Jun 07, 2012 12:11 am UTC

troyp wrote:Xanthir, why is it you seem to be always an editor of "should have happened years ago" specs, like CSS variables and more intuitive layout? Are you somehow managing to advocate this stuff or push it through? If so, someone needs to give you a medal...


If I remember correctly, he's part of the Google Chrome team, mostly on specifications. Yes, he is our personal hero.
In Minecraft, I use the username Rirez.

User avatar
Sc4Freak
Posts: 673
Joined: Thu Jul 12, 2007 4:50 am UTC
Location: Redmond, Washington

Re: Coding: Fleeting Thoughts

Postby Sc4Freak » Thu Jun 07, 2012 2:22 am UTC

Yakk wrote:Speaking of parallel code...

Take a look at microsofts amp project:
http://msdn.microsoft.com/en-us/library ... 10%29.aspx
it (ab)uses the restrict keyword (so you can say "this function is restricted to using a reduced feature set of the language", which they need to be able to reasonably run code on the GPU).

From that, we get:

Code: Select all

parallel_for_each( details, [=](index<1> idx) restrict(amp)
{
  // code goes here
});

where we can use for-each and lambdas to run code on the GPU, or in in a more traditional multiple process environment.

Rather neat solution, as it allows expression "this function must come from some restricted set of C++". The big thing missing is an in-language way to describe a set of restrictions, as opposed to compiler-provided methods.


It's worth noting that AMP is built on top of the Concurrency Runtime (which handles scheduling and task management and that sort of thing) and the Parallel Patterns Library (which gives you parallel algorithms like parallel_for_each). AMP was sort of designed for use in heterogeneous computing - running code on GPUs and the like. If you just want a powerful and expressive parallel programming framework, you can just use ConcRT and the PPL directly.

User avatar
PM 2Ring
Posts: 3701
Joined: Mon Jan 26, 2009 3:19 pm UTC
Location: Sydney, Australia

Re: Coding: Fleeting Thoughts

Postby PM 2Ring » Thu Jun 07, 2012 11:20 am UTC

Xanthir wrote:By the end of this year, you'll be able to use Flexbox in every major browser! Wooooooo!

Yay! I just had a quick look at the Flexbox specs, and it looks awesome! Thanks, Xanthir (and friends). From my brief reading, it reminds me a lot of the box system used in GTK, but it appears to be a bit more powerful than GTK, with Flexbox's ability to wrap layouts and split them over page breaks, as well as various other fancy features which must have been fun to implement. :)


PS. The plural of "basis" is (usually) "bases", but since you're using "basis" as a technical term, I guess you can pluralize it however you like. :)

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Thu Jun 07, 2012 4:05 pm UTC

So I did a phone screen for google. This is how I felt when the C and C++ questions kept pouring in. I'll probably crash and burn in the actual interview, but it's still fun to see how far I can get.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
Xanthir
My HERO!!!
Posts: 5400
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Thu Jun 07, 2012 5:49 pm UTC

PM 2Ring wrote:PS. The plural of "basis" is (usually) "bases", but since you're using "basis" as a technical term, I guess you can pluralize it however you like. :)


Fuck your made up pseudo-Latin pluralization rules. ^_^ Those were invented whole-cloth a century ago by people who Latin was the best language ever, and so we should import as many rules as possible into our Germanic language.

"basis" => "basises" is basic English pluralization rules.

(I've already had arguments about this in the WG, and so far have resolved them by just ignoring everyone who complains about it. I did the same with "axises", but it looks like unrelated edits have removed all the places where I previously pluralized that word.)

troyp wrote:Xanthir, why is it you seem to be always an editor of "should have happened years ago" specs, like CSS variables and more intuitive layout? Are you somehow managing to advocate this stuff or push it through? If so, someone needs to give you a medal...


I was a webdev before joining Google (most people on the CSSWG are just implementors, and have only done trivial sites like their homepages), and have continued to put together small web projects since then, so I think I have a pretty decent idea of what webdevs actually need.

I also have plenty of time, since working on standards is my primary job, and can be pushy and persistent when necessary. ^_^
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Xanthir
My HERO!!!
Posts: 5400
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Thu Jun 07, 2012 5:51 pm UTC

You, sir, name? wrote:So I did a phone screen for google. This is how I felt when the C and C++ questions kept pouring in. I'll probably crash and burn in the actual interview, but it's still fun to see how far I can get.


Feel free to mention that you know me, if you end up interviewing at main campus. I can be your lunch interviewer. ^_^
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
joshz
Posts: 1466
Joined: Tue Nov 11, 2008 2:51 am UTC
Location: Pittsburgh, PA

Re: Coding: Fleeting Thoughts

Postby joshz » Sat Jun 09, 2012 8:14 am UTC

Wait, Xanthir, you're in Mountain View?

We should lunch and/or xkcd-meetup sometime! I'm here for the summer, interning at Khan Academy.
You, sir, name? wrote:If you have over 26 levels of nesting, you've got bigger problems ... than variable naming.
suffer-cait wrote:it might also be interesting to note here that i don't like 5 fingers. they feel too bulky.

User avatar
Xanthir
My HERO!!!
Posts: 5400
Joined: Tue Feb 20, 2007 12:49 am UTC
Location: The Googleplex
Contact:

Re: Coding: Fleeting Thoughts

Postby Xanthir » Sat Jun 09, 2012 5:56 pm UTC

My location tells the truth. PM'd you.
(defun fibs (n &optional (a 1) (b 1)) (take n (unfold '+ a b)))

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6568
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Sun Jun 10, 2012 1:45 am UTC

I've officially given up on trying to write a .NET 4.0 class that loads a p12 containing a certificate and private key (384 bit ECC), and signs a document using EcDsaCng. The PrivateKey property on the x509Certificate2 object throws a NotSupportedException, so I found this which uses the windows API to get the CngKey object, but it throws an exception "Keys used with the ECDsaCng algorithm must have an algorithm group of ECDsa.". I check the object, and it shows the the AlgoritmGroup property as being ECDH, and I am now at a dead end.

Note that windows identifies the algorithm for the cert as being ECDSA_P384, and the really stupid thing is that there is no difference between an ECDH key and an ECDSA key. The only difference between a certificate for ECDH and ECDSA is the usage restrictions. A single cert can be used for both ECDH and ECDSA if the KeyUsage extension specifies keyAgreement and digitalSignature (not recommended, but possible).

I can't wrap my head around how Microsoft provides a class for signing a document with ECDSA but doesn't provide a way to use it with an x509 certificate (or any other format, for that matter).

Anyway, I'll rewrite my code using BouncyCastle eventually. For now, I'll get to step two of my project, writing a compatible library in C using OpenSSL, and then I'll get back to .NET.
Summum ius, summa iniuria.

User avatar
Aaeriele
Posts: 2127
Joined: Tue Feb 23, 2010 3:30 am UTC
Location: San Francisco, CA

Re: Coding: Fleeting Thoughts

Postby Aaeriele » Sun Jun 10, 2012 6:07 am UTC

Xanthir wrote:My location tells the truth. PM'd you.


Also if you're ever up in SF we should say hi (I live/work in SF).
Vaniver wrote:Harvard is a hedge fund that runs the most prestigious dating agency in the world, and incidentally employs famous scientists to do research.

afuzzyduck wrote:ITS MEANT TO BE FLUTTERSHY BUT I JUST SEE AAERIELE! CURSE YOU FORA!

User avatar
Yakk
Poster with most posts but no title.
Posts: 11115
Joined: Sat Jan 27, 2007 7:27 pm UTC
Location: E pur si muove

Re: Coding: Fleeting Thoughts

Postby Yakk » Sun Jun 10, 2012 10:35 am UTC

Thesh wrote:I've officially given up on trying to write a .NET 4.0 class that loads a p12 containing a certificate and private key (384 bit ECC), and signs a document using EcDsaCng. The PrivateKey property on the x509Certificate2 object throws a NotSupportedException, so I found this which uses the windows API to get the CngKey object, but it throws an exception "Keys used with the ECDsaCng algorithm must have an algorithm group of ECDsa.". I check the object, and it shows the the AlgoritmGroup property as being ECDH, and I am now at a dead end.

Note that windows identifies the algorithm for the cert as being ECDSA_P384, and the really stupid thing is that there is no difference between an ECDH key and an ECDSA key. The only difference between a certificate for ECDH and ECDSA is the usage restrictions. A single cert can be used for both ECDH and ECDSA if the KeyUsage extension specifies keyAgreement and digitalSignature (not recommended, but possible).

I can't wrap my head around how Microsoft provides a class for signing a document with ECDSA but doesn't provide a way to use it with an x509 certificate (or any other format, for that matter).

Anyway, I'll rewrite my code using BouncyCastle eventually. For now, I'll get to step two of my project, writing a compatible library in C using OpenSSL, and then I'll get back to .NET.

This stachoverflow has a good point:
http://stackoverflow.com/questions/4969 ... ecdsa-keys
basically the intended usage of the two kinds of keys is different, even if the raw data is the same. A key marked for one usage ... possibly shouldn't be used for the other.

I suspect an "easy" way around this would to be serialize your key in one format, munge the resulting output into the other format, then deserialize into the other key type? Many cryptography standards have human readable ASCII serialized states that you can round-trip through, no?
One of the painful things about our time is that those who feel certainty are stupid, and those with any imagination and understanding are filled with doubt and indecision - BR

Last edited by JHVH on Fri Oct 23, 4004 BCE 6:17 pm, edited 6 times in total.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6568
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: Coding: Fleeting Thoughts

Postby Thesh » Sun Jun 10, 2012 7:24 pm UTC

You're right, you shouldn't interchange them, which is why my library does this check for Key Agreement:

Code: Select all

else if ((((X509KeyUsageExtension)value.Extensions["Key Usage"]).KeyUsages | X509KeyUsageFlags.EncipherOnly) != (X509KeyUsageFlags.KeyAgreement | X509KeyUsageFlags.EncipherOnly))
{
   throw new ArgumentException("Certificate is not valid for Key Establishment");
}


And this check for the signing certificate:

Code: Select all

else if ((((X509KeyUsageExtension)value.Extensions["Key Usage"]).KeyUsages | X509KeyUsageFlags.NonRepudiation) != (X509KeyUsageFlags.DigitalSignature | X509KeyUsageFlags.NonRepudiation))
{
   throw new ArgumentException("Certificate is not valid for Signing");
}


The problem is that .NET 4.0 provides no way to get the key from that certificate into a CngKey format for use with EcDsaCng, and the only function I can find gives it the wrong type (not from the certificate), which is an arbitrary restriction.

Yakk wrote:I suspect an "easy" way around this would to be serialize your key in one format, munge the resulting output into the other format, then deserialize into the other key type? Many cryptography standards have human readable ASCII serialized states that you can round-trip through, no?


The classes CngKey and X509Certificate2 are not serializable, and the export function of CngKey throws an exception "The requested operation is not supported.". The only solution I'm left with is to use third party libraries instead of the built in classes.
Summum ius, summa iniuria.

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Coding: Fleeting Thoughts

Postby Steax » Mon Jun 11, 2012 4:02 am UTC

I finally worked out that, yes, Git repos on Dropbox are stable. I now have a way to access my repositories from any device with dropbox support, yay!
In Minecraft, I use the username Rirez.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Mon Jun 11, 2012 1:05 pm UTC

Xanthir pushed CSS variables? Son of a bitch that's awesome.

Also, whatever happened to code bowling? That was awesome. I remember printing out Good [morning|afternoon|evening|night] by recursively outputting one char at a time.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Mon Jun 11, 2012 1:06 pm UTC

What's the future of boost now that C++11 is out and about, either directly grabbing boost features (like array, shared_ptr, regex), improving upon them (lambdas), or making them trivially to implement on your own (signal/slot, scope-exit, etc.)?


sourmìlk wrote:Xanthir pushed CSS variables? Son of a bitch that's awesome.

Also, whatever happened to code bowling? That was awesome. I remember printing out Good [morning|afternoon|evening|night] by recursively outputting one char at a time.


They made a code golf stackoverflow site (supposed to also hold bowling), and during that transition, it seems to have run into the sand.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Mon Jun 11, 2012 1:10 pm UTC

I am actually not bothering to use boost because of the C++11 features. I guess it's really in the hands of those devs though. If they can come up with more useful things to implement then boost will survive. But with its current feature set, C++11 pretty much obsoletes most of it. (Is "obsolete" a transitive verb?)

Also the fate of code bowling makes me sad. I'm not good at code golf, but I could do code bowling. I guess that's why it wasn't a very good competition :P
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

User avatar
You, sir, name?
Posts: 6983
Joined: Sun Apr 22, 2007 10:07 am UTC
Location: Chako Paul City
Contact:

Re: Coding: Fleeting Thoughts

Postby You, sir, name? » Mon Jun 11, 2012 1:17 pm UTC

Yeah, that''s sort of where I was leaning as well. They do have some nice features, such as unit testing, file system stuff, and chronological features that still seem useful, but a lot of it seems very redundant with 11.
I edit my posts a lot and sometimes the words wrong order words appear in sentences get messed up.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Mon Jun 11, 2012 2:33 pm UTC

sourmìlk wrote:I am actually not bothering to use boost because of the C++11 features. I guess it's really in the hands of those devs though. If they can come up with more useful things to implement then boost will survive. But with its current feature set, C++11 pretty much obsoletes most of it. (Is "obsolete" a transitive verb?)

You have a strange definition of "most". :-)

OK, so it doesn't have to be that strange, but in terms of "% of Boost's library in C++11" it's not even close. The libraries I've used at one time or another that I think haven't made it in are a couple of the string algorithms, any, bimap, chrono (OK I haven't yet, but I'm about too), dynamic_bitset, graph (ugh), heap, iterators, lexical_cast, and program options; there are a zillion others I haven't used, and they're adding new libraries all the time (e.g. the heap library is new to 1.49).

Combine that with the fact that many of use aren't able to use C++11 yet (much of what I write ideally supports back to GCC 4.1, the installed-by-default version on RHEL 5) and Boost still has a long life left. (Also for that reason I'm not totally familiar with all of what TR1 and C++11 added, so I may be wrong about C++11 not providing support.)

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Mon Jun 11, 2012 4:13 pm UTC

What if you weighted features by frequency of use? Would "most" work better then? Also, I think (but am not certain) that C++11 added some sort of lexical_cast type function.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Mon Jun 11, 2012 4:21 pm UTC

sourmìlk wrote:What if you weighted features by frequency of use? Would "most" work better then?

That's sort of what I was thinking when I wrote "OK, so it doesn't have to be that strange". Even still, I think that for my use it wouldn't, though in part that's because I don't use shared_ptr and we have our own reference-counted smart pointer class.

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Tue Jun 12, 2012 2:37 am UTC

Okay. I retroactively revise my post to say "pretty much obsoletes a substantial portion of it."
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

User avatar
Shivahn
Posts: 2200
Joined: Tue Jan 06, 2009 6:17 am UTC

Re: Coding: Fleeting Thoughts

Postby Shivahn » Tue Jun 12, 2012 3:34 am UTC

Heh, the format I designed to save my quadtrees is apparently close enough to the Microsoft icon format that it confuses Linux.

User avatar
tastelikecoke
Posts: 1208
Joined: Mon Feb 01, 2010 7:58 am UTC
Location: Antipode of Brazil
Contact:

Re: Coding: Fleeting Thoughts

Postby tastelikecoke » Tue Jun 12, 2012 6:57 am UTC

So I've been tasked to learn Django lately, and I'm surprised at the amount of stuff that I am learning in just a few days. Now I'm wondering if I can get the ball rolling, but there's not much definite guides on the internet about broad topics want to learn, like game dev, gui design, or data structures.

User avatar
Aaeriele
Posts: 2127
Joined: Tue Feb 23, 2010 3:30 am UTC
Location: San Francisco, CA

Re: Coding: Fleeting Thoughts

Postby Aaeriele » Tue Jun 12, 2012 7:17 am UTC

tastelikecoke wrote:So I've been tasked to learn Django lately, and I'm surprised at the amount of stuff that I am learning in just a few days. Now I'm wondering if I can get the ball rolling, but there's not much definite guides on the internet about broad topics want to learn, like game dev, gui design, or data structures.


Data structures http://www.academicearth.org/courses/data-structures

Game dev http://www.gamedev.net/forum/31-for-beginners/

UI design: go find a copy of The Design of Everyday Things and read it.
Vaniver wrote:Harvard is a hedge fund that runs the most prestigious dating agency in the world, and incidentally employs famous scientists to do research.

afuzzyduck wrote:ITS MEANT TO BE FLUTTERSHY BUT I JUST SEE AAERIELE! CURSE YOU FORA!

User avatar
tastelikecoke
Posts: 1208
Joined: Mon Feb 01, 2010 7:58 am UTC
Location: Antipode of Brazil
Contact:

Re: Coding: Fleeting Thoughts

Postby tastelikecoke » Tue Jun 12, 2012 7:45 am UTC

Hey thanks :D I checked to the gamedev forum a while back, but I'm still clueless where to start with all those threads.

User avatar
Aaeriele
Posts: 2127
Joined: Tue Feb 23, 2010 3:30 am UTC
Location: San Francisco, CA

Re: Coding: Fleeting Thoughts

Postby Aaeriele » Tue Jun 12, 2012 7:52 am UTC

tastelikecoke wrote:Hey thanks :D I checked to the gamedev forum a while back, but I'm still clueless where to start with all those threads.


I'd suggest clicking the "Resources" tab to swap over there instead of the "Topics" tab.

Edit: Aha, if I right-click and copy the tab URL, it'll let me link directly to it, even though normally it doesn't update the URL bar: http://www.gamedev.net/forum/31-for-beginners/#tmain
Vaniver wrote:Harvard is a hedge fund that runs the most prestigious dating agency in the world, and incidentally employs famous scientists to do research.

afuzzyduck wrote:ITS MEANT TO BE FLUTTERSHY BUT I JUST SEE AAERIELE! CURSE YOU FORA!

User avatar
Afif_D
Posts: 184
Joined: Wed Oct 06, 2010 2:56 pm UTC

Re: Coding: Fleeting Thoughts

Postby Afif_D » Tue Jun 12, 2012 1:33 pm UTC

First I generated an random array of size n.
Then a random integer j from 0 to n-1.
if(a[j]>a[j+1])
<SWAP a[j] and a[j+1]>

Useless Sorting algorithm. But works fast for small n.

This is wat i did today.
Image

User avatar
ahammel
My Little Cabbage
Posts: 2135
Joined: Mon Jan 30, 2012 12:46 am UTC
Location: Vancouver BC
Contact:

Re: Coding: Fleeting Thoughts

Postby ahammel » Tue Jun 12, 2012 2:04 pm UTC

Afif_D wrote:First I generated an random array of size n.
Then a random integer j from 0 to n-1.
if(a[j]>a[j+1])
<SWAP a[j] and a[j+1]>

Useless Sorting algorithm. But works fast for small n.

This is wat i did today.

That's the Bruce sort.
He/Him/His/Alex
God damn these electric sex pants!

User avatar
Link
Posts: 1399
Joined: Sat Mar 07, 2009 11:33 am UTC
Location: ᘝᓄᘈᖉᐣ
Contact:

Re: Coding: Fleeting Thoughts

Postby Link » Tue Jun 12, 2012 4:07 pm UTC

I've been trying to get the hang of OpenGL, and I've gone through two days of frustration to get a piece of very basic render-to-texture code working. No matter how hard I tried, it kept showing up as black.

Turns out my render-to-texture code was actually completely correct; I just forgot to call glColor4f (1.0, 1.0, 1.0, 1.0) before trying to display my texture. Goddamn lava-farting roboJesus on a pogo stick!

User avatar
sourmìlk
If I can't complain, can I at least express my fear?
Posts: 6393
Joined: Mon Dec 22, 2008 10:53 pm UTC
Location: permanently in the wrong
Contact:

Re: Coding: Fleeting Thoughts

Postby sourmìlk » Tue Jun 12, 2012 6:00 pm UTC

Unfortunately, glColor4f and almost every other OpenGL call that doesn't exist just to bind textures or pass data to the shader is deprecated. So you'll need to move all of your code away from the fixed function pipeline, create your own modelview and projection matrix libraries, writer your own shaders, and store everything in a Vertex buffer :D

That sounds like a pain in the ass, and it is, but I don't care because I rather like OpenGL for no reason I can really understand.
Terry Pratchett wrote:The trouble with having an open mind, of course, is that people will insist on coming along and trying to put things in it.

EvanED
Posts: 4331
Joined: Mon Aug 07, 2006 6:28 am UTC
Location: Madison, WI
Contact:

Re: Coding: Fleeting Thoughts

Postby EvanED » Tue Jun 12, 2012 6:24 pm UTC

sourmìlk wrote:That sounds like a pain in the ass, and it is, but I don't care because I rather like OpenGL for no reason I can really understand.

I believe Wikipedia has an explanation :).

(OK, that's a little unfair; I only have a small amount of OpenGL experience, and none with the alternative DirectX. Still, I wasn't a fan of the API as it's too stateful, as if that wasn't basically the point.)

User avatar
Link
Posts: 1399
Joined: Sat Mar 07, 2009 11:33 am UTC
Location: ᘝᓄᘈᖉᐣ
Contact:

Re: Coding: Fleeting Thoughts

Postby Link » Tue Jun 12, 2012 6:37 pm UTC

Well, fuck. I actually only decided to move to OpenGL because SDL doesn't have the hardware-accelerated functions I need (2D stuff only, but it doesn't even do stuff like scaling and rotation in hardware). The resources I found for going from SDL to OpenGL conveniently neglected to mention that their code was deprecated. (In fact, most of the resource I've seen predate the inclusion of framebuffers into the OpenGL core.)

Meh.

User avatar
headprogrammingczar
Posts: 3072
Joined: Mon Oct 22, 2007 5:28 pm UTC
Location: Beaming you up

Re: Coding: Fleeting Thoughts

Postby headprogrammingczar » Tue Jun 12, 2012 9:33 pm UTC

Since you don't need 3D, cairo has a very nice API, and is designed to use hardware acceleration whenever it can.
<quintopia> You're not crazy. you're the goddamn headprogrammingspock!
<Weeks> You're the goddamn headprogrammingspock!
<Cheese> I love you

User avatar
Link
Posts: 1399
Joined: Sat Mar 07, 2009 11:33 am UTC
Location: ᘝᓄᘈᖉᐣ
Contact:

Re: Coding: Fleeting Thoughts

Postby Link » Tue Jun 12, 2012 10:10 pm UTC

I'd actually considered cairo (and Allegro, for that matter) before but decided to go with OpenGL because it figured it would be useful to know OpenGL anyway, and there's probably more community support for OpenGL than there is for cairo. But seeing as the OpenGL standard changes a lot, and the API isn't one I'm very comfortable with anyway, I suppose I could definitely reconsider cairo. It would also open the possibility of going with SVG instead of bitmaps... That would require some re-thinking, but it would definitely be nice. Hmmm...

Hey, where'd those past 20 minutes go?

User avatar
Shivahn
Posts: 2200
Joined: Tue Jan 06, 2009 6:17 am UTC

Re: Coding: Fleeting Thoughts

Postby Shivahn » Wed Jun 13, 2012 1:07 am UTC

I'm learning some Haskell (for Great Good!) and have a quick (sort of general) question about how best to learn things like new languages. People advise project Euler, but for the most part that's translating an imperative program into other languages (at least, for most people). I don't want to just learn the syntax of each new language, I want to learn to use that language in ways that it's good for (I don't want to be driving nails with sledgehammers, basically).

To that end, are there any good sort of... workbooks, or anything, for Haskell (or any other language for that matter? I like learning to use new things and tools for what they're useful for. I'd rather learn Erlang than try to write a distributed computing system in C, and I'd rather study Prolog more than write a program to solve a system with various constraints).

I just want to know if there are resources for (any) language that aren't tutorials, but are more like problem sets that that language is useful for. Or if there's a word for that sort of thing, so I can search myself.

User avatar
Steax
SecondTalon's Goon Squad
Posts: 3038
Joined: Sat Jan 12, 2008 12:18 pm UTC

Re: Coding: Fleeting Thoughts

Postby Steax » Wed Jun 13, 2012 1:50 am UTC

I wonder how the web (in particular, CSS) will deal with new high-resolution monitors*. How can we rely on pixels when these devices pretend to be a certain size, while upscaling graphics that lack the scalability? We now have "true" physical pixels and "software" pixels. Who decides what goes where? How does this work? WHY AM I BEING SO CONFUSED?

*) Yes, I know they've been around for a while - it's just that Apple's bringing them to their audience is giving it a nice hefty boost to mainstream.
In Minecraft, I use the username Rirez.

User avatar
Afif_D
Posts: 184
Joined: Wed Oct 06, 2010 2:56 pm UTC

Re: Coding: Fleeting Thoughts

Postby Afif_D » Wed Jun 13, 2012 2:44 am UTC

ahammel wrote:
Afif_D wrote:First I generated an random array of size n.
Then a random integer j from 0 to n-1.
if(a[j]>a[j+1])
<SWAP a[j] and a[j+1]>

Useless Sorting algorithm. But works fast for small n.

This is wat i did today.

That's the Bruce sort.


Oh me yarm!!!! I did a bruce sort all by myself without knowing someone has already done it.
Image

User avatar
jestingrabbit
Factoids are just Datas that haven't grown up yet
Posts: 5967
Joined: Tue Nov 28, 2006 9:50 pm UTC
Location: Sydney

Re: Coding: Fleeting Thoughts

Postby jestingrabbit » Wed Jun 13, 2012 3:27 am UTC

Shivahn wrote:I just want to know if there are resources for (any) language that aren't tutorials, but are more like problem sets that that language is useful for. Or if there's a word for that sort of thing, so I can search myself.


I don't know, but a problem that I had success solving with Haskell, that I found kinda interesting and fun, was the 36 officers problem.

http://en.wikipedia.org/wiki/Thirty-six ... rs_problem

Not really a class of problems, but it really lent itself to list comprehensions, which is where Haskell is strong, I guess. Another standard exercise for Haskell is to rewrite some of the Prelude functions, like map, reverse etc.
ameretrifle wrote:Magic space feudalism is therefore a viable idea.


Return to “Coding”

Who is online

Users browsing this forum: No registered users and 12 guests