Dpt/ - Daily Programming Thread

Old thread: What are you working on, Jow Forums?

Attached: 1515756027790.png (1000x793, 638K)

Other urls found in this thread:

javascript.info/
twitter.com/SFWRedditImages

ur mum

first for rolling your own crypto

non-strict semantics suck

okay i decided to learn rust. this is probably the greatest thing slice bread desu. fuck c++

Will cucking myself to the Rust compiler make me a better programmer? Why or why not?

Trannies shouldn't be programming.
Find a new hobby, faggots.

I think you're just mad because your programming socks didn't fit.

both strict and lazy have problems, lookup cbpv

whats more performant in rust?
let foo: [u8; 64] = [1;64];
test(foo.clone());
fn test(x: [u8;64]) {}

or
let mut foo: [u8; 64] = [1;64];
foo = test(foo);

fn test(x: [u8;64]) -> [u8;64] { return x; }

Employed Haskell programmer reporting in

Attached: 1463364999713.jpg (268x237, 59K)

Those poor bees :(

>_> call by push value

Attached: 1481702619198.jpg (268x249, 33K)

underrated

your mom paying you to troubleshoot her Macbook doesn't count as "employed"

People usually recommend interactive IDEs to programming beginners, because they offer autocomplete and what not. I think that modern IDE features including
- autocomplete,
- real time syntax/semantic checks,
- and some advanced search features
are actually awful for learning any language; and it's popularity is a symptom of a society whose members are conditioning away their attention-span and memory capabilities.

Convince me otherwise.

JavaScript rocks!

Attached: js-rocks.png (1000x494, 368K)

>it's
QED

>Convince me otherwise.
ide's facilitate preservation of train-of-thought

No, I completely agree.

Revising C by using the online CS50 material.

70% of the programming community is LGBT
if you want a safe space dig your own grave and lie in it pussy bitch

>lisp was never usable to write anything real
>a group of non-corporate lisp programmers maintain a lisp compiler written in lisp that produces machine code competitive with the Java

Attached: 1541152486481.png (648x379, 32K)

Stop posting this retarded diagram

this, this problems stems from the moment we started to write. Books, notes, printing and whatnot are all by the joods to make us into lazy fucks without any focus or memory.

I can't really see the problem.
>autocomplete
Nobody is going to remember all of the stdlib or even all the built in functions of langs with lots of things integrated into them. In the absense of autocomplete, people would just be using the docs. The docs are still there for details about performance, guarantees, etc. But if you just want to know the order of the arguments to be passed to a function, why not just autocomplete?
>syntax checkers
Come on, chasing semicolons and pairing brackets isn't programming.
>search features
Something that you'd stil do with a CLI tool, but is now easier to reach for.

I bet you like Sokrates

What is the simplest way of making an aesthetic GUI in python? Using Tk atm and it's like being back in 1998.

Attached: citman.jpg (420x213, 64K)

This is so unbelievably false

Aesthetic GUIs are for fucking trannies
Tk is fine

>python
>gui
why not just use javascript?

Right.
These faggots keep spreading their propaganda, then as soon as some news comes out that they disagree with, they call it fake news.
Fucking hilarious.

70% is absolutely ridiculous.
It's more like 90%.

Wrong.

change the color and post back

this

or python-qt

>Implement a mechanism to handle interruption handling
>When a program is interrupted, an interruption routine is performed. Afterwards the program continues

>The only interruption we should care about is software interruption. Such an interruption shall be triggered by that the simulated machine perform its own interruption instruction.

>This interruption instruction shall get an integer argument which indicates its position(index) in an array of the interruption routines' start addresses.

>Ergo, you should implement:

>the instruction that performs the interruption and
>the array with the interruption routines' start addresses

>Remember to make sure that regular program running continues when the interruption routine is done

skirts and programming go hand in hand

Attached: 1519758973712.png (938x681, 1.06M)

you don't know how messed up her macbook is

anime never lies

Attached: 1534849544010.png (500x441, 284K)

we should also return to the good old days when you would run one program at a time in DOS

if you need more than one program at once, run more computers

I bet you don't even watch anime, go back to your shitty board or discord

only benchmarks can reveal what is more performant in any language

Actually not a bad idea, I am way more interested in the functionality anyway

It's like third on my list of languages I want to learn, not worth doing just for this

qt is the next option. we'll see.

If that's the case I wouldn't browse an anime website.

Attached: 1515030376802.png (327x300, 85K)

is Kivy still the hot new thing for python GUIs?

>tfw no qt male programmer gf to pair program with

I take back everything I ever said C is garbage

You're on the right track comparing it to the call instruction then.

It's asking you to implement a software interrupt (SWI), also known as a supervisor call (SVC). They're functions which are provided by your operating system but can be called by user programs.
On a real computer this must be a dedicated instruction because the processor automatically goes into a more privileged mode when a SWI is called. The computer then uses the SWI index to find and call the correct function from the SWI table. Those functions are also known as syscalls, and the syscall uses its extra privileges to do OS stuff like talk directly to the hardware. The SWI table is protected from the user mode so it doesn't abuse the SWI instruction to obtain OS privileges for itself

For your purposes I don't think you have to care about privilege or memory protection, that explanation is just to help you understand why this exists in real machines.
Just interpret the operation in the same way as a call, except instead of using the operand as an address or an offset you use the operand as an index into the SWI table and jump to the address stored at that index in the table instead.

how do I read N bits from a bit (text) stream in JAVA guys?

If you ever get to wanting to learn JS do not use anything other than javascript.info/ and when you're done with that site but want to get some more techincal details about the language features then look up Dr. Axel Rauschmayer's latest book and his older Exploring ES6 one, but keep in mind that ES6 is ~4 years old at this point and we are well into a stable ES2019 feature set.

use the api

...

I'm working on ordered/concurrent pattern matching and recursion, where sorting values/selecting events happens more or less automatically and the types don't let you put things out of order. This is done by using a type operator ◇ corresponding to "eventually" in temporal logic, and only allowing the programmer to pattern match one eventual value at once. If there are multiple branches that match against eventual values, the one that matches against whichever event comes first will be taken. In general, the underlying order doesn't have to be temporal, but any total order on values also works, which is how this can be used for sorted types and sorting algorithms.

For example, here's a sorted list data type and the standard "merge" operation that takes two sorted lists and outputs a sorted list. Of course, it works just as well if you interpret sorted lists as event streams.
data List : Ord -> Ord where
nil : List A
cons : A -> (List A) -> List A

merge : (List A) -> (List A) -> (List A)
merge nil ys := ys
merge (cons x xs) ys := cons x (merge xs ys)
merge xs nil := xs
merge xs (cons y ys) := cons y (merge xs ys)

Here's a more interesting example: a balanced heap data type.
data Heap : Ord -> Nat -> Ord where
leaf : Heap A 0
branch_eq : (Heap A n) -> A -> (Heap A n) -> Heap A (1 + 2 * n)
branch_gt : (Heap A (1 + n)) -> A -> (Heap A n) -> Heap A (2 + 2 * n)

insert : A -> (Heap A n) -> (Heap A (n + 1))
insert x leaf := branch_eq leaf x leaf
insert x (branch_eq l y r) := branch_gt (insert y l) x r
insert x (branch_eq l y r) := branch_gt (insert x l) y r
insert x (branch_gt l y r) := branch_eq l x (insert y r)
insert x (branch_gt l y r) := branch_eq l y (insert x r)

remove : Heap A (n + 1) -> (A * (Heap A n))
remove (branch_eq leaf x leaf) := (x, leaf)
remove (branch_eq l x r) := let (y, l) := remove l in (x, branch_gt r y l)
remove (branch_eq l x r) := let (y, r) := remove r in (x, branch_gt l y r)
remove (branch_gt l x leaf) := (x, l)
remove (branch_gt l x r) := let (y, l) := remove l in (x, branch_eq l y r)
remove (branch_gt l x r) := let (y, r) := remove r in (x, branch_eq r y l)

Here I use in the pattern matching as well to select the eventual value without destructuring the value itself.

you may or may not find the joinads paper interesting

>People usually recommend interactive IDEs to programming beginners, because they offer autocomplete and what not.
This is objectively false. They don't.

You don't need the clone in the first one. The "mut" in the second one doesn't do anything, either.

which one

>Actually not a bad idea, I am way more interested in the functionality anyway
Qt does have much more functionality than Tk.

>The "mut" in the second one doesn't do anything,
yes it does.. you cant reassign to an immutable variable.

> clone
sorry i probably should have used a string instead to better showcase. i mean for types that dont have implicit copying.

I always come to these threads when I want to read retarded shit and so far I've never been disappointed.

nice blog
*upvote*

Doing C, how do I reassign a Char*?

I declare it at the top with:

```char* type_result[11];```

I then want to fill the contents based on some result. Is it just:

```type_result = "STRING"; ```

You have an array of char*s, not a char*.

Right, I didn't see that you were reassigning there. You still don't need the clone, though.

>writing some scripts for adobe framemaker.
Just kill me now.

Attached: 1536505094886.jpg (1024x576, 94K)

please don't remind of that manga ever again.

What manga?

Attached: n.jpg (350x502, 54K)

hi friends
what's a "monad"?

it's like a wrapper function my dude

Hawt
It's just a monoid in the category of endofunctors, what's the problem?

ah ok, thanks!

A monoid in that category of endofunctors.

Attached: 81643.png (300x300, 109K)

so i have this text stream

text stream = abc

but i wanna read 16 bits aka, 2 bytes

so i read a and b

which are

97 and 98 in integers as per ascii

which are in binary

0110 0001 and 0110 0010

but i want to get the number that is begoten
when you "glue" the above binary numbers like so

0110000101100010
which is 16 bits or 2 bytes
which is the number 24930

how do i get 24930 from 97 and 98

what's a monoid?

preferably in java

OMG WHATS A MONOID

Just shift the latter byte?

a monoid is a triple (S, +, 0) where
S is some carrier set
+ is an associative binary operation on S
0 is an element of S that acts as an identity for +, i.e. forall x in S, x + 0 = x = 0 + x

myint = (stream_p++)*;
myint = myint

S : Set
_+_ : S x S -> S
0 : S

forall (x y z : S) . x + (y + z) = (x + y) + z
forall (x : S) . x + 0 = x
forall (x : S) . 0 + x = x

Dynamic and individual substances, which have no parts, which mirror the entire universe, and these mirrorings involve not only the present, but also past and virtual future states.

Alternating if you're using a basedlang
my_number = getcharatposition(i).ascii_to_int() * 16 + getcharatposition(i).ascii_to_int();

I am classifying something. I am classifying text into whether it belongs to newspaper T or B.

should be
char* type_result

what if i want it so that if I sum any two numbers I got, they will stay 16 bits?
aka, if the sum is actualy represented with 17 bits, I just drop the highest order bit?

wtf the

Yes it does. You even have a >> and >>> distinction which C is sorely lacking.

modulo

No, you're predicting whether it should be in A or B based on previous data. That's searching, not sorting/classification.

When working with SQL databases, let's say I have a big main structure with many nested many to many relationships, needing to pull from about 20 different tables to get the full main structure
What's the best way to do so? At the moment the orm I'm using (it's utter poopshit, don't use gorm) with eager loading will do simple select on each table which is fast enough for one at a time but when I try to pull big batches (50k+) it gets very slow
At the moment it just runs those big selects with where in (values) and then populates maps with the various pks as keys and builds the structs with it, I optimized it but the queries are now the bottleneck, would it be better to throw the orm in the trash and handwrite a better select with lots of joins?

>would it be better to throw the orm in the trash and handwrite a better select with lots of joins?

Yes, ORM begin for inserts, updates or trivial consults, but handwrite SQL for reports or analitics.

so basically you can't prove something doesn't halt because it never halts

Kinda. You can't prove that something halts because the thing that you use for proof never halts.

Are you able to just divide by the size of a data type in C without doing sizeof(int) for example?
Asking for a friend

Attached: anm25.gif (400x486, 161K)

yes imo. ive learnt a lot just from the compiler telling me what to do. avoided lots of mistakes i would have made if i was just using c++

>wants to use the size of a data type
>doesn't want to use sizeof
What did she mean by this?

You mean like x/4 instead of x/sizeof(int). If so then yeah I guess you could, but there's little to no benefit to doing since 1) you will lose comparability if the sizes change due to platform 2) you should be using stdint.h if the size really matters enough that you have a specific number to divide by 3) the size will be a compile time constant so getting rid of the sizeof doesn't benefit you 4) there's little to no readability gain.

LMDB vs RocksDB? which one should i use? im using rust so the only good key/value db's with rust wrappers are those two.

>come on, you know what I meant by "fixed program, fixed input."
Well, it has nothing to do with the halting problem so it's a critical distinction.


>What do you mean by "solvable?"
You can tell if a specific program halts or not.

>Because if you could, then you could solve the halting problem by searching the space of proofs (proofs are finite and can be checked in finite time).
No because we're not solving the halting problem.
A given program is a finite length thing, to tell if it halts or not you just create a big table of all instruction sequences of that length which would lead to infinite loops and then you just pattern match and see if any of those appear anywhere - if not, the program halts, if you find a match, it never halts.