/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Turing_machine
twitter.com/NSFWRedditVideo

first for TRAPS!

template raw asynchronous programming system?

this would be a better thread if SOME PEOPLE didn't try to program with

BIG

MEATY

JAVA

No one does though.

...

you know it!

game cheats (CS:GO)

Your computer is not a Turing machine, bra.

en.wikipedia.org/wiki/Turing_machine
>A Turing machine is an abstract machine[1] that manipulates symbols on a strip of tape according to a table of rules.
Note 'abstract'.
>The machine operates on an infinite[4] memory tape divided into discrete cells.
Note 'infinite'.

well, you don't need to have Thread with java, you just need to
implements Runnable

thank you for using an anime image

Demo part for c64... I got a techtech scroller running and need a second part... some text zoom with sprites maybe.

Could you actually give any examples on just how much of a performance gain did you get by switching to C++? What sort of program is it, and what parts had the biggest differences in speed?

200%

20% to 50% I'm not even joking desu
Compilers are shit

It gives you +10 performance.

>year 2017 of our lord Jesus Christ
>logic programming is useless outside of specific domains
>computers don't solve problems on themselves
>fifth generation computing project was a mistake

Logic programming is coming. Check out the Berkeley Orders of Magnitude stuff.

That's too vague.

What is your program doing? Is it a game? Processing strings? Audio/Video?

What exact parts actually benefited the most from the switch?

How to get a gf?

Prolog came and went.

when going from c++ to c you should get almost no improvement, but when going from c++/c to assembly you could get a small improvement, but I don't think thats worth the extra effort

Prolog is incredibly ugly. I'm not surprised it tanked.

sudo apt-get gf
or
sudo yum-install gf
should do the trick

From the fifth paragraph of the very article you posted:
>A programming language that is Turing complete is theoretically capable of expressing all tasks accomplishable by computers; nearly all programming languages are Turing complete if the limitations of finite memory are ignored.

Worth it?

>you could get a small improvement
you can get considerable improvement depending on specific task and platform

I didn't say anything about languages, derp.

Furthermore, with respect to your unrelated post:
>if the limitations of finite memory are ignored

You'd probably be better off with Skiena.

Is Clojure worth learning/experimenting with?

>he doesn't know

>JVM
It's garbage.

This is better. Learn to code, not to try to cheat interviews.

Better to use CL, Racket, or Scheme if you want to learn a Lisp.

What would you recommend as an alternative for a modern lisp that focuses on immutability?

Scheme or Racket.

I'm currently doing SICP and I was wondering if it's relatively easy to switch to CL later if I feel like it?

which algorithm is the most essential besides the obvious ones you can figure out for yourself

All of them.

hash map is the only relevant data structure

>Worth it?
No. Interviewers aren't looking for a perfect answer, they're looking for how you tackle problems you've not seen before, how you think, and whether trivial unexpected shit stops you in your tracks. You get exactly fuck all help with any of those from cramming a book.

int * p = new int[somenumber]


i have this array. i want to create a couple threads and then tell each thread to work on a range of elements of that array. for example, one thread is supposed to work on the first half of the array and the other thread is supposed to work on the second half of the array. i'm gonna give each thread the pointer to that array like so

void somefunc(){
threadclass thread_01(p, size_t start, size_t half);
threadclass thread_02(p, size_t half+1, size_t end);

thread_01.work();
thread_02.work();
}
//----------------------------------------------
class threadclass{
int* p;
size_t from;
size_t to;

threaclass(int* ptr, size_t f, size_t t){
p = ptr;
from = f;
to =t;
}

public void work(){
for(size_t i = from; i < to; ++i){
p[i] = i;
}
}

}


is this gonna work or will i have to add some sort of mutex to the work function?

go programmers pls go

>which algorithm is the most essential besides the obvious ones you can figure out for yourself
This depends on the company.

At the company I work for we have a lot of data processing, analyzing, etc... So we need algorithms that are associated with that.
Also we need to create or own algorithms, since the field we work in hasn't many companies (that publish their results / best practices / ...)

Anyways, learning to program isn't the same as learning how to write (good) algorithms.

Which field are you in, is it a corn field?

So.. Lets imagine you have 8 values for 1 sensor, 512 sensors per (lets call it) 'device', 4 of these devices and then you have one dataset per 0.0001s. You also have 12+hours of recorded data.
Please tell me, how a hash map can handle ANY data structure, especially the one I mentioned, please.

>Please tell me, how a hash map can handle ANY data structure
Easily.

You just need to set the hashing function and load factor appropriately and it will work.

Very funny. Cancer like you should leave this thread.

Daily reminder to use hashmaps for everything.

>8 values for 1 sensor
"Values"? Bits? Bytes? Words? Floats? Doubles? Something exotic?

rob pike pls go

Hamlets

8 values would be three bits worth, genius.

>Daily reminder to use hashmaps for everything.
Not everything. There's arrays too. Arrays are great for dense int->value maps.

No.

There is only hashmap.

>dense int->value maps
A lookup table is the correct term for that.

Daily reminder that mutable datatypes are deprecated.

It's not the 1970s any longer. You're going to have to get over it.

what if i want a fibonacci heap

>There is only hashmap.
You appear to believe it. That's even funnier.

Nevaaaaar.

There is only hashmap.

Making everything immutable was a temporary hack while the details of effect systems were being worked out. Now it's really not all that useful.

You think effect systems are anywhere near ready? They're not.

Sorry if this isn't the place to ask but what's highly customizable GUI with decent documentation that I can use for rendering text and images (mainly SVG)? Any language is fine and I'm on Windows 8

what if i want a sorted map

emacs

>never being able to rub that smooth bald head
why live

Okay, let me modify that statement a bit. Even if effect systems aren't ready YET, it still means mutation isn't deprecated.

This is a BLUE board!

Effect systems are meaningless because they aren't available in C. Using them entails learning a new language that cannot be used without learning new skills on top of already knowing how to program. Any language like that is dead in the water and will be totally forgotten in a year.

Okay well good luck using C without mutation.

i'm just gonna try i guess, wish me luck

There's no such thing as computation without mutation.

>go to interview
>user, what's the difference between linked-list and an array
>don't call us, we'll call you

Well, not on von Neumann computers anyway.

How can I make this python code even shorter?

from sys import argv
script, from_file, to_file = argv

indata = open(from_file).read(); open(to_file, 'w').write(indata)
print("Copied %s to %s" % (from_file, to_file))

>implying

You probably won't go through too much pain if you're already thinking in a Lispy style, but CL is a much larger language. Many functions in Scheme have slightly different names in CL. It's a Lisp-2 (Scheme by comparison is a Lisp-1, which means variables and functions share the same namespace). There are many other things, but you can discover those yourself. I'd say dive into CL after you read your book, as it's fairly battle-tested.

There is no such thing anywhere in reality. Computation is a process of change. A process of change cannot happen without change.

Is Norwegian useful for programming?

>make this python code even shorter
Why do you have an indata variable?
Why do you use multi-letter variable names?

All Norwegians learn English in school.

perl

It's only useful in Scandyland.

Does anyone have a Norwegian compiler that produces even half-decent x86 code?

Can it be made shorter than this?
from sys import argv
script, a, b = argv

open(a).read(); open(b, 'w').write(b)
print("Copied %s to %s" % (a, b))

Doesn't really matter, it's going to be bloated as fuck anyway.

script, a, b = __import__('sys').argv and \
open(a).read() and \
open(b, 'w').write(b) and \
print("Copied %s to %s" % (a, b))

It's part of an exercise. I had to make this into as few lines as possible.

Contrary to what others have said here, the book is not just a list of interview questions intended for rote memorization. The questions are supposed to be representative to give you practice answering such interview/whiteboard questions, but also gives generalized advice about how to tackle such problems. If working through it helps you get a better job or even just makes you more confident interviewing, I would think that's $20-30 well spent.

Maybe you should consider looking at that book too, sir.

>python 2

>Can it be made shorter than this?
You've changed the meaning.

oi /dpt/
i'm making a scraper in C# that keeps track of 2 craigslist-likes sites, and texts me if I a thinkpad pops up under 100$

that's kinda sexy right?

>C#
Nope.

from os.path import exists
script, from_file, to_file = __import__('sys').argv

print "Copying from %s to %s" % (from_file, to_file)

indata = open(from_file).read()

print "The input file is %d bytes long" % len(indata)

print "Does the output file exist? %r" % exists(to_file)
print "Ready, hit RETURN to continue, CTRL-c to abort."

raw_input()

open(to_file,"w").write(indata)

print "Allright, all done."

print((lambda _,f,t:(open(t,'w').write(open(f).read()),"Copied %s to %s"%(f,t))[1])(*__import__("sys").argv))

beautiful

>inb4 python

literally give me a language better for this. C# has sexy OOP to keep track of shit in non-hacky ways.

give me an anime image to relieve myself.
i need to relax after a hard programming session.

>>> from sys import argv
>>> a,b,c = argv
Traceback (most recent call last):
File "", line 1, in
ValueError: need more than 1 value to unpack