Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.
89

I guess people often claim that C is faster than C++ because it's easier to reason about performance in C. C++ is not inherently slower or faster, but certain C++ code might obscure hidden performance penalties. For example, there can be copies and implicit conversions which are not immediately visible when looking at some piece of C++ code. Let's take the ...


86

2D / 1D - mapping is pretty simple. Given x and y, and 2D array sizes width (for x-direction) and height (for y-direction), you can calculate the according index i in 1D space (zero-based) by i = x + width*y; and the reverse operation is x = i % width; // % is the "modulo operator", the remainder of i / width; y = i / width; // where "/" is an ...


34

update: See bottom of reply This answer comes a bit too late, but I hope to shine light to others (particularly now that C++ standard committee wants to incorporate Cairo into std): The reason nobody really cares about "accelerated vector graphics" is because of how GPUs work. GPUs work using massive parallelization and SIMD capabilities to colour each ...


30

Code written in C++ can be faster than in C, for certain types of tasks. If you prefer C++, use C++. Any performance issues are going to be insignificant compared to algorithmic decisions of your software.


25

I don't think it is really true that nobody really cares about "accelerated vector graphics" as written in this answer. Nvidia seems to care a fair bit. Besides Kilgard who is the lead technical guy on NV_path_rendering (henceforth NVpr to save my fingers), the Khronos president, Neil Trevett, who is also a VP at Nvidia, has promoted NVpr as much as he ...


24

I personally do not think you have to be good artistically to create pleasing user interfaces. What makes a good UI is not up to creativity, but is more related to a couple of well-established guidelines. If you follow these guidelines and practice some you can create great interfaces yourself. I would suggest doing the following... Read about what ...


23

One of the design principles of C++ is that you don't pay for features you don't use. So, if you write code in C++ and avoid features that don't exist in C, then the resulting compiled code should be equivalent in performance (though you would have to measure this). There is negligible cost to using classes, for example, compared to structs and a bunch of ...


15

In my company, there are a few people specialized in this job. They are designers. And they know HTML. They can be a bridge between the designers and the front-end engineers; which they usually are. This way, we just have to integrate their HTML. This is a hard job. There's a reason sites like "PSD to HTML in 24h" work well. The solution in our company is ...


14

One reason that higher level languages are sometimes slower is that they can hide behind the scenes a lot more memory management than lower level languages. Any language (or library, API, etc) that abstracts away low level detail can potentially be hiding costly operations. For example, in some languages simply trimming trailing whitespace from a string ...


12

My art ability is about 5th grade on a good day:). I employ a graphic designer, either professionally when at work, or my wife, who has excellent art skills and loves using them. Note that in my mind Graphics design is not UI/UX design. I either do a majority of UX, or employ a UX expert to retain control of UX, who then works with the GD to make it look ...


11

X is practically the most low-level graphics API a Linux application will likely use on a modern Linux Desktop. Most applications won't even bother going that deep and will instead use a GUI toolkit implementation like GTK or Qt. Below that there's only the hardware drivers and probably some X-internal APIs for the drivers. But those are not meant or ...


11

graphics.h isn't relevant to anything. It's been 10-15 years since that header was useful. The same for the Turbo C compiler. You need to upgrade your compiler to, let's say, Visual Studio 2010 Express (free) for Windows. Then you can look at things like Direct2D and GDI+ for 2D graphics.


11

In the past, I have found that using a spreadsheet application such as Excel to generate test data has been very useful for testing mathematical code. Writing the same mathematical model twice using two different tools (a programming language and a spreadsheet) helps you spot any mistakes, and ensures that the test data you generate is independent from ...


10

Back in the graphics.h days each compiler had it's own limited graphics library. Now you program to either DirectX (Microsoft) or OpenGL (everywhere). After a few years of being sidelined to high-end Unix cad OpenGL/OpenGLEs is making a big splash on mobile devices For a list of books see https://stackoverflow.com/questions/5926357/c-opengl-books One ...


10

There are a couple of things you could try: Try to find some example values that are "obviously correct" (in the sense that any future maintenance programmer can easily see that and why they are correct, and verify their correctness in their heads without using a calculator) Look up the paper your algorithm comes from and see whether they have examples ...


10

OpenGL only has functions to work with a graphics context, nothing else. You need at least a platform integration library to get such a context. But in reality you of course need more functionality, such as input handling. GLFW, GLUT and SDL2 are just different ways of getting such additional functionality. SDL2 is nice because it also includes audio and ...


9

If you’re looking for graphical assets there are a few websites which collect high-quality graphics for free use: Bootstrap for arguably the best (but definitely the hottest right now) UI web framework Glyphicons for an icon set that complements Twitter’s Bootstrap UI framework Subtle Patterns for, well, subtle background patterns FamFamFam’s Silk icons ...


8

Since it is open source have you considered using a free, existing site like Github rather than building a new website? As for a logo, you could try: Farming the job out and perhaps offering $25, someone in the world might well be willing to do it for that price. As part of your Githup homepage ask for help designing a logo. Run a contest and announce it ...


8

You can hire specialists for this sort of thing, but you don't need innate artistic ability to learn some basic techniques. My undergrad degree actually required a semester of "art for engineers." Taking a class or two at your local community college could be very beneficial. You still won't be as good as people specially trained in the field, but you can ...


8

The opencv image processing library does it by saving the image and comparing it to a reference image - it has a bunch of c++ test functions and macros to handle approximate image matching etc.


8

In cases like these, where the unit test would essentially be duplicating the function, I've often wondered if I should be writing unit tests at all. What I've come to conclude is that sometimes yes, it is valuable. In most cases I wouldn't bother with such a test, but for any critical part of a system I would because, although the test itself doesn't seem ...


8

You either pick a language that allows the syntax you want, or write it out longhand and accept that it "look[s] horrible". For vector arithmetic, there are at least 3 different operations that are reasonably denoted by * (or times or product), and you'd have to have a language that takes return types into account to disambiguate all of them. It's then not ...


7

If you want to get input events without using X then you will have to read them out of device nodes. Linux has a generic input subsystem called evdev that most drivers take advantage of. So to read input events, you can read from any of the device nodes in /dev/input. An easy trick to find the mouse device node is to run "cat" on the device nodes one at ...


7

A very basic and completely untested pseudo-code for drawing an ellipse using a parametric polar equation is below: Function draw_ellipse(int X1, int Y1, int X2, int Y2) RX = (X2 - X1) / 2 RY = (Y2 - Y1) / 2 CX = (X2 + X1) / 2 CY = (Y2 + Y1) / 2 for Angle = 0 to 360 X = CX + cos(Angle) * RX Y = CY + sin(Angle) * ...


7

While I think the upsides you provided can be true, there is one particular upside for matrices that I think matters a lot: almost all transforms that one wants to do in graphics - scaling, rotation, translation, etc. - can be represented as matrix multiplication. It's nice to have a common format - an interface, if you will. Additionally, compositions of ...


6

Graphics typycally require some knowledge about platform specific interfaces, some general math, and eventually some typical pattern. You can start from the Widows GDI (and GDI+) and from the X Window system (for Unix/Linux) and move to 3d with openGL(every platform) or Direct3d(on Windows)


6

I'm not sure there is a "right way", but a reasonably effective way of cooperating with a designer is to first build an unstyled system that uses templates and allows for the easy interchange of all templates. Then, once you have a functional-but-unstyled (or minimally styled) interface, you hand the results over to the designer for styling. A decent ...


6

My question is, how does a program tell a graphics card to process something instead of the CPU? The short answer is that every graphics card must come with a driver implementing a standard graphics API such as OpenGL or DirectX, so that the code running on the CPU can call standard functions from that API. When writing your code, this is largely ...


6

There're several good reasons for representing transforms as matrices: Vectors are used a lot in 3D graphics; Matrices are efficient data structures to store multiple vectors; The modern graphics pipeline is shader-based and requires the client application to send data quickly (e.g. buffers); The client can use a single function call to send the transform ...


6

OpenGL didn't 'embrace' global state so much as it was one of few sensible solutions to a technical problem. It's expensive to communicate with a video card. Flipping bits in video memory is considerably more expensive than flipping bits in ordinary memory. As an example it's so significant that later versions of OpenGL got rid of immediate mode, because ...


Only top voted, non community-wiki answers of a minimum length are eligible