Search found 497 matches

by korona
Mon Aug 11, 2014 10:47 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

Oh wow, that's impressive! Do you need every file in every build, though? Because I'd be very tempted to partition the rules up (in a similar way to how you'd do recursive make) and then only include the rules for the files you need. That could be based on the build target, static configuration or ...
by korona
Sun Aug 10, 2014 10:17 am UTC
Forum: Coding
Topic: Getting debug info from GCC
Replies: 3
Views: 3559

Re: Getting debug info from GCC

What exactly do you want to do? Do you want to print function addresses at runtime? Do you want to disassemble executables in a GUI?

What file format is your GCC targetting? ELF is well-documented and can be parsed easily.
by korona
Tue Aug 05, 2014 9:23 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

noexecpt(expression) handles the most common case (saying I do not throw). There is a proposal to add `std::except< T, Error >` to C++1y. In functions where I do not care about the error, I use `optional<T>` and return `nullopt` when the function failed, and it works reasonably well. I've googled f...
by korona
Sat Aug 02, 2014 10:07 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

If you want first-class functions, you can use std::function. You still have to think about lifetimes of captured variables, to use casts and wrappers for compatibility with functor-based interfaces, and to make design decisions about the tradeoffs between fast lambdas and slow std::function. Sure ...
by korona
Thu Jul 31, 2014 9:05 pm UTC
Forum: Coding
Topic: Funniest/Most Annoying Code Comments
Replies: 662
Views: 137053

Re: Funniest/Most Annoying Code Comments

I don't quite see how binary and works. Is there any use for it? Binary forms the basis of all computer calculations. Nearly everything calculated on a modern computer is done in binary, before being translated into your normal "decimal" notation. (There were older computers that performe...
by korona
Wed Jul 30, 2014 10:43 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

Well compiling assembly is no different than compiling C. Just run "as -o object.o source.S" (I think "gcc source.S" should also suffice). There are many tutorials and references on the web that teach you how to write lo level programs like x86 (non-EFI) boot loaders or toy kerne...
by korona
Mon Jul 28, 2014 11:04 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

What if you include some library in your code and see that it breaks all your existing code base because it introduces an implicit cast to a random type? Then it is a stupid library and you shouldn't use it. This is already a problem in C++ by the way, with implicit casts to bool and the like. So a...
by korona
Sun Jul 27, 2014 9:54 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

I strongly agree with EvanED here: In the expression "auto x = e;" x should always have the type of e. There are billions of bad things that could happen otherwise. Suppose some header file declares a type T (even in another namespace!) with a constructor: "template<typename X> class ...
by korona
Wed Jul 23, 2014 6:17 am UTC
Forum: Coding
Topic: JS: Recursion
Replies: 7
Views: 3545

Re: JS: Recursion

Yeah, depth first search is really ugly to code iteratively. While the usual DFS can relatively easily be done by using an explicit stack it gets really ugly (and inefficient!) if you need something like the pre- and post-order traversals of the graph. But in general iterative versions will almost a...
by korona
Sun Jul 20, 2014 9:39 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

@Jplus The problem is that the pointer-to-member is supplied as a template argument and not a function argument. @Yakk Here is the full code (with your Res(Args...) suggestion implemented). It is actually very simple. template<typename Res, typename... Args> class Callback<Res(Args...)> { public: te...
by korona
Sun Jul 20, 2014 12:44 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

So I have a C++ project where I'm using a lot of callbacks. I decided to write a "Callback" class, that is basically just a wrapper for an object pointer + a function pointer. I have a function that takes an object and a function-to-member pointer and returns such a callback. The code look...
by korona
Wed Jul 16, 2014 12:32 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

Coding low level stuff like kernels can be a very enjoyable exercise. I wrote a small operating system some years ago. (well it grew quite big - about 35k sloc - in particular because I built an own language and tool chain with compiler, assembler and linker for it). However starting programming wit...
by korona
Tue Jul 15, 2014 6:25 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

I'm not a fan of printf in general for debugging, unless it's a small program - it probably suits your needs here. However, you may consider using an IDE like KDevelop which doesn't have nearly as steep a learning curve as GDB. I use mostly printf debugging, even for large projects. In my experienc...
by korona
Tue Jul 15, 2014 6:01 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

Just a quick thought: When debugging C/C++ programs I rarely use GDB at all. The best debugging tool is printf. GDB is nice for checking where a segfault happens or why some code is stuck in an infinite loop but I don't use it to inspect variables or look at the control flow. printf is faster for th...
by korona
Sat Jul 12, 2014 10:44 am UTC
Forum: Coding
Topic: Funniest/Most Annoying Code Comments
Replies: 662
Views: 137053

Re: Funniest/Most Annoying Code Comments

Honestly I find the nested version easier to read. If just are only a few lines have a high indention level (i.e. the whole loop fits on a screen) I don't think breaking that stuff into functions makes sense. The indention level can be reduced by 1 by using "if(num % div == 0) continue". C...
by korona
Tue Jul 08, 2014 10:24 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

And similarly, when a CPU reads 200GB from a disk to its 256GB RAM (yes, I've seen computers that beefy) to perform a database operation that a GPU can't do (one, because it doesn't have Disc I/O and two, because a GPU only has ~2GB of RAM), it isn't very "impressive" either. I was not ta...
by korona
Tue Jul 08, 2014 4:43 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

You posted pgstorm as an example of GPU accelaration. pgstorm runs a small part of SOME complex queries on the GPU. In addition to that PostgreSQL itself uses multiple CPU threads to process queries. That is simply an unfair comparison: It is parallel CPU vs. parallel CPU + GPU. Try PostgreSQL with...
by korona
Tue Jul 08, 2014 4:21 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

You posted pgstorm as an example of GPU accelaration. pgstorm runs a small part of SOME complex queries on the GPU. Look at their example: SELECT ... WHERE sqrt((x-25.6)^2 + (y-12.8)^2) < 15. That is a calculation that can be done with SIMD. Of course such a query is faster on the GPU. However such ...
by korona
Tue Jul 08, 2014 4:00 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

The are many parallel problems that CPUs are better at. GPUs make terrible web servers, database servers and so on. If you want a scientific problem that cannot be efficiently parallelized on the GPU but can be parallelized on the CPU look at the NP complete problems. There are many NP complete prob...
by korona
Fri Jul 04, 2014 10:31 am UTC
Forum: Computer Science
Topic: a little rng
Replies: 9
Views: 6403

Re: a little rng

Congratulations on your number generator. Whether or not it's (pseudo-)random remains to be proven. AFAIK there are no provably good pseudo-RNGs because that would allow you to construct a one-way function (at least if they match your second criterion and satisfy the next-bit test ). Calling rng() ...
by korona
Tue Jul 01, 2014 2:54 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

You don't make the heap a bunch of void*: the heap are blocks of data of some size. The API gives read access by returning a void* to an element, which client code (or maxro wrappers) casts to a T*. Look at how qsort works: there is a stride length between elements, and it supports data larger than...
by korona
Mon Jun 30, 2014 1:16 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

std::priority_queue usually (unless you specify a different container than std::vector as template argument) allocates all memory in a large chunk. That is both space efficient and cache friendly. To retrieve an item from the queue no unnecessary pointer dereferences have to be done. It is not possi...
by korona
Mon Jun 30, 2014 11:17 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

That only works if your data structure is allocated on the stack.

E.g. it is not possible to implement a global std::priority_queue<int64_t> this way if void* is 32-bit.
by korona
Sun Jun 29, 2014 4:40 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

A serious drawback of using a void* structure (even internally) is that you'll have to heap-allocate the items if they don't fit into a void*.
by korona
Sat Jun 28, 2014 10:10 am UTC
Forum: Mathematics
Topic: What would be the all around "best" base to use?
Replies: 52
Views: 13148

Re: What would be the all around "best" base to use?

cyanyoshi wrote:A simple modification to the standard decimal system is to have a -1 digit instead of the 9 digit. That gets rid of that pesky negative sign once and for all!

? How would you represent -2?
by korona
Sat Jun 28, 2014 9:46 am UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

C++ has some advantages over pure C code. In addition to what has already been posted: Classes and namespaces: This is mostly a syntactical improvement. Methods and vtables can be done in C but they just look ugly. See the GObjects library. Templates / Generic data structures: I've often seen sub op...
by korona
Wed Jun 25, 2014 12:05 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

Absolutely. The beauty of C++ is that it offers the ability of writing high level code while you're still able to tell how that code is actually executed on your processor. In addition to that C++ is arguably the most flexible (imperative, compiled) programming language.
by korona
Wed Jun 11, 2014 6:29 pm UTC
Forum: Coding
Topic: Object oriented programming is bullshit
Replies: 32
Views: 12013

Re: Object oriented programming is bullshit

You don't see any subclasses or convoluted hierarchies here. There is a single class: the Pokemon class. Every behavior of each pokemon is configurable. Type information and behavioral differences are held in arrays or members. You wouldn't subclass "Pokemon" into "Grass Type", ...
by korona
Fri May 23, 2014 12:05 pm UTC
Forum: Coding
Topic: Funniest/Most Annoying Code Comments
Replies: 662
Views: 137053

Re: Funniest/Most Annoying Code Comments

I understand your point but honestly for ( int i = 0; i < n; i++ ) do_stuff(); do_other_thing(); is very easy to spot. I prefer the for ( int i = 0; i < n; i++ ) do_stuff() syntax. Google's coding standards explicitly say that there is no preferred form so I guess I'm not the only one with this opin...
by korona
Fri May 23, 2014 10:11 am UTC
Forum: Coding
Topic: Funniest/Most Annoying Code Comments
Replies: 662
Views: 137053

Re: Funniest/Most Annoying Code Comments

Anyone who writes a loops like for ( int i = 0; i < n; i++ ) do_stuff(); deserves whatever bad things happen to them anyway. (and if they omit the indent, cull them from the gene pool) I don't see what is wrong with that code. Clearly the intention is to run an operation multiple times and do basic...
by korona
Sat May 10, 2014 12:50 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

Using a html <table> for things that are not tables is bad because <table> has a semantic meaning, e.g. it may be read in a different way by screen readers or styled in a different way if you're using a text-only browser. The CSS property "display: table" however has no semantic meaning an...
by korona
Mon May 05, 2014 9:02 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

I love my CS professor, but damn, she can be evil sometimes. This is a problem she gave us to test our knowledge of how scope works in Java. Figure out its output. Lets see: public class Parent { public int x = 0; // class variable public Parent(int x /* local variable. overrides class variable */)...
by korona
Thu May 01, 2014 10:23 pm UTC
Forum: Coding
Topic: Win32 API Topic (Raw Windows C++ ftw!)
Replies: 8
Views: 6164

Re: Win32 API Topic (Raw Windows C++ ftw!)

Basically, its the only way to implement the Open / Close principle in C. You gotta pass around opaque pointers (or integers into an array). When you interact with those pointers, you need to have pre-defined data types that is passed into a function into the pointer's structure. It is honestly a l...
by korona
Mon Apr 28, 2014 8:26 pm UTC
Forum: Coding
Topic: The "IT DOESN'T WORK!" thread
Replies: 1958
Views: 525182

Re: The "IT DOESN'T WORK!" thread

Java's reference behavior actually makes sense from the virtual machine's POV. You cannot have C++ like pointers and references in a managed language as they are inherently unsafe. If Java had C++ references each referenced local variable would have to be heap allocated.
by korona
Sat Apr 26, 2014 10:48 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

FT: When I see statements like "Haskell's monads are a concept borrowed from category theory" I always assume that the person who wrote that doesn't know more about category theory than the first two paragraphs of the Wikipedia page. Haskell's monads and category theoretic monads have tota...
by korona
Sat Apr 26, 2014 5:18 pm UTC
Forum: Computer Science
Topic: Why is a good Wifi password necessary?
Replies: 16
Views: 9125

Re: Why is a good Wifi password necessary?

If the attacker is able to abuse a security vulnerability in some program running on your computer it might be possible (depending on the severity of this vulnerability and the privileges the attacked process has) for him to get full access, e.g. administrator access to your computer, including but ...
by korona
Wed Apr 23, 2014 10:56 pm UTC
Forum: Coding
Topic: How many programming languages do you know?
Replies: 119
Views: 33325

Re: How many programming languages do you know?

I'm very proficient in C++, C, Java, JavaScript (and my own imperative and functional languages :D) I know most of the glitches and corner cases that exist in these languages and I'm able to write complex programs with only minimal use of reference manuals. I'm also very proficient in x86 assembly i...
by korona
Sun Mar 16, 2014 9:48 pm UTC
Forum: Coding
Topic: Suggest an open-source C/C++ IDE
Replies: 22
Views: 7379

Re: Suggest an open-source C/C++ IDE

Have you tried Eclipse?
by korona
Wed Mar 12, 2014 9:47 pm UTC
Forum: Mathematics
Topic: Circularity in Formal Languages?
Replies: 51
Views: 12975

Re: Circularity in Formal Languages?

You can treat them as plain symbols without any underlying meaning. Proofs can be done on a fully syntactical level. Examples of such proof systems are: http://en.wikipedia.org/wiki/Natural_deduction Here the inference rules behave like you expect from informal proofs. http://en.wikipedia.org/wiki/H...
by korona
Tue Mar 11, 2014 8:00 pm UTC
Forum: Coding
Topic: Coding: Fleeting Thoughts
Replies: 9890
Views: 1828950

Re: Coding: Fleeting Thoughts

First dumb suggestion: Don't produce 50000 strings per second? Second dumb suggestion: Write a class that allocates a big block of memory (say a few kilobytes) and have it allocate the strings in there. When the block is filled, create a new one. Once every string in a block has been consumed by th...

Go to advanced search