[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: 331
Thread images: 33

File: 1480590811928.png (389KB, 934x1000px) Image search: [Google]
1480590811928.png
389KB, 934x1000px
What are you working on, /g/?

Old thread: >>58026223
>>
>>58032469
Absolute madman
https://github.com/whatsthisnow/ProjectD
>>
>>58032482
>LinuxD.sln
Toppest of keks
>>
File: 1471289579297.jpg (87KB, 720x720px) Image search: [Google]
1471289579297.jpg
87KB, 720x720px
>the same two images every damn time
>>
>>58032503
just noticed that, lel.
>>
>>58032482
What is this?
>>
How do you make programs automatically run from terminal in Sublime? I looked but can't find shit
>>
Just added thread archival to akari-bbs!
Threads bump off the board now.
I also fixed an issue where you could still reply to archived threads if you tried hard enough.
>>
>>58032473
>>58032424

What did you except from universities?
They use programming to count heavy maths but not for professional web-fizzbuzzing.
>>
>>58032482
>Currently glibd is currently empty, as I haven't done any work on it yet.

Translation:

>I HAVE THIS REALLY GREAT IDEA FOR A GAME I JUST NEED PROGRAMMERS AND ARTISTS!
>>
Copypasting from the previous thread because I didn't get an answer:

This my first year of university and we have programming classes.This semester is Fortran and the next one will be C++.I'm generally interest in programming but I don't really have any prior experience with it,but I thought it would be cool to start programming on my own,however the problem is:

>Should I start programming in Fortran or wait for the next semester so I can learn C++?Some people have told me that C++ is way better but I'm not sure what the difference is.
>How the fuck should I start?I downloaded Codeblocks but I seriously have no idea how to even create a simple program and how to run it,in classes we just write the code in Text Editor and run it through the terminal but our computers run Ubuntu,I'm running windows and no I'm not going to change my OS in order to code
>>
>>58032538
He's rewriting the Linux kernel in D, pretty self-explanatory
>>58032556
He just got started on it, calm yer tits senpai
>>
>>58032569
I should also add that I'm not a computer science major so more advanced programming is probably out of the question unless I choose a postgraduate degree or something like that.
>>
>>58032587
>He just got started on it
you can say the same about 90% of year old patreon projects
>>
>>58032569
>I'm running windows and no I'm not going to change my OS
No, not going to help you. Suffer.
>>
>>58032569
Don't listen to the hipsters bullying Fortran. The language is as bad as any. Also istall a Linux distro, it's almost impossible to get work done on Windows.
>>
File: 123412341234.jpg (23KB, 480x360px) Image search: [Google]
123412341234.jpg
23KB, 480x360px
>>58032482
gnu/linuxD when
>>
>>58032549
>All trademarks and copyrights on this page
It begins...
>>
>>58032587
>He's rewriting the Linux kernel in D
For what purpose?
And can you even compile a kernel with any of the D compilers yet?
>>
>>58032549
>written in c
thats pretty cool was it a pain in the ass
>>
>>58032482
not haskell/10
>>
>>58032601
>>58032603
so is coding in windows really that bad?I thought it was just kind of different but not that it's impossible to get work done.One of my friends uses a linux just so he can code so I guess I should have taken the hint.Thanks for the help anyway.
>>
glib, tbox, qlibc, what to use?
>>
>>58032587

I know, I'm just razzing.
>>
>>58032638
I can't say it's BAD, but it's just annoyingly retarded like the rest of the system.
>>
>>58032643
None.
Build up the abstractions you need yourself from syscalls/os libs.
>>
>>58032482
It should have been python
>>
>>58032671
No you fucking retard.
>>
https://github.com/ValeriyKr/sfb/
>>
>>58032569
Fortran is literally formula translator. It follows many mainframe-time design choices, and the best it does - translating formulae in assembler.
Output formatting is alien to modern languages.

As about me, I started with Basic, and my first classes were in Pascal.

>>58032638
Can't say if it is absolutely bad, it feels OK when you're inside the sandbox provided by Visual X languages, and I've never dealt with the OS directly.
You may to disregard my opinion if you want to.
>>
>>58032638
this might help you. i don't use windows so i can't personally vouch for it

https://msdn.microsoft.com/commandline/wsl/about
>>
>>58032659
I can say it's bad. Everything is broken.

Locales? Broken. Posix compliance? Non existent. C99 support in visual studio? No. C11 support in visual studio? No. Awesome snake_case apis? Enjoy your shitty CamelCase. Usable shell? Only pretend bash with hard locked Ubuntu version set in 2014.

Windows is even worse than OS X without brew (which is generally unusable!)
>>
Eating kebabs and flirting with qt traps
>>
Can anyone that knows C tell me how does this library achieve what it does? Does it just spawn threads per process or is it actual green threads?

https://github.com/sustrik/libdill
>>
how do i git gud at commenting my code?
I have over 200 lines with no comments
>>
>>58032719
If Qt is for traps, what is Gtk for?
>>
File: kyr.jpg (435KB, 566x800px) Image search: [Google]
kyr.jpg
435KB, 566x800px
M-Merry xmas /g/

def memetriangle(str: String, n: Int): String = {
var nl = "\n";
var i=1;

for(i <- 1 to n){
nl += repeat(" ", n-i) + repeat(str, i*2-1).substring(0, i*2-1)+ "\n";
}

def repeat(str: String, x: Int): String = {
var y="";
for(i <- 1 to x){ y+=str; }
return y;
}
return nl;
}

memetriangle("'*'", 30)


                             '
'*'
'*''*
'*''*''
'*''*''*'
'*''*''*''*
'*''*''*''*''
'*''*''*''*''*'
'*''*''*''*''*''*
'*''*''*''*''*''*''
'*''*''*''*''*''*''*'
'*''*''*''*''*''*''*''*
'*''*''*''*''*''*''*''*''
'*''*''*''*''*''*''*''*''*'
'*''*''*''*''*''*''*''*''*''*
'*''*''*''*''*''*''*''*''*''*''
'*''*''*''*''*''*''*''*''*''*''*'
'*''*''*''*''*''*''*''*''*''*''*''*
'*''*''*''*''*''*''*''*''*''*''*''*''
'*''*''*''*''*''*''*''*''*''*''*''*''*'
'*''*''*''*''*''*''*''*''*''*''*''*''*''*
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*'
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*'
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*'
'*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*''*
>>
>>58032795
BABY, you know I don't comment my code!
>>
>>58032795
Reread your code and comment lines where you aren't sure you'll be able to understand them if you'll retuen to your code in a half of year.
>>
File: no.jpg (186KB, 816x488px) Image search: [Google]
no.jpg
186KB, 816x488px
>>58032761
>concurrency in C
>concurrency without a garbage collector

It's not even using green threads.
>>
>>58032795
Good code is self-commenting. No need to add anything else.
>>
>>58032509
and?
>>
>>58032863
>concurrency without a garbage collector
What are you implying?
>>
>>58032894
tracking data dependencies become overly complex when concurrency is involved.
>>
>>58032929
for you
>>
>>58032811
gay tranny kludges
>>58032824
hello, nice shirt :^)
>>
>>58032929
No, not really. Look at Rust, for instance.
>>
haskell or common lisp
>>
>>58032929
Lrn2ownership
>>
>>58032638
>so is coding in windows really that bad?I
No, it's perfectly fine.
It has all the relevant text editors, compilers, interpreters, debuggers and IDEs.
The workflow can be mostly identical on any OS if you use editors like vim or emacs.
>>
>>58032761
Looks like just coroutines, no threads involved
>>
>>58032974
>N:N
>ownership

kek
>>
>>58032633
Maybe string manipulation would have been easier in other languages, but everything else would be the same.
You still have to interpret the get string and write wrapper functions for database operations.
>>
>>58033108
Sounds like a bad situation all around. Preventable, though.
>>
>>58032469
How to force myself to learn assembler?
>>
>>58033147
you dont, dont force yourself to things you don't want to for the sake of doing something. find something you enjoy as stupid or weird u think it is
>>
>>58033147
delete your compiler
>>
>>58033147

For fun or do you have a particular reason?
>>
>>58033147
You have to wear stripped knee high socks for that
>>
>>58033174
>For fun or do you have a particular reason?

particular reason.

revenge.
>>
>>58033168
I want, but every time i try to find material i get either some prehistorical books about dos programming or shit for degenerate first graders about what hexadecimal system is
I'm tired of it and ready to give up and not come deeper than C
>>
File: 1457551465286.jpg (10KB, 280x200px) Image search: [Google]
1457551465286.jpg
10KB, 280x200px
I gotta learn java + javafx and Python.

Any suggested material for learning this?

fml
>>
>>58033310
>Any suggested material for learning this?
internet
>>
>>58033310
>java + javafx
The oracle tutorials are surprisingly good

>python
First, decide which version you want to learn. Are you interested in 2.x, or 3.x?

There are good official tutorials available for both:
https://docs.python.org/2.7/tutorial/
https://docs.python.org/3.6/tutorial/
>>
>>58033217
Forget about x86 then, I got the armv8 reference manual and qemu arm64 emulator and writing stuff for fun now, VGA pokers small kernels assembly serial console games
>>
>>58033217
In my opinion, assembly languages are only useful to learn after you have a strong grasp of system architecture. Only then will be able to understand how assembly relates to the hardware, and you won't have a bad time learning it.

I haven't read it myself, but this one seems to be well-reviewed: Computer Systems: A Programmer's Perspective
>>
File: 1443822648778.jpg (108KB, 640x640px) Image search: [Google]
1443822648778.jpg
108KB, 640x640px
>>58033367
WHere are the oracle tutorials I looked online and saw multiples?

sorry im noob af
>>
>>58033452
kys retard
>>
File: Kimi Dake no Ponytail_34.jpg (170KB, 968x1600px) Image search: [Google]
Kimi Dake no Ponytail_34.jpg
170KB, 968x1600px
Anyone tried Bitcoin-paying freelance jobs? What's the best site so far?
>>
>>58033452
https://docs.oracle.com/javase/8/javase-clienttechnologies.htm
left-most and right-most columns
>>
>>58033464
sell pics of u in panties
>>
>>58033217
I learned x86 asm from simple trial and error over a long period of time while debugging my own programs and reverse engineering other programs
at that time I wasn't even aware of any books on it besides the x86 architecture manual which I never got a hold of and probably wouldn't have read anyway
>>
>>58032638
It's fine. If you stick to the Visual Studio stuff, it's really nicely integrated and a breeze to get actually useful stuff running within a short time.

Currently working on an SQL DB with a couple convoluted stored procedures and XQuery stuff for importing horrible XML files into usable tables. Ties in pretty well with Visual Studio for generating deployment scripts and versioning of table schemas.
Writing CLR/.NET code for server-side stuff is pretty nice as well, some things just don't map well to SQL.
Just finished setting up the tables and data input today. Next week will start with some other projects before I get back on writing an ASP.NET MVC frontend. Turns out it's pretty similar to using something like Rails to get shit done, unlike the old and entirely retarded ASP/Webforms stuff.

Apart from that ecosystem, nothing's stopping you from installing bash/gcc or any other combination of tools.
>>
>>58033191
Clearly you don't want revenge hard enough if you can't even force yourself to learn something.
>>
File: nani.png (304KB, 722x768px) Image search: [Google]
nani.png
304KB, 722x768px
Why hasn't anyone reinvented programming to make it easier?
Why is everything still text based?

>>58033464
>draw a girl
>call it a boy
>>
File: symbolics-3600-keyboard-1.jpg (229KB, 2742x1407px) Image search: [Google]
symbolics-3600-keyboard-1.jpg
229KB, 2742x1407px
Can someone please recommend the best lisp books? I'm trying to get better at emacs lisp.
>>
>>58033629
>Why hasn't anyone reinvented programming to make it easier?
https://en.wikipedia.org/wiki/DRAKON
https://drakon-editor.com/
>>
>>58033655
No, and yes (with exceptions).

As long as you're curious and you know how to learn, you can learn anything.
>>
File: scratch-01.jpg (400KB, 1035x751px) Image search: [Google]
scratch-01.jpg
400KB, 1035x751px
>>58033629
>>
File: 1476557403992.png (8KB, 179x181px) Image search: [Google]
1476557403992.png
8KB, 179x181px
>>58033666
I have something similar to this in my computer wishes file

thank you devil
>>
>>58033666
>drakon
>means devil in romanian
>666
>>
>>58033629
Easier for who?
Basically the answer to that question is why we have many different programming languages.
>>
File: IMG_155.jpg (3MB, 4032x3024px) Image search: [Google]
IMG_155.jpg
3MB, 4032x3024px
What does your programming environment look like, /g/?
>>
>>58033629
I believe in the future, programming will be like VR constructions.

Imagine being able to see the whole code as a gigantic 3 dimensional tree or graph with unlimited scaling/zooming factor. (You can make yourself smaller to edit assembly or bigger to edit the code with much higher abstraction).

All of this would be edited in real-time by avatars of other developers and you would be able to interact with your virtual coworkers by speaking.

Sorry for bad english
>>
>>58033666
I got the urge to write something serious in something like this.
What should I write?
>>
>>58033807
>You can make yourself smaller to edit assembly or bigger to edit the code with much higher abstraction
This isn't how it works.
>>
>>58033805
>eating rice with a fork
>eating rice out of the plastic bag

what the fuck are you
>>
>>58033805
>have large monitors to the left and right
>typing into a tiny monitor on a tiny keyboard instead
For what purpose?
>>
>>58033805
Nice PRODUCT PLACEMENT
Hashtag coding with faggot
>>
>>58033850
More space for papers and books
>>
>>58033807
>smaller to edit assembly
That'd be very confusing. I'd suggest the opposite. Either way a translation to assembly (compilation) often doesn't have good correspondence to where you are in the actual source.

I find node based representations of programs very confusing usually because they show you too little.

Also the best way to represent something that large would be a hyperbolic tree.
I'm not sure people are that well suited for hyperbolic trees in VR. But I'd love to have a look.
>>
>>58033805
>plastic bag rice

What the fuck?
>>
File: alina chan.jpg (680KB, 1280x1918px) Image search: [Google]
alina chan.jpg
680KB, 1280x1918px
>>58033485
ty my boipuc belongs to u
>>
>>58033805
I don't want to make other people feel discouraged from posting but I REALLY hate everything about the contents of this image.
>>
>>58033860
if you were to remove the monitors from your desk you might be able to make that point
but as it stands, you cannot
>>
>>58033805
>fork can't maintain balance and falls over launching rice and shit all over laptop
>>
File: fucking-image.png (302KB, 1920x1080px) Image search: [Google]
fucking-image.png
302KB, 1920x1080px
>>58033826
Roll.
>>
>>58033924
Most of these are just awful (not really programming related) and certainly not 'serious'.
But I'll roll.
>>
>>58033899
belongs to everyone*
>>
>>58033924
>posts the image with all the harder ones removed
kek
>>
>>58033943
I'll just pretend I got 44.
It's not super serious but it's certainly got more room for exploration than implementing a God damned algorithm. Why is that even there? It's not a programming challenge it's a text input challenge at best.
>>
About to take a vector calculus final... Thinking of making an application that graphs your network of friends
>>
>>58033991
If it's so easy then do both dumbass
>>
>>58034076
build a list of pornstars who are on facebook then see how many people away each of your friends are from any of them
>>
>>58034083
Anon I'm not sure you understand my post.
>>
>>58034107
"too trivial" but you still can't do it
>>
File: haskell-scala.png (332KB, 550x733px) Image search: [Google]
haskell-scala.png
332KB, 550x733px
/g/ BTFO
>>
>>58034097
>tfw once removed from Claire Abbott
>>
>>58034191
Maybe the only other languages they've used are C or C++.
>>
Finished my pi procedure, shitty enough performance desu

(define (pi-get n)
(pi-iter 0 1 n 0))

(define (pi-iter sum a n count)
(if (< count n)
(if (= (modulo count 2) 0) (pi-iter (+ sum (pi-calc a)) (+ a 2) n (+ count 1))
(pi-iter (- sum (pi-calc a)) (+ a 2) n (+ count 1)))) (display (* 4 sum)) (newline))

(define (pi-calc a)
(/ 1.0 a))
>>
File: 1469643738953.png (541KB, 1280x720px) Image search: [Google]
1469643738953.png
541KB, 1280x720px
>>58032469
Do strings written to a network socket have to be null-terminated, given that the delimiting byte is not the null byte?
>>
>>58034384
no
>>
>>58034384
No, just write the length of the string beforehand
>>
>>58034384
they can be whatever you want. It's just bytes as far as the socket knows.
>>
>>58034384
no
>>
>>58033642
Practical common lisp, land of lisp, SICP and there is lots more I guess
>>
>>58034384
No of course not, Java uses length for eg and some kind of EOF thing I believe.
>>
File: 1478415807930.jpg (67KB, 800x557px) Image search: [Google]
1478415807930.jpg
67KB, 800x557px
How is impure to use conditionals?
>>
I've grown tired of vim. Are there any good text editors for OS X besides Sublime?
>>
>>58034526

It's not. Dijkstra's formal methods outlined how to spec for-loops and if-statements (conditionals).

Boolean logic is proofed a long time, logic gates are basically boolean conditionals.

Thus, there is nothing impure about them. They are however not always optimal for performance.
>>
>>58034527
Emacs.
>>
So Anon, which build system do you use for your cross-platform C/C++ programs?
>>
>>58034622
GNU make
>>
>>58034622
Python scripts
>>
>>58034622
CMake
>>
>>58034622
unity .cpp
>>
Can I return a char * pointer to a static buffer within the program?
>>
>>58034847
depending on the phase of the moon yes
>>
>>58034847
Sure.
>>
>>58034847
It might not be thread-safe, but yes
>>
>>58034847
not with this mentality. post anime image next time
>>
>>58034847
You can but if it's stack allocated and just went out of scope that's a terrible idea.
>>
>>58034893
>if it's stack allocated
He said it was static.
>>
In memescript you're not supposed to use traditional for loops, Douglas Crockford says so.

What is the correct way to write this function?

function addTile(symbol) {
for(var i = 0; i < 2; i++) {
tiles.push({
id: addCount,
symbol: symbol,
div: document.createElement("div"),
span: document.createElement("span"),
visible: false,
hasListener: false
});
}

addCount = addCount + 1;
render();
}


Every object I add to the tiles array, there needs to be a unique duplicate object added as well.
>>
size_t strrev(const char* input, char* output)
{
if (!input || !output) {
return 0;
}

if (*input) {
size_t n = strrev(input + 1, output);
output[n] = *input;
return n + 1;
}

return 0;
}
>>
>>58034847
Sure. But remember that if you're going to change what's in the static buffer in the future, then you need to consider the returned pointer to be temporary. For example, don't stick the returned pointer into a table and then expect that pointer to point to the same string forever -- the string will get clobbered the next time you change the buffer.
>>
>>58034923
Use asm.js and render everything on a canvas
>>
>>58034934
>Non tail-recursive
It's garbage.
>>
>>58034934
>implying NULL equals to zero
>>
>>58034956
It does.
>>
>>58034956
In C it does.
>>
>>58034947
>tail-recursive
kys
>>
>>58034934
>>58034947
>any form of recursive function calls
it's trash
>>
What's the best C book that isn't the K&R?
>>
>>58034968
>>58034976
Oh. I thought it's implementation-defined.
>>
>>58035022
well, you thought wrong.
>>
>>58035022
It's Complicatedâ„¢

A NULL pointer doesn't have to have the value 0 in memory, and doesn't have to compare equal to an int with value 0 for example, but does have to compare equal to the literal 0...

The literal zero in the context of a pointer always means NULL, even though NULL isn't necessarily 0...
>>
>>58035045
ok
>>
>>58035022
It's underlying representation is implementation defined.
However, the null pointer is 'equal' to zero logically.
>>
Working on my terminal emulator, adding support for sixels because sixels are cool.

I'm also extending them to support true color RGBA sixels, for maximum almost standard compliant image showing.

Make sixels great again.
>>
>>58034622
On windows I open visual studio and hit f5
On linux I open eclipse and hit ctrl+b
>>
>>58034527
atom is decent
>>
>>58035105
cancer?
>>
>>58034527
I hear good things about vs code.
>>
>>58035158
lol
>>
>>58035170
Yes, it's terminal.
>>
File: asdf.png (18KB, 203x209px) Image search: [Google]
asdf.png
18KB, 203x209px
>>58035213
>>
>>58035213
You need to stop, you were born in the wrong universe.
>>
What should I use to feel the power of old true hackers?
>>
>>58032569
start by learning to install and installing a proper linux distro, arch would be a good start.

You will learn a lot about programming culture while trying to make your linux pretty.

And find literally any java or c++ or c# tutorial online and start doing exercises. Not python or c because ones i recommend will be harder and python and c++ will come like candy once you learn(not master, just start to learn) how to code in java or c++.

And ALL programs essantily run from terminal, you can do it on windows with windows' own terminal, but it really not worth your while to learn it, spend your time learning bash instead.
>>
>>58035261
That's the nicest thing anyone has ever told me, thanks anon.
>>
>>58032638
Well for me i hate desktop envoirments and afaik windows doesn't allow you to get rid of it, and since everybody only knows bash learning window's command line is a chore; all of this unless you wana be a VS/eclipse slut which in that case go for it.
>>
>>58035308
>start by learning to install and installing a proper linux distro, arch would be a good start.
>You will learn a lot about programming culture while trying to make your linux pretty.
no

>And ALL programs essantily run from terminal, you can do it on windows with windows' own terminal, but it really not worth your while to learn it, spend your time learning bash instead.
use an IDE
>>
>>58032638
don't listen to linux neckbeards on /g/, windows is perfectly fine just use a decent IDE with any compiler like gcc
>>
>>58034923
Array(2).fill().forEach((_) => {
tiles.push({
id: addCount,
symbol: symbol,
div: document.createElement("div"),
span: document.createElement("span"),
visible: false,
hasListener: false
});
});
>>
>>58035517
>windows is perfectly fine just use a decent IDE with any compiler like gcc

how do i use gcc on windows?

i installed mingw and when i type gcc in the command line says "not found" or something

do i have to do something more?
>>
>>58035539
wow its fucking nothing
>>
>>58035542
i think to run it from command line you set the path variable

but using a terminal is so fucking hipster neckbeard-like, just use a makefile in your IDE
>>
>>58034384
depends on how you gona extract them on the other side.

If you are using a library just read specifications, tough the answer is %90 no.
>>
what's a black end engineer?
>>
File: 342.png (17KB, 900x900px) Image search: [Google]
342.png
17KB, 900x900px
>>58035539
Do people actually do this instead of just creating a traditional for loop?
>>
>>58035634
yes redditor
>>
>>58035634
Kill yourself, you retarded frogposter.
>>
>>58035631
>black end
you mean back end?
>>
>>58035631
an asshole
>>
>>58035634
only fedora tippers
>>
>>58035631
sounds like an open position at github
>>
You have 60 seconds to prove that you're not a pajeet and/or your CS degree actually means something
>>
>>58028973
Shift floats into ints and use them to index into array.
Linear in difference of max and min.
>>
File: letsactuallyuselogic.jpg (184KB, 1024x775px) Image search: [Google]
letsactuallyuselogic.jpg
184KB, 1024x775px
>>58034306

In Scala,

def piGet(n: Int) = {
quickPi(0, 1, n, 0, 1)
}

def quickPi(sum: Double, a: Int, n: Int, count: Int, sign: Int) {
if(count < n){
System.out.println(sum*4, a, n, count)
quickPi(sum + (piCalc(a)*sign), a+2, n, count+1, sign*(-1))
}
}

def piCalc(a: Int) = { 1.0 / a }

System.out.println(piGet(10000))
>>
>>58035696
I have no CS degree.
>>
File: Screenshot.png (887KB, 3840x2400px) Image search: [Google]
Screenshot.png
887KB, 3840x2400px
>>58035696
ok
>>
>>58035696
In cubical type theory we can represent higher logical relations (typically equalities) as hypercubes of increasing dimension using a presheaf model of so-called coloured type theory.
>>
>>58035739
>coloured type theory.
MLK is rolling over in his grave
>>
>>58035726
>mac
>not pajeet
>>
>>58035715
In Python
def piGet(n):
quickPi(0,1,n,0,1)

def quickPi(sum,a,n,count,sign):
if (count < n):
print (sum*4,a,n,count)
quickPi(sum + (piCalc(a)*sign), a+2, n,count+1,sign*(-1))

def piCalc(a):
return 1.0/a

print (piGet(1000))
>>
If you do not write referentially transparent functions then you are not programming.
>>
>>58035781
lmao

ok virgin
>>
I want to make a Piet (http://www.dangermouse.net/esoteric/piet.html) interpreter in Python.

How the fuck do I read images in Python 3?
>>
>>58035793
How are you going to write a function that writes any output or takes any input then?
>>
File: IMG_3528.jpg (1MB, 3000x2000px) Image search: [Google]
IMG_3528.jpg
1MB, 3000x2000px
Just press da button and it takes photos :-)
>>
Java and C# are completely unusable programming languages. Have fun constructing all the dictionary instances yourself, and only being able to abstract over types of kind *.
>>
>>58035804
Use the IO type to describe side effects, but not actually do them.
>>
how can I make a python script return an error if no argument was passed?
>>
>>58034306
double pi (void) {
return 355.0/113.0; /*Close enough*/
}

Rate my implementation
>>
>>58035809
What do you use instead?
Pascal?
>>
>>58035726
Which one are you?
>>
>>58035808
Now just gotta improve code, but atleast it werks.
using nrf24l01 modules now. They have way less latency then 433mhz modules
>>
>>58035823
delete this man
>>
>>58035822
A language that doesn't get in my way nearly as much.
>>
>>58035804
Either model the effect directly or model the state of the world as state inside your program.
>>
File: autist gets his neetbux.jpg (40KB, 432x307px) Image search: [Google]
autist gets his neetbux.jpg
40KB, 432x307px
>>58035823
Found him
>>
>>58033642
I'm currently going through Clojure for the Brave and True

Clojure's a lisp that compiles to JVM bytecode, I'm not a huge fan of that but the book is really good and the syntax is really similar to other lisps I intend to get more use out of
>>
>>58032469
feels fucking good being a genius. this girl was sucking on my dick while i wrote this -

for x in range(0, 20):
for i in range(x, 400, 20):
print(newlist[i])
[\code]
>>
>>58035819
rate mine
double pi (void) {
return 22.0/7.0; /*Close enough*/
}
>>
>>58035837
OK
>>
>>58035804
1) Code a virtual universe
2) Let it run. It doesn't need to interact with the real world, ergo all the code can remain pure like my waifu
>>
>>58035869
>>58035865
Fucking shitty side-effecters
>>
>>58035872
>Using a function
>Not just using a macro
//Close enough
#define PI 3
>>
>>58035816
That goes against what he said.
>>
So, I am reading chapter 6 of "Think Python" and doing the exercises.
This is what I have coded. https://en.wikipedia.org/wiki/Ackermann_function

def ack(m,n):
int(m)
int(n)
if m==0:
return n+1
elif n==0:
m=m-1
return ack(m,1)
elif m>0 and n>0:
redack=ack(m,n-1)
m=m-1
return ack(m,redack)
else:
return False


It does the work for the small numbers right, ack(3,4) gives 125, however when you try something like ack(4,1) or ack(5,0) it gives me infinite recursion with "line 8, in ack redack=ack(m,n-1)" error.

Here's the solution by book's author: http://www.greenteapress.com/thinkpython/code/ackermann.py
I don't get it, why does he put "ackermann" as an argument iside another "ackermann" with reduced input m and n variable instead of declaring this reduction? Should it like make recursion ifinite, cause he would just achieve in fact each step is performed with the ORIGINAL variables reduced by one and not with the RESULTING EACH TIME REDUCED variables?

So far, I hate Python's syntax and don't think you may use it for any other thing but doing some shitty web-related scripty stuff.
>>
This is a pure function. You don't need to use Haskell to write pure code.

int64_t f(uint8_t n)
{
if (n <= 1) return n;
if (n > 92) return -1;
n -= 2;

uint64_t a = 1, b = 1, c = 0, d = 1, e = 1, f = 0;

while (n) {
uint64_t g, h;
if (n & 1) {
g = a * d + b * e;
h = b * d + c * e;
f = b * e + c * f;
d = g;
e = h;
}
g = a * b + b * c;
a = a * a + b * b;
c = b * b + c * c;
b = g;
n >>= 1;
}

return d;
}
>>
The maximum possible width of a UTF-8 character is 4 bytes, right?

I'm trying to truncate strings and I don't want to overflow or cut off the first half of a unicode character.
>>
>>58035910
No, it doesn't.

>>58035917
Can you prove the Ackermann function should terminate for all non-negative m and n?
>>
This is pure code:

putStrLn "roos and wombats, mate"


This is not pure code:

println("roos and wombats, mate");
>>
>>58035888
side-effecter? I don't know what that is
>>
>>58035921
Haskell enforces purity. Any naughty functions need to be wrapped in a monad.
>>
>>58035963
println is just describing the action, not doing it
:)
>>
>>58035976
Purity has nothing to do with monads.

You can do IO in Haskell without using monads at all:

(putStrLn "crikey, mate") *> (putStrLn "that drop bear almost got me")


>>58035990
Can a call to println be replaced with the value it returns?
>>
What's the best programming language to use when you don't know how to type?
>>
>>58036050
Malboge
>>
>>58036050
Haskell.

But you should learn to type anyway.
>>
>>58036050
You know it's an oldschool LISP tradition to type with two fingers
>>
>>58036050
Whitespace. You only need to know three keys.
>>
>>58035952
Yes, the computer runs out of memory eventually.
>>
>>58035888
The fuck is a side effecter?
>>
>>58036086
Suppose the computer has infinite memory. Can you prove it terminates?
>>
>>58036091
>>58035972
Someone who writes non-referentially transparent code.
>>
>>58036099
I would not suppose that. I live in reality.
>>
>>58036099
1) Ask God i it terminates. God is omniscient and therefore knows.
>>
>>58036131
God is not real.
>>
this is a faggot:

>>58035963
>>
>>58032824
looks like shit
>>
This is a dunce: >>58036174
>>
>>58036099
Yes.
>>
>>58036227
Good.
>>
>>58036111
Is there something non-transparent about Clojure inherently?
>>
>>58036255
Yes, unless you are writing the trivial program that does nothing other than return unit.
>>
>>58036099
it's pretty obvious that it terminates
>>
>>58036309
Not to Python, which apparently believes that it recurses infinitely.
>>
How do I convert this text

>17th of December 2016 02:00

Into a localdatetime in java?
I have this so far
String dateTimeString = "17th of December 2016 02:00";

DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd MMMM yyyy HH:mm");
LocalDateTime dateTime = LocalDateTime.parse(dateTimeString, formatter);


Do I have to make a parser method?
>>
Whats the Ukraine of programming?
>>
>>58036337
Python
>>
>>58036321
sys.setrecursionlimit(float('inf'))
>>
>>58036333
No, you need to tell it that to expect a literal 'of'.
>>
>>58036349
Why would you ever want a recursion limit?
>>
>>58036357
DateTimeFormatter only accepts it's own arguments, so telling it to expect a custom string doesn't work
>>
>>58036299
I'm afraid I still don't understand, It's not like the inner-workings of a lisp interpreter or JVM are some kind of mystery

It's probably just inexperience on my part, I've been writing small programs since I was 14 but I've never taken a proper course, not really prepared to call myself a programmer
>>
>>58036349
DateTimeFormatter.ofPattern("dd'th' 'of' MMMM yyyy HH:mm");


>>58036406
https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
>
 '       escape for text             delimiter
>>
>>58036379
so you know if you fucked up? if you have deeply nested function calls your code is straight up terrible
>>
>>58036420
Any program that runs on the JVM must have a main function of type String[] => Unit.

Referential transparency means that we can replace an expression with the result of evaluating it. Unit is a singly-inhabited type, and that single value is (). Therefore any referentially transparent Clojure program may be replaced with ().

If this is not the case for your program then it is not referentially transparent.
>>
>>58036436
thats it famm. Thanks.
>>
>>58036436
Thank you, you saved me from going to the trouble of writing a counterexample.

>>58036458
I have written useful programs that recurse infinitely. A recursion limit is not useful in general.
>>
>>58036490
>I have written useful programs that recurse infinitely.
just use a loop you autist
>>
>>58036522
Loops are not practical, nor rational.
>>
>>58036460
That's all well and good, but I fail to see how a lack of referential transparency is a negative aspect of a given language, furthermore doesn't that apply to programs compiled from java source?
>>
File: [tilting increases].png (27KB, 500x500px) Image search: [Google]
[tilting increases].png
27KB, 500x500px
>>58036541
>>
>>58036543
Lack of referential transparency forces you to violate the DRY principle.

Unless Clojure has some structure like IO that it interprets the main function as then it applies to Clojure too.
>>
File: rust.jpg (199KB, 812x408px) Image search: [Google]
rust.jpg
199KB, 812x408px
>>58032955
>Rust
>>
>>58036541
>loops are not practical

>loops are not rational

have you... ever... touched soure code?
>>
>>58036593
I have written production code using C, C++, and Java. It is not something I will ever willingly do again.
>>
>>58034622
One simple build.bat/sh script per platform.
>>
>>58036586
lol, it's like there's a 1st grade CS'er doing the assembly manually
>>
Post good nips 2016 paper trailers

I thought these were cool
https://www.youtube.com/watch?v=btr1poCYIzw
https://www.youtube.com/watch?v=PtHbAlLMhl8
>>
>>58036614
>I have written production code using C, C++, and Java.

tell us more.

how are C++ and C code in the industry?
>>
>>58036541
please tell me you're not employed in this field.
>>
>>58035793
No such thing as referentially transparent on actual computers.
Every instruction executed modifies (at the very least) the instruction pointer.
>>
>>58036628
I had only just finished university back then so l knew almost nothing about programming, hence my naivete.

C, C++, and Java are not practical languages.

>>58036634
I am currently employed as a software engineer.
>>
>>58036672
>C, C++, and Java are not practical languages.


what are some pratical languages?
>>
File: blazingly fast.jpg (318KB, 1025x690px) Image search: [Google]
blazingly fast.jpg
318KB, 1025x690px
>>58036619
Blazingly fast zero overhead memes
>>
>>58036659
putStrLn "wagga"


Please show me where the instruction pointer is modified in the above code.
>>
>>58036685
Haskell, Idris
>>
>>58033805
Thanks for the cancer.
>>
>>58036693
Depends on which actual computer you're executing it on.
>>
>>58036711
It never modifies anything, ever.
>>
>>58036659
Doesn't matter because that's typically (99.999% times) not an observable effect.
>>
>>58036723
You're insane.
>>
>>58036723
It does if run on an actual computer.
Step over it in a debugger, observe the IP value before and after.
>>
>>58036576
I might be (I totally am as I don't fully understand the issue) talking out of my ass here but in Clojure, and any other Lisp dialect I've been exposed to there is no distinction between functions and operands, functions can be passed as data and returned just like a variable in any other language, this includes the main function.

Clojure also doesn't care about data types, You could ask it "Is this thingy here a string?" and it would return a boolean value, but otherwise it couldn't give a watery shit what kind of data you're working with, even if that data is the program you're currently running

Maybe I need to rephrase this, the way you typed out
>Any program that runs on the JVM must have a main function of type String[] => Unit
makes absolutely no sense to me, if data from the main function has to be returned as a particular type that's a hangup with java, but it's never been written into a single program I've compiled and it seems referentially transparent according to this definition
https://wiki.haskell.org/Referential_transparency
>>
File: output_Sep18_17-02-25.jpg (3MB, 4096x2160px) Image search: [Google]
output_Sep18_17-02-25.jpg
3MB, 4096x2160px
Procedural generation. Draw a bezier curve. Jiggle the control points. Repeat. Throw it through a primitive HDR transform.

Next up on the agenda is hooking it up to a SMFL window so I can actually see what I'm doing when I tweak parameters.
>>
>>58036586
>>58036619
>>58036688
Rust doesn't generate the assembly though, they use llvm.
>>
>>58036747
>I've compiled and it (clojure) seems referentially transparent according to this definition

ambiguous wording
>>
>>58036706
i'm sure that's why the industry picks C, C++ and Java over Haskell and Idris, because Haskell and Idris are just too practical
>>
>>58036737
It's a pure expression. It doesn't 'do' anything.

You may be conflating it with something that interprets it.

>>58036747
The JVM looks for a method with the signature

public static void main(String[] args)


when you tell it to run a program.

>Clojure also doesn't care about data types
Types have nothing to do with referential transparency.
>>
Are GPGPU and CUDA/OpenCL a meme or are they actually useful?
>>
>>58036781
It the only type of programmers they can afford.
>>
>>58036793
only useful for very niche applications like computer vision
>>
>>58036792
>you may be conflating it with something that interprets it
So then printf is pure too
>>
Common Lisp is practical.

The book title said so.
>>
>>58036798
get over yourself
>>
>>58036793
Unless you're in the medical field, cracking passwords, or interested in offline rendering, yes, they're memes.
>>
>>58036792
>It's a pure expression. It doesn't 'do' anything.
Then it doesn't evaluate to anything either, so it's a meaningless point.
All code in any language is preferentially transparent by that definition since nothing could ever mutate until it's actually interpreted/executed.
>>
>>58036586
It's just a different calling convention. This makes it seem like a really big difference when the actual code is only two instructions in comparison.
>>
>>58036810
No, it is not. You cannot replace a call to printf with the value it returns without changing your program.
>>
>>58036792
Now I understand why people hate typical Haskell faggots.
>>
>>58036824
See >>58036827

>>58036798
It is a false economy because one Haskell/Idris programmer can do the work of several C/C++/Java programmers.
>>
>>58036793
If you want to actually use more than ~10% of your machine's computing resources, yes, they are quite useful.
>>
>>58036776
It's beside the point. Rust is dead now. Go has killed it.
>>
>>58036823
there's also anime image upscaling
>>
>>58036688
>web devs are so shit they need to check for overflow every time they multiply integers
>>
>>58036792
>The JVM looks for a method with the signature
>public static void main(String[] args)

I'm pretty sure you're thinking of the java compiler, which might check for a main function of that format, I honestly wouldn't know, point being that has never been written into any program I've written in clojure, compiled with lein, then run on a JVM, nor has anything equivalent been written into any of my programs, I do have a -main function, because that's an efficient way of organizing the program, but my code would be perfectly valid without it
>>
>>58036827
>See >>58036827
>No, it is not. You cannot replace a call to printf with the value it returns without changing your program.
What program?
It's just an expression.
Replacing printf("hello") with 5 doesn't change anything (unless you actually run the program, but you were explicitly not talking about that apparently)
>>
>>58036848
The overflow checks don't exist in the optimized version so what's the problem?
>>
>>58036879
rust still has a bunch of safety features that can't be turned off
>>
>>58036893
Go on.
>>
>>58036860
It changes the expression that is the program.

These are the same program, because '2' is referentially transparent:
2 + 2

4


These are not the same program, because calling 'println' is not referentially transparent:
println("referentially transparent my arse");

;
>>
>>58036848
After buffer overflows integer overflow is the second biggest cause of vulnerabilities (the last couple kernel priv escalation exploits were because of (signed) integer overflows).
>>
>>58036893
not to mention the eye cancer syntax
>>
>>58036851
The Java compiler does not check for a main method.

What is the entry point of a clojure program?
>>
>>58036900
https://til.hashrocket.com/posts/9f39124f6f-rust-array-access-is-bound-checked-at-runtime
>>
>>58036904
>These are not the same program, because calling 'println' is not referentially transparent:
Of course it is.
Any function returning void is trivially preferentially transparent - just replace them all with a void expression (i.e a no-op).
Only way you could observe the difference would be to run the program and physically observe the output - but that as I've said is the case for any language.
>>
>>58036919

Are you talking about the main namespace?
>>
New thread:

>>58036933
>>58036933
>>58036933
>>
>>58035917
bro, taking a long-ass time to run does not imply it's performing infinite recursion
>>
>>58036930
Yes, by default, because otherwise "safe Rust" would not be safe. If you use iterators or unsafe access, you don't pay for bounds checks. They can also often be optimized out.
>>
>>58036938
>Any function returning void is trivially preferentially transparent
But what if it modified a global variable?
>>
>>58036973
>global variable
>>
>>58036977
Yes? I don't think you understand purity.
>>
>>58036973
>But what if it modified a global variable?
It still always evaluates to (void).
Whatever side effects it does is only visible if you execute the program, and then we run into the fact that something like an instruction pointer is always modified anyway.
>>
>>58036996
If it has side effects, it's not referentially transparent: it's not pure.
>>
>>58037003
The expression doesn't have any side effects - it's just an expression.
println("anything") ALWAYS evaluates to void, you can replace all println() calls with nothing and still have the expression evaluate to the same result.
What it does at runtime is of no consequence, otherwise IO () wouldn't be pure.
>>
>>58037041
What if it's output is piped back into itself? Or written to memory it's using?

I do understand where your confusion has arisen, but you'll have a hard time getting away from the fact that: side effects = impure = not referentially transparent.
>>
>>58037087
>What if it's output is piped back into itself?
Or someone attaching to your process with a debugger reading the IP register?
Yes, nothing is refentially transparent then as I've repeatedly said.
>>
>>58037124
No True Scotsmen doesn't trump PLT.
>>
>>58037133
I started this discussion with that example your retard, there's no ad-hoc moving of definitions here.
>>
>>58037157
Your example has side effects, is impure, and is not referentially transparent.
>>
>>58037165
The side effects are only produced by the runtime - just like Haskell's IO () for example.
>>
>>58037186
You've been conflating the result of evaluating the procedure (which is NOT pure and returns void) and evaluating the expression that represents this action (which evaluates an action and IS pure).

Furthermore (which is where I've come in, because it's actually wrong, rather than just an accidental conflation), you stated that if something evaluates to void, it must be pure.
>>
>>58037186
>>58037288
Anyway dude, I'm knackered.

You can't guarantee referential transparency even if doing something as mild as printing to stdout, have a read about it if you like. Thanks for a good debate.
>>
>>58035696
>>58035726
>tfw just broke everything
>>
File: DSC_0618.jpg (3MB, 4608x3072px) Image search: [Google]
DSC_0618.jpg
3MB, 4608x3072px
>>58035808
>infinite jest
did u rike it?
Thread posts: 331
Thread images: 33


[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.