/dpt/ - Daily Programming Thread

Previously on /dpt/ What are you working on, Sup Forums?

Working on setting up a nice Linux environment to use OCaml to write my language.

Currently learning assembly. More specifically, practicing converting between the 3 number systems used so I can be faster at it.

>assembly
"assembly" doesn't exist

Thoughts?

How does your team do software dev?

i like to stimulate my prostate when i fap

Look they're all different dialects of assembly. You wouldn't call southern a different language, no, it's just another way of speaking english. It's still english.

You use your finger or a dildo?

A nice Linux environment isn't possible.

One of my opsec security mates suggested this book: Hacking The Art of Exploitation.

Is this actually a good book?

So I have a map file that looks like this:

111111111111
100000000111
101111110111
101000010111
101000010111
101000010111
101100110111
100000000111
100000000111
111111111111
111111111111


and I'm trying to load it into a 2D array in C like this:

char map_data[height][width];
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
c = fgetc(tile_map->file);
if (c == '\n') continue;
map_data[y][x] = c;
}
}


However it seems to be loading in the wrong data.

Help?

pic related is the output i recieve

The best programming language is OCaml

How do I convert an integer character to an actual integer in C?

For example, if I read a file and it contains '3', fgetc won't read 3 but will read the number that corresponds to the character 3, right? How I can I get the number 3 as an integer?

atoi
scan functions

>code tag abuse

Why does every programmer these days have the hipster glasses and goatee? What happened to the image of a programmer being a fat neckbearded basement dwelling autist?

Beard + thick-rimmed glasses + undercut = new programmer chic

What year again did that image begin happening?

Looks like the height and/or width are off. If you write a dummy character instead of leaving the garbage when you read a newline, you'll more easily see what's going on.

You also need to be careful of line endings - it may be more than just a newline.

can confirm, shaved my beard and switched to contacts to avoid association with fuckin nu-male programmers, brogrammer 4 lyfe

> implying the obvious

Since about 2012 or so. Maybe earlier.

First of all, in Windows there are two symbols for an end of the line: \r\n
Then, when you read in cycle and say "continue", you skip a cell.
Don't use fgetc.
Try something like this:
FILE *file;
char str[width+2];
fgets(buf, width+2, file);

fuck. I made a mistake
str = buf

Same here. Recently I stopped shaving because finally I can grown a proper beard. Worn it for like 3-4 months (after it grown) and now I'm clean shaving again from the very same reason.

Haha I didn't even know fgets existed. I thought you had to read files character by character.

Thanks!

Wrote a desktop visualizer for X last weekend. Just finished pulse support for it.

>high functioning autism

does c++ have premade tools like java does? do you just #include things like binary search trees etc etc etc or do you have to make them yourself?

yes

I'm back again. This is the last thing I need but I just can't figure it out. I want to make the progress bar show how many of the images are downloaded.

This is in a class called imageboard
int count = 0;
if(filename != "" && extension !=""){
QString link = "

Trying to learn Xlib/Xcb bullshit.
I have opted into no window events at all except WM_DELETE_WINDOW, yet I get a spurious "Event 64" from the window manager (event->response_type is 192) when I minimize the window.

Anyone know what the fuck this event is?

i was looking forward to making them myself

you can always implement it yourself for practice. No one is forcing you to include anything

I know that feel. I try and implement a lot myself outside platform abstractions like OpenGL.

how to initialize this 2D boolean array in C++ with size M * N?

bool **adjacency;

bump

you have a char x_char
int x_int = int(x_char - '0');

im a c++fag so idk if that's the right type conversion syntax, but that's essentially how u do it

>go to hackathon
>team up with some guy
>theme: file conversion
>set up a flask web server with bootstrap front-end
>allow user to upload photo
>get photo, use microsoft cognitive services API to get a photo description
>use some other API to segment description in small meaningful parts
>use bing API to image search meaningful parts and download one image for each
>put images together into a gif using imagemagick
>return gif to uesr
>user uploads photo and gets back a gif that describes the image
>extend it to text files (txt, docx, doc, pdf, etc) using zamzar conversion API
>win 1st place for hackathon
we just stitched together a bunch of APIs guys

bool **adjecency = new bool[M];
for(decltype(M) i = 0; i < M; ++i)
adjecency[i] = new bool[N];

whats decltype you're using there?

can't you just do:
bool **adjecency = new bool[M];
for(int i = 0; i < M; ++i)
adjecency[i] = new bool[N];

?

Opinions on OCaml? Is it fun? What kind of things is it good for?

I'm considering dual booting ubuntu to learn it better, windows support seems pretty shit for it.

I meant to learn it, in the first place. No previous exp.

OCaml has some very interesting features which make it useful:

1. It compiles to byte code and is fast. One can write embedded systems and OS in it.

2. Still it has higher level functional constructs and garbage collection, no need to worry about memory leaks.

3. Not sticking to pure functional programming makes it a bit easier (at least for me) as compared to Haskell. Also one doesnt have to worry about lazy evaluation like in Haskell .

4. F# is repackaging of OCaml by Microsoft on its .net platform. One can write apps for Windows platform for F# just like in C#. There seem to be lot of libraries around for F# unlike OCaml.

OCaml like C++, Nim and Rust is a systems language. Just that its functional first. The use cases of all these will be same.

Why you should learn it:
1. To learn Functional Programming.
2. To learn a fast high-level language.
3. for a Finance industry job, if one's company uses it.

You never specified what type M and N are so I used decltype to make it agnostic.

error: cannot convert ‘bool*’ to ‘bool**’ in initialization

it gives me this error

How my team does software dev:

Team consists of 4 people.
>me™, the Java/Android code monkey
>her™, the UI designer from Mexico
>him™, the project manager/iOS dev/brogrammer
>it™, the monolithic asshole CEO/boss

She sends a .psd to Him and he approves the design. I never have direct contact with her, because she is a woman and must be protected from monkey. He throws the .psd into my cage, and I extract the assets and start a nice day of Android Brogramming™. When I am finished, I push my code out of the cage and he looks at it. If it is good, I am awarded 2 bananas and one CrackRock™. If he is unsatisfied, he opens my cage and slaps me, leaving me vulnerable and crying on the ground. But I deserved it, I am just a monkey, I should have known better than to try to add unit tests to our codebase and waste valuable resources. Sometimes, when I am smoking a good monkey CrackRock™, it will come to the cage. No matter what I have done for the day, it will berate me and belittle my intelligence. However, it is the one that provides our company with bananas, allowing me and my other two treemates to keep living. When the day is over, I find the juiciest monkey bum and go nanners over my raging monkey cock. I wake up in a haze of cum and CrackRock™, and after getting myself together I begin another day at the zoo.

My job is bananas.

Doing some shit in python for a summer class.

>tfw done with hardest C++ CS classes and I'm just cruising through with fun classes now

Also, Python is cool as shit.

...

Woops the first new needs to be:
new bool*[M];

I just graduated and don't have a job yet
Where can I find some ideas for projects to work on in the mean time to keep my mind sharp and possibly pick up a few more programming languages for marketability

in your head you stupid monkey

>Also one doesnt have to worry about lazy evaluation like in Haskell
Nota bene, it has support for lazy evaluation in the stdlib, but it's not as nice as Haskell.

I'M NOT STUPID
RAAAAAAAAAAAAAAAAAAAAAAaaaaaaaaaaa... ._.

It's actually rust.

new bool [M][] you forgot to make it look cool

Shit libraries, have to use a 3rd party standard library to get anything done, there are 3 competing standard libraries, 1 is incomplete but works for web stuff, 1 is complete but massive and can't be used for web stuff, 1 is buggy and broken.
Programming support on windows leaves to be desired.
Type system isn't as powerful as I'd want, but the module system is fantastic.

Ocaml is as much of a systems language as haskell or go.

>Beyond the wind - Taishi Remix -
>Shibayan
>CYTOKINE
Fucking fantastic taste

Not programming, but setting up a Gogs/git server for internal use in our organisation.
It will also contain router configuration and several deploy scripts for virtual machines.

what's a nontrivial project i can work on thats doable as a rising junior in csci?

Guys is lama book actually good to learn perl?
anybody knows good tutorials?

>Not programming, but...

Not programming, but this is my next programming rig. I hate most laptop brands; even Lenovo is turning into shit. Might as well try something new, and also built for Linux with no driver conflicts.

>Ubuntu

What's that?

Also what's wrong with Lenovo? I've had my Thinkpad X201 for a few years and it's holding well

#pragma once
class point
{
public:
point();
~point();
};


what does this stuff mean? i googled about creating an object in c++ and it doesn't say. idk what pragma once is, or what point(); and ~point(); are

#pragma once

compiler specific pragma that tells the compiler not to include the file more than once

point();
constructor declaration

~point();
destructor declaration

Do you know anything about OOP?

pragma is like c style header guards.
#ifndef LONG_STUPID_LOOKING_HEADER_NAME
#define LONG_STUPID_LOOKING_HEADER_NAME

>Do you know anything about OOP?
no i don't, because it's bad and for codemonkeys like you

Yeh I can clearly see that after being overwhelmed by constructor.

System76 only sells their machines with Ubuntu on them, but it should be compatible with all modern Linux distributions. I plan on installing OpenSuSE Leap on it, since it's the distro that has always just worked for me.

It's a System76 Kudu. System76 is a company that specializes in Linux laptops. I knew I needed to get a new laptop because the keyboard on my Thinkpad T440p is now dead (half the keys, including the spacebar and enter key do not produce any response; I am now typing this using a cheap USB keyboard), and since I've been finding programming on Windows to become increasingly annoying, I figured I'd get a Linux machine. With System76, I get no driver conflicts guaranteed. I also considered ThinkPenguin, but what ultimately sold me on System76 was more or less that there were less options for higher end machines with ThinkPenguin, and also, that they don't support the new AC band on Wifi, whereas System76 does out of the box.

There's nothing wrong with OOP, or with Functional Programming, or with combining the two. What is bad is taking either to their logical extremes. In OOP, this might be creating overly complex patterns for simple problems, and in FP, this might be making unnecessary copying to avoid state changes.

pragma once is it, pragma is a non-standard compiler instruction and can do a variety of things.

Why would you need higher end machines? Can't you do your computations on a rented server/VPS if you need this type of resources? Surely with the advent of cloud computing there are more important criteria when considering a laptop, no?

Btw I don't mean to criticise your choice, I totally have a lot of things I find unpleasant with my Thinkpad, but just curious

How do people work with laptops without trackpoint? Losing my track point would definitely cut into my productivity quite a bit

ye that's what i meant, my bad for not stating once clearly. I was just refering to THE pragma in his code block.

I have a trackpad and it's enough to use my computer.

is there any version of java's this for c++? or do i have to name setter arguments something different than the object's variable?

1. I don't do and won't do "cloud computing". I refuse to depend on another person's computer to get my work done. Using the cloud for backups is okay, but my files should be located on machine as much as possible.

2. It's name is Android Studio and it is a resource whore like no other.

3. Also, virtual machines. Something I have an interest in is kernel development, and I would like QEMU or VirtualBox to not run like dogshit.

yes its called this.
but it's a pointer so u need to use this->

Learning Java, not much else. I know C/C++/Javascript to an extent so it's been easy to pick up so far, there's a lot more overlap than I was expecting.

How did you do kernel development on Windows?

length s - (maximum $ map length $ group s)

Learn Haskell.

You don't. You can try, but just don't.

what is, in your opinion, the advantage of learning Haskell?

i see you solve simple problems quickly.

i might consider learning it

>Haskell

{-# LANGUAGE TemplateHaskell, OverloadedStrings, OverloadedLists, GADTs #-}
{-# LANGUAGE MonadComprehensions, ParallelListComp, TransformListComp, RecursiveDo #-}
{-# LANGUAGE UnicodeSyntax, LambdaCase, MultiWayIf #-}
{-# LANGUAGE BangPatterns, ViewPatterns, PatternSynonyms, TupleSections #-}
{-# LANGUAGE RankNTypes, TypeFamilies, MultiParamTypeClasses, ExistentialQuantification #-}
{-# LANGUAGE DeriveFunctor, DeriveGeneric, DeriveFoldable, DeriveTraversable, DeriveTraversable #-}

It's sufficiently different to be (a) interesting and (b) mind-expanding.

I find myself thinking 'applicatively', if that's a word, and less imperatively these days.

ty, also how do i do what im trying to do here
string x("(" + x + ", " + y + ", " + z + ")");
correctly?

this was surprisingly accurate

std::string::size_type getmin(const std::string &str)
{
std::vector elems{};
elems.reserve(str.size());

foreach(const auto &ch: str)
elems.push_back(std::count(str.begin(), str.end(), ch);

return str.size() - std::max_element(elems);
}

Wonder if you could somehow do a simple list comprehension in C++.

I never got the TM thing? I know it means trademark and stuff, but what do people use it for in this kind of context?

kek

Good goyim.

Llama book? Yes. Camel book? Not unless you're already an experienced programmer.

I learned with the camel book, and was not an experienced programmer. It was painful. But at least the camel book is still useful when I need to figure out the odd areas of perl, whereas the llama book wouldn't be.

It adds a flavor of ironic coolness.

You have to be a supreme meme connoisseur to understand.

But like how does it relate to the initial meaning? I kind of get that it mocks the fact that big corporations feel the need to trademark everything, but not sure if this is all

you're right, he used the meme poorly

But i'm not saying that... I was just trying to understand not accuse them for misusing a meme lol

I actually took an old beige box desktop that's been collecting dust in the corner of my living room (it's basically from 2000 or 2001 or so), and installed Debian on it. I've done some basic boot level programming on it with i386 assembly and a floppy. That said, I'd like to work in architectures other than just 32-bit Intel, and QEMU doesn't always like to play nice on Windows... and even when it does, cross compilers don't play well on Windows at all.

Imagine you receive an android body by mail.

It has a 48 degrees of freedom (DOF) with 12 hrs of battery life (avg physical activity) with all necessary sensors (eye CMOS cameras, microphones, gyro/accel, tactile sensors, speech dynamic) and 10-core ARM CPU inside (there is a wifi as well, so offloading computation to the cloud is possible), and a microcontroller for precise motion control linked to main CPU.

You have a full access to software and firmware, you can use standard dev tools (compilers, runtimes) and OSes for main CPU and the microcontroller.

How would you program it?
What are the main technical problems in this project?
Which approaches/methods/algorithms would you use?
Which software would you use?