/dpt/ - Daily Programming Thread

Old thread: What are you working on Cred Forums?

Other urls found in this thread:

github.com/lehitoskin/ivy.git
screeps.com/
docs.python.org/3.6/library/hashlib.html#hash-algorithms
github.com/nick-gits/calcupy
reddit.com/r/golang/comments/552gfp/go_has_spoiled_me/
docs.racket-lang.org/reference/concurrency.html
en.wikipedia.org/wiki/Progressive_enhancement
tour.golang.org/
golang.org/doc/
webchat.freenode.net/?channels=go-nuts
golang.org/pkg/go/build/
twitter.com/NSFWRedditGif

First for anime boobs.

>First for anime boobs
>Doesn't post anime boobs

Can you please change it up at least once in a while?

how do I describe myself if I do python, programmer, coder or scripter

How do you post code in the white box? Do you just upload a .c file?

>inb4 newfriend

post your workspace station

What is the best functional language to get into FP for someone that never done FP.
I know in order of skill:
Java, c++, python
(love python though)

why is this only 389 KB and is 557 KB

read the sticky, newfriend:

Yes, upload the file through where you normally upload an image

read the sticky, newfag

Haskell

or ocaml/F# if you're still an imperative oop baby
or lisp if you're a dynamicfag

Thanks friendos. :^)

>seen these threads for years upon years
>if I had started programming back then I'd be OK/decent by now

/blog cya guys

What do you think about Scala?
I know Play framework supports it, so that's a big plus for me.

Imagine someone took a really nice FP language then took a massive sweaty Java dump on it

Start now.

Can you even see anything with a font that small.

Sonar software that makes a 3D map through mic's sound for MS. Pretty big team.

prettty cool

how do the sensors work exactly, is it like a bat?

give more information

Since WDG is dead...

NodeJS is giving me a case of the cancer.
Are there any non-cancer alternatives? I just want to make a webserver users can log in to, and be served some data through ajax calls or whatever.
Is there any way to do this without requiring 27 npm modules? Do I have to use PHP?

>Do I have to use PHP?

why not? why are you using nodejs? because its cool and trendy?

fuck outta here

"Script Child", or something of the sort

>Since WDG is dead...
Fuck off

>implying there are only two backend technologies out there
Ever heard of python, rails, java, C#, *insert almost any language here*?
But why so harsh? /wdg/ is always dead, and you rarely can have a normal conversation there. I think /dpt/ and /wdg/ should be the same thing, since the subject is very similar. Web programming is programming after all.

Should I just be using vectors all the time in C++? Seeing as I can't make an array an attribute (no really wtf)

>webshit is programming

>But why so harsh? /wdg/ is always dead, and you rarely can have a normal conversation there. I think /dpt/ and /wdg/ should be the same thing, since the subject is very similar. Web programming is programming after all.
No
No
No
No

I hate you and everything you believe

>I CANNOT HANDLE BANTER

>banter
I wasn't joking

GAS THE WEBSHITS

DPT NOW

no false flags

Arrays in most modern languages are pretty much useless (with very few exceptions), so yes.
Can you please elaborate?
Prefferably using arguments and not Cred Forums tier "kys" type responses?

>Ever heard of python, rails, java, C#, *insert almost any language here*?

Well that's why I'm asking. I have heard of those technologies but I can't make an informed decision myself. Rails I know is just as much of a clusterfuck as nodejs. ASP.NET is probably too enterprisey?

/dpt/ and /wdg/ are not remotely similar
Nobody in /dpt/ wants to join with /wdg/
Nobody in /dpt/ wants /wdg/ here

Don't you need stereo audio for that?

>Arrays in most modern languages are pretty much useless (with very few exceptions), so yes.
Been trying to force the issue because lolfaster thinking it will matter one day, guess I'll just stop doing that.

I would suggest python.
Rails I never used but heard mixed opinions.
C# and Java, yeah for 'simple' websites (i. e. not big, complicated systems) probably too enterprisey.

Java, C++ and Python all support functional styles, like higher order functions. If you've never used any of that, you should.

If you want to learn FP, +1 for Haskell. It's uncompromisingly pure and will not fool you into thinking you know FP because you've copy-pasted Java code into a scala editor.

If you need to use FP in practice right now and you don't care so much about learning, Scala is better for the same reason.

You still didn't give any argument.
I seriously don't get it. What difference does it make if the frontend of an application is a desktop GUI or Web page?

Just chose something. Once you start working, you'll figure out what your pain points are and can switch to something you like better.

GUIs don't count either

>You still didn't give any argument.
It's easy to see how a blind person might think that

How to find non-cucked open source projects to work on?

Webdev is usually just a mish-mash of spaghetti code, with people usually not learning what's going on, just following tutorials or modifying other people's code until it does what they want. The /dpt/ is more of a discussion of the act programming than /wdg/ is.

I did. I chose nodejs. My pain points are the five thousand node modules you need to install to do anything, and the fact that they're all running on god knows what version and nothing is compatible with anything else. The documentation is shit, and the writeups from people significantly more patient than me who have managed to configure everything correctly are all outdated and use some unspecified version of everything. That's why I'm here.

ASP.NET is fine. It's like PHP with a (much) better backing language. It's not enterprisey at all, quite the opposite.

The problem with it is that it really only runs on Windows*.

* Don't try to argue against this unless you actually host a modern ASP.NET site on mono right now.

in my required assembly language class

I don't like this.

Assembly is fun, I wish my Uni had a class for it

I'm very out of the loop. What are my chances of hooking up some affordable ASP.NET hosting nowadays? Do I need a dedicated windows box for $100s a year with all the pains of configuring it that comes with it?

Try php. It was pretty comfy for me. Although it's a shitty language in itself, it's an established language for server side scripting.
OR you could try out some other language you wanted to try out. Most other languages use web frameworks on top of the language itself so it might suffer from what you don't like. PHP was made for web so it pretty much just works.

Is this real life?

Still no argument.
Ok, that's a fair statement I actually agree with, I see where the hate comes from now. Thank you for actually putting anything into this conversation.

I guess it would be: PHP is easier to get into webdev (very straightforward), but python is just a much better language (with far more use cases so it might come in handy in the future).

are you trying to make me feel dumb

What you learned or done in the class? I've had fun with mine too.

no we just started learning and he doesn't explain very well and I'm having trouble following, lol.

no, just hungry for quiche

Yes

Hi Cred Forumsentoomen

I'm wanting to start studying to gain some sort of qualification or certification for c/c++/c#

Are there any worth my time doing?

Preferable it will be study at home or weekend to fit around a normal job/routine.

Some one please point me in the right direction, I plan on doing some freelance coding on my spare time as a secondary income stream. I have already learned a lot of C# and i'm currently self studying C in a linux enviroment.

cheers mates.

>I can't make an array an attribute
wut

>I just want to make a webserver
That's the reason why PHP and SQL exists!

Where da sticky? /new/ here but I don't see it

...

go to www.Cred Forums.org/g/ first post is the sticky.

Literally the board sticky.
also code tags are [code /code] with [] on both sides
... dumbass

>tfw legit working on getting a big boy job

How do I make it so that instead of looping in the while loop and printing "TOP" "TOP" "TOP" over and over again, it only prints out "TOP" or "BOTTOM" etc... if it changes?

int main(void)
{
int t, b1, b2, b3, b4; //t for time, b1-b4 for buttons
double ax, ay, az, gx, gy, gz; //Accelerometer and gyroscopic data in x,y,z

while (TRUE)
{
scanf("%d, %lf, %lf, %lf, %lf, %lf, %lf, %d, %d, %d, %d", &t, &ax, &ay, &az, &gx, &gy, &gz, &b1, &b2, &b3, &b4 );
printf("Echoing output: %d, %lf, %lf, %lf, %lf, %lf, %lf, %d, %d, %d, %d \n", t, ax, ay, az, gx, gy, gz, b1, b2, b3, b4);
printf("At %d ms, the acceleration's magnitude was: %f\n", t, Mag(ax, ay, az));
if (Mag(ax, az, ay)

>I live outside of the US, can I apply?

>No. Right now, we are only placing the candidates in the US.
well thanks for nothing.

Save the variables each iteration and compare them the next iteration.
Something like this:

while(TRUE) {
// skip this iteration if same values as last iteration
if (prev_ax == ax && prev_ay == ay) continue;

...

prev_ax = ax;
prev_ay = ay;
}

Thanks! However I don't think solves my problem (unless I'm being a retard)

The background on is transparent.

Fuck, ignore the deleted post, I wasn't paying attention.

Use a boolean to keep track of the last state and only print if it changed.

assembly is the most boring way to develop software.

k&r ex1-18

What do yo think?

#include

#define MAXCHAR 256

/* Remove trailing blanks and tabs */
int main()
{
int c, nc, nb;
char line[MAXCHAR];

nc = nb = 0;

while((c = getchar()) != EOF) {
line[nc] = c;

if (c == ' ' || c == '\t') {
++nb;
} else {
if (c == '\n' && nb > 0) {
nc = nc - nb;
line[nc] = '\n';

if (line[nc - 1] == '\n')
--nc;
}

nb = 0;
}
++nc;
}

if (nb > 0)
nc = nc - nb;

line[nc] = '\0';

printf("%s", line);
return 0;
}

except ax,ay,az,gx,gy,gz are all being read in from a controller, and I'm only using them to determine an orientation, then printing the orientation. Could I do something like this and somehow check on controllerState to not print if controllerState = previous controllerState?

(in main)
if (Mag(ax, az, ay)

Ignore this, I'm an idiot.
brb killing myself

nc -= nb

i don't see why that would make any difference

the color and transparency are constant in both cases

Well good thing this is an anonymous image board.
Otherwise we would make fun of you for the rest of time.

You are right, but that operator hasn't been introduced yet.

Trying to do it from zero to please my "do it by the book" autism.

That's the gist of it yeah. The reason this is giving you some trouble is because you don't have proper separation of concerns. You do some printing in main and some in Orientation. Let the menu/ui part (in main) consern itself with printing stuff. Let Orientation consern itself with calculating the orientation. Imagine if you instead had

char* Orientation(double gx, double gy, double gz)
{
double tolerance = 0.15;

if (Close_To(tolerance, 1.0, gx))
{
return "RIGHT\n";
}

... etc.


Then you could easily
if (Mag(ax, az, ay)

What are some porn related programming tasks
if any of you have done anything interesting please share

scrapping Cred Forums threads looking for facebook pictures

is /wdg/ dead rn

already done something with scraping, just imagefap

Damn this just made everything click for me. Thanks a million.

A porn site I browsed let you sort by age, boob size, ass size, etc, but you couldn't do a more advanced search other than a single column sort. I wrote a scraper to grab all of the models and their attributes and dumped a .csv file. Now I can find the 21 year old chubby blondes with giant asses with no problem.

And what are you waiting for to share ?

Wow, this sounds amazing. It'd be like having those character sliders in video games, but with pornstars.

It's possible to get an adv here ? if yes{

Computer Science student on 2nd year, in need to get a new computer. im pretty much thinking about getting an MacBook Air due to it's lightweight, easy to take to classes. BUT i also do some photoshoots and filmmaking for hobbie. Any adv ? At start i was thinking getting 2 machines, but it will be a little bit pricey i think.
}

hey that's a cute idea

there's tons of sites that have pornstar bios, you could very easily make a program where you input stats and it returns a list of the girls that fit the criteria

you can make a toy query system even and even make rules and shit

Thinkpad all the way. Got a really nice one for around 1200 but I know you can get ones for cheaper. Super durable, sick keyboard, and better OS

>in 10 years time every male will be an expert in SQL

Get an MBPr. The better screen will help. No reason to get 2 laptops. What would the second one have been anyways?

Webdev here, JS or plain html?

Why are you even asking this question? You should know based n what you're going to do

I was thinking about a iMac and a mbAir

hmm, ill take a look on em, but i'm kinda have a hipster spirit on me... wanna look good...

Haskell

r-right... I mean... this thread isn't about asking questions... Well... I was always being rejected by anyone including Cred Forums... I'm sorry for the disturbance... I'll end my life. :(

>hmm, ill take a look on em, but i'm kinda have a hipster spirit on me... wanna look good...

you already knew what you were going to buy before you asked the question

fuck off drone

Give Ruby a try. That's what all the hipster programmers are using, and if you get good at it and don't mind doing fucking web development for a living you can make decent money writing it too.

Learn Racket.

You should have been more specific. I myself prefer pure HTML before relying on JS. Of course, when I use JS, I also don't go and use JQuery to bloat my page. Or Bootstrap. I roll my own.

>it's called ruby on rails
>there are no rails

I'm calling my fucking lawyer

c'mon, don't get mad, i said i'll take a look, there's a chance...

Sob sob Cred Forums doesn't care about me.

If you really want to learn web development, follow a tutorial and learn the absolute basics about how HTML/CSS/JavaScript work together to make web pages.

Then, work on a small project on your own. It's SUPPOSED to be shitty and useless, but you'll learn. If you have issues you don't know how to fix, google them first and if you really can't find an answer then ask a specific question.

If you're willing to spend a few dozen hours and actually put in the work necessary, even a complete retard can learn how to make a website.

...

This.
My website is pretty much just paragraphs. and links.

Ruby is a nice language, but Rails is a bloated shitpile. You're better off without it.

Plenty of good web scraping practice to be had there family

Oh... Actually my question is: Would you prefer pure HTML website or are you fine with Ajax loaded content?

Companies are big fans of bloated shitpiles though, so if you want to make stupid amounts of money learn Rails and join a Ruby consultant firm.

Whichever makes better use of Haskell

If the purpose of your website is simple, like a personal homepage or something that just displays data/images/whatever, then a static website is going to be best because it's fast and simple and easy to maintain.

If you want dynamic content, you're going to need to have some kind of JavaScript-powered thing.

I would prefer pure HTML. I think Google does too if you care about SEO.

How fucking pathetic can you be?

Look for ones written in Racket.
github.com/lehitoskin/ivy.git

Said a guy browsing Cred Forums

what i just like porn
programming about things you like feels good

no bully

make porn games.
if youre lucky you could make quite a bit of money from it.

>If you want dynamic content, you're going to need to have some kind of JavaScript-powered thing.

No. If you want dynamic content, generate it on the fucking server and serve my browser a nice, self-contained, "static" HTML document that I can view and save in its entirety without having to download and execute your buggy and slow JavaScript code along with 20MB of frameworks and libraries it depends on.

Currently working on the ASCII Art challenge on codingame.com

the site has a lot better setup than the rather dry and boring practice sites i have experienced.

there's a command line tool named "rails"
were you mad when you didn't receive a physical gem

>>xxxxxxxx
Anyone use Lynx as their primary browser or this is just another meme?

I hate Javascript frameworks too (they were useful in the past with IE but are basically memes at this point), however raw vanilla Javascript is usually fine.

>xxxxxxxx
I forgot Cred Forums censored passwords

$z=398)

Not him but I'm still waiting for my JavaBeansâ„¢ to make some sweet coffee.

hunter2

>were you mad when you didn't receive a physical gem

I'm still mad that scaffolding doesn't build REAL scaffolds.

This site could be so much better though.
>Bloated
>Boring step by step multiplayer games
>Servers take years compiling 3 lines of C
>Terrible artistic theme

It's made in France so...

DOCLAY FizzBuzz:

REGISTER i ARABIC 1 1;
REGISTER mod3 ARABIC 1 1;
REGISTER mod5 ARABIC 1 1;

DEFAULTS
SET
WHILE = "${i}

Is this the new self-obscurificating language everyone talk about?

How could i block direct access to video on my server?
Is it possible?

>block direct access to video
u wat

you know anything better ? I am just happy it gets me programming every day.

block something like
mysite.com/folder/video.mp4
Can i block that?
So videos can be only played through player?

What are you trying to say, buddy? Our lord and savior OCaml comes from France!

So it doesn't use the native HTML5 player and people can just right click download it?
I guess you can just write your own player but not sure how effective it'd be.

Can't you just change the permissions on the server?

yes you'd have to disallow direct linking (i.e, inspecting packets to make sure they're going to a webpage rather than the direct .mp4 video)

Porn sites do this sometimes to prevent downloading their videos

I haven't tried but this looks interesting:
screeps.com/

The rules are too complicated for me. I would rather have something simple that let more freedom to your creativity

What's the difference between a for-in and a for-each loop?

If it doesn't let you cheat with clever programming techniques, then it's not even worth it.

Clojure.
Since you're familiar with Java already, you'll have access to all the familiar Java libraries; interop between Clojure and Java is painless.

The anti-aliasing doesn't need to be very good to look acceptable with a constant-colour background.
As soon as you have transparencies, the edges have to be extra sharp or the whole image looks like shit.

Assuming you're talking about Javascript, for-in can list properties in objects.

It's javascript only actually...

>It's javascript only actually...

Javascript is plenty exploitable.

>screeps.com/
Looks pretty fun.

Currently working on creating a web scraper using Python but every now and then I get blocked for too many requests to the server.

Is there any way to randomize my IP address after a set number of web requests? Otherwise, any other suggestions as to alternatives to circumvent blocking would be appreciated

What's the difference of between
curl -o myfile myurl
curl myurl > myfile

you cant continue downloads with the second one.

Crawl one page from multiple servers at a time, not multiple page from one server.

am i considered a developer if i just publish a shitty app on google play and make a few bucks off of it?

what's the best way to pack resources in a binary file to be used in python?
possibly something that's not pickle

let's say i have a project using multiple images that i don't want to leave around and i want every image packed into one file instead

if by publish you mean you created it. then yes 100%. a lot of people talk the talk but never make anything, so you would be ahead of the population.

Problem is that I'm scraping thousands of pages specifically from one website, so I don't think I can do that. I tried implementing a 60 second delay when the program catches a 500 error but still no luck.

i really just took an apk and changed the shit in smali and asset files. then read the directions in google sdk and followed the instructions on how to publish it. it checked out fine.

How do I convert a runtime assert to a compile-time static assert?
I need it to stop compiling if someone screwed with the member order of an enum type.

>Implying we're people and not AI
>Implying this website isn't a one-to-one discussion with NSA
>Implying the population exists
>Implying implications

von neumann was a god

I'm still am, you fucking retard. A god can't die.

i wonder if he hated gypsies

There wasn't so many gypsies back then, now, to tell you the truth, I don't really care.
This other dimension is much cooler than your shithole and I can cuck Alan The Little Gay Bitch all the way.

mfw people are von neumann machines of another species

Easiest method would be to get a zip-like library and create an archive where you can store your images as you would store them in a directory.

Tar is pretty standard, but consider just sticking with multiple files.

If you've got a ton of shit that gets updated and stored to disk at shutdown (state, binary resources, cache, etc), and you need to load based on complicated criteria, consider SQLite.

You can also just concatenate them all into a single binary file, and store the offsets and lengths separately or at the start of the file. That's more-or-less tar.

i am going to learn c++, i am as of now installing anjuta and am reading the c++ programming language book
what are some tips for a noob l

>Burn C++ book
>Learn C

Church fixed circles around you

i've never seen such hate for c++
you guys are alright

Trying to figure out why my hash-dron collider won't work... ? Fuark

This isn't hate. It's about protecting your mental health and preventing your lifetime from being sucked into a oversized circlejerking blackhole.

thank you

why are you passing an argument to md5
what

Idk. I don't use that shit. Read the docs, especially that there is a proper error message there.

docs.python.org/3.6/library/hashlib.html#hash-algorithms

Found the error. Had to tell py var i should be a string with utf-8 encoding before converting from hex. Time to wait and see how long it'll take to crack my pass.

#include

int main()
{
int v[]={1,2,3,4,5,6};
for(auto x : v)
std::cout

Maybe I should re-think my variable names ...
tok->key.key = key;

nigga u really learning OCaml now?

nvm figured out i need c++11

he hates haskell because it's too perfect and challenges his worldview

still better than t->k.c = f;

>haskell [...] too perfect

Sure, let me know when somebody is actually using software written in Haskell.

Nerd!

I'm trying to get pip installation to work on my project, I've been fucking with this pypi website for like 2 hours straight, can anyone tell me what happens when you try to

pip install calcupy
or pip3 install calcupy

I don't understand what I'm doing wrong and why python packaging is so fucking complicated
github.com/nick-gits/calcupy

>i-it's not like I like haskell or anything! baka!

reeeeeeee

you're messing with us right

Can your statically typed language do this?
data Fix f = Fix { unfix :: f (Fix f) }
cata f = f . fmap (cata f) . unfix
ana f = Fix . fmap (ana f) . f

If I'm storing URLs in a trie for the purpose of making a web crawler that doesn't double-visit pages,
1. is a trie even a good data structure for this? I assume it is, given its nature and
2. Should I be storing by URL (I.E. a branch would look like >Cred Forums.org > g > thread > 56842194) or should I be storing by character (I.E. a branch would look like 4>c>h>a>n>o>r>g>........)

I'm leaning towards a trie with url-based branches since it makes the most sense to me but I wanted to make sure I wasn't falling into a weird gotcha

Thank god it can't.

>non-termination

My language does not support catamorphisms or anaphormisms.

i don't think your language supports polymorphic recursion either

>people use exceptions

>trie with url-based branches
You're gonna have
Level 1: root
Level 2: every domain in the world
Level 3: maybe 10-20 pages per domain

If you're aiming for any kind of efficiency you'll have to do better than that.

I'm not planning on having it search the entire web, the plan was to have it target a single website + all subdomains, subdirectories, and alternate servers (so imgur.com, irc.imgur.com.... etc)

The ultimate goal is to see if I can mine data out of blogs on tumblr

That's correct.

no, but it can have an 8k hello world binary instead of a 1.8 one

Rate my assert hack!
#define crash_if(x) for(; (x); assert(!(x)))
crash_if((IMPORTANT_NUM % 2) != 0)
{
printf("OOPS THAT WASNT EVEN");
something();
}
...
$ ./test
OOPS THAT WASN'T EVEN!
test: test.c:42: abloo_bloo: Assertion `!(IMPORTANT_NUM % 2 != 0)' failed.
Aborted

The best part is you can use it like crash_if(expr); without the if statement because the semicolon ends the for loop.

1.8 < 8000

I'm writing C after years of Java

Doing anything with strings is so, so tedious in this language

I would say the same for Java

t. I don't know what string.h is

I know what string.h is. String manipulation is still tedious.

I don't follow. Can you write a proof?

How is that better than
if (expr)
{
printf("oops that wasnt even");
exit(-1);
}

Why not? They do what I need them to do, and in a reliable fashion.

I'm trying to populate a linked-list from a text file. For some reason the link that I'm using as a beginning is getting populated along with the actual list. Anyone know why?


link data, head;// data will traverse, head will be the beginning
FILE *fpointer;
fpointer = fopen(argv[1],"r"); //opens file name passed in, read only
char singleLine[20];
while(!feof(fpointer))
{
char* test = fgets(singleLine,20,fpointer);// holds line that will populate list
if( i == 0)
{
head = malloc(sizeof(struct node));
head->item = fgets(singleLine,20,fpointer);//stores first line in head.item
head->next = NULL;
data = head;
i++;

}

else
{
data->next = malloc(sizeof(struct node));
data = data->next;
data->item = test;
}


}
fclose(fpointer);
data->next = NULL;

You mean that everything points to singleLine, is that it?

>char* test = fgets(singleLine,20,fpointer);
>head->item = fgets(singleLine,20,fpointer);
fgets just returns the buffer you passed in, and doesn't allocate any new space.
So every node you're creating has the same pointer to 'singleLine'.

This is why you shouldn't use C.
You should *learn* C, but you shouldn't use it. It's a painful language for doing anything remotely high level (see: doing anything at all).
Lisp is best language

What in particular are you finding tedious?

>Lisp is best language

Not only that, but it existed BEFORE C and also did everything right. If only we'd put more faith in that jew McCarthy.

Not him, but:
Rewrite the following 4-line Python script into C:
fh = open("file.txt")
for i,line in enumerate(fh):
words = len(line.split())
print("{} {} in line #{}".format(words, "word" if words == 1 else "words", i + 1)
That'd probably be atleast 20 LOC in C

;-(
I'm going to reinvent computers and do it correctly this time around

> Lisp is best language
is that just a meme? or do you really mean what you say? I never understood why people like Lisp, on the other hand i never really looked at it as all the brackets gave me headaches. However im grateful that Haible developed libffcall because of Lisp (i have it replaced by a custom lib with similar functionality nowadays though)

MFW C/Lisp cucks devote their lives to making useless low-level garbage for free on github while i have a job with 80k starting after spending 8 months learning java

Lisp does a lot of things right from the start, and then everything it doesn't get right you can just make a macro to implement literally any feature.
My current favorite language right now is Racket, it's a simple Lisp with excellent documentation and a ton of awesome tools. If you can find a single feature of Python or Ruby that Racket doesn't already have, it can probably be implemented with a few macros. It's honestly so comfy, it's everything I could ask for.

>hating yourself and selling out to capitalism in a shitty code monkey Java job
Were you supposed to sound convincing?

>I'm going to reinvent computers and do it correctly this time around

Best of luck.

I'd be more inclined to use Lisp if I could find a viable use for it that I can't already do rather well with either C++ or Ruby.

What are you making?

I'd be more inclined to use it if I hadn't been brainwashed to program in C-likes. The brackets and semicolons have been seared into my brain.

>dynamic typing
>parens everywhere
It's nice, but it hardly did *everything* right.

>brainwashed to program in C-likes
>he thinks null termination and array decay are normal, acceptable things
That's so sad user.

Go (golang)
reddit.com/r/golang/comments/552gfp/go_has_spoiled_me/
it has some odd things, but, overall, it's just awesome

>The /dpt/ is more of a discussion of the act programming than /wdg/ is.
have you tried actually reading these threads? it's always basic shit, "do my homework", "what language should I learn", "my lang > your lang", etc.

docs.racket-lang.org/reference/concurrency.html
Racket even has the equivalent of Goroutines and Go channels

you have to reset your requests.Session() object every so often

en.wikipedia.org/wiki/Progressive_enhancement

RITCHIE DID NOTHING WRONG! RITCHIE DID NOTHING WRONG! IT'S JUST THE WAY THINGS WERE!

Why was null termination even used? It makes everything O(n) when it could be O(1) and it saves a negligible amount of memory compared to storing the string's length.

>It was okay to enslave black people then, so it must still be okay now, right?
mfw C fags literally think like this

Back then, they thought that storing the length of an array alongside a pointer to its contents was too memory intensive. Yep. 4 extra bytes that could be put into a register was unacceptable overhead. Talk about premature optimization for christ's sake.
C could have been defined with tuples and first-class bounded array syntax and it literally would make the langauge 10x comfier to use, but C was literally designed to be easy to implement a compiler for. It's the biggest virus in computing history.

You know what? That's probably a good idea.
I asked a quesiton earlier about ASP.NET that wasn't answered, but it applies to Go as well. How much is hosting a Go web application going to cost me?

It's the best (and worst?) of both worlds, in a way.
If you want to store the string's length you do it yourself and get your O(1).

>if you want to store the string's length you do it yourself and get your O(1)
And then you have to rework the entire library ecosystem to work with your new custom array type, and you still have major troubles coping with strings that have nulls in them. Because an ascii string isn't ascii if it can't cope with nulls. Been there, done that, found it easier to abandon C altogether.

Thanks for pointing out where the problem was. I was able to fix it using fscanf and declaring the size of the array in the nodes. 1st week using c and I would have never been able to figure that out.

>tfw too stupid to understand Haskell

#include
#include

int main()
{
char buf[256];
int i = 1, n = 0;
freopen("file.txt", "r", stdin);
while (fgets(buf, sizeof buf, stdin))
for (char *p = buf; p && *p; p += strspn(p, " \r\n\t\v"), ((p = strpbrk(p, " \r\n\t\v")) && ++n) || (printf("%d word%s in line #%d\n", n, n == 1 ? "" : "s", i++) && (n = 0)));
}
11 lines.
Only 1 statement per line.
3 lines are "trivial" (blank or '{', '}').
3 lines of language "overhead" (#includes, and int main()).
So 4 significant lines.
I can think of some ways to save even more lines, but that would require some changing some shit with how the program is called and some pointer conversion shit.

None of BCPL, B, or C supports character data strongly in the language; each treats strings much like vectors of integers and supplements general rules by a few conventions. In both BCPL and B a string literal denotes the address of a static area initialized with the characters of the string, packed into cells. In BCPL, the first packed byte contains the number of characters in the string; in B, there is no count and strings are terminated by a special character, which B spelled `*e'. This change was made partially to avoid the limitation on the length of a string caused by holding the count in an 8- or 9-bit slot, and partly because maintaining the count seemed, in our experience, less convenient than using a terminator.
Individual characters in a BCPL string were usually manipulated by spreading the string out into another array, one character per cell, and then repacking it later; B provided corresponding routines, but people more often used other library functions that accessed or replaced individual characters in a string.

>So 4 significant lines.
Mistyped. 5 significant lines*.

python isn't a real programming language though but ok

Meanwhile the Python example wasn't cutting absurd corners, and if it was, then it was only cutting out a single line (e.g. the ...if...else expression for appending the "s" in case of multiple words).

>How much is hosting a Go web application going to cost me?
it compiles to a binary, so... feasibility depends on the server. I myself am running a website in redhat's openshift (uses amazon) for free.
if you ever manage to get lots of users, you'll save lots of resources (i.e., $$$)
my suggestion: start here tour.golang.org/
then read docs and some blog posts: golang.org/doc/ and if you need help, you can ask in that subreddit, or in webchat.freenode.net/?channels=go-nuts , or the mailing lists, etc.
Go is pretty easy to learn, except for a few things...

>And then you have to rework the entire library ecosystem to work with your new custom array type
not really, most string functions work without knowing the size
and those that do need to know can be easily avoided by using something else.

>stockholm-syndrome C fags this delusional

>most string functions work without knowing the size
But they're O(n).

Yes, I know my C example is 'shit'.
I just decided to interpret what he said a code-golf challenge (except for lines).

How do you people stay productive?
Pomodoro? Trello? Distraction free setup?
I'm really stressing out on how little work I achieve on a day.

Every basic string function in other languages (besides strlen) are O(n) or worse.

They don't have to be.

i have work as part of my routine. i don't work that many hours a day, but i work every day without fail

Really? REALLY?

You are incorrect.

i mean they dont need to calculate the size at all.
they just keep going until they hit null.

What are some functions that have to be at least O(n) even if you know the size?

palindrome detector

reverse

Please explain how knowing the length in advance is going to make string copy, search, or comparison faster (in the big O sense).
All I can think of is maybe string concatenation with will be O(m) instead of O(n + m).

Right, because those are very useful functions in practice.

search for first occurrence of a substring

compare

a pure shitposting device using a Cortex M board that can only render Cred Forums, do JS-less captcha and show images with a 5 inch LCD

analyze the strings of the posts you're replying to before you reply to them

I suppose this is getting away from just plain algorithmic complexity, but if you know the size ahead of time you can do things like compare, copy, etc. in parallel.

Yeah I realised that, so I deleted my post.

Smart languages prefix the string with important information like size, whether or not it's a palindrome, the reverse of it, etc.

Sure, it ends up being a large space requirement, but that's fine.

Programmer is fine. Only kiddies who've done their first tutorial in C++ or Java get elitist about "scripting vs programming". Unless the Python you are doing is a highly specific use in part of a greater system, then it's fair to call it programming.

14 LOC in C89
#include
#include
#include
int main(void) {
unsigned int i = 1, w;
char *t, l[1024];
FILE *f;
f = fopen("file.txt", "r");
while (fgets(l, 1024, f)) {
for (t = strtok(l, " "), w=1; t; w++, t = strtok(NULL, l));
printf("%d %s in line #%d\n", w, (w > 1) ? "words" : "word", i++);
}
return 1;
}

13 LOC in C99
#include
#include
#include
int main(void) {
unsigned int i = 1, w;
char l[1024];
FILE *f = fopen("file.txt", "r");
while (fgets(l, 1024, f)) {
for (char *t = strtok(l, " "), w = 1; t; w++, t = strtok(NULL, l));
printf("%d %s in line #%d\n", w, (w > 1) ? "words" : "word", i++);
}
return 1;
}
Neither triggers any warnings in GCC.

how do i make recursion trees?

It's all programming. Whether you're scripting or developing a library/application/whatever depends on what you're making, not the language you use. That said, Python is good for scripting and not general development.

Each call is a node. When you have a recursive call, you add a branch to that node from the current node.

>#include but doesn't use it
>return 1;
>C99 warnings:
test2.c:9:40: warning: declaration shadows a local variable [-Wshadow]
test2.c:10:39: warning: variable 'w' is uninitialized when used here [-Wuninitialized]
>C99 solution doesn't even work

can you give an example? i watched so many videos about it my mind is blown and i'm not even sure what i can call a recursive tree

Are you on windows? python is much easier on Linux

Apparently my gcc is too old to have -Wshadow, and I just missed the rest because I used to do some overcomplicated malloc() magic and forgot to get rid of stdlib. How embarrassing.

def fib(x):
if x < 2:
return x
return fib(n - 2) + fib(n - 1)

data Tree a = Leaf a | Node a (Tree a) (Tree a)

instance Functor Tree where
fmap f (Leaf v) = Leaf (f v)
fmap f (Node v l r) = Node (f v) (fmap f l ) ( fmap f r)

Ew

>Python
>tail recursion
RIP the stack.

many thanks

Can someone explain to my why the submitBTN_click1 counter isn't working?

>C# webform
>assigned integer count to 0
>upon submit button click, ++count and display text (as well as guess, which all works)
>it counter counts only from 0 to 1, then does not count beyond 1

I'm sure I'm overlooking something very simple.

I have come to the realization that the most practical languages today are C++ and C#.

This is deeply troubling.

that's not tail recursion

That's not even actually tail recursive

that's not even tail recursion

Wow, user, you're so smart and clever and attractive!

I feel lik you're looking down on me

Fuck microsoft.

For not answering the question and instead taking the mention of recursion and trees to make a binary tree in Haskell and bizarrely implement Functor for it. First of all, "recursion tree" is something different. Also, that Haskell is entry-level.

GENTOO
E
N
T
O
O

i used to make the same mistake you did when all i was told about tail recursion is that it's when the last thing is a recursive call. i realized what it was when i was reading SICP in my free time last summer and was drawing out a recursion tree

just call a function more than once senpai

OK what the fuck is a GOPATH, and why do I need to set it as an environment variable? That's a massive pain on windows. Can I only ever have one Go project active at the same time? Who comes up with this shit?!

Well, it's true. That's what tail recursion is. However, the last thing in that function is addition.

I haven't touched ASP.NET in like 8 years, but why would you expect your class instance to survive across round-trips?

Each request constructs your class anew. If you want count to survive, you need to store it somewhere durable like in a session or I think I remember a mechanism that serializes just that kind of state and puts it in a hidden form field. I forget what it was called.

static int count = 0;

You can set per-process environment variables even under windows. You just have to write a .bat wrapper.

how else wuld you instance that tree?

Why did you even implement Functor in the first place? That's what's bizarre. It has even less to do with the question.

>You can set per-process environment variables even under windows. You just have to write a .bat wrapper.
??? Did no one stop to think for one second about how fucking dumb this is? Or am I missing something?

>That's a massive pain on windows.
Windows key.
e-n-v, enter.
alt-n (to click on the New button)
GOPATH, tab
ctrl-v, enter, enter

That's not difficult.

i know it's true, but it's not a useful explanation to people who don't know what it is. the novice sees the last thing written in the code is fib(n - 1) and assume that's the last thing that happens in the function

kek, yeah all I needed to do was set count to static

thanks dudes

Ask microsoft, not me. I'm not the one who decided to reinvent the wheel instead of reusing the elegant and powerful environment syntax from UNIX that literally every other major OS vendor implements.

There's no more useful explanation because that is literally what a tail call is. If a recursive call is the last thing that happens (besides returning its value), it's a tail call.

The problem is thinking that the last thing written top-down, left-to-right is the last thing that happens, which has nothing to do with recursion. It's easier to see what the last thing to happen is if you're in a functional language, but it's not difficult to show that it's not a tail call in any language.

>That's a massive pain on windows
>windows
you are and , right?
I've never compiled Go code under windows... but I guess you are overreacting, m8. you do NOT need the compiler to run a Go program. also, it's not difficult to setup the compiler/toolkit.
anyway, you should use a linux VM, IMO. it won't take you a lot of time to setup one, install the Go toolkit and make a backup of the VM. also, it's really easy to cross compile a windows binary

is it that hard? yikes
GOPATH lists directories where import should look for packages. you can put as many directories in there as you like

That's because of "friendly" programming languages that use this stupid thing they call "infix notation". So confusing. Sexps are much clearer in that regard.
(+ (fib (- n 2)) (fib (- n 1)))
When put like this, not even a fool would think that the addition happens first.

>better make everything more verbose because some retards can't parse infix

>Sexps

are sexy.

actually just read the top bit here
golang.org/pkg/go/build/

Yes it was an overreaction based on a misunderstanding, my bad. I was already at the end of my patience from earlier. I could hve used a VM, I have one set up, I just felt like trying windows this time.

fib 0 = 1
fib 1 = 1
fib n = ((+) `on` fib `on` (n-)) 2 1


What's the problem?

NEW THREAD!

The problem is that you are using closed recursion.

fib' r 0 = 1
fib' r 1 = 1
fib' r n = r (n-2) + r (n-1)

fib = fix fib'
fastfib = memofix fib'

Why don't you reimplement this using a tree hylomorphism?

Presumably that's what memofix does. I never gave the implementation.

python script that scripts the use of cli h@k3r tool 1337! for use on pwn phone. Fucking hate typing on soft keyboard, Auto plz...