[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: 337
Thread images: 43

File: anime_programming_language.png.png (1MB, 1200x1800px) Image search: [Google]
anime_programming_language.png.png
1MB, 1200x1800px
No spam edition anime edition.

Previous thread: >>60618874

What are you working on, /g/?
>>
>>60621778
First for Ruby, most comfy language.
>>
File: old_hag_langs.png (173KB, 600x355px) Image search: [Google]
old_hag_langs.png
173KB, 600x355px
>>60621778
Threadly reminder that Fortran is a beautiful language that is in no way old or outdated.
>>
>>60621778
>>60621800
>>60621821
real thread here:

>>60621773

also, sage
>>
File: pet.gif (328KB, 500x517px) Image search: [Google]
pet.gif
328KB, 500x517px
>>60621841
No, this is /dpt/ anime edition.
>>
>>60621872
It is not paedophilia, we just appreciate cute girls.
>>
File: awkward_programming_neet.jpg (164KB, 620x500px) Image search: [Google]
awkward_programming_neet.jpg
164KB, 620x500px
>>60621778
I'm learning Ruby and hopefully use Ruby on Rails to create some fun stuff. What are some good Ruby on Rails resources?
>>
is there more of the last op's rewrite
>>
File: programming_challenges_v1.4.png (304KB, 1920x1080px) Image search: [Google]
programming_challenges_v1.4.png
304KB, 1920x1080px
Rolling for project.
>>
>>60621962
>inked list
nice project
>>
>>60621978
It may be basic for someone who is expert at a particular language. However, I want to change myself, so I could try to implement a linked list in a language I've never used before like Haskell or Prolog. ;-)
>>
>>60621978
A list of tattoos you want?
>>
>>60622022
implementing a singly linked list in Haskell is probably the easiest thing you could ever imagine


https://en.wikibooks.org/wiki/Haskell
>>
>>60622043
I figured since Haskell is functional and from my small knowledge of Lisp, linked lists seem to be an important data structure of functional languages.
>>
>>60622060
There's a built in linked list too.
They're really nice because they are incredibly simple semantically.
A list is either null ([]) or a cons list (head : tail)

product :: Num a => [a] -> a
-- product has the following type:
-- where a is a Num (this is like an interface, and it's generic on any a that meets the interface)
-- [a] -> a
-- (function from) list of a to a

-- defining the "product" function
-- [] is an empty list
product [] = 1
-- product of an empty list = 1

product (x:xs) = x * product xs
-- (x:xs) is a cons list - the bit before the ":" (x) binds the head
-- the xs binds the tail
-- function application f(x) is simply f x
>>
>>60622095
You're not helping. Also this thread says non anime in the OP, tard.
>>
>>60622104
>>60622112
You new fags, just ignore him.
>>
>>60622095
>>60622104
no, I, the OP, deleted it because it had nothing to do with programming
hopefully they will also delete this one once they get up...
>>
>>60622104
>don't trigger them
So you do admit that it's you faggots that start the spamming by provoking them.
>>
>>60621962
rolling on rust
>>
>>60622214
>I am so sick of typing giant letters
You're the one that killed the last thread.
>>
>>60621962
rell
>>
>>60622214
>try to implement first class functions in it
std::function<int(int)>

Well, that was hard.
>>
>>60621962
Rolling on assembler
>>
>>60622238
guarantee optimisation by C++ compilers for std::function s is trash
>>
File: dlang_chan.jpg (138KB, 470x545px) Image search: [Google]
dlang_chan.jpg
138KB, 470x545px
Threadly reminder that dlang-chan is not dead; she's going to have her GC tumor removed (eventually); she's super duper cute; and she's a blast to write in! Say something nice about her, /dpt/!
>Features
https://dlang.org/comparison.html
>Standard library
https://dlang.org/phobos/index.html
>GC
https://dlang.org/spec/garbage.html
https://dlang.org/blog/2017/03/20/dont-fear-the-reaper/
https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
>Books
https://wiki.dlang.org/Books
>>
>>60622246
>advocating pedophilia
I really wish you aren't serious, though. Anyways, that thread would have proceeded as normal if nobody started spamming the thing. So it seems to me that the one who actually killed the thread was the faggot that spammed the giant letters.
>>
>>60622252
>not writing machine code opcodes with a hex editor
>>
>>60622306
It's only spam if you don't like it. It's just a place-holder OP image if you like it. Are you so insecure that the mere sight of an anime girl sends convulsions throughout your body and you are unable to control your desire to spam?
>>
>What are you working on, /g/?
An OpenGL spritebatcher in C to be used in a 2D game. I wanted to try doing sorting on the GPU instead this time (for opaque sprites) so I started over, and I'm implementing blending now.
>>
>>60622245
Same reason we let tryhard pooloos like your dumb ass in here: everyone is welcome. Now, shut the fuck up, shitstain.
>>
Hello could you please remove visual basic from that image?
It is a very disturbing image.
>>
>>60622361
That's not how you write a function that returns a function pointer.
>>
Roll for project reee
>>
>>60622476
That is fucking disgusting.
>>
>>60621778
if I have a website and there's a text box for say a subscription(getting their email) how would I save that to that database using php, and then retrieve that information?
>>
>>60622490
No, how you write that is like this:
int (*(*)(int (*)(int)))(int)
>>
>>60621962
Rolling on COBOL
>>
>>60622516
>>60622361
in Haskell this is just
(Int -> Int) -> Int
>>
>>60622516
A trailing return type would make this more readable, e.g. in Rust:
fn(fn(isize) -> isize) -> fn(isize) -> isize
>>
Object-oriented
>>
File: images (4).jpg (7KB, 245x206px) Image search: [Google]
images (4).jpg
7KB, 245x206px
>>60622476
You sick, perverted monster. Scheme-chan was a pure-hearted cinnamon roll and you defiled her.

What you're doing should be illegal. People like you shouldn't be allowed around sweet innocent functional languages.
>>
>>60622560
No, it's
(Int -> Int) -> (Int -> Int)


>>60622570
>>60622528
Yes, most people agree that C's function pointer syntax is pretty crap, but there is nothing you can really do about it now. Anything beyond the most trivial uses normally get simplified behind a typedef.
typedef int (*intfn_t)(int);
intfn_t myfn(intfn_t arg);
>>
>>60622589
triggered
>>
>>60621778
why is there no Lisp-tan?

What would she look like /g/?
>>
>>60622596
I misread, he didn't phrase it very well
>>
>>60622560
>>60622596
why is everything in haskell so fucking counter-intuitive?
Theres literally no distinction between what is an input and what is a return type, its retarded
>>
>>60622599
She definitely has to have a big (((Nose)))
>>
>>60622616
You're a brainlet who doesn't understand currying.
>>
>>60622616
a -> b

a is the input
b is the output

-> right associates


extremely intuitive
>>
>>60622599
She is off counting her sheckles.
>>
Why is safe mutli-threaded concurrency so fucking easy in golang
It's almost unfair compared to how other languages handle asynchronous tasks
>>
>>60622616
>I have no idea what curryfication is
>>
>>60622642
a -> b -> c -> d
oh good job now a b c are inputs and d is output, and its incredibly unclear that this is the case
(a -> b) -> (c -> d) oh good now its even less fucking clear
Haskell is purely for autists who think Esperanto is the future
>>
>>60622656
Honestly read a book nigger.
It's like that for a very specific reason.
>>
>>60622656
How is this unclear?

(a -> b) -> (c -> d)
The input is (a -> b)
The ouput is (c -> d)


You seriously have trouble with that?
>>
File: O0QkrgR.jpg (97KB, 1280x720px) Image search: [Google]
O0QkrgR.jpg
97KB, 1280x720px
>>60622656
>not knowing order of operations
>>
>>60622599
A sweet and unassuming old Japanese lady with glasses and a hair bun. She was probably moe as fuck when she was young, and is quite moe now too, but in the immaculate old-people way. She bakes nice things, is knowledgeable about ancient Greek literature, and is secretly a powerful witch.
>>
>>60622676
Stop just shitposting your OC waifu, numbnuts.
>>
>>60622656
Everything in Haskell takes one argument and returns one.
If you have f(x, y) and you only specify f(x), it won't error, but rather return a function f(y) where x is already bound.
>>
>>60622683
I don't have an OC waifu. That is genuinely my vision of what a Lisp-tan would be like.
>>
>>60622656
>>60622691
you can use tuples if you have issues understanding currying and right associative ->

(a, b, c) -> d
>>
>>60622616
What? I don't get how you can call that "counterintuitive".
>>
>>60622656
Are you literally brain dead or something?
>>
>>60622617
>>60622643
LOL JEWS
HAHAHA INCLUDE ME IN THE (((SCREENCAP)))

FUCKING EBIN MY MAN :-------D
GAS THE KIKES AM I RIGHT

kys
>>
>>60622727
>trying too hard
>>
>>60622670
>>60622673
>>60622675
>>60622691
>>60622701
Autist brigade in full force I see
Haskell is syntaxically nonsense in comparison with every other language in existence.
>>
>>60622656
Something tells me you'd need to consult stackoverflow on how to write a fizzbuzz.
>>
>>60622656
Object-oriented brainlet detected.
>>
>>60622740
see
>>60622741
The syntax can't be simpler.
You're retarded.
>>
>>60622740
>(c(*)(d))(a(*)(b)) is better than (a -> b) -> (c -> d)
>>
File: what-a-fucking-retard.jpg.png (261KB, 552x414px) Image search: [Google]
what-a-fucking-retard.jpg.png
261KB, 552x414px
>>60622740
>I do not understand it so it is the language that is the problem!
>>
>>60622782
>untyped
Completely unrelated.
>>
>>60622740
I don't even like Haskell but if you can't grasp this, you are beyond hope.
>>
>>60622740
I hope you're baiting because no one should be this stupid and have the pretension of thinking they know how to program.
>>
>>60622792
Shhh let the brainlet think they can make it in the industry. It is more fun to watch them crash and burn that way,
>>
>>60622805
We were discussing types.
>>
>>60622820
>where f is of the form ...

>wants types but doesn't want to admit it
>>
>>60621962
rolling
>>
>>60622740
I don't even use Haskell or am that into functional programming but you're plain dumb.
'->' is "transforms to" or "leads to": input a leads to output b. I don't get what's so complicated here. Or do you not get how parentheses work? Arithmetic must be a bitch to you then.
>>
Why are imperative bros so cozy but functional posters are notorious autistic shitters?
>>
>>60622870
I am the guy right above you. What autism are you talking about?
>>
File: 1495098374483.png (137KB, 500x568px) Image search: [Google]
1495098374483.png
137KB, 500x568px
>>60622870
Imperative assholes are just as cancerous. There are just less of them. One bee in your ear is bad, but a swarm is easier to notice.
>>
>>60622820
this for one
>>
>>60622870
>why do retards infuriate smart people so much
>>
>>60622883
>There are just less of them.
Are functional faggots really this delusional?
>>
>>60622890
not even retards vs smart people, more like retarded way vs smart way
>>
File: pizza~~.png (243KB, 479x537px) Image search: [Google]
pizza~~.png
243KB, 479x537px
Can someone rate my terminal rice script?
It generates a color scheme from an image and overwrites your xfce4-terminal colors~

https://paste.installgentoo.com/view/raw/0c7fd1d7
>>
>>60622925
Functional Programming: A True Story
>>
>>60622925
kek
>>
>>60622925
Christ you people have issues... Is this how traps happen?
>>
>>60622973
effeminate men are basically catty women on an emotional level, so yes
>>
>>60622973
>Being such a newfag to not even recognize obvious copypasta
>>
>>60621962
rollan
>>
>>60622973
No, what you did was ignore my original question and offer bullshit. My six ITS certs give me a comfy understanding of hardware and firmware. I know some assembly stuff as well.

I was asking for programming projects in some relation to my current skill-base.

Your solution read like: "Hey, I know you're an active programmer using some of the industries top-used languages, and your question was asking for projects possibly related to said languages, but instead I'm going to offer the idea that you should ditch those interests and pursue an entirely different language that you have already worked with in college, but maybe this time you should really go deep with it. Otherwise, give up on being a real programmer."

Man, I was just looking for more serious side-projects to work on. My job has me developing software for a medical information system, which is cool and all, but I wanted to see if you guys had any ideas of what I could write, at home, as a more involved project. Instead, I got shit.

Oh well, back to the Stack Exchange / Reddit. At least the levels of glorified smart-ass are a bit lower on those sites.
>>
>>60621962
rolling
>>
>he fell for the OOP meme
Name me [0] good reason that you are forcing yourself to think about designing a program instead of actually programming.
>>
>>60623558
Because if I design the program first it's easier to then actually program it, and then easier to make changes to it.
>>
>>60623558
Because the projects I work on are longer than 1000 lines and have other people working on them, something the FP crowd will never understand.
>>
>>60623582
75% of the people will never write on a scale for it to be worth it. Hell, a vast majority of people here will only write by themselves, making OOP irrelevant.
>>
>>60623558
Would you build a house without designing it first?
>>
>>60623596
You are excused, friend.
>>
>>60621962
roll
>>
Don't design just do it, you can get the mindless monkeys to fix the code later. But it's imperative to be a do'er who comes up with the inspiration that morans can design out later.
>>
>>60623686
Just programming for the sake of it is codemonkey tier.
>>
File: Cattura.jpg (47KB, 1041x489px) Image search: [Google]
Cattura.jpg
47KB, 1041x489px
I'm trying to understand who to get good at multithreading in high level language and for fun i'm trying to implement an IRC server in python. I don't really know why python: i could have picked java but it doesn't matter as soon i understand the theory. One day i'll learn how to do it in C++.
>>
>>60623741
Learn Lisp.
>>
>>60623711
>assigned to make program w/ 2 weeks deadline
>spend 1 week designing it, 1 week of actual programming
>boss furious because program not done
>get fired
or
>make an actual functioning program within two weeks and fix bugs later

Usually the second option is true for people, if option one happens, you get outsorced to pajeets.

>>60623635
How often do you build a house? Programs here rarely reach beyond garden shed tier.
>>
File: output.jpg (2KB, 98x22px) Image search: [Google]
output.jpg
2KB, 98x22px
Threadly reminder that AS3 is the greatest language:
function f(a:*):* { var p:* = function(... args):* {return (args[args.length-1])}; return p((a*a).toString().split("")); }
var o:Object = new Object(); o.f = f; o.ob = new Object(); o.ob.f = o.f; trace(o.ob.f(256));
>>
>>60623769
Trash.
>>
>>60623760
>finish your 2 week program on time
>still in production use 10 years later
>have to spend millions of dollars in testing and developers to make sure nothing breaks when your legacy garbage is updated
>>
>>60623760
False dichotomy. Why couldn't you design your program and get it working within a two week span?
>>
>>60621962
roll
>>
>>60623788
If you've ever been at a larger company you would know this is true. Look at the banks for example.
>>60623793
It was an example. You would not get fired realistically, just ask for an extension of the deadline.
>>
File: object.jpg (2KB, 136x22px) Image search: [Google]
object.jpg
2KB, 136x22px
>>60623780
B-but as3 is the greatest language ever... it must be immaculate
var O:Object = new Object();
O.OB = new Object();
O.OB.OBJ = new Object();
O.OB.OBJ.OBJE = new Object();
O.OB.OBJ.OBJE.OBJEC = new Object();
O.OB.OBJ.OBJE.OBJEC.OBJECT = new Object();
trace(O.OB.OBJ.OBJE.OBJEC.OBJECT);
>>
>>60623794
Wtf
>>
>>60623819
ez
>>
>>60623769
>I write my code pre-minified
artisan kode
>>
>>60623818
Does it have macros?
>>
>>60623839
https://divillysausages.com/2011/04/04/as3-conditional-compilation-or-ifdef-in-flash/
>>
>>60623558
I actually want to get into OOP, but I use C# and write small programs, where should I start?
>>
>>60623938
C# is POOP cancer so you're already standing knee-deep in shit.
>>
>>60623960
I already read the yellow book and got quite familiar with the language. It's also used a lot in the industry. It's either C#, Java or Python.
>>
>>60621778
I want to marry C-tan.
>>
just going to modify a tiny tool, https://github.com/Fuuzetsu/jenkinsPlugins2nix

>>60622101
sadly linked lists are actually not really nice and it's insanely common that a code-base is plagued by their use (sometimes in guise of String)

I was going to link
www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/list-or-not-list/ and www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/data/ but it seems down right now… Perhaps seek these in Google cache
>>
>>60624261
>sadly linked lists are actually not really nice and it's insanely common that a code-base is plagued by their use (sometimes in guise of String)
they aren't nice for performance

though in Haskell laziness obviates a lot of that (but not all of it)
>>
When using linked lists in C++... what should I declare my instances to be? Pointers to structs or structs?

#include <iostream>

struct Node {
int data;

Node(int val) : data(val) {};
Node* next;
};

int main() {
Node head(5);
Node second(4);
head.next = &second;
std::cout << head.data;
std::cout << head.next->data;
return 0;
}


If I declare them pointers, then the member initialization list doesn't work anymore :/

#include <iostream>

struct Node {
int data;

Node(int val) : data(val) {};
Node* next;
};

int main() {
Node* head(5);
Node* second(4);
head->next = second;
std::cout << head->data;
std::cout << head->next->data;
return 0;
}


I get
error: invalid conversion from `int` to `Node*` 
Node* head(5);
>>
>>60624277
No, not even a lot. Everything but cons and uncons sucks, only real usecase pretty much is to use them as streams and even then we have a lot better structures for that already.

Seems the links I posted in my previous post are back up.
>>
>>60624302
you're thinking of complexity given strict evaluation
if you've got one string appended to another string, "that's bad", but if you're lazily asking for it, you traverse once anyway and don't need to traverse again for the append
>>
>>60624300
You need to dynamically alloc your pointer
Node* head = new Node(5);


don't forget the deletes
>>
Question for the Ruby developers: do I still need to prepare my asshole for penetration after I took a shit or am I ready to go?
>>
>>60624343
Why do I need that? I thought I need to do that when I want to keep the nodes on the heap outside of the scope
>>
>>60624353
Because your pointer need to point somewhere
>>
>>60624358
But I could do
Node* head
and my pointer wouldn't point anywhere no? When do I need to make sure my pointer points somewhere
>>
>>60624398
Fuck you're retarded. Grab a book and fucking read it dude
You obviously don't understand any of this shit
>>
>>60624411
Just explain me. Why
Node* head
works and
Node* head(5)
doesn't?
>>
>>60624418
Because
Node* head(5);

is the same as
Node* head = 5;

which isn't valid
>>
>>60624429
Oh lol okay sorry I don't know what I was thinking
>>
Working on a Python script that'll manage some files on Mac and Linux, an there's a simple function to delete empty folders, however 'hidden' files have been a pain to detect since the function looks if the folder has zero files in order to remove it, any workaround to be able to delete the folders that are empty but have some hidden files on it anons?
>>
>>60623741
The main thread should read from the console as an admin interface. The second thread should wait for incoming connections and spawn new threads for each one. Those new threads put all incoming messages into a single queue which handles the parsing.
>>
>>60624452
If a directory has hidden file it's not empty
problem solved
>>
>>60624429
Thanks bro I got my linkedlist healthy and running now

#include <iostream>

struct Node {
int data;

Node(int val) : data(val) {};
Node* next;
};

void addNode(Node* head, Node* newNode) {
Node* node = head;
while (node-> next != NULL) {
node = node->next;
}
node->next = newNode;
}

void printList(Node* node) {
while (node->next !=NULL) {
std::cout << "(" << node->data << ") -> ";
node = node->next;
}
std::cout << "(" << node->data << ")" << std::endl;
}

void removeTail(Node* node) {
while (node->next->next != NULL) {
node = node->next;
}
node->next = NULL;
}

int main() {
Node* head = new Node(5);
addNode(head, new Node(4));
addNode(head, new Node(2));
printList(head);
removeTail(head);
printList(head);
delete head;
return 0;
}
>>
>>60624513
You need to loop through your list and delete every single pointers to free it correctly
use valgrind to find where you fucked up
>>
>>60624462
over engineering
>>
>>60624462
it's kinda like that, but i still have to make the console reading thing.
i have a multiplexer function in a thread that sends all the messages and a read function for every client. i still have to make this better with circualre non blocking socket
also i'm currently drowning in classes. i guess i had too much java.

>>60624546
i over engineer everything. you should see my 32 class irc client model
>>
>>60624334
Well it's not letting me inline code so here http://lpaste.net/7326749882356596736
>>
>>60624566
>>60624334
and yes in this pre-constructed case you are saved with foldr but hopefully point stands, trivially amended to defeat that
>>
>>60624561
if you like to over engineer, then learn Ada, the most over engineered programming language ever made.
>>
>>60624532
I see. Apparently there's much better ways to do this using templates and destructors


template <class T>
LinkedList<T>::~LinkedList() {
ListElement<T> *current = head_;
ListElement<T> *next = nullptr;

while (current) {
next = current->GetNext();
delete current;
current = next;
}
}
>>
>>60624566
>>60624591

It's weird that doesn't fuse

Is there not a rewrite rule that says

last (a ++ b) = last b
>>
>>60624596
Yes of course but you should try and come up with your own shit in the beginning and understand how this works
Otherwise you're no better than poo in loos
>>
>>60624609
Yeah I wasn't gonna copy paste, I'm just checking what others are doing.

But like can you answer just one more thing--the initial thing I asked in my first question. I don't really understand why do I have to declare my nodes as pointers? Can't I do
Node head
in main()?
>>
>>60624452
>empty
>but have hidden files
Pick one.
>>
>>60623760
By your logic, FP is only to be used when you are shit /g/ tier. I personally write code that spans multiple files, thousands (usually 10s of thousands) or lines of code, and is worked on by at least four others on my team. If you seriously think "fixing bugs later" is a good mentality to have, I hope to never work with you. You are the worst kind of programmer. Do it right the first time. Do not shit the bed and clean it up when people start to complain of the smell.
>>
>>60624632
Yeah you can do that but every other node needs to be dynamically allocated with new, so why do it differently for head?
>>
>>60621962
roll
>>
>>60624604
No because it's untrue

last (undefined ++ "b") -> error
last "b" -> b


You can use right fold and use rules for fold/build and ++ to get rid of the append completely but all that goes to shit if you need more access

http://lpaste.net/3131690827105959936
>>
>>60621962
STOP FUCKING ROLLING NIGGERS
learn how to use the fucking command line
shuf -i 1-99 -n 3
>>
>>60624650
Well can't I have the other nodes to be Node instances too like
Node second
and then just have the code taking in account that they're not pointers like
    Node head(5);
Node second(4);
head.next = &second;
std::cout << head.next->data;
>>
>>60624706
Whatever dude, you don't get the point of data structure like this
Like I said, grab a fucking book on basic CS shit and you'll get it if you're not retarded
>>
>>60624508
>>60624635

Got it. How do you guys would go about doing this script? this is if I'd like to still remove the directory if it has one of the hidden files created by the OS, an option would be to raise exceptions on most of the hidden files that are created by the system but I just feel that's not the correct way and I haven't been able to find any real answers on Google.
>>
>>60624728
But it compiles and gives the same output :/
>>
>>60624742
Ok nevermind don't even bother opening a book, you're too retarded for this shit
>>
File: GyirW.jpg (155KB, 513x800px) Image search: [Google]
GyirW.jpg
155KB, 513x800px
>>60624704
>I can newfag harder than anyone else!!
>>
>>60624704
>mfw shuf exists and is installed on my machine
>i would've
$echo "$RANDOM % 100" | bc
>>
>>60624758
I don't understand what's the problem. They both work on the same way on the surface and I'm asking why should I prefer one way over the other
>>
>>60624759
fuck off nigger, by rolling you're not contributing to the already shit thread
fucking pleb if you want to roll go to /b/ and never come back
>>
>>60624742
He is bitching because what you are doing is horribly inefficient. BY having to transverse nodes like that, you are wasting a shitton of processor cycles. That is shit only a pooloo does. I am guessing you are home taught or very new to programming, which is fine, but yes. Get a book on optimization or algorithms.
>>
>>60624781
Ok I see so it works but it's inefficient thanks bro
>>
File: fsharp.png (3KB, 256x256px) Image search: [Google]
fsharp.png
3KB, 256x256px
red pill me on f#
>>
>>60624803
Just don't.
>>
>>60624803
slippery slope
>>
>compilation is highly parallelizable
why is there no c compiler utilizing opencl yet
>>
I've got two python dictionaries and I want to loop through and if the keys match, do something, however

for i in dictionary:
print(i)


Prints the key, how do I access the value associated with i?
>>
>>60624840
>>compilation is highly parallelizable
No it's not. Compilation is highly serial.
It's just that you can run compilers on multiple files at the same time.
>>
>>60624861
for key in dict.keys():
print(dict[key])

or
for key, val in dict.items():
print(val)
>>
>>60624874
for key in dict.keys():
print(dict[key])


You don't need (or want) to call the keys() method. Just
for key in dict
>>
>>60624874
cheers.
>>
>>60624898

These return that the object is not scriptable.
>>
>>60624939
What?
>>
>>60624939
scratch that I'm retarded
>>
File: 2340983083.png (49KB, 718x621px) Image search: [Google]
2340983083.png
49KB, 718x621px
Works but seems like spaghetti, is there a better way to do this?
>>
>>60625032
though in python3 u need to import reduce from functools
>>
>>60625032
Cleaner way is to do it recursively
def factorial(x):
if x == 0 or x == 1:
return 1
else:
return x * factorial(x-1)
>>
>>60625032
def factorial(n):
if n == 0:
return 1
else:
return n * factorial(n-1)
>>
>>60625032
 factorial = lambda x: 1 if x == 0 else x * factorial(x-1)
>>
>>60625085
>>60625094
Recursion is shit in python because it doesn't do tail recursion.
>>
Which statically typed language that has REPL has the easiest interface to C?
>>
>>60625032
factorial n = product [1 .. n]
>>
>>60625111
Yeah but it's elegant and makes you feel good when you write it.
>>
>>60625116
Don't know about easiest but Haskell is a good candidate, capi, inline-c, ...

Seems a bit of a weird question, what's the usecase?
>>
File: fizzbuzz_idris.png (221KB, 1920x940px) Image search: [Google]
fizzbuzz_idris.png
221KB, 1920x940px
r8 my statically proven FizzBizz
>>
>>60625168
>array index starts from 1
It's not even a programming language.
>>
>>60625185
>1st entry is 0
>an array of length 1 with 1 entry is accessed by reading the first entry, or number 0
Yeah good logic there brogrammer.
>>
>>60625168
>statically typed
>Lua
wot
>>
File: ffi.png (13KB, 635x157px) Image search: [Google]
ffi.png
13KB, 635x157px
>>60625141
>>60625116

though pointers can be a pain since you've got CUIntPtr but also (Ptr a) and shit
>>
File: 500px-Abraham_Simpson.png (68KB, 500x500px) Image search: [Google]
500px-Abraham_Simpson.png
68KB, 500x500px
Rate my name to ascii art generator using COBOL /g/.
I'm posting the main procedure, the full code is here https://pastebin.com/KiLFXfaB

IDENTIFICATION DIVISION.
PROGRAM-ID. CHAR2ART.

ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT LETTERS-FILE ASSIGN TO "LETTERS.DAT"
ORGANIZATION IS LINE SEQUENTIAL.

DATA DIVISION.
FILE SECTION.
FD LETTERS-FILE.
01 LETTER-DESC.
88 END-OF-LETTER-FILE VALUE IS HIGH-VALUES.
02 F-LETTER PIC X.
02 F-LETTER-POS.
03 F-LETTER-1 PIC X(7).
03 F-LETTER-2 PIC X(7).
03 F-LETTER-3 PIC X(7).
03 F-LETTER-4 PIC X(7).
03 F-LETTER-5 PIC X(7).
03 F-LETTER-6 PIC X(7).

WORKING-STORAGE SECTION.
01 LETTER-TABLE.
02 LETTER OCCURS 26 TIMES INDEXED BY LETTER-IDX.
03 LETTER-I PIC X.
03 LETTER-PARTS PIC X(7) OCCURS 6 TIMES.

01 I PIC 99.
01 J PIC 99.
01 NAME PIC X(15).
01 ID-VALUE PIC 99 VALUE ZEROS.

PROCEDURE DIVISION.
PERFORM FILLED-TABLE
DISPLAY "NAME : " WITH NO ADVANCING
ACCEPT NAME
MOVE FUNCTION UPPER-CASE(NAME) TO NAME

PERFORM VARYING I FROM 1 BY 1 UNTIL I > 20
IF (NAME(I:1) = SPACE) THEN
EXIT SECTION
END-IF

SEARCH LETTER
WHEN LETTER-I(LETTER-IDX) = NAME(I:1)
SET ID-VALUE TO LETTER-IDX
PERFORM DISPLAY-LETTER
END-SEARCH
SET LETTER-IDX TO 1
DISPLAY " "
END-PERFORM

STOP RUN.
>>
>>60622642
Wait hold up, so what happens when you want to define a function that takes a single input and does not return any output and also when you want a function that takes no input but returns some output? Wouldn't the signature look the same for both then?
>>
File: Capture.png (3KB, 648x271px) Image search: [Google]
Capture.png
3KB, 648x271px
>>60625274
It uses this LETTERS.DAT file :
A-------      |-------|     ||     |-------
B| | -------| || |-------
C_______| | | | -------
D | |-------| || |-------
E-------| |-------| | -------
F-------| -------| | |
G-------| |------- | |-------
H| | -------| || || |
I - | | | |
J - | | | ---|
K | | | / |/ |\ | \
L | | | | | -|--
M -------| | || | || | || | |
N ----- | | | | | | | |
O ----- | || || | -----
P|------| ||------| | |
Q|------| ||------ | | |
R |----- | | -|-
S -------| ------- |-------
T | | |---- | | -|-
U | || || ||-----|
V \ | \ / \ / \/
W | | || | || | ||--|--|
X\ / \ / \/ /\ / \ / \
Y\ / \ / \/ | | |
Z-----/ / / / / -------
>>
>>60625275
A function takes input and returns output.

If you want to perform effects, typically you use monads or something similar.
In this case, you still return a value, and that value is the effect.
For example:

putStrLn :: String -> IO ()

() is the unit type. It is analagous to C's void type.
There is one value of type (), and that value is also called () (or unit).
>>
>>60625226
You're meant to use Storable anyway, it works for most common usecases; as well as bracket-like things
>>
>>60625484
Does Ptr have the same representation as C pointers?
>>
>>60625533
Ptr is just Addr# with phantom type parameter. Addr# is some implementation primop. You can convert Ptr to IntPtr (intptr_t) though
>>
>>60621962
Rolling
>>
>>60625588
It looks like it works
>>
Have you practiced your Rust today, /dpt/?
>>
>>60623769
did you know that the actionscript VM is open source?
https://github.com/adobe/avmplus

someone tried making a nodejs-like cli interpreter:
https://github.com/corsaair/redtamarin
>>
>>60621962
Roll.
>>
File: index.jpg (8KB, 275x183px) Image search: [Google]
index.jpg
8KB, 275x183px
I have a Multi threaded chat server in Java, where multiple clients can connect and talk.

how do i implement a "blacklist" feature, that is, refusing connections from particular clients, identified either by their IP address or by their identity in the service?
>>
>>60625872
Make a blacklist file and when you receive a connection, if the IP is balcklisted, instead of accepting you just drop it
done
>>
>>60625872
,,,
>>
>>60625890
but i'm testing this on my computer, and the IP of the client connecting to the server will always be the same
>>
>>60625944
then use the fucking nickname
>>
So, I am trying to code a method in Java.
It should do the following:
Get the length of the array
create a blank new one with the same length;
then something to do with a for loop I guess:
For (int i = length SampleArray; i>=0;i--)
outputArray[0] = SampleArray[i];
outputArray[1] = SampleArray[i-1];

Ah yes, I should also come outclean and tell you gus I have no Idea about Arrays and I am just now learning what the fuck that is from tutorialspoint.
I guess I just want to know how I can refine my logic on these steps.
I am sure there are some things I just can't really know yet.

    static int[] reverse(int[] list){
int length =list.length;
//int[] actually, I just do not know how I should do the loop and am reading about arrays right now to get an idea.

return output;
}

psvm{
int[] sampleArray= {1,2,3,4,5,6,7};
reverse(sampleArray);
}
>>
>>60626056
https://en.wikipedia.org/wiki/Array_programming
int len = SampleArray.length;
for (int i = 0; i < len; i++)
outputArray[i] = SampleArray[len-i-1];

an array is sort of a container of a certain length from which allow you to insert, read, modify and remove objects. to retrieve an object, you pass it an index (starting from zero), like this:
myArray[myIndex]

note that, if an array start from index 0, and has a length len, the last element will be at myArray[len-1]
>>
>>60621778
Honestly, all you casual "Programmer" NEETs have not a simple clue what you're doing on your macbooks. Real programmers use windows and write real code, not stupid garbage that looks like english and only has a few lines. A real programmer could write what you guys can in a few lines in hundreds. Get real kids.
>>
>>60621962
Roll
>>
>>60626278
>windows
https://xato.net/windows-spying-and-a-twitter-rant-19203babb2e7
>>
File: 110.jpg (41KB, 400x300px) Image search: [Google]
110.jpg
41KB, 400x300px
>>60626278
You forgot linux fags who write custom scripts for their tile windows (gap)
>>
>>60626343
what's linux?
>>
>>60621962
rollan
>>
File: gnu-llvm.png (788KB, 3062x1618px) Image search: [Google]
gnu-llvm.png
788KB, 3062x1618px
well?
>>
>>60626278
here's your (You), because you had me until the second sentence started
>>
>>60626583
llvm is the primary backend for most things anymore.
>>
Go back to /a/
>>
>>60621778
I want to fuck visual basic, marry R, and have PHP as a daughter.
>>
>>60626278
>Using lines of code as a metric
What are we, IBM?
>>
>>60621962
>>
>>60626686
thats a murder suicide waiting to happen
>>
>>60626686
And this is why anthromorphizing programming languages is a bad idea
>>
>>60626712
Could anyone explain what the challenge is supposed to be?
>>
>>60626729
Do 98 if you're so smart
>>
>>60621962
JUST
>>
>>60626274
What about this?
        static int[] reverse(int[] list){
int length =list.length;
int[] output = new int[length];
int count=0;
for (int i =length-1; i>=0;i--){
output[count++] = list[i];
}


return output;
}

it works and I think is not so bad.

But I guess there is a lot of redundant code in it.
>>
>>60626743
I'm not implying I'm smart, I literally don't understand what I'm supposed to do, that's like the opposite.

I don't get how i can program "Internet Time"
>>
>>60622656
>Throwing Esperanto under the bus
Kaj vi estas gajan
>>
>>60621864
Tsutsukakushi the cutest
>>
>>60626686
I want to do a riming job on FORTRAN while fingering COBOL at the same time.

BASIC and C are taking Perl in a DP
>>
File: received_1777397529236955.png (302KB, 960x720px) Image search: [Google]
received_1777397529236955.png
302KB, 960x720px
How is everyone doing in Project Euler?
>>
What language (s) would you recommend a computer engineer to know aside from C/C++?
>>
>>60626848
are you bent on being employable?
Then java.
>>
>>60626845
Boring and too math focused.
I wish there was a project euler for more open ended/general programming problems that wasnt rampant with pajeets.
>>
>>60626848
C#, jQuery, JavaScript
>>
>>60626848
Haskell.
>>
>>60626845
Too much poojet pandered challenges.
>>
File: 1445705986467.jpg (31KB, 853x480px) Image search: [Google]
1445705986467.jpg
31KB, 853x480px
/dpt/ why does this code crash but only sometimes?
#include <stdio.h>
int main() {
int* x = malloc(sizeof(int));
*x = 12;
free(x);
printf("%d\n", x);
return 0;
}

Truly C is the worst language if it can't even behave consistently
>>
>>60626751
it's OK. you don't really need count, but, whatever

btw, that wikipedia article assumes you know some math, so just ignore it... wiki sucks for this kind of stuff, they love to throw very technical definitions where they aren't really needed
>>
>>60626845
to be divisible by 2 a number needs to be a multiple of 2
to be divisible by 3 a number needs to be a multiple of 2
to be divisible by 4 a number needs to be a multiple of 2 twice
...
it needs to be divisible by 2 four times, by 3 twice, and by all other prime numbers up to 20
so it's 2^4*3^2*5*7*11*13*17*19 = 232792560
gibe (You)s
>>
>>60626989
Because your using a language for cniles.
>>
File: images.png (5KB, 226x223px) Image search: [Google]
images.png
5KB, 226x223px
>>60626989
>, x
>not *x
>the code he's trying to ill-informedly laugh at for crashing doesn't even crash
>>
File: 1494830091136.gif (1MB, 500x280px) Image search: [Google]
1494830091136.gif
1MB, 500x280px
>>60621962
role
>>
>>60626989
C behaves consistently though. It's your operating system that gives you the segfaults and stuff.
>>
>>60626989
try not writing shite code
>>
>>60621962
roll
>>
>>60626989
because sometimes the operating system allows you to access the variable at x, but sometimes it has denied access between free(x) and printf(whatever, x)
>>
File: 2009-05-25-165998.jpg (220KB, 800x600px) Image search: [Google]
2009-05-25-165998.jpg
220KB, 800x600px
How do I into simple and fast webapps? I just want to do something and put it in a docker container.
What should I use?
>>
>>60627045
wait no, you're not accessing the variable but printing x as the pointer
are you sure you're not lying?
>>
>>60625193
>the first entry, or number 0
That's not what array indices mean. Array indices are distances, not ordinals.
>>
>>60626989
you should be more humble and not look for someone to direct your anger, frustration and incompetence unto.

t. some Loser trying to learn Java
>>
File: stoned-guy.jpg (24KB, 555x555px) Image search: [Google]
stoned-guy.jpg
24KB, 555x555px
>>60627097
The poster was a falseflagging C-tard who was trying to pretend to make fun of C in a stupid way as a strawman against sensible anti-C folk. However, as C-tards tend to do, he fucked it up.
>>
>WPF coming to linux
wowie
>>
>>60627168
>WPF coming to linux
>I can have a linux that looks like Windows
>wowie I can be in with the cool kids and still show my support for the big fat smelly shillcorp! :-D
>>
File: 1494851263619.jpg (33KB, 452x456px) Image search: [Google]
1494851263619.jpg
33KB, 452x456px
>>60627207
Why are you so mad, anon
>>
>>60627217
>he a winfag
>HE A WINFAG
>YOU A WINFAG
>LOL U A BITCH
>>
>>60626773
>Kaj vi estas gajan
This barely makes sense in esperanto, m8.
>>
>>60627086
elm desu.
http://elm-lang.org/
>>
>>60626989
>what is undefined behaviour
>>
>>60627246
>elm desu.
I'll check it out. Thanks
>>
File: 1473145203777.jpg (32KB, 712x714px) Image search: [Google]
1473145203777.jpg
32KB, 712x714px
>>60622738
>>
File: 1489027391040.jpg (170KB, 842x856px) Image search: [Google]
1489027391040.jpg
170KB, 842x856px
>>60621962
Rollan
>>
>>60621962
just fuck me up
>>
hmm.
Now I wonder how i can manage this:
Reverse an array directly.
Which means, I am not NOT allowed to make a new array for it.

So far, this is my idea:
{1,2,..,n} <-read length
take the n, push the values in these indexes a step forward so that index 0 will be empty.
Now put it there:
{n,1,...,n-1} repeat it until the condition is met, that the length of the for or while loop reaches zero...
>>
>>60621962
roll 2d10
>>
>>60621962
Let´s give it a try.
>>
>>60627485
you just did nothing
>>
>>60621962
>>
>>60627485
Congrats on your quadratic algorithm
>>
>>60625116
Easiest interface -> Lua.
>>
>>60625184
Love it. I know I'm alone with that, but I find that amazing.
>>
>>60624592
It's brainlet confusing over engineered with being well engineered, again. C++ is over engineered, and poorly at that.
>>
>>60621962
roll
>>
>>60627796
Looking for real language.
Ocaml seems to have decent ffi but it doesn't have native types, float in ocaml is just double which seems bit questionable.
Nim might be only statically typed language that has decent ffi to C.
>>
>>60627834
Multi-processor systems are becoming more common, but so are amazingly fast single-processors.
This implies the need for at least two forms of concurrency; multi-threading within a single processor,
and multi-processing with several processors. In addition, networking (both WAN and LAN) imposes its own demands
and special-purpose architectures abound. Because of this diversity, i recommend parallelism be represented
by libraries within C++ rather than as a general language feature. Such a feature, say something like Ada's tasks,
would be inconvenient for almost all users.

It is possible to design concurrency support libraries that approach built-in concurrency support both in convenience
and effiency. By relying on libraries, you can support a variety of concurrency models, tough, and thus serve the users
that need those different models better than can be done by a single built-in concurrency model.

-- Bjarne Stroustrup, PhD

also, Ada's object model is bad to the point no one want to use it in the industry.
>>
File: logo.png (10KB, 128x128px) Image search: [Google]
logo.png
10KB, 128x128px
>>60627885
Enjoy your added cognitive load then, maniac.
>>
File: book.gif (173KB, 400x486px) Image search: [Google]
book.gif
173KB, 400x486px
Do shell scripts have any semblance of variable scope within conditional blocks/loops, or is everything in the global scope for the entire duration of the program?
>>
>adult male
>not using rdmd instead of sh
>>
>>60626870
>*x = 12;
Does this input '12' at x's memory address or does it give x the address 12?
>>
>>60627901
>I'll post something that really doesn't say much about anything at all. Checkmate.
>>
>>60628008
pls respond
>>
>>60628031
>>60628008
Were meant for >>60626989 (how the fuck did I even end up quoting that post?)
>>
>>60627485
for(int i = 0; i< myArray.length; i++)
int tmp = myArray[i];
myArray[i] = myArray[len-i-1];
myArray[len-i-1] = tmp;
>>
>>60628020
>doesn't say much about anything at all
ok, since Bjarne words are too hard to understand for you, here a simpler version

Instead of offering an obsolete concurrency model as a library, Ada bloated its syntax and semantics to built-in it. but, yeah, that's totally not over engineering.
>>
>>60628031
pls gtfo
>>
>>60628203
I will after someone answers.
>>
File: mfw.jpg (5KB, 179x180px) Image search: [Google]
mfw.jpg
5KB, 179x180px
>mfw starting to harness C++17's true power
>>
>>60627955
In bash you can have function scope, but you need to explicitly declare it as 'local' or by using 'declare'.

good() {
local n

for n in {1..10}; do true; done
}

bad() {
for n in {1..10}; do true; done
}

n=5
good
(( n == 5 )) && echo true
bad
(( n == 5 )) || echo "n = ${n}"


true
n = 10
>>
>>60628234
I will only answer after you gtfo. DEADLOCK
>>
>hate Python
>want to find some fairly popular and simple language
>discover Lua
>learn it suffers from backward incompatibility
>hate Lua
What next should I look?
>>
>>60628242
whats even new in it?
>>
>>60626870
>boring and too math focused
Hello skiddy.
>>
>>60628263
I think you don't know the answer and are just avoiding my question.
>>
>>60628284
Nested namespaces are the killer feature desu
>>
>>60628242
killing your coworkers?
>>
>>60628285
I want broken programs to debug and fix, not re-implement algorithms.
>>
>>60628295
>on /g/
>works
>>
>>60628138
Thanks for doubling down on that "appeal to celebrity" fallacy.

Building it into the syntax allows it to be easier to use as offers optimizations, how is that "inconvenient" again, Bjarne?
>>
Recreating the Human theme in Ubuntu 8.04 on GTK+3
stay tuned
>>
>>60628290
>the killer feature
Well they certainly will kill any readability thats on life-support.
Would become a non-feature if sepples had proper modules though.
>>
>>60628301
Sorry you can't
#import <problemsolver>

for real life programming.
>>
>>60627812
Thanks, I think I'm going to add a proof of strict total order and a proof of the first element being n. Too bad the standard library doesn't have anything to help with the ordering proof, looks like I'll have to implement all the properties myself.
>>
>>60628301
>not re-implement algorithms.
>re-implement
>re-
>implying
Found the QA brainlet.
>>
>>60628008
the prior
>>
NEW THREAD!!

>>60628373
>>60628373
>>
>>60628327
Actually that's the vast majority of real life programming, which is exactly why it's a boring and horrible job and everyone who does it is a code monkey.
t
b
q
f
h
fa
ma
la
ma
ding
dong
>>
>>60626989
Can really NO ONE itt answer what
 *x = 12; 

does? (That is the problem line with your code by the way.)
>>
>>60628301
>>60628386
>he thinks euler programs require you to reinvent algorithms
So, how's that intro to programming class going along huh?
>>
>>60628400
>(That is the problem line with your code by the way.)
No, it's not, dumb samefag.
>>
>>60628355
What does
 x = 12 
do?
>>
>>60628400
CAN LITTERALLY NO ONER ANSWER 2+2=??
>>
>>60628251
Also didn't think about it when I posted but you can also create scopes with subshells, just wrap it in (). Although spawning a process just to have a scope seems somewhat inefficient.
>>
>>60628416
>No, it's not,
Why? What does that line do?
>>
>>60622279
Deprecated by Rust and modern C++.
>>
>>60621962
ROLAN
>>
>>60628355
wrong
>>
>>60625290
Why aren't the letters on the same line?

>>60628400
It writes 12 to the memory address of x because of the dereference pointer. Without the dereference pointer it would change the memory address x is pointing to.

>>60628424
Change the memory address x is pointing to to 12.
>>
>>60628616
Correct.
>>60628556
Incorrect.
>>
>>60627885
Lua is a good language.
>>
>>60621962
roll
>>
>>60626717
/g/ as a whole is one big murder-suicide waiting to happen.
>>
>>60626848
>[insert language NEET /g/ayman is shilling]

Why do morons even ask this question? Are you so new that you do not know people just shill one language to be tribalistic morons here? Just learn one language really, really, really well and then branch off to other popular languages from there.
>>
>>60621778
programming for uni atm
haven't showered all weekend and I sit here in my boxers and it's super warm
I stink

what do, finish or shower
you decide, /dpt/
>>
>>60629457
dress like a woman
>>
>>60629741
no clothes sadly
>>
>>60629805
I guess then take a shower then finish.
>>
>>60621962
whatever it is, im building it in js. im feeling edgy tonight
>>
>>60628327
are you stupid? have you ever actually worked in software development?
>>
>>60624803
for people who are on lsd and have the clever thought : "MDMA would go well with this wouldnt it?"
Thread posts: 337
Thread images: 43


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