[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 325
Thread images: 25

File: 1489862824177.jpg (130KB, 1280x720px) Image search: [Google]
1489862824177.jpg
130KB, 1280x720px
What are you working on, /g/?

Old thread: >>59475371
>>
first for fuck Sweden
>>
>>59482218
Karen can't read tho
>>
Idris is a language you can depend on.
>>
File: 1484892475893.png (54KB, 800x473px) Image search: [Google]
1484892475893.png
54KB, 800x473px
I'm absolute shit at programming and have no idea what I'm doing, but somehow I managed to get a glut window running in PHP.

It gives me some callback error if I add any more code though.

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$g_rotation = 0;
$g_rotation_speed = 0.2;
function display() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();

}

glutInit($argc,$argv);
glutInitWindowSize(500,400);
glutInitWindowPosition(300,100);
glutCreateWindow('basic test');
echo glGetString(GL_VENDOR), PHP_EOL;
echo glGetString(GL_RENDERER), PHP_EOL;
glClearColor(1, 0, .2, 1);
glutDisplayFunc(display);
while(true){
glutMainLoop();
}
?>
>>
>>59482270
>PHP
Why?
>>
>>59482218
What useful flags do you use with clang?

right now, i'm using

clang -Wall -Wno-unused-function *.c
>>
>>59482270
>graphics programming in PHP
>>
What's the best job if you just want to write scripts?
>>
>>59482270
>PHP as a first language
Don't
You even don't use the way it was intended.
>>
>>59482305
-Weverything
>>
>>59482312
Sysadmin
>>
>>59482324
lol ok

you don't need half of 'em
>>
>>59482218
Cute image
>>
File: 1472351309836.png (89KB, 391x499px) Image search: [Google]
1472351309836.png
89KB, 391x499px
>>59482300
Someone put up a post in the last thread implying you can't program games in PHP. I wanted to try.
>>59482319
>>59482307
I know PHP is a shit language used for web backend but I seem to be too retarded to understand anything else.
>>
>>59482331
And what's the best job if you just want to write scripts that call other scripts?
>>
i'm unironically starting to use a lot of C++ features and i love it

but i'm not sold on static_cast, reinterpret_cast etc. what's the rationale for using them? are you never supposed to use C-style casts like (int) foo?
>>
Can somebody teach me how to sort items in an ascending order?
I've been looking into algorithms, but I would like to hear your opinions.
>>
>>59482312
System administrator
>>
>>59482218
I just want to get behind her and put her whole foot in my mouth
>>
>>59482370
> i'm unironically starting to use a lot of C++
I sersrly hope you extern C your api nigger.
Also fuck you for using sepples.
>>
>>59482367
AI/bigdatafag
>>
>>59482367
web dev
>>
>>59482384
easiest way to implement: loop through all items, check if current + 1 > current, if yes swap them.
repeat until everything is sorted.
>>
>>59482358
> but I seem to be too retarded to understand anything else.
Currently you can understand every Algol-descendant language after a quick introduction.
>>
>>59482384
Use bogo sorting.
>>
What is:
'Dynamic array, implemented with a ring buffer (use a statically sized array underneath the hood)'

I thought a dynamic array was a data structure separate from a ring buffer array?
>>
>>59482384

here are two useful links.

https://www.toptal.com/developers/sorting-algorithms

https://www.youtube.com/watch?v=kPRA0W1kECg
>>
>>59482384
after 50+ years of programming arent there ready built in functions that do this for you?
>>
File: 1476325919564.png (593KB, 940x647px) Image search: [Google]
1476325919564.png
593KB, 940x647px
>>59482436
nah I can't.
I tried but /g/ is shoving so many languages down my throat that I can't remember a single one.
So this time I'm trying to do the one which everyone hates.
I'll probably end up like "always do the opposite of what /g/ says"
>>
>>59482370
>what's the rationale for using them?
it has to do with type safety. C-like casts do not perform any type of check on the casted object nor the casting type, so type confusions bugs may happen.
>>
>>59482370
I dont know how much you know about static_cast, but you get compile-time error if you cast to incompatible type; in which case you would normally get runtime problem. But it's more to write so i personally dont use it.
>>
File: trollface.jpg (42KB, 640x640px) Image search: [Google]
trollface.jpg
42KB, 640x640px
>>59482403
const int a = 10;
int *b = const_cast<int*>(&a); // works fine
>>
>>59482370
>what's the rationale for using them?
Like >>59482473 said, it's about type safety.
>>
How does one hack the Gibson?
>>
File: 1484489390405.jpg (76KB, 1024x576px) Image search: [Google]
1484489390405.jpg
76KB, 1024x576px
>>59482489
This shit triggers me.
>>
File: imgonnafuckyourshitup.jpg (11KB, 343x345px) Image search: [Google]
imgonnafuckyourshitup.jpg
11KB, 343x345px
>>59482489
>const but not really, lol

C++ was a mistake.
>>
>>59482218
THE TRASH LANGUAGE
-a stack represents the garbage bin
-data is thrown into the trash, which is analogous to pushing to the stack
-when the trash is taken out, the entire stack is popped and pushed to the outside garbage can
-at regular intervals of time, the trash gets picked up by the garbagemen
-each element of the stack is then popped and processed at the processing plant
>>
>>59482489
Shouldn't mutating through "b" be undefined? Otherwise the compiler can't do any optimizations based on const.
>>
>>59482584
void func(const char *param, size_t sz, bool modify)
{
if(modify)
strncpy(const_cast<char *>(param), sz, "new string");
printf("param: %s\n", param);
}

...

char buffer[16];
const char *unmodifiable = "string constant";
func(buffer, sizeof(buffer), true); // OK
func(unmodifiable, strlen(unmodifiable), false); // OK
func(unmodifiable, strlen(unmodifiable), true); // UNDEFINED BEHAVIOR
>>
>>59482600
What is the point of const_cast then? Is there ever a legitimate situation where it's needed?
>>
File: 1484674532376.png (393KB, 450x450px) Image search: [Google]
1484674532376.png
393KB, 450x450px
>>59482489

Can somebody why mutable and const_cast exist?
>>
Making a Hangman game in c++.
Thinking about how I'm going to keep score, i.e. the outcomes of past played games.
>>
working on a chat bot that imitates my chatting behaviour on tinder so I don't have to pick up bitches myself.
>>
>>59482489
pretty sure you cannot modify the const value anyway, since it is placed in a R/-/- section at compile time.
>>
>>59482489
Well you can do that with C too but it's undefined behavior. Problem with people writing c++ is that they don't give shit about others. Currently C ABI is the only way for other programming languages to use libaries.
>>
>>59482621
mutable causes an object to not be const in the first place, whereas const_cast changes a const reference to a non-const reference.

While const_cast is “dangerous” since it allows you to attempt to modify a memory location that might be const, mutable is “safe” and does not present this possibility.
>>
File: wotsit.jpg (17KB, 268x350px) Image search: [Google]
wotsit.jpg
17KB, 268x350px
What le fug is happening
I'm trying to do a quicksort algorithm but if I input some array it just makes the array all zero's except the end which is turned into the largest value in the array so if I put in
4 5 63 2 1 6
I just get
0 0 0 0 0 63

#pragma once

#ifndef QUICKSORT_H
#define QUICKSORT_H

template <typename TYPE>
void quick_sort(TYPE* START, TYPE* END) {
TYPE* i = START; TYPE* j = END;
TYPE pivot = *(START + ((j-i) / 2));

while (i <= j) {
while (*i < *pivot)
++i;
while (*j > *pivot)
--j;
if (i <= j) {
*i ^= *j;
*j ^= *i;
*i ^= *j;
++i;
--j;
}

if (START < j)
quick_sort(START, j);
if (i < END)
quick_sort(i, END);
}
}

#endif // QUICKSORT_H
>>
>>59482447
i'd be interested in knowing this too
>>
>>59482674
Why would somebody use #pragma once and the Include guards? Explain it please.
>>
>>59482641
make sure it is in a binary file
>>
>>59482674
>XOR swap, for a generic no less
>>
>>59482447
i guess it's like a chink usb memory which lies about its capacity. the interface is the same as for an array of dynamic size but when the dynamic size exceeds the static size it wraps around and overwrites itself because ring buffer
>>
>>59482698
Intel uses them.
>>
>>59482758
nice fallacy
>>
>>59482674
whoops ignore that *pivot
>>
File: 1487545293763.png (14KB, 559x471px) Image search: [Google]
1487545293763.png
14KB, 559x471px
php teapot
>>
>>59482705
Good idea
>>
>>59482784
too late bro
>>
>>59482218
debugging my debugger using two other debuggers simultaneously.
i have no idea what the fuck is going on anymore
>>
>>59482939
Who's going to debug those two debuggers?
>>
>>59482447
this is a confusing one, i'm stumped
>>
>>59482801
PHPpot
>>
>>59481973
>>59482033
if anyone was curious, you need to import numpy
import numpy as np
for i in np.arange(0,1,0.01):
#do something

works.
>>
File: 1489418342836.png (67KB, 400x400px) Image search: [Google]
1489418342836.png
67KB, 400x400px
>>59483158
"you need to import"
>>
>>59483249
So?
>>
>>59483158
from numpy import arange
>>
>>59482981
well fuck you, now I need a third debugger.
>>
>>59483322
bad practice, namespace separation is good
>>
>>59482249
Do you have non anecdotal evidence?

>>59482403
What if your API uses classes?
>>
.section .data

.section .text
.globl _start
_start:
call hello_world
movl %eax, %ebx
movl $1, %eax
int $0x80

.type hello_world, @function
hello_world:
pushl %ebp
movl %esp, %ebp
subl $20, %esp
pushl $72
movl %ebp, %esi
subl $20, %esi
popl %eax
pushl $0
popl %edi
mov %al, (%esi, %edi, 1)
pushl %eax
popl %eax
pushl $87
movl %ebp, %esi
subl $20, %esi
popl %eax
pushl $1
popl %edi
mov %al, (%esi, %edi, 1)
pushl %eax
popl %eax
pushl $33
movl %ebp, %esi
subl $20, %esi
popl %eax
pushl $2
popl %edi
mov %al, (%esi, %edi, 1)
pushl %eax
popl %eax
pushl $10
movl %ebp, %esi
subl $20, %esi
popl %eax
pushl $3
popl %edi
mov %al, (%esi, %edi, 1)
pushl %eax
popl %eax
movl %ebp, %eax
subl $20, %eax
pushl %eax
pushl $14
call print
addl $8, %esp
pushl %eax
popl %eax
movl %ebp, %esp
popl %ebp
ret

.type print, @function
print:
pushl %ebp
movl %esp, %ebp

movl $1, %ebx
movl $4, %eax
movl 12(%ebp), %ecx
movl 8(%ebp), %edx
int $0x80

movl $0, %eax

movl %ebp, %esp
popl %ebp
ret

assembly code (gnu assembly) for a program which prints "HW!\n" to the screen
the string is contained on the stack

generated by my compiler
there's a lot of superflous pushing and popping, but that's fixable
>>
File: ylyl.jpg (284KB, 1280x720px) Image search: [Google]
ylyl.jpg
284KB, 1280x720px
Why are there no calculators using cached values? All I see is just parsing whatever user entered into the program, not responding to events by the user. Couldn't even find anything on google about this.
>>
How do things resolve in an If/else statement?

A(), a function that takes a short time to do, returns bool
B(), a function that takes a long time to do, returns bool


I come upon instances where I need to check that both A and B are true.

if (A() && B()) { ... }
// or
if (B() && A()) { ... }


Which is faster? If if statements resolve L to R, then the first one is better, as it won't even check B() if A() is false, right?
>>
>>59483426
I will not read your code until you post an intel version
>>
>>59483429
HOLY SHIT I NEED TO WRITE A BULLSHIT CALCULATOR IN MUH C NOW BECAUSE THATS ALL I AND C ARE GOOD 4
>>
>>59483439
Yup, && and || (besides other maybe) are short-circuit evaluated operators.
>>
>>59483439

depends on the language but most will do both you need to nest the if statements

if (A) {
if (B) {
...
>>
>>59483429
Calculators don't normally need to care about performance
>>
File: 1489796898493.png (451KB, 718x904px) Image search: [Google]
1489796898493.png
451KB, 718x904px
>>59483459
That doesn't really answer my question, my man.
>>
>>59483429
> Why are there no calculators using cached values?
My calculator has 26 memory cells nig
>>
>>59483443
i might one day decide to make it be able to compile to an intel syntax assembly

it's hard to read either way, but an empty string is on the stack, the correct characters are written to the correct places, a pointer to the string beginning is passed to a "print" function which writes to standard output using syscall "write"
>>
>>59483443
The conversion is trivial.
>>
>>59482218
I'm a front end web babby what """real""" programming language should I learn? It's mostly for learning and fun.
>>
>>59483502
I meant cached as in the operands get set as you type, so all the program has to do is just to compute the expression.
>>59483487
But it's hard to believe nobody wrote anything like that. Nothing on github, nothing on google. I guess I was the only one autistic enough to write one.
>>
>>59483554
Any one language with a c (not case-sensitive) in it
>>
>>59483554
>fun.
what's fun for you
>>
>>59483419
>What if your API uses classes?
Use them internally and only provide struct in your library to outside. Alternatively wrap you shitty oop shit in funtions that take opaque pointer as parameter and call your ugly oop methods in the your ugly sepples impletantition you dirty oop nigger.
>>
>>59483555
> I meant cached as in the operands get set as you type
I can set and save a formula.
Later I can call the formula, and the calculator just asks me for values.
Values are saved before you turn off the calculator.
>>
>>59483429
>All I see is just parsing whatever user entered into the program, not responding to events by the user. Couldn't even find anything on google about this.

Nigga, wut u mean by dis?
>>
>>59483439
>I come upon instances where I need to check that both A and B are true.

Doesn't that mean that the function maps time to bool is overlapping cases and you don't have 2 separate distinctive cases for what is short and what is long?
>>
i like how /dpt/ meme'd about vulkan several years ago like "hurr don't learn opengl wait for vulkan" and yeah it has pc gaymen support but the support on android is dreadful, it's like nvidia shield and samsung s7 and that's about it, most of the nougat devices skip vulkan and apple doesn't seem interested at all, what a farce, it'll be several more years before android uses vulkan for UI rendering (and presumably has vulkan as a core requirement)
>>
>>59483657
Who cares about mobile gaming?
>>
>>59483476
>most will do both
which do? java doesn't, c doesn't.
>>
>>59483598
You press ".", programs detects you want to input a decimal, then you press 1, then 2. On each key press operand A gets set to 0 then 0.1 then 0.12 and so on, then you press any of +/-* keys then the next operand. The program detects all your activity and fills out values internally on the fly, then you press = and the expression gets computed with the pre set values without any parsing of the string you just wrote. The program only sees events that you generate and acts accordingly.
>>
>>59483694
Not him, but normies do.
>inb4 who cares about normies
They are retarded and spend on those things so you can make a nice profit.
>>
>>59483695
"most" means "languages that aren't C derivatives'.
>>
>>59483701
That's how calculator works.
What's wrong?
>>
>>59483249
yeah I know it's terrible, especially beacause of the fact that python was supposed to be the "it just werks" language
>>
>>59483738
Nope, all the calculators I've seen parse whatever you wrote as a string. They don't respond to single events.
>>
>>59483763
Calculators don't even know what strings are.
>>
>>59483781
I think anon is talking about how programs are calculators parse polish notation. Physical calculators operate the way he describe.
>>
>>59483781
I'm not talking about a hardware calculator if you didn't notice.
>>
Downloaded Java 8 in Action that some anon mentioned earlier as it seemed to be well-regarded. This greeted me in the preface
>Back in 1998 when I was 8 years old
>he's as old as me
I'm a fucking failure
>>
>>59483429
you mean like calc.exe or what?
>>
>>59483576
So Python?

>>59483577
Learning core concepts and programming principles I haven't learnt as a web dev. Doing funky abstract real time image processing maybe.
>>
webshit freelancing so I can get out of my dad's home
wish me luck /g/ents
>>
>>59483864
I'm pretty sure the standard windows calculator simply parses strings.
>>
>>59483883
how much do you earn?
>>
>>59483887
bruh it doesn't even let you input plain strings just numbers n shiet
>>
>>59483920
>I don't know what strings are: the post
>>
>>59483869
>Learning core concepts and programming principles
my advice would be to focus on online programming courses, regardless of muh languages
>>
>>59483920
Fuck, are you retarded?
>>
>>59483848
Don't let it get to you friendo, there is ALWAYS someone better than us at ANYTHING we can think of. By the same token, there are always people who are worse than us.
You have to ignore those thoughts and focus on getting better.
>>
>>59483938
>>59483948
fucking hell, what are you even on about, why would it use strings internally, it does symbolic computation behind the scenes
>>
clear
$path = "E:\TestEnv"
if (-not (test-path "$env:ProgramFiles\7-Zip\7z.exe")) {throw "$env:ProgramFiles\7-Zip\7z.exe needed"}
set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"

$pspfolders = Get-ChildItem -Directory $path | Where-Object { $_.Name -match "^[0-9]" }
foreach($folder in $pspfolders)
{
$subfolders = Get-ChildItem -Directory $folder.FullName

foreach($subfolder in $subfolders)
{
Set-Location $subfolder.FullName
$file = Get-ChildItem -File $subfolder.FullName | Where-Object { $_.Name -match ".rar$" -or $_.Name -match ".001$" }
if($file.Exists)
{
$file = $file[0]
$file.FullName

sz x $file.FullName
Remove-Item * -Exclude *.iso
}
}
}


Had a bunch of folders with following structure:
MainFolder
-Subfolder
--SubSubfolder
---file.rar
---file.00
---file.01
---file02
--SubSubfolder
---file.001
---file.002
...

In the end they all contain archives that are split in multiple volumes, so I set the .rar or .001 as the ones used for extracting.

I think all of them extract a single .iso file in the end, so is there a way I can pipe the 7z result into an object (variable) so I can delete everything in the folder except that extracted file?
Like this I'm pretty much relying on the extracted file to always be .iso

This is so fun though
>>
I'm working on Particle Swarm optimisation with r software.

Any suggestions are welcome lads.
>>
>>59483909
about 300$/week
it's like double the general wage in my third world shithole tho so its great
>>
>>59482674
I figured it out I just had to not use a XOR swap
>>
>>59483997
>is there a way I can pipe the 7z result into an object (variable)
Do you mean the text output by 7zip or the data extracted?
>>
>>59484094
basically I just need the filename of the extracted item, so I can exclude it from deletion
>>
>>59483993
We're not talking about physical calculators.
>>
>>59484070
Are you front end or back end? What languages and frameworks are you using?
>>
>>59484117
if a program isn't doing literal text processing it should usually not have to operate on strings. you'd use more efficient data structures for the given task.
>>
>>59483993
And how exactly does one do ``symbolic computation" without strings?
>>
"There's rarely a case where you need to define a copy constructor or copy assignment operator.
Store pointers in stl containers and define clone functions for the cases where copying is necessary."

Is this good advice?
>>
What's a good place for practicing programming 101 problems?
>>
>>59484147
All calculator applications parse your input as a string and then calculate the result.
>>
>Sepplesfags still don't have an option or result type in 2017
>>
>>59484202
/g/dpt/
>>
>>59484210
>what is a GUI
>>
>>59484202
reddit
>>
>>59484225
Exactly what I'm talking about?
>>
>>59484225
And how does the GUI communicate with the implementation code, genius?
>>
>>59484141
PHP (laravel, codeigniter, WP etc) and jquery, vue, angular
I also do bootstrap and purecss
pretty much front end and back end based on PHP
>>
>>59484202
codewars.com
maybe hackerrank
>>
>>59484238
You can make a calculator which takes keyboard presses
>>
>>59484238
a GUI application does not necessarily have to parse input as a string.

>>59484243
>click/type 2
>click/type +
>click/type 2
>click/type =
>display 4
no string parsing required
>>
>>59484202
Write a program that returns the largest substrigs of the given two
aeasdfknic ieasdknic -> easd
>>
>>59484263
So then how does it display the result to the user?
>>
>>59483426
>AT&T
Bullet through head
>>
>>59484257
Yes you can and that was my original point. The problem is you can't find anything like that on the Internet.
>>59484263
True, but in reality it's much harder than that because you need to account for backspace, floats. The code gets really really long.
>>
File: 4.png (22KB, 423x322px) Image search: [Google]
4.png
22KB, 423x322px
>>59484272
>>
>>59484263
Not him but how would you parse sin() log() abs() etc?
>>
>>59484292
>The code gets really really long.
no you just use a tree or someshit

>>59484296
you could match a sequence of key presses like e.g. the key combos in fighting video games
>>
help im autistic

how do i get a percentage in java as an int? casting is cancer

for example

int a = 10
int b = 1

how do i get a result of int c = 10
>>
Dear /dpt/,

Where's the best place to go from my introductory CS class, taken to fill a mandatory elective? I have trivial knowledge of C and Python: I placed at the top of the class, but I know how little that means. I don't want to become a major, nor do I want to take more meaningless electives now that I've filled that requirement, but I'd like a clear pathway for fun and possibly a little extra job security.
>>
>>59484108
You could try filtering on LastWriteTime.
Get-ChildItem | where LastWriteTime -lt (Get-Date).AddDays(-1)

That will filter anything older than a day ago and would be easier than trying to grep the output from 7z.
>>
>>59484329
>fun
>job
pick one
>>
>>59484324
(b/a) * 100
>>
>>59484324
int c = a
>>
>>59484324
5% of 30 as an int = 30 * 5 / 100
>>
>>59483426
>int 0x80
>not syscall
>2017
>laughing_girls.jpg
>>
>>59484318
>tree
Can you elaborate? I simply wrote an enumeration with keypresses and handled them in the handler with a shitton of if/else cases.
>>
>>59484341
Not everyone is as much of a cynic as you.
>>
>>59484376
ha
>>
>>59484339
>Get-Child
What kind of pedo language is this?
>>
>>59484339
what does LastWriteTime correspond to? 'Modified' time? Because the extracted items keep their modified time, which goes back to 2005.
Although you've given me the idea to use CreationTime instead, since it will correspond to the time it was extracted.
Thanks

>>59484404
powershell
microsoft is a giant pedo ring
>>
>>59484358
>>59484380
this doesnt work its just giving me 0 as a result for everything
>>
A proven stack
pragma SPARK_Mode;
generic
Max_Size : in Positive;
type Element_Type is private;
Nothing : in Element_Type;

package Formal_Bounded_Queue is

subtype Index_Range is Natural range 0 .. Max_Size;

type Queue_Type is private;

function Not_Empty (Object : in Queue_Type) return Boolean
with Inline;

function Is_Empty (Object : in Queue_Type) return Boolean
with Inline;

function Not_Full (Object : in Queue_Type) return Boolean
with Inline;

function Size (Object : in Queue_Type) return Index_Range
with Inline;

procedure Clear (Object : in out Queue_Type)
with Inline,
Post => (Is_Empty(Object));

procedure Push (Object : in out Queue_Type; Item : in Element_Type)
with Inline,
Pre => (Not_Full(Object)),
Post => (Size(Object'Old) = Size(Object) - 1);

procedure Pull (Object : in out Queue_Type; Item : out Element_Type)
with Inline,
Pre => (Not_Empty(Object)),
Post => (Size(Object'Old) - 1 = Size(Object));

private

subtype Array_Range is Index_Range range Index_Range'First + 1 .. Index_Range'Last;
type Data_Array is array (Array_Range) of Element_Type;

type Queue_Type is record
Queue_Size : Index_Range := 0;
Head : Array_Range := 1;
Tail : Index_Range := 0;
Data : Data_Array := (others => Nothing);
end record;

function Size (Object : in Queue_Type) return Index_Range is
(Object.Queue_Size);

function Not_Empty (Object : in Queue_Type) return Boolean is
(Size(Object) > Index_Range'First);

function Is_Empty (Object : in Queue_Type) return Boolean is
(Size(Object) = Index_Range'First and Object.Tail = Object.Head - 1);

function Not_Full (Object : in Queue_Type) return Boolean is
(Size(Object) < Index_Range'Last);

end Formal_Bounded_Queue;
>>
>>59484452
try this
(30 * 5) / 100
>>
>>59484452
Convert to double?
>>
>>59484459
Should give zero
>>
>>59484324
>casting is cancer
why would you not use a tool perfectly suited for the problem at hand
>>
>>59484475
1 actually
>>
>>59484453
pragma SPARK_Mode;
package body Formal_Bounded_Queue is

procedure Clear (Object : in out Queue_Type) is
begin
Object.Queue_Size := 0;
Object.Tail := 0;
Object.Head := 1;
end Clear;

procedure Push (Object : in out Queue_Type; Item : in Element_Type) is
begin
Object.Queue_Size := Object.Queue_Size + 1;

if Object.Tail = Array_Range'Last then
Object.Tail := Array_Range'First;
else
Object.Tail := Object.Tail + 1;
end if;

Object.Data(Object.Tail) := Item;
end Push;

procedure Pull (Object : in out Queue_Type; Item : out Element_Type) is
begin
Item := Object.Data(Object.Head);

if Object.Head = Array_Range'Last then
Object.Head := Array_Range'First;
else
Object.Head := Object.Head + 1;
end if;

Object.Queue_Size := Object.Queue_Size - 1;
end Pull;

end Formal_Bounded_Queue;
>>
>>59484492
Isn't that what he wanted?
>>
>>59484459
>>59484380
>>59484358

>people on /g/ thinking an int result can be a decimal

never change
>>
>>59484508
A percentage is not an int in the first place, the user wants it to be int without casting so be it
>>
>>59484508
>implying I wasn't meming
r-retard
>>
>>59484191
Anyone? Comment?
>>
>>59484453
>>59484497
How are the properties proven/checked? You get a compile time error if one of them fail?
>>
>>59484562

donno c++ is retarded
>>
>>59484191
Can you give me a use of a pointer itself? How is pointer useful?
>>
I'm simplifying a lot of the networking code in BasicTV by making generic functions for transmitting data in chunks and eliminating some no longer needed buffers.

>tfw kicking myself for not getting a working demo before March Madness
>>
(((mixin)))
>>
>>59484285
why
>>59484381
i could use a .equ syscall if i need, but no need really
>>
>>59484581
You get a warning of varying intensities if a property is able to by false.
>>
>>59484324
Probably something like
int c = (int) (((double)a / (double)b) * 10);
>>
>>59484603
Pointers are completely useless.
>>
>not using hlists
It's like you don't even care about your code being correct.
>>
>>59484191
Yes. Implicit deep copying was a mistake, and so is move semantics requiring a null object.
>>
>>59484685
that doesnt work.

i ended up doing


c = ( (int)(a / (b*.01) ) );



and it works. since /g/ couldnt figure out a non casting way.
>>
>>59484709
Deep copying can be fine, suppose your class is the same size as a pointer
>>
>>59484339
>>59484427
good thing I didn't run this shit on the actual folders, looks like some of them had an additional .png in them and ofcourse that had the latest CreationTime.
So I just said fuck it and sorted them by size, exclude the largest one

if($file.Exists)
{
$file = $file[0]

sz x $file.FullName
$lastfile = Get-ChildItem -File $subfolder.FullName | Sort { $_.Length } | Select -Last 1
$lastfile.Name
Remove-Item * -Exclude $lastfile.Name
}
>>
Script kiddies get out
>>
>>59482384
>Can somebody teach me how to sort items in an ascending order?
muhThings.Sort()
or
muhThings.OrderBy(x => x.SomeProperty)
if you're wanting to sort by some part of the Thing.

It's {currentYear}. Roll your own specific sort algorithm later if the performance must be improved.
>>
if (A) { print "A"; }
else if (B) { print "B"; }
else { print "C"; }


If only A is true, output is "A"
If only B is true, output is "B"
If both A and B are true, is output "AB", or just "A"? This is in C++.
>>
>>59484734
Key word: implicit. I like the way Rust does it where assignments are always moves or shallow copies (both implemented like memcpy) and you have to call a clone method to deep copy.
>>
>>59484801
AB
>>
>>59482350
clang -Weverything -Werror
>>
>>59484801
A
>>
>>59484801
A
>>
>>59484801
C
>>
>>59484801
>>59484825
>>59484834
>>59484847
>>59484851
Don't listen to there dorks, it's ABC
>>
>>59484801

D
>>
>>59484324
c = (b * 100) / (a * 100)
>>
>>59484801
come on this is the kind of thing you get spoonfed in the first hour of learning programming
>>
If I write a program that continiously takes inputs like
printf("abc");

int x = 10;
printf(x+1);


Would that be called an interpreter?
>>
>>59484947
No, unless you actually act upon the input and let an other language or construction translate the inputs into instructions that are immediately executed.
>>
>>59484541
int c = (a * 100)/b;
>>
File: WRONG.jpg (28KB, 600x600px) Image search: [Google]
WRONG.jpg
28KB, 600x600px
>>59484687
>>
>>59484977
Okay so
>>>print("abc")
>>>run
>>>output:
"abc"
>>>_

is an interpreter?
>>
File: 964.png (764KB, 600x719px) Image search: [Google]
964.png
764KB, 600x719px
what do you guys think is best for beginning compsci students. a hard language but teaches you foundations thoroughly, or an easier language to prepare the students for the harder ones?

I started with C# and then branched into basic C, C++, Haskell, and javascript for my classes. I'm wondering how it all would be if i went from C/C++ to an easier one like C#.

What's your take on it /g/?
>>
>>59484999
Give me a formal proof that pointers have any use.
>>
>>59484999
Could you give me a use of a pointer that invalidates >>59484687?
>>
>>59485006
LANGUAGES
DOESNT
MATTER
>>
>>59485006
Lisp.
>>
>>59484947
Not really sure what you're asking, but this would be an interpreter:

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int n;
scanf("%d", &n);
printf("%d\n", d + 1);
return(EXIT_SUCCESS);
}
>>
>>59484801
nigga what does else mean to you
>>
I wrote my own language today which compiles to JVM bytecode. It can actually do FizzBuzz :3
It's a strongly typed langauge with type inference.

fizzbuzz()

function fizzbuzz() {
print("please enter the amount of iterations: ")
var iterations = read(number)
var currentIteration = 1

while (currentIteration <= iterations) {

if currentIteration % 3 == 0 && currentIteration % 5 == 0 {
print("FizzBuzz")
} else if currentIteration % 5 == 0 {
print("Buzz")
} else if currentIteration % 3 == 0 {
print("Fizz")
} else {
print(currentIteration)
}

currentIteration++
}
}
>>
>>59485027
That's not an interpreter, it can only print things while an interpreter does a lot more things
>>
>>59485027
no
>>
>>59485043
>today
wut
how did you do it in one day

ive been writing one that compiles to assembly and had to start with compiling a number than two numbers added etc. worrying about stack and types and shit
>>
I know the thread is full of Rust shill, I need your help.

I'm trying to implement custom Iterator to extend an existing iterator with a single additional value. I want these iterators to work over references. So I store both the original iterator and the additional value and I walk over the iteratior and when it ends I want to return the reference to the additional value. The problem is, the lifetime of the references the original iterator returns is different from the lifetime my custom iterator (and thus the additional value I store in it) has. I tried to use lifetime subtyping on the `next` method, but then I break the Iterator trait, so I'm kinda out of ideas.

Here's the code to play with: https://is .gd/8sWTGy
>>
>>59485009
>>59485013
A pointer is used to keep track of the current instruction in machine code. Without pointers, NO programs could exist.
>>
File: 1485438720022.png (423KB, 720x720px) Image search: [Google]
1485438720022.png
423KB, 720x720px
>>59482240
What did we ever to do you?


Except for our country being ruled by a disgusting socialist government that gives a false sense of hope to the gommunists that "true communism" can ever exist.
>>
>>59485046
>>59485051
An interpreter CAN do more things. It doesn't have to. Cat is an interpreter, for example.
>>
>>59485080
>I'm trying to implement custom Iterator to extend an existing iterator with a single additional value.
chain
>>
>>59485075
I used ANTLR 4 so i didn't have to write the lexer/parser, and the JVM is stack based, so it's really easy. You don't have registers or c calling convention, you simply push things on to the stack or remove them from it. But it took me more like 3 weeks, Today is the day its finally able to do small programs like this.
>>
>>59485097
no
>>
>>59485081
Wrong.
>>
>>59485006
C but with C++'s <iostream>. There's no need to use printf, scanf and other archaic functions, but you still will learn something (which is not the case with all modern gay languages like Python or JavaScript).
>>
>>59485117
Oh yeah for the bytecode generation, I used Jasmin, that I don't have to write opcodes directly in hexadecimal form.
>>
>>59485135
C++ iostreams are cancerous and retarded.
>>
>>59485146
yeah but printf and scanf are even more cancerous and retarted
>>
>>59485080
Lifetimes are the one thing I hate about rust.
I can't for the life of me figure out what the syntax for them even means.
>>
>>59485115
Chain requires Item of both iterators to be equal, and since I need the Iterator to be over references, I can't get two iterators with the same lifetime.
In my original problem I have a vector with relatively big objects and another such object outside of the vector and I want to iterate over them without moving/coping them around.
>>
>>59485162
printf is an excellent function. scanf is not great, but sscanf is pretty decent.
>>
>>59485146
Bitshifts, bitshifts everywhere.
>>
>>59485162
You're cancerous and retarded.
>>
>>59485025
I agree to a certain extent, but students have to venture into a language eventually. The difference between the languages should not be neglected, especially for beginning students.

The difference between C and C# is not negligible
>>
>>59485025
That's like saying
>RACE
>DOESN'T
>MATTER
when it clearly does
>>
>>59485006
I wonder what breed of programmers would we get if we teached them Haskell first
>>
It's funny how Java gets all shitted on while C# is equally shitty but only newer (and therefore some nice features) and gets praised. Languages that don't run natively are cancer anyways.
>>
>>59485127
Okay, give me an example of an instruction set which can execute programs without using pointers.
>>
>>59485235
I shit on Microsoft Java all of the time.
>>
File: 1486399766979.png (342KB, 394x394px) Image search: [Google]
1486399766979.png
342KB, 394x394px
fuck me i need a new job
development speed is crippled because of bad code, bad database design, coupling all over the fucking place and zero testing
cant even refactor shit without some other shit breaking
>>
>>59485221
Back to your safespace, snowflake.
>>
>>59485185
Printf is literally the only thing C got right.
>>
>>59485084
Allow beautiful Swedish women to be raped by disgusting muzzies.
>>
>>59485235
it took you this long to figure out language wars are just memes?
>>
>>59485138
>>59485117
oh i see, good work

mine can do fizzbuzz too, but i need to define a function that takes a number and makes it a string
can only print strings as of now, lol
will do tomorrow
>>
>>59485235
>Languages that don't run natively
can you explain?
>>
>>59485235
/dpt/ has shit taste in languages. some of these tards are just trolling anyway
>>
>>59485205
for the most part when learning CS, most programs what language you use to make it doesn't matter
you can write compilers, implement algorithms, do machine learning or whatever in any language

i agree, differences shouldn't be neglected though, obviously, there's value in learning how the different languages operate in terms of language engineering, but it's not that crucial for the programming itself
>>59485221
races and languages are not the same
analogies are not symmetries, analogies are very good at confusing people
>>
>>59485318
.NET runtime, it's like a fucking JVM.
>>
Genius idea for a project

Install a camera inside of your fridge, and print QR codes on all of the food that has what it is and the expiration date. Warn when food becomes expired through some sort of web app. Keep track of where it is by recording the direction relative to the camera.
>>
Back to the topic of making an interpreter, here's my plan:

1. Everytime the interpreter is called, a new file is created in /tmp
-stdio is imported by default
-file starts off as the following:
import std.stdio;
int main(string[] args)
{

2. while true parse stdin lines
3. if it starts with import statement put them at the beginning of the file
4. import lines count++
5. if it does not have an import statement:
- paste the line after main().
- append the line at the end of the file
6. if the user enters EOF, a } is appended in the end
7. the file is compiled, and executed if compiling was successful
>>
R8 my hello world program, /g/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(void)
{
FILE *f = fopen("tmp.c", "w");
const char *tmpc = "#include <stdio.h>\nint main(void){printf(\"hello, world\\n\");return 0;}\n";
if (!f) return 1;
fprintf(f, tmpc);
fclose(f);
system("gcc -o tmp tmp.c");
unlink("tmp.c");
system("./tmp");
unlink("tmp");
return 0;
}
>>
>>59485388
kuro is such a slut
>>
>>59485394
notaquine/10
>>
>>59485362
agreed
any programmer worth his salt will eventually learn "the big three" programming paradigms anyway, i dont think it matters that much which one you decide to start with
>>
>>59485414
t-three?
>>
>>59482218
What's the book under K&R (the one with a butterfly on it) and the other one visible (looks like Introduction to Algorithms but I may be wrong)?
>>
>>59485403
What does that mean?

>>59485414
>any programmer worth his salt
>his
[TRIGGERED]
>>
>>59485425
more like two, but most professors i've met make a huge deal about counting imperative as its own paradigm so i just do it automatically
>>
>>59485428
Butterfly one is Javascript: the good parts or something like that.
>>
>>59485455
How dare you put it in there, OP, this isn't /wdg/!
>>
>>59482358
>Someone put up a post in the last thread implying you can't program games in PHP. I wanted to try.

>Someone told me you can't use a hammer to put a screw in the wall.
>I wanted to try.
>>
Why do I procrastinate every project I get in college?

I'm in my final semester taking 4 upper division cs courses and I just can't bring myself to even start coding them outside of 24 hours before they are due. Then I get nervous as fuck that I'm not going to finish or its going to be sloppy code and I hate doing these assignments.

Am I just depressed? Am I burnt out? Anyone else experience this shit?
>>
Say I have a bunch of text in JSON format like this:

"customers" : "John Smith (jsmith) extra unimportant text, Mary Sue (msue) extra unimportant text, firstName lastName (userName) extra unimportant text...


How do I extract just all the first names, last names and usernames in the parentheses while ignoring the rest of the crap?
>>
File: 1456518382216.jpg (98KB, 500x707px) Image search: [Google]
1456518382216.jpg
98KB, 500x707px
>>59485401
Get over it
>>
>>59485485
>4 upper division cs courses
name them pls

or say wat their about
>>
>>59485511
Use regular expressions.
>>
>>59485447
So imperative, OOP, and what else?
Don't tell me it's functional.
>>
>>59485511

regex
>>
>>59485388
>D
Slut
>>
>>59485528
Sure.
Machine learning.
Big data and Information Retrieval.
Advanced algorithms (mostly a shit ton of dynamic programming and NP-completeness ).
Operating Systems
>>
>>59485564
>Operating Systems
what do you do there more precisely

what is the course about
>>
File: C91 774.jpg (442KB, 1280x1814px) Image search: [Google]
C91 774.jpg
442KB, 1280x1814px
>>59485527
No, you.
>>
>>59485176
Two lifetimes are considered equal as long as one completely contains the other. What have you tried, using chain?
>>
>>59485542
>>59485547
No idea how to do that but at least I know where to start looking, thanks lads
>>
>>59485580
It's just using C and assembly to model how an OS communicates with hardware. We haven't gotten to the big project yet but have just learned a bunch of shit regarding the scheduler and synchronization of processes.
>>
File: pls.png (51KB, 400x250px) Image search: [Google]
pls.png
51KB, 400x250px
prodrider is down, send help
>>
>>59485639
I thought progrider was down for awhile already.
>>
>>59482270
holy cow, I wanna make games using PHP now. This language is full of surprises, and one of its dirty tentacles has opengl bindings, who would have guessed. Thanks anon
>>
People in this site either are underage or watch too much cartoons for their age.
>>
>>59485658
Not them, but it's been down for like a week or two by now.
>>
>>59485658
Yes and that was ok for moment but it's still down! Where is everybody?
>>
>>59485688
Nothing will match world4ch /prog/.
>>
>>59485667
I watch anime whenver
- I'm having a meal, need something to watch
- Absolutely bored
- Need a good 20 minute break
Anime fits the criteria perfectly.
>>
>>59485667
I masturbate to cartoons.
>>
>>59485511
import json
import re

with open("file.json") as fh:
data = json.load(fh)
matches = re.findall("(?:^|, )(\w+) (\w+) \((\w+)\)", data["customers"])
for firstname, lastname, username in matches:
print("%s, %s, %s" % (firstname, lastname, username))



something like this should work, regex might even be an overkill if the data is well structured
>>
>>59485769
I know... I feel sorry for you.
>>
So I need some advice. I am kind of stuck in a rut with my career right now

I went to school for IT Management, except we didn't actually learn anything IT related. Graduated and got a good job as a Supply Chain Manager (I was a double major)

However this shit isn't for me, and the only thing I would feel qualified for is a basic help-desk position in IT.

I started learning Python a year back as a hobby, and found that I REALLY enjoyed programming. The whole process of figuring out how to solve a problem using code, and then writing it and searching for my issues excited me. I fell out of it because I was busy, but with my job life being so shit I need to make a change.

1. If I wanted to start learning to program seriously what route should I take? I don't know at this point what I would want to do (The biggest thing I made was an ASCII art based dungeon crawler in Python). I was thinking about grabbing up an "Intro to Comp Sci" class off edX or something so I can at least get into the mindset of what it is like.

2. Are there some good resources for getting a feel for what working as a programmer is like? Like a nice website that gives you ideas of the types of things I would be expected to do in any given job

3. Obviously this is the biggest elephant in the room, but what languages should I be looking at. All I know is some Python and a decent bit of SQL. My friend keeps shilling Rust to me but I have no idea if it will end up being practical.
>>
File: 1489962277329.png (32KB, 400x250px) Image search: [Google]
1489962277329.png
32KB, 400x250px
>>59485639
optimized
>>
>>59485913
>If I wanted to start learning to program seriously what route should I take?
Either start reading books or go to uni. Learn C++
>>
>>59485913
>Python background
You are not ready for Rust yet. Learn C.
>>
>>59485945
Im already in debt from 5 years at uni with two degrees, but I will do books+edX
>>
>>59485960
>Education makes people bankrupt
Nice country there, fag
>>
>>59485972
Tysm!
>>
>>59485972
I mean it's completely my fault for going into uni for a shit degree
>>
>>59485913
>I want to get a job and get paid
Learn JavaScript, Python (which you already have) and then move on to Java or Python

>I don't care, I just love programming
Pick any language that appeals to you. Rust is a nice choice and your friend is right.
>>
>>59485913
>>59485960
>americans have to pay millions of dollars to get an education
tip top lel
>>
>>59486001
In my country, the government owned universities/colleges would cost you less than a car
>>
>>59485960
There's a breadth of quality online courses you can do as well, if you want that structure they provide. I'm currently working on the one below by Princeton and it's great
>https://www.coursera.org/learn/algorithms-part1
>>
>>59486029
Thank you, structure really helps me learn.

I was doing TeamTreehouse as well as my friend had a sub
>>
If languages don't matter then why aren't you writing in C?
>>
>>59486082
Because languages don't matter
>>
>>59486082
If languages don't matter then why aren't you writing in Haskell?
>>
>>59486082
Best way to prove that languages don't matter is successfully applying the worst one
>>
File: 1486453556217.png (289KB, 540x438px) Image search: [Google]
1486453556217.png
289KB, 540x438px
Compile Time Function Execution (CTFE):

Functions which are both portable and free of side-effects can be executed at compile time. This is useful when constant folding algorithms need to include recursion and looping. Compile time function execution is subject to the following restrictions:

>The function source code must be available to the compiler. Functions which exist in the source code only as extern declarations cannot be executed at compile time.
>Executed expressions may not reference any global or local static variables.
>asm statements are not permitted
>Non-portable casts (eg, from int[] to float[]), including casts which depend on endianness, are not permitted. Casts between signed and unsigned types are permitted
>>
>>59486082
>If languages don't matter then why aren't you writing in machine code?
ftfy
>>
I'm using cURL with PHP to get data from a paginated API.

What's the easiest way to loop through to get every page's data into one array?
>>
>>59486249
for(i=0;i++;i<numberOfPages)
data[i].put(array)
>>
>>59485235
>C# is equally shitty
I respectfully disagree.
>>
>>59485394
I can make it go deeper if you want:
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define MAX_PROGRAM_SIZE (1u<<9)

int main (int argc, char **argv) {
char program[MAX_PROGRAM_SIZE];
char *msg;
FILE *f = fopen("tmp0.c", "w");

if (!f)
return 1;

if (argc > 1)
msg = argv[1];
else
msg = "hello, world";

sprintf(program, "#include <stdio.h>\n#include <stdlib.h>\n#include <unis"
"td.h>\nint main(void)\n{\n char *msg = \"%s\";\n FILE *f = fopen"
"(\"tmp.c\", \"w\");\n const char *tmpc = \"#include <stdio.h>\\n"
"int main(void){printf(\\\"%%s\\\\n\\\");return 0;}\\n\";\n fprin"
"tf(f, tmpc, msg);\n fclose(f);\n system(\"cc -o tmp tmp.c && ./t"
"mp\");\n unlink(\"./tmp\");\n unlink(\"./tmp.c\");\n return 0;\n"
"}\n", msg);
fprintf(f, "%s", program);
fclose(f);
system("cc -o tmp0 tmp0.c && ./tmp0");
unlink("tmp0"); unlink("tmp0.c");
return 0;
}

^ This took me a lot longer than I expected.
>>
>>59486286
microsoft java is crap though
>>
>>59486286
Same, with Java 8 it's now clear that C# is worse.
>>
new anime thread when?
>>
>>59486295
stop

also
>^ This took me a lot longer than I expected.
you dumdum
>>
>>59486301

Factually incorrect.
>>
>>59485913 here.

Would you say, (based on your feedback) this is a fair TL:DR to entering the Programming Industry?
1. Learn more Python, then Java
2. Take some beginners Comp Sci courses on Coursera/edX
3. Actually get good at Python/Java
4. Start learning C++
5. Wipe my ass with my Toilet Paper diploma and look for a job
>>
>>59486310
They have anime threads all day long in >>>/a/ and a bunch of other boards.

>>59486317
You're the dumdum. All that escaping is not easy
>>
New thread:

>>59486332
>>59486332
>>59486332
>>
New thread (in English):

>>59486363
>>59486363
>>59486363
>>
>>59486336
anime website
>>
>>59486386
With some non-anime boards.
>>
>>59486282
alright, fair, now how can I do it without specifying the amount of pages so the loop keeps going until cURL gives an error?
>>
>>59486403
Created for anime fans by anime fans
>>
>>59486019
>being such a richfag you don't know how many people bankrupt themselves buying cars
>>
>>59486461
You can get a functional car for less than $5k.

If you don't have the money right now, you can get it on credit.
>>
>>59486654
>If you don't have the money right now, you can get it on credit.
So instead of going bankrupt now, you go bankrupt when you have to pay it back.
>>
>>59487867
it depends. how did you get the job?
>>
>>59485928
How to optimize files?
Thread posts: 325
Thread images: 25


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.