/dpt/ - Daily Programming Thread

What are you working on Jow Forums?
previously

Attached: *ports C99*.png (1107x1077, 531K)

Wow a new thread!

Yea amazing right?

Taking an intro to OS class and I need to implement my own fixed point arithmetic for priority scheduling, I'm a C pleb and general CS brainlet pls help

>tfw failed my first CS mid term

What the fuck nothing on the review and homework was on the exam! Time to switch to web development

Attached: sad bod.jpg (406x451, 27K)

neat
>pls help
well, what did you try already?

syllabus?

Cobol and Java do not compete in the same market, bro. Nice try though.

Julia GPU programming master race reporting in.

Attached: julia.jpg (2560x1920, 3.45M)

I'm completely stuck, they gave us function stubs to work with and basically said have at it, I conceptually get what needs to happen but C is so difficult to decipher to me. Literally just anything to point me in the right direction would be great

I'm re-learning Java and C++. What IDE should I use? Used to use Eclipse but I really hated it, the fact you couldn't compile outside of the very specific workplace configuration used to be me insane. Suggestions?

Attached: 1522083145257.png (900x900, 329K)

post stubs

Reminder that lazy evaluation exists at the CPU level and imperative programming is a poor fit for low level programming.

Python cannot beat Perl because Perl is already popular.

Daily reminder that the meltdown patch was all about stamping it out.

>back-compat dont real
SpaceBook cannay beat MyFace because MyFace is already poppler.

VS code and VS comunity

>EEE and VendorLockIn
ftfy

Don't listen to the microshill. For Java get Intellij, C++, get QtCreator

>C is so difficult to decipher to me
Then you lack the natural talent necessary to use a computer.

C is the most intuitive of all programming languages. It's pure computation expressed as text, putting abstract thought and raw hardware instructions in perfect harmony.
C is truth itself. How can truth be difficult to understand? Clearly, the problem is with you.

Is that meaningfully different from VS? The last time I downloaded VS it took like 30 gigs was unresponsive and never worked demanding constant updates that bloated it even further. I'm loath to try again...

don't believe 's meems
and be prepared for similar autismo-tardation in gee threads if you stick around

hm

Future Proof Code is Written in C

Meltdown is a bug, not a design flaw. Hence why it doesn't affect every CPU with out of order or speculative execution.

Sepples webdev :^)

Attached: Screen Shot 2018-03-28 at 9.37.23 PM edited.png (2880x1704, 1.36M)

c is weak type trash, rust is the future old man

CPU caching is just fancy memoization.

Currently working on a lexer. I have no idea what I'm doing nor am I sure what I'm actually writing a lexer. I'm sick of writing pajeet tier reader macros so I'm writing something that takes my own make believe psedu BNF grammar. At the end of this hopefully my reader macros will not be pajeet and only the underlying lexer.

Here's my current grammar for a string:
`((char #f (#\a #\b #\c #\d #\e #\f #\g #\h #\i #\j #\k #\l #\m
#\n #\o #\p #\q #\r #\s #\t #\u #\v #\w #\x #\y #\z
#\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\0 #\- #\=
#\! #\@ #\# #\$ #\% #\^ #\& #\* #\( #\) #\_ #\+
#\[ #\] #\; #\' #\, #\. #\/
#\{ #\} #\| #\: #\< #\> #\?
#\space #\tab #\newline))
(any #f (char #\\ #\"))
(escaped #t #(#\\ any))
(string-meat #f (char escaped))
(string #t #(#\" * string-meat #\")))

How are you doing that struct initialisation?

When I do it, I can't do the .struct_member = 1 syntax because C++ doesn't that recent C language feature.

What version of C++ are you using?

>webdev in C++

what's the point? are you masochist?
kek

Attached: ss.png (746x794, 100K)

I'm trying to record some data from a Unity project with a C# script and I want to serialize it with a timestamp. However, I get throwing DirectoryNotFound errors. It works as long as I don't try to do add anything dynamic like the timestamp. Any idea what the fuck is going on?

public class DataCollector : MonoBehaviour {
...
static string path;
static DateTime ts;
...

void Start () {
rb = player.GetComponent ();
ts = DateTime.Now;
path = String.Copy("Assets/Resources/test" + ts.ToString("yyyyMMddHHmmsszzz") + ".csv");
sw = new StreamWriter (path);
...
}

Does it handle Chinese characters?

Well it handles them the same way it handles a missing ". Returns Nothing.

what the fuck

Apparently it's supposed to be available in C++20, but Clang supports it for all C++ versions (with a warning about C99 if -Wpedantic is on). I don't know if GCC supports it, I don't have it installed.

>what's the point?
To showcase modern C++ as a web-ready langauge (aka it soothes my autism)
>that pic
man what ugly formatting and colors, who the fuck would do that :^)

>fails on caps

Why are you not just using ascii codes and comparing bulk ranges?

I tried it in MSVC with C++14 and it politely told me to fuck off :(

>be an absolute beginner and brainlet
>bang out a solution to some chapter two exercise that's basically cash register software
>works perfectly fine with some amounts, shits the bed with change for nickels and pennies with other amounts
>this is due to actual fucking limitations of computers
What did I get myself into?

Attached: im done.jpg (300x360, 56K)

>expecting full c++ support on visual studio this century

memes aside vs2017 has pretty decent support for almost all language features (fuck having to even say that). If you don't hate yourself though just go get a windows compiled version of clang and use that to compile instead.

Part of why it looks weird is that I've been fucking around with making things static and nonstatic, and private in an attempt to see if that's causing the issue; none of that has had any effect.

>using floats to store currency values
I hope you don't seriously do this

I'll keep this in mind, I intend to split a good portion of this code off into a reusable framework. As far as I'm concerned you shouldn't be running a production environment off anything but a Linux box (preferably CentOS) but that doesn't necessarily help people learn.

To be fair this is a C++20 feature, and iirc the C++20 feature set isn't finalized yet so there shouldn't be an expectation that compilers support it.

Funnily enought I'm using vs2017 because of the built-in cmake 3.9 support

FINE
(define (ascii-seq char n)
(map integer->char (iota n (char->integer char))))
`(alphanumeric #f (,@(ascii-seq #\A 26) ,@(ascii-seq #\a 26) ,@(ascii-seq #\0 10)))

Trying to solve project euler problems in asm.

B-but. the cents!

Plugging my question about something related to compilers:

Anybody knows the name of the topic(s) I should look into?

You using floats or doubles for currencies?
Computer math 101: real numbers don't real

store it as an integer, multiple and divide by 100 to convert to and from stored to actual value. Or store it as a string and parse the strong.

I have no idea, but that looks like Prolog maths without any syntactic sugar

What you have there is just infix notation. No different from (+ (+ (/ (* 8 y) (- 4 z)) 8)

if(x==1) {
x++; y++;
} else
++z;

might be represented as
(if (== x 1) (block (post++ x) (post++ y)) (pre++ z))

Anyway the magical word you're looking for is abstract syntax tree.

Chip 8 Emulator

Right now, I'm less focused on implementing the operation codes, and more on making sure I can render all the text/graphics correctly using SDL .

Anyone know why I'm getting "pixel hiccups" in the webm attached? (apologies in advance for shitting up the bitrate. I'm new to compressing videos to the 4MB limit). Like, why are a bunch of letters flashing ?
I have a "gfxToWindow" method to get an array and draw it to the screen, and I have a "WindowClear()" method that draws the bg.

Below is the code for both of them, and they're the only places where I change the renderer:
chip8::gfx_To_Window()
{
for(int row = 0; row < HEIGHT; row++)
{
for(int col = 0; col < WIDTH; col++)
{
if(gfx[col + row*WIDTH]) //current pixel is ON
//I call SDL_RenderDrawPoint on a bunch of points in this fn'
pxl_To_Window(col * SCALE , row*SCALE, SCALE);
}
----------------
void
Window::clear()
{
SDL_RenderPresent(_renderer);
SDL_SetRenderDrawColor(_renderer, 0, 0, 200, 255);
SDL_RenderClear(_renderer);
}


What am I doing wrong?

Attached: out3.webm (1280x1100, 424K)

>$1.01*$1.01 = $102.01

I mean for addition/subtraction it works fine but it fails miserably on multiplication granted you just have to eugh calc the amount of numbers you're multiplying by and then do num_mults*decimal_constant

Branch & jump instructions.

No double buffering?

I'm having a really weird ass issue with C and SDL2 right now (also using Codeblocks and Windows 8.1).

So when I go to draw my level (tile based), it'll go through and draw any tile that could appear on screen. For some reason now, it won't draw the very first tile.

Here's the weirder thing though. If I make a random draw call before my for loop, then the first tile within the for loop will draw.

What I have learned from this is the first call to draw the tile doesn't do anything even though it says it does. I've even ran it through the debugger and I can't figure it out.

What can I do to fix this?

(101 / 100) + (101 / 100)
2.02

My car won't start, but when I push it down the hill it'll kinda roll, you know?

Float in Python

Maybe?

How do I check if I'm double-buffering and how do I prevent it?

Sounds like you've fixed it. I've had to a similar thing for ncurses. In my init code there is a ungetch(1); getch():

/dpt/ how do I into building a desktop app that reads data from a .xls spreadsheet and spits out pretty graphics? javascript?
something like pic related

Attached: paymetric_dashboard3.jpg (800x600, 103K)

>for addition it works fine
>for multiplication it fucks up under immediate assumptions

that is what I wrote but paraphrased. Also you're wasting cycles.

(101+101)/100 is the same effect.
(101 * 101)/100 -> wrong answer of 102.01
instead you've got to do ..
((101 * 101)/100)/100 -> 1.0201 truncated to 1.02.

wpf

That's not an ideal fix though, this is something i'd like to fix.

a neural network library in C with Vulcan support.

right, I meant to do multiplication but had a brainfart

In your words, what do you call these things:

class {
private:
int year;
char *name;
...
}


I've never thought about what these variables should be called, and would just refer to them as maybe "local variables" or "class variables".
I damned near failed an exam about JS when they asked me to "iterate over the properties" because I didn't know what the fuck a "property" meant.

double buffer isn't something you can easily accidentally do. all that's different is you have 2 buffers for filling data for rendering. On one frame you're rendering from the [0] element on the next frame you're rendering on the [1] element. Meanwhile on the cpu/host side you're updating the opposite buffers (at least hopefully) It's done to reduce pipeline stalls. Most people do triple buffering now so there's additional head room incase either gpu or cpu is a bit slow and helps smooth our stalling.

>it fails miserably on multiplication
You can multiply two 32-bit integers into a 64-bit integer with no loss of precision cheaply on x86 at least. Software can do it for any precision.

class members/member variables

>with Vulcan support
I'd rather use even opengl compute shaders. But I'm pretty sure openmp has gpu acceleration.

an anonymous namespace is one that has no name and is only valid for the current translation unit in c/c++ so in that same vein I'd say anonymous class. If the members were public and there were no constructors I'd call it an anonymous pod(plain old data).

how does wpf compare with a js library like pic related?

Attached: chartjs-tutsplus.jpg (400x277, 8K)

This. Similarly function in a class/struct are called member functions. "Methods" is gross Javaspeak.

Fields.

I'm a burger flipper who has been working on video games with a friend, I do all the programming and I refrain from using any libraries that do more then SDL
any chance that I can get a job in software or anything tech related or should I just kms because I hate flipping burgers

>methods is gross javaspeak
You mean every programming language except for C++ speak. Dumb seppleslet.

>methods
>class functions
>member functions
errr

I mean they're functions.... that are a member of a class really just a function pointer that requires and implicitly provides *this to the call stack what else are you supposed to call it?

>methods are function pointers

Attached: 1521912231368.jpg (638x558, 63K)

whatever you choose, it'll need to be heavily sugar coated to look like that.

JavaFX is by far the easiest with FXML and CSS.

WPF and XAML can be as good but it's a nightmare to learn

QML

Most functions in C/C++ are memory addresses that are passed to the platform's equivalent of a CALL instruction. Sometimes those addresses are known at linking, sometimes only at runtime.

a method. c++ calls methods member functions because the committee thinks its fancy or something and want to be different.

>conflating a language with its compiled form
There's nothing to stop you from interpreting C. It didn't stop Terry.

interpreting is just a run time compiling of the language. you still have some intermediary between the actual executed ops on the cpu. Any target is valid. and at some level its going to be a branch call on whatever architecture you're using. Typically that's going to be stored in the elf data or dll or exe or whatever the fuck your compile target is and it'll be loaded in to memory for the cpu to execute. Yes you can put other steps in between the end result but it boils down to the same thing.

So yes; methods (member functions) are just glorified function pointers. if it's non virtual it can be known at compile time and inserted directly at the call site otherwise its going to be a vtable look up.

>>conflating a language with its compiled form
void func(){}
??? f = func;
so what's the type of f?

alright thanks

literally who

What does this have to do with methods, exactly?

void func(){}
using func_type f = decltype(func);
//func_type -> void(&)()

By this logic, labels (for goto) are just glorified function pointers.

They literally are.

Do I have to mention that you have to set up the registers...? I mean what the fuck do you want, yes there's more compiler book keeping than whats mentioned but its not like its wrong either.

>>but goto is just another branch which means its just like a function
If you do the book keeping sure.

Are methods still function pointers if you "execute" code on paper?

What paradigm is a good fit for low level programming?

no. because its not code.
>>but paper is code hurr
no an execution of operations is code.
>oh so assembly machines are code then
kys

So are jumps that are part of conditions or loops function pointers? You have to set up registers for the next iteration or correct branch.

Incoherent post.

No they're not the same; they both include jumps, but calls also require stack management. In fact on many architectures there's a separate assembly instructions for "call" & "return" vs. "jump" that automates the stack pushing & popping.

What if the method is inlined? Clearly it ceases to be a method because there is no call stack management and it is not a function pointer.

How long do you have to be a developer before you stop feeling like and being a brainlet?