[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: 318
Thread images: 34

File: 1463210410094.png (1MB, 1000x1400px) Image search: [Google]
1463210410094.png
1MB, 1000x1400px
Old thread: >>55253746

What are your working on, /g/?
>>
First for 6502 assembly
>>
File: anime.png (201KB, 335x365px) Image search: [Google]
anime.png
201KB, 335x365px
Thank you for using an anime image.

When will Haskell get refinement types?
>>
>>55269029
Benchmarking GPUDirect RDMA over PCIe and over InfiniBand.
>>
reposting from old thread:

I'm entering my 3rd year as a CS major... feel like I don't have a general grasp on CS; I can figure out things, and I have gotten an A in all my CS related classes so far, but browsing any kind of CS forum or doing anything more complex than data structures loses me. I've been trying to study on my free time lately, mostly just reviewing basic C++ and Python because my skills have decayed some over the summer, but still feel like I have a super rudimentary grasp on things. Is this normal?
>>
>>55269061
I N T E R N S H I P
>>
>>55269061
What are you expecting to get out of your CS education?

>browsing any kind of CS forum or doing anything more complex than data structures loses me
Specific examples?
>>
>>55269061
>Is this normal?
lol no
>>
>>55269070
i'm getting one this next summer at a reasonably big company, is that where i learn the sick memes?

>>55269074
just to be able to read a thread like this or a similar forum on programming and be able to understand generally what everyone is talking about, to have an idea where to start for any kind of project, etc.

>>55269077
what is normal for a 3rd year CS student then?
>>
>>55269106
>just to be able to read a thread like this or a similar forum on programming and be able to understand generally what everyone is talking about
You are truly lost if /dpt/ stumps you
>>
>>55269106
>what is normal for a 3rd year CS student then?
After my second year, I had already built a simplified C compiler and my own OS kernel (both were classes at my uni).
>>
>>55269132
I really mean to have a general grasp. The specific forums and their difficulty is just semantics, anon
>>
>>55269164
I have classes similar to that coming up - I was at a CC for my first 2 years, this upcoming year is my first year at a real uni. I've actually only taken 3 legitimate CS classes tbqh
>>
So is Haskell a language only used by homosexuals and girls, or is it just a meme?
>>
File: functional programming.jpg (64KB, 440x389px) Image search: [Google]
functional programming.jpg
64KB, 440x389px
>>55269204
Haskell is used by wizards
>>
>>55269193
>I was at a CC for my first 2 years,
Honestly, this explains why you're feeling a bit lost.
>>
>>55269258
Yeah, our CS department was honestly pretty shit. Sink or swim at uni, I guess
>>
>>55269221
Yes, homos. That is what I said.
>>
>>55269221
>> Haskell...

Used... kek
>>
Daily reminder that IO monads in Haskell are stateful containers
>>
Currently working on some Google Apps Script add-ons for work. Working on some android apps in my free time.
>>
File: zvzcfghd.jpg (16KB, 396x385px) Image search: [Google]
zvzcfghd.jpg
16KB, 396x385px
tfw ur codan
>>
File: yeb.jpg (196KB, 800x763px) Image search: [Google]
yeb.jpg
196KB, 800x763px
>>55269301
tfw ur codan
>>
>>55269106
Don't listen to these faggots. You don't need to know any of the shit these weebs talk about to get a real job.

Everyone has different starting points, but unless you're gonna get a masters or PhD, a lot of the under the covers stuff is meaningless.
>>
File: cauchy.png (41KB, 1157x755px) Image search: [Google]
cauchy.png
41KB, 1157x755px
Made a thing in Mathematica to look at the poles and zeros of a transfer function and its projection of a Bezier curve to demonstrate Cauchy's argument principle for a control systems class.
>>
File: 1466352701842.jpg (76KB, 343x336px) Image search: [Google]
1466352701842.jpg
76KB, 343x336px
>>55269456
>all those parameters
>all that nesting
>>
>>55269493
Nesting is one of the key methods of generating information in Mathematica. Things like
someFunction[arg, option]

will pretty much always give different results than
someFunction[arg, {option}]

or
someFunction[arg, {{option}}]

and so on.
>>
>>55269347
Sure, maybe if you're working webdev, but every other field requires some actual competence.
>>
>>55269456
I remember learning a bit about that in my controls course. Neat stuff.
>>
>>55269546
>someFunction(...) is distinct from x = ... in someFunction(x)
>>
File: Win10CodeIntegrity.png (801KB, 2466x1325px) Image search: [Google]
Win10CodeIntegrity.png
801KB, 2466x1325px
>>55269358
> What?
> Can you give an example of a program like this?
> I've never seen this before
> is it a new thing in windows 10?

It's been here since Win8. But it's never been turned on. Even on current Win10 it's not on by `default`. But the policy exists.

Let me power up my Win10 VM, and I'll show you.

As seen in WinDbg which is kernel debugging the Win10 VM. The Signing level policy is set to 0 from SeILSigningPolicy.dll, which means anything can run. But if I change it to 1 (unsigned code can run), 4 = authenticode (signed by anyone with valid root cert), 8 = microsoft signed code, 12 = (windows code only - e.g. windows store apps allowed like metro calc). And in the future who knows if Windows decide to change the default value.

DRM in the future will move probably to signing policy 8, only Microsoft signed code and above can run in that booted OS. Prevents people with screen capturing tools without microsoft signed code (because why will MS give those tools certs unless they can give a good enough business reason).

So yeah, that is the future where DRM will head to protect itself from capturing tools.
>>
File: dafuq.jpg (7KB, 180x168px) Image search: [Google]
dafuq.jpg
7KB, 180x168px
>>55269029
Hi /g
I am working on a wordpress plugin and was told not to enque google jquery

for the life of me i can not enque wordpress jquery

this is the google enque that works

function abc_jquery_enqueue() {
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js", false, null );
wp_enqueue_script( 'jquery' );
}
if ( !is_admin() ) {
add_action( 'wp_enqueue_scripts', 'abc_jquery_enqueue', 11 );
}



this does not work
function textdomain_load_jquery() {
wp_enqueue_script( 'jquery' );
}
add_action( 'wp_enqueue_script', 'textdomain_load_jquery' );


can anyone enlighten me as to what i am doing wrong, or even share a snippet. Thank you
>>
File: Win10CodeIntegrity_8.png (530KB, 2574x1277px) Image search: [Google]
Win10CodeIntegrity_8.png
530KB, 2574x1277px
>>55269673
>>55269358
Oh yeah, let me show you the example of a block. Cffexplorer.exe is an unsigned program. Let me change that policy to 8 (MS signed code only). And notice the error in the screenshot, it blocked it from running as it's not signed MS code.
>>
>>55269601
That's just sugar since
a = 1;
b = 2;

gets translated to
CompoundExpression[Set[a, 2], Set[b, 5], Null]
>>
>>55269863
>that's just sugar
>literally my complaint
>>
>>55269739
>>55269673
hm
so in the future everyone who uses windows and wants to pirate software will also need to obtain a tool that will bypass the windows authorization shit, like RemoveWAT
still though, the future of DRM is getting even more bleak
>>
>>55269892
I'm being facetious. I recognize your point, I'm just very lazy.
>>
>>55269902
Even RemoveWAT will not help. These signing policies checks are done in the kernel itself, and secure kernel booted and protected by HyperVisor can override your changes.

Secure kernel has higher privileges than you. Secure kernel code has higher privileges than SYSTEM. And you can't elevate to the secure kernel, like you could to SYSTEM.

Win10 as much as there is telemetry and monitoring, is really locked down and secure from "unauthorized" intruders and malware.
>>
>>55269863
>mathematica
>MATHEMATICa

>imperative
>>
How the hell do I debug a program that will compile in debug mode but not release mode.
I dont even know where to start.
>>
>>55269982
none of that matters because the user will always be able to modify the things on their system
perhaps it will be slightly more complicated, requiring you to boot from a usb and run a program that modifies your windows installation
and eventually the pirates will streamline it to make it simpler for the normies
>>
>>55270035
1. Read the error message carefully
2. Find an interpretation to it
3. Figure out a sequence of actions that might solve that
4. If it passes, exit, if not, go back to 1. with the new knowledge you have.

Since knowledge is increasing, this algorithm is proved to terminate.
>>
>>55269106
>is that where i learn the sick memes?
No, that's where your love for programming dies.
>>
>>55270107
> none of that matters because the user will always be able to modify the things on their system
Not on Win10. The user/admin is restricted. The flow of control goes:
Hypervisor -> secure kernel -> *kernel -> *usermode

Everything with a star next to it, can be controlled by the user/admin, so kernel can be accessed if you elevate to NT\SYSTEM.

Secure kernel is proprietary locked MS code. You can kernel debug it like I am from a VM. But from within usermode/admin/system, you can not access it easily, unless every pirate will start shipping vbox DLLs and requiring you to put WIN10 in a VM to use there software, it's not as easy as it once was.

Not saying it won't be impossible. But your generic video capturing tool etc is not going to cut it for Win10.

> perhaps it will be slightly more complicated, requiring you to boot from a usb and run a program that modifies your windows installation
EFI will stop you from modifying Windows. There is an entire chain of trust from boot to loading Windows 10 SUBSYSTEM.

> and eventually the pirates will streamline it to make it simpler for the normies
Pirate jobs have just become 1000x more difficult. You'll need exploits to get to secure kernel. And with MS instant updates with no choice to refuse. Exploit windows are very small. And people who find exploits nowadays won't be so quick to deploy them, as blackmarket from gov, to ruski, to chinks, all looking for nextgen exploits against there competitors and willing to pay big bucks.

Windows 10 when all this insanity is turned on, is an extremely secure OS.
>>
>>55270155
Its an indecipherable linker error telling me there a problem with a function. But if the problem was with the function it wouldnt compile in debug mode.
>>
>>55270264
Simplest solution is to torrent the cracked windows from said pirates
Then only 1 exploit is ever needed, because everyone can use that version and improve it by disabling windows update, packaging it with the good updates, etc
>>
Family and race traitor. I need your spiritual guidance.
I want to make an application to manage files on my file server. Adding/removing/listing files is all it should do for now. Nice to have features are user management and RSS support.
So that leaves me with two options: writing a website or client/server application. A website runs on anything that has a web browser, but requires me to write HTML/CSS which I don't like. A client/server application gives me the option to write a native client, but requires me to write a client for each platform I want to use it on (desktop, mobile) and maintain the code base.
What should I pick?
>>
>>55270405
Create the website with python +Django
Prablem salved
>>
File: xml.png (126KB, 2000x1835px) Image search: [Google]
xml.png
126KB, 2000x1835px
>>55269029
Is XML saving the world soon, /g/?

Before you bury me under a flow of insults, let me explain: I'm an Emacsgoer since birth, I've been using Org mode to try and write down and encrypt both transient items of my day-to-day life and permanent traces of important thoughts I've had, and I'm not all enthusiastic about its structure, especially in contrast to the XML I've seen during my internship. It comes down to several different things that IMHO break with the files+text based approach, namely:
- the markup syntax, yet another reinvention of Markdown with its own annoying idiosyncrasies, whereas XML was made to be a clean, robust, and extensible syntax precisely to mark up text.
- the PGP layer: maybe 3 ways to go about it, can't encrypt stuff you append without decrypting everything, or it becomes a mess, whatever. And attached files on top of that. I sense that an encryption plugin inside a nosql database would blow it off the water, amirite?
>>
File: mongodb.png (27KB, 413x484px) Image search: [Google]
mongodb.png
27KB, 413x484px
>>55270540
- directory or heading? inline code/data or attached file? the distinction should not exist, yet I don't know what to do as Emacs naturally chokes when files become too big. So where do I split up? And that literate programming support, omg... It works with simple expected use cases, but then you fuck it up or you edit something you shouldn't have...
- Orgmobile... OMG don't get me started on it. No offence, but SOAP+XML would have almost guaranteed a trivial mobile app that just works, no? Instead we have fragile-shit-over-ssh... ssh on fucking mobile phone ffs!
- A DB would be infinitely more efficient at packing archives and moving attachments around, it's hundred times researched, why reinvent the wheel?

Org mode is definitely free software, but it's definitely not open as it easy to extend like XML is. Anywhere I can look into to find a general hierarchical organiser that's freedomic and self-hosted? I'll say it, web technologies are far better at abstracting common basic stuff than whatever design principles GNU might have had... Please don't hang me!
>>
>>55270264
>>55270333
You guessed it...

...

...

...

INSTALL GENTOO!
t. my computer actually belongs to me.
>>
>>55270533
I was thinking about using Go since it has everything I need without using 3rd party libraries. How is Python + Django going to help me?
>>
>>55270333
>>55270107
no, consider iOS
there's a piece of immutable firmware which checks if the bios code is signed
the bios code then checks if the bootloader is signed etc.
the only reason jailbreaks exist is because of bugs in trusted code. there's a huge attack surface since you have physical access to the device and can do all sorts of things.
this is trust chain for boot is coming to PCs as well.
The best part is that free hardware has issues as well since if the user can change bios code, then so can malware.
And there are already freely available proof-of-concepts of various firmware/EFI/bootloader malware.
It's a lose-lose situation pretty much
>>
>>55270577
Because it allows you to make a website without writing any html which is what you wanted
>>
File: 2016-06-26-110518_1353x477_scrot.png (103KB, 1353x477px) Image search: [Google]
2016-06-26-110518_1353x477_scrot.png
103KB, 1353x477px
playing with sockets
>>
>>55270294
Google shit related to the general structure of the error, the language you're writing in, and the tools you're compiling with. Is it that it can't find this function or that it can't find something it needs from within that function? Surely something is misconfigured in the parameters for the release variant for reasons beyond your reach as a luser, as is consistently the case with modern shIDEs.
>>
>>55270608
I'll look into it.
>>
>>55270569
or whoever knows what code runs on ME/whatever amd has
>>
>>55269721
>jquery.min.js
problem is you are not calling it into the header, thank you for solving this and please share.
>>
File: swag.jpg (38KB, 580x346px) Image search: [Google]
swag.jpg
38KB, 580x346px
>>55270656
Ya rite. I guess that, as Apple becomes a PC vendor like any other in my view (yuno, same hardware, OS is just icing, and no-OS/GNU-Linux is becoming easier to find), we the elite will diverge to use fundamentally different machines with maybe a different architecture, but at least ones that can't run Winfuck because they aren't treacherous enough. That would be a situation where open hardware computers (Librem, Novena, Ubuntu, whatever) become the new macs while wintards don't change the least bit. Perhaps?

t. haters gonna hate
>>
File: 4bb8628f84.jpg (8KB, 343x61px) Image search: [Google]
4bb8628f84.jpg
8KB, 343x61px
>>55269029
Yesterday I added a mini player view to the r/a/dio app.
>>
File: screenshot.png (434KB, 1920x1080px) Image search: [Google]
screenshot.png
434KB, 1920x1080px
Working on my xscreensaver replacement.

Currently adding support for XRandr and DPMS extensions.

Picture related, screenshot of the saver I'm going to use.
>>
Have you used Hadoop yet /g/?
>>
>>55270830
>Java based
>>
>>55270830
no
seems useless outside of clusters, and most people here don't use those
>>
>>55270801
I'm not familiar with C#, but would it have any problem running with Mono on Linux?
>>
File: phosphor.png (24KB, 1280x720px) Image search: [Google]
phosphor.png
24KB, 1280x720px
>>55270808
Please, PLEASE don't forget the fully working phosphor pty! Pretty please?
>>
File: 1441920689438.jpg (89KB, 510x614px) Image search: [Google]
1441920689438.jpg
89KB, 510x614px
>>55270830
>Java
>>
Hello Graphic Programmers

Am I wrong to assume that an Index Buffer isn't worth it if the object only has four vertices? Trianglestrip.
>>
>>55270916
A person opened an issue exactly about that, I don't think it will work since Mono doesn't provides the WPF framework, and prolly NAudio doesn't works on Mono.
>>
>>55270921
I'm not going to remake any of the xscreensaver hacks, but I am likely going to add a support layer for them, so you can just use the already existing plethora of them.
>>
File: 1466914478276.jpg (649KB, 900x2200px) Image search: [Google]
1466914478276.jpg
649KB, 900x2200px
Can someone post a link to a collection of general, good CS pdfs? General books like pic related; it's annoying trying to find pdfs for individual books when I know someone out there has a google drive or a github where I can download a zip of all of them and delete what I don't want
>>
>>55270958
Oh well.
>>
>>55270931
>NEET
>>
File: DSC02237.jpg (3MB, 3200x2400px) Image search: [Google]
DSC02237.jpg
3MB, 3200x2400px
>>55269029
>What are your working on, /g/?
learning good stuff compared to you cs-fizzbuzz-pros :^)
>>
>>55271003
>PAJEET
Are you dealing with at least double digit TB?
>>
>>55270973
libgen.io has all the pdfs you need

this is also a good book, if interested in binary/floating point/assembly/optimization/memory/systems ect. It uses C for example code http://csapp.cs.cmu.edu/ I used the latest version in a CS class I just completed, the older editions are 32bit you want the x64 version.

No quality version on libgen I don't think yet, actual book costs ridiculous money
>>
>>55270630
Yeah everything basically says it can be impossible to determine the error. Only useful thing is that the difference between the release mode and debug mode could a difference in symbol maps.
>>
>>55270957
No. It's pretty standard to use just a vertex buffer for quads or triangles, obviously a buffer for UVs will become useless aswell.
>>
>>55271028
>learning good stuff compared to you cs-fizzbuzz-pros :^)
blinking diodes?
>>
>>55269289
As if anybody who knows Haskell isn't aware of that fact...
>>
>>55271028
Yeah we all took that class in freshman year too
>>
File: output.webm (2MB, 640x480px) Image search: [Google]
output.webm
2MB, 640x480px
>>55271079
>using NAND gates for a flipflop
>using a shift register
>using ADC conversion on atmega8a
>using diodes to verify everything :^)
>>
>>55271097
no class. just interest, m9 :^)
>>
>>55271114
Seriously, stop wasting your time. Fizzbuzz is a meme, but at least people are aware of that.
>>
>>55271047
yeah, I see a really shitty scan of it. i will check it out though, thanks for the info
>>
File: output.webm (3MB, 1920x1080px) Image search: [Google]
output.webm
3MB, 1920x1080px
>>55271156
>learning useful stuff
>waste of time
:^)
>>
>>55271068
Gracias amigo
>>
How is va_args implemented in C?
Is it part of the language, or is there some preprocessor magic that turns the ... operator into some magic that takes an arbitrary number of arguments like what printf does?
>>
>>55271179
care to inform any of us how this is useful
>>
>>55271195
probably just uses everything pushed onto the stack from the call
>>
>>55271199
>care to inform any of us how this is useful
this in particular is not useful, but creating a good knowledge base on microcontrollers can someday be useful.
Making simple projects which use all kind of crap in a microcontroller helps, m9
>>
>>55271219
>this...is not useful

okay
>>
>>55269070
I've done internships for the last few summers. I didn't learn shit besides how to work at that particular company.

>>55269061
If you want to learn more do research over the summer. I hope you go to a good school.
>>
>>55271219
Unless you're young and planning to go for EE, I doubt it'll be more than a hobby.
>>
>>55269058
>>55269204
>>55269221
>>55269273
>>55269289
>>55271093
Haskell is a trick to get "goyim" to waste their lives on something useless.

>b-but le Indians can't use Haskell
Neither can anyone else.
>>
>>55271279
>being this mad you don't understand such a simple language
>>
>>55271062
>it can be impossible to determine the error
Wtf are you working with? No seriously what is this platform on which link error are unsolvable? (and also whatcha gonna do?) Care to post details so we can all avoid that fuckery like the plague? Thank you very much.
>>
>>55271279
nice meme son

>neither can anyone else
This is obviously untrue, so you must be generalizing based off of your own personal experience. Since you are incapable of understanding Haskell, you would do best to keep your half-witted opinions to yourself.
>>
>>55271195
... is a special operator. The implementation is compiler and platform specific. On Linux with GCC and Clang the first 6 integer arguments and first floating point argument follow the standard calling conventions, everything else gets pushed onto the stack. The compiler generates the proper code for each call of va_arg whether the data is in a register or on the stack.
>>
>put to work on the company communication module
>have to maintain 5 different language implementations of the same protocol
shit was more painful then i imagined
anyone have experience to share with using grpc? (auto generated RPC based on protobuf)
>>
>>55271264
I am doing CE, m9
>>
>>55271331
visual studio 2015. avoid it.
>>
>>55270035
>>55271527
You've probably fucked up the settings
>>
>>55271527
You just have to learn the VS linker errors
You start to memorize what they mean eventually
>>
what were your guys' starting salaries at your first full-time? how much are you making now?
additional info like location would be nice

the shit i'm seeing on indeed and glassdoor varies wildly even in the same company so I don't know what's acceptable for a new grad
>>
>>55271730
what's your area? also can depend on if you have experience
>>
>>55271730
>what were your guys' starting salaries at your first full-time?
490k NOK (4 years ago)

>how much are you making now?
455k NOK

>additional info like location would be nice
Oslo, Norway
>>
>>55271279
i can smell your salt all the way from here pajeet
>>
>>55271891
>i can smell your salt
Is this some kind of modern euphemism for cum or something?
>>
>>55272002
Why do you smell of cum, anon?
>>
File: teqbean.jpg (3KB, 100x100px) Image search: [Google]
teqbean.jpg
3KB, 100x100px
>>55272002
xD good one
>>
File: 20090701122032.jpg (42KB, 450x370px) Image search: [Google]
20090701122032.jpg
42KB, 450x370px
Programming challenge: Create a function "randomCase" that takes a string and returns a string with all of the characters in the original string in a random case with equal probability of upper or lower.

i.e. randomCase("hello") might return "hEllO" or "HelLo"
>>
Working on developing a sort of rudimentary radix sort in C++. Having a bit of an issue, though. While the function header looks like this:

void radixSort(int loIndex, int hiIndex, int stringIndex, string (&arrayToSort)[])
, and I called the function by typing radixSort(0, 33, 1, StringArray), XCode is freaking out and won't let me compile because "There's no matching function ot call to 'radixSort' "
>>
>>55270540
XML is powerful but garbage.
Why <tag>content</tag> instead of "tag": {content} or hell, even <tag></>
The repetition and verbosity is tremendously stupid.
>>
>>55269058
Liquid Haskell, you baka. But GHC has full dependent types, so there's no point.

>>55269289
Monad is a monad, the point of abstraction is that you don't need to care about whether it's containing state, a writable log or whatever.
>>
>>55272115
This could probably be written better but it works.
void randomcase(char *str)
{
long len = strlen(str);
unsigned i;
for (i = 0; i < len; i++)
{
if (rand() % 2)
{
if (isupper(str[i]))
str[i] += ' ';
else if (islower(str[i]))
str[i] -= ' ';
}

}
}
>>
File: 3-18-15-large-266x300.jpg (55KB, 266x300px) Image search: [Google]
3-18-15-large-266x300.jpg
55KB, 266x300px
post the best code you've ever written.

i need some inspiration
>>
>>55272266
Nice try Bill
>>
>>55272266
sorry it's proprietary
>>
>>55272138
use
string arrayToSort[]

Also I'd suggest making that function static
>>
>>55272266
do {
nothing();
} while (lazy);
>>
>>55271730
In nyc you'd get 80-100k starting depending on the position+company
>>
File: 1370845911914.jpg (210KB, 600x445px) Image search: [Google]
1370845911914.jpg
210KB, 600x445px
Is developing C basically an insane idea to do on Windows?
Does anybody actually do it? What's the preferred editor?
>>
>>55271730
>for a new grad
Take whatever you think you deserve and cut it in half.
>>
>>55272115
(defn random-case [in]
(apply str (map #(if (= 1 (Math/round (rand)))
(clojure.string/upper-case %) %) (clojure.string/lower-case in))))

(random-case "fizz buzz")
>>
>>55272115
randomCase[s_String] := RandomChoice[{ToLowerCase, ToUpperCase}][#] & /@ Characters[s] // StringJoin
>>
>>55272329
Hm... I made the changes you suggested, and the function works as intended, (and this might belong in /sqt/, so be warned), but how would I be able to return arrayToSort? I know about passing by reference (which is why I had '&' in the initial function header), but it didn't seem to work when I did it

Thank you anyways for the pointers
>>
>>55272115
public string randomCase(string str) 
{
string rString = string.null();
for(int i = 0; i < str.length(); i++)
{
Random r = new Random();
if(r % 2 == 0)
rString + str[i].toLower();
else
rString + str[i].toUpper();
}
return rString;
}
>>
>>55272221
>Monad is a monad, the point of abstraction is that you don't need to care about whether it's containing state, a writable log or whatever.
...but that means it has side-effects, you dummy.
>>
File: StaySnugSmug.jpg (52KB, 517x524px) Image search: [Google]
StaySnugSmug.jpg
52KB, 517x524px
>>55272011
He masturbated.
>>
>>55272515
What does that even mean? It doesn't sense to say 'this thing has side-effects'/
>>
>>55272425
>Thank you anyways for the pointers
here's some more
0xFF928A821C9A81BC
0x9ADEADBEEFDEAD

An array of the form
int arr[] = {1,2,3};
is of an array type.
When you use
sizeof arr
it gives you the total size of the array.
However when you use an array it collapses down to a pointer, pointing to the first element of the array:
assert(*arr == 1);
assert(*(arr+1) == 2);
assert(*(arr+2) == 3);
assert(arr[0] == 1);
[...]

The conventional solution to your problem is returning a pointer to the first element:
int *f(int arr[]) {
return arr;
}


Keep in mind that you're already modifying the data within the array you passed, there's no need to pass the array by reference.

Also read this: https://stackoverflow.com/questions/5724171/passing-an-array-by-reference
>>
>>55272400
better:
(defn random-case [in]
(apply str (map #((rand-nth [upper-case lower-case]) %) in)))
>>
>>55272393
Damn anon that sounds like you learned from experience. Are you a hiring manager?
>>
>>55272646
too many characters

git gud or git out
>>
>>55272599
It means that every time you do an operation on the IO monad, a puppy dies because the monad is impure.
>>
>>55272671
kek
>>
>>55272679
Again, there's nothing like impure monad from the categorical/theoretical point of view.
>>
>>55272679
>IO monad is impure.
haven't we already gone over this?
>>
>>55272663
No but I've sat in on a lot of interviews for potential new hires.
If you have solid internship or past work experience in the field you can ask for more, but the biggest reason we almost never took fresh graduates was they wanted seasoned developer pay.

Understand your actual worth. Do you have prior work experience with the tooling they're looking for? Do you have prior internship experience? Have you personally written anything genuinely impressive on your github, or is it the same 90 half-written projects from "hacker challenges dot com" that every applicant has?

If you're expecting $35/hr, be willing to take $20/hr and negotiate in six months for a proper pay bump. If you're good at your job you probably won't even have to wait for that, one of the few grads we did hire went so far out of his way with everything he did that he got a 50% raise in his first three months.
Once you've worked for about 3-5 cumulative years of experience, then you can start jumping at 90k salaries.


Also those numbers are relative to where I live (non-metropolitan west coast) so just inflate it to whatever you live around. I think it's something like 50k where I live is roughly the same as 100k in balitmore once you adjust for cost of living
>>
>>55272709
>>55272719
in Haskell it is indeed impure
>>
>>55272719
>>55272709
Well, yeah, we already concluded it's impure (hence >>55269289)

>>55272777
Trips of truth
>>
>>55272795
Nice circular reasoning.
>>
What is the point of using the typedefs from stdint.h?
>>
>>55272760
Oh and by "sat in on a lot of interviews" I mean we don't actually have a specific hiring manager for my team. It's the VP, the project manager, product owner, and a fistful of devs (it's usually on a "if you want to" basis). The first three actually make the call but they more or less take our input as a yes or no.
>>
I'm used to writing programs with all variables global, and deallocating them explicitly. I like a lot of C++, but feel like I'm working against the notion of "scope" and a call stack in general.

I'm stuck trying to figure how to conditionally declare classes, have a consistent and unified way of storing them, without calling around everywhere, etc. It's becoming obnoxious. I don't know why I can't mentally trace a viable path.
>>
>>55272777
what is your definition of "impure" then?
>>55272795
code within the IO monad has no side effects and no mutable state
>>
>>55272816
Because int is anything from 16 to a Graham's number in bitwidth, whereas uint32_t is guaranteed to hold (at least) 32 bits.
>>
>>55272837
in Haskell specifically, IO is impure and acts in an imperative matter (i'm not talking about pure composition of an impur program) there's also unsafeDoIO and such
>>
>>55272849
What if you're trying to compile your software on a platform that doesn't support 32-bit integers?

I would think you can make your code portable simply by introducing bounds limitations using INT_MAX?
>>
>>55272837
>what is your definition of "impure" then?
Operations have side-effects

>code within the IO monad has no side effects and no mutable state
But that's wrong; the monad is stateful and state is mutated.
>>
>>55272866
>What if you're trying to compile your software on a platform that doesn't support 32-bit integers?
Then uint32_t will be implemented as two uint16_t in the same way 64-bit integers are handled on ARM32 architectures.
>>
>>55272861
> acts in an imperative matter
correct, however "act" means "mimic" in this case
>>55272872
code in the IO monad has no side effects at all. the side effects are part of the Haskell runtime, not part of the code you write. no part of your code is performing stateful/effectful operations.
>>
>>55272872
>Operations have side-effects
What operations? What side-effects?

>the monad is stateful and state is mutated
No it's not inside.
>>
>>55272917
>code in the IO monad has no side effects at all. the side effects are part of the Haskell runtime, not part of the code you write. no part of your code is performing stateful/effectful operations.
This is some serious mental gymnastics

>hurr durr it's not the code that causes side effects, it's the runtime that evaluates the code that causes side effects
>>
>>55272872
The Lambda Calculus and the Turing machine are equivalent to each other. Therefore, there is a translation mechanism that can encode any Turing Machine in the lambda calculus. A Turing Machine is inherently stateful. This means that pure functions can encode stateful behavior.

I don't know what you're trying to prove here anon, it seems awfully petty.
>>
>>55272917
>act means mimic
Not true, IO is ACTUALLY impure.
It doesn't need to be but it is.
>>
>>55272949
>The Lambda Calculus and the Turing machine are equivalent to each other
They're not. A Turing machine is inherently impure.
>>
>>55272948
It's like anon said the other time, but not about Haskell but the IO monad from a theoretical perspective - it's a pure program that returns an impure program.
>>
>>55272963
WHAT THE FUCK IS IMPURE???/?/??
>>
>>55272948
it's not mental gymnastics, it's a program that returns instructions of what to do to another program.
>>
>>55272974
>it's a pure program that returns an impure program.
MENTAL GYMNASTICS

>>55272980
Mutating state based on input, you idiot.
>>
>>55272760
Nah your company is just jew as fuck
>>
>>55272963
...anon, do you even know computational theory?

https://en.wikipedia.org/wiki/Turing_completeness
Any program expressed in the lambda calculus can be expressed by a Turing machine and vice-versa.

>>55272980
mutating state is what people usually mean
>>
>>55273003
>it's a program that returns instructions of what to do to another program.
By this logic, Java is pure.
>>
>>55273011
That's not mental gymnastics you retard that's a higher order program

What the fuck do you think compilers do?
>>
>>55273016
>>55273011
How does a fucking Turing machine mutate state while λ calculus doesn't?
>>
>>55273034
>What the fuck do you think compilers do?
So compilers are considered pure now?

Then ALL code is pure then, because it's ran through the compiler, and it's the returned code (aka the executable) that is impure.
>>
>>55273050
Turing machines are in essence a finite state machine, the same input can yield different output based on the state AND input can mutate this logic altering state.

Mutating state is considered a side-effect and the former is usually considered impure.
>>
>>55273054
>Compilers are considered pure
They fucking can be you idiot.
They take a string and output, bijectively, a byte string / a sequence of bytes

(this is ignoring the technicality of them only being passed the file by location)
>>
>>55273078
So if I write a universal Turing machine in lambda calculus, which is pure, the result will be impure?
>>
>>55273085
I'm glad we solved this once and for all then, any compiled code is pure (it is, after all, the code translated into bytecode that is impure, not the code itself) and there is no reason what so ever to use Haskell over, e.g. C or Java.
>>
>>55273034
>In spite of Haskell being purely functional, IO actions can be said to be impure because their impact on the outside world are side effects (as opposed to the regular effects that are entirely contained within Haskell). [1]

[1] https://en.wikibooks.org/wiki/Haskell/Understanding_monads/IO#Pure_and_impure

>>55273050
A Turing Machine writes to a tape. That cell is now mutated. The Lambda Calculus is just a set of rules regarding function expansions and abstractions -- you can replace any function application with its expansion and the expression is equivalent to the original.

That all being said, arguing it isn't wise to segregate side-effects to a set of functions that allow errors to be expressed vis-a-vis the type system is somewhat foolish. Haskell's IO system is an intelligent way to handle impurity, and while I personally favor Clojure, the system has influenced how I think about and write code in every language.
>>
>>55273107
>So if I write a universal Turing machine in lambda calculus, which is pure, the result will be impure?
Yes, just like an compiler on an interpreter is pure but yields impure result.
>>
>>55273032
no it's not, side effects are implicit and state can freely be modified in Java. and it doesn't even do what you just said it does. in Haskell, IO is just data
>>
>>55273127
>A Turing Machine writes to a tape. That cell is now mutated. The Lambda Calculus is just a set of rules regarding function expansions and abstractions -- you can replace any function application with its expansion and the expression is equivalent to the original.
Holy shit, how retarded are you? They're both abstractions. There is no 'tape' in a Turing machine, you fucking mongrel. The lambda calculus is as much a set of rewriting rules as a TM is.

>>55273133
OK, thanks for proving how mentally challenged you are.
>>
File: 4chan.jpg (218KB, 1106x838px) Image search: [Google]
4chan.jpg
218KB, 1106x838px
>>55273127
>mfw most haskell fags doesn't realize that IO is impure
>>
>>55273116
That's not the point you fucking idiot, and we're talking theoretically not fucking Haskell. Yes, if you want to be a fucking ass that can't communicate with people properly (read as: if you want to be autistic), machine code is just a sequence of bytes so it's just data. Doesn't mean you can't reason between pure and impure programming you dolt. In Haskell if it doesn't have IO in its type, then you can almost certainly compute it at compile time

>>55273127
The Haskell IO monad & implementation are ACTUALLY impure
>>
>>55273161
>There is no 'tape' in a Turing machine, you fucking mongrel
Do you even know what a Turing machine is?
>>
I want to make my own game engine using SDL and I want to make it a library so that I can use it for lots of stuff.

So I opened Code::Blocks and made a static lib project.

I then put a bit of SDL code in as a test and it compiled fine.

Now I'm trying to use that test library in another project but it just says that SDL.h doesn't exist from the header.

Am I dumb? I have no idea how to make a library.
>>
>>55273184
I don't think YOU know what it is.
>>
>>55273161
Part of how Turing machines are expressed requires a transition function that permits overwriting an existing value on some abstract tape apparatus. This action is the **definition** of impurity.
>>
>>55273192
CAN'T YOU SEE WE'RE BUSY ARGUING SEMANTICS
>>
File: nixos-logo-only-hires.png (88KB, 1183x1024px) Image search: [Google]
nixos-logo-only-hires.png
88KB, 1183x1024px
>>55273116
Nix strawman. Yet, I believe reading about Nix could give you a better understanding of when purity is useful. (Worked for me, -> https://nixos.org) That's being said while foolishly assuming you're curious deep down.
>>
The stupidity occurring in this thread right now...
Why would I come here.
Goodbye /dpt/.
>>
>>55273209
Exactly a fucking transition function, lambda calculus has reduction rules. What's the difference? None, it's just syntax.

That's a retarded definition, by the way, I don't think it's even mathematically valid. What the fuck is 'overwriting', 'existing values' and 'some abstract tape apparatus'?
>>
Why do Haskell fags shit up every fucking programming thread? Can't you shitheads go discuss semantics in your containment thread? Jesus Christ, you're literally arguing that you should only write programs that don't do any form of I/O at all. WHAT THE HELL IS THAT USEFUL FOR?
>>
>>55273212
kek
>>
>>55273192
You should be using gcc and makefiles. When you understand what the compiler / linker are doing, then use a more opaque IDE.

I genuinely believe attempting to either delve, or return, to the fundamentals is the solution for the majority of problems.
>>
>>55272115
const randomCase = s =>
s.split('')
.map(l =>
l[`to${Math.random() > 0.5 ? 'Upper' : 'Lower'}Case`]())
.join('')
>>
>>55273276
>WAAA I DONT GET HASKELL WAA
>NA NANA NA NA I CANT HEAR YOU

this is the daily programming thread not the weekly java forum
>>
>>55273276
>Boohoo my eternal general is getting replies about stuff I don't care about, what will I do
>>
>>55273209
By the way, having seen, attended and taught quite a few undergraduate math courses, it's clear you have the typical problem with understanding these abstractions in general. Don't worry, I had the same problem, it goes away with practice.
>>
>>55273276
>you're literally arguing that you should only write programs that don't do any form of I/O at all
That's literally the opposite of what we're arguing.
>>
>>55273166
People drink the kool-aid and start spouting off nonsense they don't understand. Having IO operate the way it does in Haskell is great, but IO is inherently impure and its wrong to pretend otherwise.

>>55273259
It is just syntax -- the two are equivalent. But Turing machines are impure: its operations have side-effects.

>A Turing machine is an abstract machine that manipulates symbols on a strip of tape according to a table of rules; [1]
If a symbol on a tape at a given cell changes, that is impure. That's my **definition** of impurity -- I'm saying that impurity is capturing this phenomenon.

>>55273311
I'm using abstraction in the technical sense, i.e. 'truth' is an abstraction typically labeled as lambda xy.x

Your condescending attitude is completely unjustified and makes whatever you say sound foolish. You'd get more people to listen to you if you had more respect.

Most of you are arguing semantics. It's pretty autistic.

[1] https://en.wikipedia.org/wiki/Turing_machine
>>
File: 1448043632456.png (234KB, 530x500px) Image search: [Google]
1448043632456.png
234KB, 530x500px
I'm writing an MPD bot in C++ that learns my music tastes and adds music to the queue for me.
Now when I kill MPD, ncmpcpp will just sit there and wait for MPD to come back up, how do I do this in my own client? I don't want it to exit on error if it goes down, and I think a "try connect and sleep and repeat" loop is inefficient. My MPD can be down for quite a while depending on where I am (I.E. not connected to my home server which houses all my music), so if I choose a low sleep amount, it will be waking my laptop up too often and wasting battery, if I choose a high sleep amount, then when MPD does come back up, it'll be quite a while before my bot catches on.
Are there any options I can pass to the socket descriptor to block until a successful connection is made?
I want the bot to be up at all times.
>>
PyQT or PySide?
>>
>>55273378
From a theoretic standpoint, the IO monad is used to build up a computation object

In a pure language, this object is simply returned. In an impure language, this object can be (literally, not in the bind sense) run.
>>
Working on the adding features to the library jawampa, for an internship.
>>
>>55273421
what's the advantage?
>>
Friendly reminder to filter the words monad and "pure" + "IO" in the same post.

Haskell autists need to be purged from this board.
>>
>>55273449
Fucking this.
>>
>>55273438
Well, if there's a function that doesn't have "IO" in the signature, you know it's pure and can be done at compile time, and can be memoized, etc etc. You can also isolate side effects and such.
>>
/g/, what's your vim color scheme?
>>
>>55273411
Something something async task.
https://www.youtube.com/watch?v=_z-RS0rXg9s
>>
>>55273421
This is true. It's a pretty cool effect -- I was using 'impure' kind of sloppily here. Read a sweet blog post about creating integration tests using this sort of behavior.

I love Clojure and get paid to write it but I shamelessly appropriate Haskell ideas. I've had a few ideas with how to encapsulate this sort of behavior intelligently in a dynamic language, hopefully I can start playing with some of them this week.
>>
>>55273411
Set the socket timeout to a very high value

https://stackoverflow.com/questions/2597608/c-socket-connection-timeout
http://developerweb.net/viewtopic.php?id=3196
>>
>>55273461
but what about imperative languages that have an explicit keyword for allowing side effects? does this make them pure?
>>
>>55273464
"wood"
>>
>>55273491
Obviously it doesn't -- Haskell doesn't have a specific keyword for its IO. IO is just a monad, and is in no way special. See what
>>55273421
said, as it is correct.
>>
>>55273491
No, that's not what I said.
With an IO monad, everything is built up as an object.
In a pure language, that object is "returned by the entire program".
In an impure language it is run. In haskell it kind of smudges the line.

In a pure language, any function that does IO must have IO in its type - it can't "look" at an input value, for instance, it can only say "this is what i'll do if i get an input value", and put that "todo" into an IO object
>>
File: 1454330292307.png (136KB, 800x969px) Image search: [Google]
1454330292307.png
136KB, 800x969px
>>55273378
>If a symbol on a tape at a given cell changes, that is impure. That's my **definition** of impurity
...and a quite superficial one actually. (No offence) If you can model mutable state as taking the old state in its entirety (in this case a list of memory cells for the Turing Machine) and returning a new version of it alongside with a value, then you have a pure fonction that expresses this idea of mutated state - and that's not just imaginary: that's what the State monad in Haskell does, and it is regarded as pure. I'd even argue that there is no impure implementation of Turing machines, given "pure" meaning that evaluating it doesn't affect the result of other functions, nor is its result affected by anything besides its inputs, because Turing machines aren't supposed to have side effects outside of a band that we can emulate, and that they aren't supposed to see anything from the outside world. What do you think? Also someone please my off-the-top-of-my-head definition thanks.
>>
>>55273526
(and before the language lawyers dissect this, I mean that you could use the FFI and create your own equivalent to Haskell's IO in Haskell)
>>
since lambda calculus came up as it invariably does in these threads, I've made a small lambda-repl-ish thing in python. If anyone is interested I could post links.
>>
>>55273547
I like Bjarne's thinly veiled disgust for typical human behavior.

It's by no means misanthropic, but it shows he's put up with enough shit to have a "this again" attitude. Refreshing.
>>
>>55273584
POST! POST! POST! POST!
>>
>>55273584
Where do you think you are?
>>
>>55273602
It's crap currently. Looking for any obvious errors or bugs. but go ahead and let me know if you find anything.

https://github.com/CodeGrimoire/ChurchREPL
It's also on pypi. ( I think version 1 is up) so a simply
pip install churchrepl
should work.
>>
>>55273627
/g/? Am I mistaken? I'm confused.
>>
>>55273543
You can model it that way, but that's not what a Turing Machine is doing. Once that write is accomplished, that data at that cell is lost. Using the Lambda calculus to implement this grants more freedom in the sense that you could create any sort of transformations to retain information at a cell and provide referential transparency to other abstractions. This means that in the Lambda calculus I can have only local effects, etc. by modeling a Turing machine this way, while the behavior of a Turing Machine always allows destructive (and thus impure) behavior.

>I'd even argue that there is no impure implementation of Turing machines
If I have a Turing machine that uses another as an abstraction the actions of one machine absolutely __can__ effect the other. It won't always necessarily, but the point is that this capability is a fundamental feature of the Turing machine.
>>
>>55273584
Not interested. Don't post something that will have little meaningful effect on my life either way.
>>
>>55273640
Which thread?
>>
>>55273664
dpt. I'm still lost.
>>
>>55273672
And what does dpt stand for?
>>
>>55273688
daily programming thread. You know instead of Socratic questioning we could have arrived where you want to insult me a good five minutes ago.
>>
>>55273641
I should also add that this loss in information is the source of criticisms for certain language paradigms.
>>
>>55273688
We stand for PROPRIETARY SOFTWARE

you open source communists need to get the fuck out
>>
>>55273700
This is the only way you'll learn.

Do you think it's really appropriate to post your programming project in a programming thread?
>>
Just bypassed some download protection on some music site and feel proud of myself.
What have you accomplished today that made you feel good about yourself <3?
>>
>>55273700
This. I'm very busy and want to see how anon will ultimately be insulted before I have to leave.
>>
>>55273724
Yes. And fair enough answer to the Socratic questioning comment.

>>55273719
when the hell did dpt become Proprietary.
Besides. it's maybe 400 lines incl. testing or python. It's hardly news worthy or profitable
>>
Just wrote a Chip-8 interpreter in C + GLFW
I now want to make a compiler that would take my own little scripting language and compile it to Chip-8 instructions.

I know only the basics about compilers (like the process, Parse --> AST --> output)

Any tips? Any good books / webpages I can read?
I'm also pretty new to C, trying to switch from Java.
>>
>>55273749
*of python
>>
>>55273749
So you should post it then, anon! Our bark is a lot worse than our bite here.
>>
>>55273770
Was not expecting! Thanks. I did post! That was a pleasant surprise
>>
Anybody get SDL_IsGameController() to return true for an afterglow 360 controller?

Using windows 8.1
>>
>>55272115
Just Rust my shit up

extern crate rand;

fn randomCase(s: &str) -> String {
s.chars()
.map(|c| match rand::random() {
true => c.to_lowercase().next().unwrap(),
false => c.to_uppercase().next().unwrap(),
})
.collect()
}
>>
>>55273767
dragon book
>>
>>55273780
I don't know Python, but I am generally wary of use of instanceof in Java. Is it considered good style in Python? Could you move e.g. the contains_lambda function into a method on lambda expression objects?
>>
>>55273864
(I mean isinstance in Python, my guess is it's similar to instanceof in Java)
>>
>>55273780
Oh, and (slight) apologies for messing with you.
>>
>>55273864
Yeah I threw this together pretty quick. I'll look into a better implementation. something more polymorphic.

>>55273881
I got it.

>>55273893
No need! it was funny!
>>
>>55273903
From the readme it looks sensible so far, and what I assume is the parser spec is very neat and tidy.

Which evaluation strategy will you use, or will you let the user choose? I don't see eta or beta reduction implemented yet, so I assume that's still to be written?
>>
>>55273861
Thanks, anon. Didn't know what it was. Risky google.
>>
>>55273996
Alpha conversion is implemented. Beta is being written mostly today
I have to figure out how i'm going to do lazy evals. Recursion blows the stack currently.
>>
Hey best friends, I'm working on a paint-like application, I have a question about program architecture.

I've got 3 different sets of options

1. Colors
2. Brush type (pencil, squares, spray can etc)
3. Some settings for symmetries

Since I have 3 different html forms, one for each of them, I wanted to structure my application in an MVC-kind of way.

As I understand mvc, that would result in 9 files, 3 html views/templates, 3 controllers and 3 models. But I have a problem, my actual brush logic needs all settings from all three those models, to draw a line I need to know what color to use, what brush is selected, and if it should mirror or not.

Should I pass all three of these models into a higher-level mvc-component or something? Is MVC even nestable?
>>
>>55273996
I'm sure I could put in a flag for users to chose evaluation strategy after lazy is done.
>>
>>55274041
Everything is nestable
>>
>>55274041
I'd say it sounds like you need a data structure that encapsulates your application settings that you can provide to your different components.
>>
>>55273709
>I should also add that this loss in information is the source of criticisms for certain language paradigms.
Agreed. Not all data structures are persistent, do I add just to bring in the word.

>>55273641
Fuck it, not gonna respond in details: I should be sleeping rn. The point I disagree with you on is this defining purity thing: Wikipedia has the same definition I already wrote, and I think yours stems from a misunderstanding.
>evaluating it doesn't affect the result of other functions, nor is its result affected by anything besides its inputs
Looking closely, a pure function could be implemented with mutable variables internally - as long as this doesn't bleed out - in which case mutability does lead to impurity. But if you think all mutability is inherently impure you're wrong, as I just showed. If you're not sure, consider this: if two rigourously identical implementations of the same function are written one in an imperative manner and the other in a functionnal manner, does that mean this function is sometimes pure and other times not? Doesn't seem right to me.

As for Turing machines: they are pure given this definition, I still believe that. Their result depends only on their program and their input, and they have no effect besides their output, so if you wrote an impure Turing machine interpreter, you did it wrong. I'm not sure what you have in mind with your second paragraph, so I'm not directly addressing that, sorry. I'll check this thread tomorrow, see you.
>>
>>55274072
>>55274058
Hmm yeah, feels like I was overthinking it. I can write a small data structure that encapsulates all my settings which can then be passed around throughout the application
>>
>>55274020
Yeah, lazy evaluation is tricky. You could create a class Lazy that initially contains an unevaluated lambda expression, and that saves its result and reuses it for repeated evaluation requests, and then make substituted variables point to these Lazy objects. I'm not up to thinking about whether it would fix your stack problems, though.
>>
>>55274151
MonadState
>>
>>55274175
I was thinking of just adding in some c extension modules. There's a good base setup already done. just needs a little polishing.
>>
>>55274192
JavaScript, not godLang, sorry
>>
>>55274082
>a pure function could be implemented with mutable variables internally
Yes -- but while that pure function is globally pure (which is what we __really__ care about) it is definitely locally impure. This is usually acceptable, so languages like Clojure let this happen via Transients and the like.

>two rigorously identical
I'm not sure what you mean by this; in general it's impossible to prove two algorithms are equivalent.

>Their result depends only on their program and their input
Globally, yes. It seems that we're just confused on the global vs local purity issue. We could even claim that a program like Bash is *globally* pure. We're really just arguing about what granularity of purity is tolerable in the creation of robust applications. My school of thought is that mutations local to a function and thread are typically safe, whereas global mutations need a protection mechanism in place.
>>
Does anyone have an example of a programming language that doesn't have block syntax but some other sort of structure?
>>
>>55274216
functional languages?
>>
>>55274216
befunge
>>
>>55274216
Prolog
Haskell
>>
>>55274216
Python? White-space indentation?

Common-lisp (or any other lisp for that matter)

(defun test-* ()
(let ((*test-name* 'test-*))
(check
(= (* 2 2) 4)
(= (* 3 5) 15))))
>>
>>55274208
PureScript? It compiles to JS
>>
So many quick replies, wow.

>>55274237
This one is wrong, because those are still blocks, just with alternate syntax.

>>55274226
>>55274233
>>55274236
Could you guys post an example? I was under the impression that at least haskell and most other functional languages also had block structure (I know that OCaml does).
>>
>>55274305
Here's some Befunge
 v>>>>>v
12345
^?^
> ? ?^
v?v
6789
>>>> v
^ .<


It probably won't compile. spacing matters and I'm sure formatting got lost along the way
>>
>>55274305
I mean they look like blocks but they really aren't

Haskell, for instance, is __generally__ pure
>>
>>55274305
What looks like block structure in Haskell is just repeated function chaining:

do
x <- f
y <- g x
h x y

-- is equivalent to

f >>= (\x -> (g x) >>= (\y -> h x y))
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
where can i learn how to use API s?

does anyone have a good website or book?
>>
>>55274082
And correct me if I'm misunderstanding here, but the wikipedia definition of purity requires that:
>Evaluation of the result does not cause any semantically observable side effect or output, such as mutation of mutable objects or output to I/O devices

I'd say that altering a tape-cell is a text-book example of mutation of a mutable object.
>>
>>55274347
ah, that's that weird 2D-like language, right?

>>55274352
Maybe I'm not communicating what I mean properly

https://en.wikipedia.org/wiki/Block_(programming)

They are blocks because they're groupings of statements and expressions. A pure language will still have expressions (function application and evaluation). My question just arose because I was reading something and they keep talking about block-structure as if not every language had it, when I can't think of any counter-example.
>>
>>55274413
Which APIs?
>>
>>55274428
It's one of them, yes.
>>
>>55274017
gotcha boo
>>
>>55274439
anyone
>>
>>55274428
>a language without expressions
What, like assembly?
>>
>>55274428
And they're not blocks.
Haskell doesn't have statements, it only has expressions.
>>
how difficult is the build process for Rust programs? if it's as difficult as for C programs, then fuck Rust.

seriously, who the fuck created this insane mess? this piece of crap makes me want to kill myself
>>
>>55274606
What's wrong with make?
>>
>>55274606
Is gcc -lX foobar.c so hard?
>>
>>55274563
Well, what do you want to write a program to do?
>>
>>55274580
I'm still not sure Haskell doesn't have a block structure, sort of. I can't quite explain it, but you can have things like

if wtv then g(2) else f(3)


g and f here kind of act like blocks. I don't know if you understand what I mean.

>>55274567
Kinda. Fortran too.
>>
>>55274612
oh, I don't know, an0n...

>>55274629
it is when you are trying to cross-compile, have to use a shitload of libs, each one with its own bugs, quirks, and so on.
have you tried compiling anything other than a hello world?
>>
       ~  +##################################################+     
~ # #
~ # ------- ----- ----- ------- #
~ # | | | | #
~ # | ----- ---- | #
~ # | | | | #
~ # | ----- ---- | #
~ # #
~ # * * * * * #
~ # \\\\\\ #
~ # * by RV * #
~ # \\\\\\ #
~ # * * * * * #
~ +##################################################+
~
~ ====================================================
~
~ @@@@@@---- Basic Shapes (Small) ----@@@@@@
~
~ $SQUARE $CIRCLE
~
~ * *
~ +----+ * *
~ | | * *
~ | | * *
~ +----+ * *
~ * *
>>
>>55274612
>>55274629
>I have never compiled anything beyond my first hello world program.
>>
>>55274666
It's not a block, it's an expression.

in Haskelly
if c then x else y
evaluates to either x or y depending on c
it doesn't 'execute' x or y
>>
>>55274683
circle is a little off mate
>>
>>55273378
>Most of you are arguing semantics. It's pretty autistic.
Welcome to /g/ - technology
>>
>>55274718
const $ const Norsk
>>
>>55274670
I don't even think rust supports cross-compiling.
Also, I think it might be you that's the retarded one.
>>
>>55274718
>for å snakker
>Ã¥ snakker
Lær deg norsk, din taper.
>>
>>55274666
They're still just expressions. You can write if-then-else as a function:

if :: Bool -> a -> a -> a
if True t f = t
if False t f = f


Then your example becomes:

if wtv g(2) f(3)
>>
>>55273411
exponential backoff
>>
>>55274718
shut up you dirty socialdemocrat pig
>>
>>55274688
I understand what you're saying, but I disagree with part of it: It does "execute" x or y: It evaluates the arguments of the functions and then applies the function definition to them. This is executing orders, even if they have no side-effect/there's no notion of state.

My problem is in forming clear, non-circular definitions of the following concepts:
Block structure
Scoping
Statement
Expression

I have a "sort of" idea of what each one of them is, but I can't see how you can have scoping without having a notion of a block. For example, in haskell,

let w = 5;

^^^^^^^^^^
let f w =
w + 2;;
vvvvvvvvvvv


The first w's scope would be everying pointed by the ^^^ and vvv, and the second w's scope would be everything else. I cannot understand how the "let f w ..." expression would not be considered a block, nested in outer one. Additionally, I have an hard time justifying that haskell doesn't have block structure just because it doesn't have statements, when, as I understand them, all expressions are statements.

This might not be a discussion for /dpt/, but I don't know where else to go.
>>
>>55274788
Careful. Remember Haskell uses lazy evaluation. Function arguments are only evaluated if they are used.
>>
>>55274788
It does not execute
It has evaluation order
Evaluation is not execution
That is not a block, that is a scope
>>
>>55274811
haha, but that doesn't matter, it just means the function is applied first and the arguments are evaluated later

I just hope I'm not looking too stupid
>>
Learning concurrency in Ada for a course I have to do next semester
>>
>>55271179
>i can't a make shit register without fucking something up
>>
>>55274821
you can't make a self application such as the Y or Z combinators without carefully hacky tricks or lazy evaluation.
>>
>>55274821
Don't worry man, Haskell is very different from most mainstream languages, it's difficult to get one's head around. I'm having a difficult time explaining it, but one way might to be think of it this way: Haskell has no way to sequence statements like C or Java or whatever, there's no semicolon.
>>
>>55274736
>calls other people retarded
>is unable to google "cross-compiling rust"
>has never compiled anything beyond a "hello world" program
>>
>>55274737
Well shit, I spend ages trying to make sure I'm using a correct preposition and then I fuck up the infinitive.
>>
>>55274860
>he thinks his opinion matters
kek
>>
>>55274820
I'm sorry but you're basically just repeating things I have heard and am aware of, but not really justifying them. I'll try to explain a bit again:

>It does not execute
>It has evaluation order
But an evaluation order still introduces an order in which parts of an expression must be resolved first, like sequence points in C introduce order for the execution of statements. How do you make the distinction?

>Evaluation is not execution
I know, but at the same time, I do not. How can you disassociate the two things when they are to similar? Evaluating is reducing an expression to a simpler expression, executing is carrying out orders.

>That is not a block, that is a scope
But the scope of each of the w's is predicated on there being logical "blocks"/areas of code which you can isolate and talk about. Why do you say that the w parameter shadows the global w? Because it's in a block which extends its "superblock"'s environment. No?

I would greatly appreciate all points of view and explanations on this matter.
>>
>>55274850
No, no, I understand that haskell, like ocaml (; aside) doesn't allow you to say "this expression will be reduced before this one". But how does that mean that there's no execution of instructions? Is it not just a semantic battle?

>>55274833
You will need to explain that in non-category theory terms please.
>>
I have to sort a singly linked list composed of words from the entirety of War and Peace. My sorting algorithm works but I need to do the sort in under 20 seconds and I am nowhere close to it. Can anyone give me any hints?
>>
New thread!!!

>>55274909
>>
>>55274910
If you absolutely have to use a linked list, you might consider mergesort.

If you can use an array instead, then do that and use quicksort.
>>
>>55274918
I have to use a singly linked list (it's a uni assignment). I tried to use merge sort but failed horribly, I'll give it another go.
>>
>>55274767
>MPD goes down for hours
>Comes back up
>Hour later, bot realized MPD is back up
Yeah no.
>>
>>55274906
Basically because you evaluate arguments first, if you have first-class object functions (like python) you will evaluate a function as an argument first.
Now let's say we have this code:
def Y(f):
arg = lambda x: x(f(f))
return arg(arg)

Do you see the problem?
In lazy evaluation if x returns null or some object in which f is not called then you are fine.
Otherwise, f gets evaluated. and then that inner f gets evaluated &c &c... Without lazy evaluation fixed-point combinators (like the one above) are difficult to do. if not impossible. Feel free to correct me anyone, I'm pulling this out of my ass.
>>
>>55275119
should be
arg = lambda x: f(x(x))
sorry.
>>
>>55275119
>>55275136
ah, ok, I think I understand you.

I don't want to be rude, but I don't think that is related to my question about scope though
>>
>>55275154
probably not. I just wanted to clarify lazy evaluation
>>
>>55275183
thanks
>>
>>55272866
>What if you're trying to compile your software on a platform that doesn't support 32-bit integers?
Same thing as when you used 64-bit integers back in the day on pre-64-bit hardware, the compiler will automatically write instructions that deal with it as a pair of 32-bit (or smaller if your platform is really old) integers and deal with this detail for you

Being 32-bit or 64-bit or whatever doesn't automatically make it impossible to do arithmetic with larger numbers, it just means that's the word size the processer can natively work with so it's most efficient when staying within those bounds

>I would think you can make your code portable simply by introducing bounds limitations using INT_MAX?
No, the actual size of C's standard integer types varies wildly depending on the platform you're targeting and therefore so will their numeric range; when you use stdint.h you at least know exactly what you're getting and for some applications (anything with different data formats or deserialization) that is absolutely essential
>>
>>55274684
If it's really that hard for you, use qmake. I use it on most of my larger projects.
Thread posts: 318
Thread images: 34


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