/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

gnu.org/software/lightning/
github.com/CyanogenMod/android_hardware_samsung_slsi-cm_exynos5420
twitter.com/NSFWRedditGif

I am currently working on my lisp. How easy would it be to make it use a jit library?

Thank you for not using a political image

Have you already got a non-JIT bytecode compiler up and running?

Thinking about messing with the rendering of a program to make it pulse the intensity of images ever 0.5 to 2.4 seconds in a predefined pattern.

Not yet, I just browse the syntax tree and execute it. I could however make a VM + bytecode compiler relatively easily.

asking from previous thread

Yeah, before you work on JIT you should translate your code from a tree of instructions into a vector of instructions

Why are you saying this anime character is Jewish and why is she/he/it holding a special ed textbook?

Basically like the difference between

return x + 3y

and

move x to R1
move y to R2
mult y with 3
move Result to R2
add Result with x
return Result

*mult R2 with 3

what does this code do?
def all_permz(elementz):
if len(elementz)

Asked a bit late in the last thread...

What would be the best language to write a graph database in? I was thinking it would work well with any OO language, but I dunno if there would be a perk to using a functional language.

Do you want performance or conciseness and composability?

in C, is there any advantage in doing


void test(const char *string);


instead of

void test(char *string);

?

are you just giving an hint to the compiler, telling you will not modify the string

Well likely composability and performance over conciseness. It's for a piece of software that multiple users will be using constantly and the database will be constantly changing as per the users' wishes.

Probably a good use case for R.

Unfortunately composability and performance isn't a choice

If it is not going to be modified at all, and if modifying the string will cause unwanted side effects, just play it safe and make it const. No reason to give yourself a chance to mess things up. If you end up needing to be able to modify the string, go back and change things up.

reduces likelihood that you will introduce unintended side effects.

Sounds like a good use for R, if you're specifically trying to implement a graph database. That's about as far as I can recommend without more context.

C++

Anyone can help me with some simple task, I can't get it to work..

1. Write a program that calculates prime numbers and numbers of Fibunacci on different threads.
a. The first thread starts searching for prime number from 1, until killing of the program and when a prime number is found the program must present the time for finding this number.
b. The second thread is calculating and printing numbers of Fibunacci from 1 until killing of the program. When a new number of Fibunacci is found the program prints this number and the time for calculating this number.
c. The time is shown in ms (milliseconds)
d. Think about strategies for not having overlapping messages from the console.
e. The program must work with large as possible numbers. When the number is too large to be held in type like unsigned long long the program stops the calculation of that kind of numbers and shows error message.

Example output:
Prime 1, 0.1 ms.
Fibunacci 1, 0.1 ms.
Prime 2, 0.1 ms.
Fibunacci 2, 0.1 ms.

Hasklelfags will defend this:
>you lose the ability to define hylomorphisms because the result of an anamorphism can't be turned into an input for a catamorphism

For more context, see:

the part I am not getting is the using lib to actually make it happen like the example output, otherwise the logic is ok

Code Academy for python.

I don't know if I'd write an entire app in R. But if there was any way for the database backend to be R and something more app-friendly (?) for the front end, I'd go with that. If you're really looking to write a good database system from scratch, definitely use R.

LPTHW
AKA Learn Python The Hard Way. The author is kind of a prick, but the book will teach you. It's also available online for free iirc.

Well you've given us the task, but none of the existing code you've written. We need more context if you need help solving something. If you're asking us to write from scratch...well I don't know if that'll happen.

the author is a prick AND his books are not good learning material

R has a C interface and there are a lot of gui front ends for it. I'd say it's completely possible to make the back end in R and use something more friendly for the front end.

I didn't do LPTHW, just skimmed through it. His Learn C the Hard Way was a decent intro to C though so I just assumed. I actually learned python first through the python starter tutorial in the docs and then codeacademy python. Just kind of assumed LPTHW was decent too. Oops.

That sounds pretty awesome. Going to double up my recommendation for R then for the guy originally asking the question.

>Fibunacci

I will look into it, thanks!

I want to learn Scala and/or OCaml but have no project ideas. What do you do in situations like these?

Learn Haskell instead

this should be all you need

void FibThread(pointer to mutex){
for(){
lock mutex
print number;
unlock mutex
}
}

void PrimeThread(pointer to mutex){
for(){
lock mutex
print number;
unlock mutex
}
}

create FibThread
create PrimeThread
WaitForMultipleObjects(2, handle to both threads, true, INFINITE);

Anyone knows how to check with Xcb if a window is already open?

I already know haskell.

Then why would you want to learn something as awful as Scala?

Friendly reminder to write code every day or you lose your powers!

git gud

>awful
I'd just like to say that is is probably not a good idea to rip on other programming languages. They all have their perks and disadvantages.

That is in fact not true

Try just doing some of Project Euler then. That's usually how I learn a programming language.

that's like saying
>people with down syndrome aren't "disabled"; they're "differently abled"

But go too hard on the code and you get burnt out. Seriously, don't get burnt out. It's really easy to do it with programming.

No, Scala is a perfectly fine programming language. You are using a very bad analogy for this particular situation. What you want to compare is an esoteric language to something like C++--now that is like calling a disabled person differently abled.

Enjoy getting flustered everytime someone likes something you don't though! Tata!

Just think of something random and then start making it. Anything that comes to mind and is a manageable medium or small project.

You could always go with making a simple interpreter / toy language or perhaps a chip8 emulator.

+1 For project euler. HackerRank can be pretty fun too. Just choose a problem, solve it in the language you're learning. It's great for that. The only thing I don't like about either of these is that they tend to not show you how a lanuage works in the big picture of things, but for syntax and structuring algorithms they're amazing. Try a combo of small problems, then just pick a project at random and do it once you get an idea.

>No, Scala is a perfectly
stopped reading here, because what you said was
>not a good idea to rip on other programming languages. They all have their perks and disadvantages.

Imagine there's a language that's exactly like C++ except "bool" is replaced with

"HowMuchWoodCouldAWoodChuckChuckIfAWoodChuckCouldChuckWood"

Antox is written in Scala if you want to contribute to open-source android project

>Cyanogenmod team forces exynos5420 device maintainers to use the exynos5422 hardware trees because they're newer
>They take the 5422 tree and rename everything to 5420
>The 5420 kernels are not compatible with 5422, this causes many bugs related to display, camera, memory allocation
>Maintainers request to merge back to official 5420 hardware trees which have worked fine for years
>Cyanogenmod team tells them to fuck off and decompile proprietary binaries so they can fix the bugs
>Device maintainers abandon official support for their devices
>Most 5420 devices are left abandoned and with bugs
Why is the CM team so autistic

wrong thread?

friendly reminder that you should spend 1% of your time writing code the other 99% thinking

sorry I didn't realize it's only programming if you're working with less than 200 lines of code

Imagine that there are people out there that get this militant about people using different programming languages than they do!

#define bool HowMuchWoodCouldAWoodChuckChuckIfAWoodChuckCouldChuckWood


Problem fixed.

gnu.org/software/lightning/

I don't get it, how can they force them?

what are you talking about?

> #include
What a shit language

>being this mad that not all languages are equal

sorry I didn't realize it's only programming if you're working with less than 200 lines of code

I have just finished learning Java up to the point of data structures and their implementations. Where do I go from here?

official devices (devices that appear in the cyanogenmod website) can only use 3 non-official repos (device (android configuration for the specific device), kernel, vendor (proprietary binaries)), every other repo has to be from the cyanogenmod github.

exynos5420 needs to import repos to support the SoC.. Cyanogenmod supported this SoC with the repo github.com/CyanogenMod/android_hardware_samsung_slsi-cm_exynos5420

They decided that the 5422 hardware code would work with the 5420 chip... So they changed it without asking the device maintainers

I was browsing the nethack source and I found the fact they were still usin archaic c function syntax interesting.

int
eat_brains(magr, mdef, visflag, dmg_p)
struct monst *magr, *mdef;
boolean visflag;
int *dmg_p;
{
...
}


Are there any other projects still in development that use this syntax? Are there any advantages to it?

Oh you don't like using a define? How about this then..

enum class Bool : unsigned char {
False = 0,
True = 1
};

enum {
False,
True
};

>#include

Sir, I think you might be differently abled.

Im working on an emulator for the Ti430 in C for a computer architecture class.

My ~/.emacs

>still usin archaic c function syntax
you know, it's possible that piece of code was written when that syntax was all the rage.

Time to learn a real programming language.

#define False 0
#define True 1

Yes I expected a shitty meme reply like this.

Why would you need both?

Just

#define False 0
..
if (False)
if (! False)

>#include

#define False 1
#define True 0

Well what sort of stuff are you looking to do?

git gud

Typed enum of char guarantees sizeof() == 1 by the c++ standard.

It's not a meme though. Learn Design Patterns and then have fun at your soulsucking corporate job for the next 30 years.

kill yourself

>people still unorinically pretending this isn't a language fault

A example of this:

enum class Bool_Typed : char {
False = 0,
True = 1
};

enum Bool_Untyped {
False,
True
};

int main()
{
Bool_Typed temp = Bool_Typed::True;
Bool_Untyped temp2 = Bool_Untyped::True;

std::cout

nice rebuttal

desu your comment didn't have much of a rebuttal either.

nice cum back

this, it was just a continuation of his shitty meme

#include
using namespace std;

class fuck {
public:
void outputs;
int number;
cout > number;
}
}

int main(){

myclass loldong;
loldong.fuck();
return 0;
}

why doesnt this work? can you not call cout's and cin's in a class before main and then call them in the main?

That's real C. The other one was something ANSI copied from C++ when they wanted to pretend C wasn't a systems language.

C today is C++--.

uhhhhhhhhhhh
c++ doesn't allow you to just have instructions floating in the middle of nowhere
put that shit inside a function

So i'm just practicing c++ and came upon "class templates" which are fucking weird to me.
Note that I've just started learning about classes and templates.

template
class MyTemplate {
T element;
public:
MyTemplate (T arg) {element=arg;}
T divideBy2 () {return element/2;}
};

// class template specialization:
template
class MyTemplate {
char element;
public:
MyTemplate (char arg) {element=arg;}
char printElement ()
{
return element;
}
};

Can someone explain what the fuck is going on here? Pretty please?

pretty sure you have a bracket too much

also change myclasss to fuck
you're mixing class name with methods.
loldong.fuck() doesn't do anything and is actually invalid

Main is where the code begins execution (Entry point). Any code outside of a function / class member will cause a compilation error, and will not be execute until called.

Something that would work looks like this

class fuck {
public:
void outputs()
{
cout

What are /dpt/ approved snacks?

What do you guys eat when you program?

let's say you had a class that dealt with ints
but then you wanted the same functionality, but dealing with chars instead
you might duplicate functionality inside your class, or duplicate the class itself like so
class MyIntClass{
public:
int a;
void print(){ cout

...