/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

youtube.com/watch?v=XDWMqwXU9dQ
youtube.com/watch?v=eAkPbXwsii4
youtube.com/watch?v=qNG6ZBzVBvQ
en.wikipedia.org/wiki/Category:Common_Lisp_software
en.wikipedia.org/wiki/Category:Lisp_software
gamasutra.com/view/news/169296/Indepth_Functional_programming_in_C.php
youtube.com/watch?v=NyUMHEua7-A
web.cs.ucdavis.edu/~filkov/papers/lang_github.pdf
youtu.be/NbAjiLz26zM
twitter.com/NSFWRedditVideo

Thank you for using an anime picture.

what kind of music or noise do you use for concentration?

"The most powerful programming language is Lisp. If you don't know Lisp (or its variant, Scheme), you don't know what it means for a programming language to be powerful and elegant. Once you learn Lisp, you will see what is lacking in most other languages." -Richard Stallman

Hardcore techno

>Richard Stallman
Kept reading there.

Any non-free jazz or drone.

like what?

I'm making my own chan with blackjack and hookers: 4kev.org

Nigger rap

Apart from computer algebra systems what real world software uses a Lisp dialect?

emacs

youtube.com/watch?v=XDWMqwXU9dQ
youtube.com/watch?v=eAkPbXwsii4
youtube.com/watch?v=qNG6ZBzVBvQ

"The C programming language was a terrible mistake whose consequences continue to plague us 40-some years later."

Jon Carmak, 2016

en.wikipedia.org/wiki/Category:Common_Lisp_software
en.wikipedia.org/wiki/Category:Lisp_software

I meant for the source

I read that it's why I excluded CAS.

CAS isn't the only thing on there you liar.

Can I get away with putting C++ on my resume and write only C with classes?

I'm trying to make myself more employable and everyone here asks for java and C++.

Carmack would never say that. He still loves C.

u gon git fuked with template questions

It's a quote from Jon Carmak though.

constexpr auto operator[](std::ptrdiff_t n) const
{
switch (dir)
{
case up: return matrix_iterator { *this + n };
case down: return matrix_iterator { *this + n };
case left: return matrix_iterator { *this + n };
case right: return matrix_iterator { *this + n };
}
}
what the fuck am I writing
does any of this even make sense?

public class Exam{
private Float [] grade;

public void setGrade (...)
(...)
}

how do i set values for this type of array?

He took the functional pill years ago.
but
>I do think "good C++" is better than "good C" from a readability standpoint, all other things being equal.

>"good C++"
I've yet to see such a thing.

templates seem simple enough, I'd be willing to learn that, I just don't want to take a C++ job if I'll be expected to write idiomatic C++ all the time

the madman did it
gamasutra.com/view/news/169296/Indepth_Functional_programming_in_C.php

FAKE NEWS

How do I pass int pointers (arrays) to functions, manipulate the int pointer, and be able to use the modified array outside the function?

void getFractions(const int numTerms, int* numArray, int* denomArr)
{ //Runs Fine
std::vector A(numTerms, 0), B(numTerms, 0);
A[0] = 1; A[1] = numArray[0]; //b
B[0] = 0; B[1] = 1;

for(int i = 2; i < numTerms; i++)
{
A[i] = numArray[i]*A[i-1] + denomArr[i]*A[i-2];
B[i] = numArray[i]*B[i-1] + denomArr[i]*B[i-2];
}
std::cout

What interpreters does Sup Forums like to use on ipads/iphones?

I want to try some programming on the device itself.

>Indepth_Functional_programming_in_C
>Open link
>It's about C++
Fuck you.

Best books for Data Structures in Java? I'm in an introductory class and it's kicking my ass.

I need to learn more about:
Time Complexity

Lists
Stacks & Queues
Trees (Binary/Red-Black Trees)

And how to search through the aforementioned data structures.

Don't learn it for Java. Learn it in general, then apply the theory to whatever language you want. Also, CLRS

>CLRS
I've seen this recommended a lot, I'll check it out thanks.

And I'd prefer Java books just because I need to get this shit down pat relatively soon, and I feel that it'll be easier using a book that's Java oriented.

I know he's a functionalfag now, but C and C++ still have a special place in his heart.

I mean, he even described Java as a 'fully specified C.'

Well, the pseudocode in it is pretty easy to read, so you shouldn't have much trouble translating it to Java.

it's sunk cost fallacy. He knows what's right but he's shackled down by the chains and weights of C and C++

You need to understand C++ OOP syntax and understand OOP well, but not specifically have a bunch of experience in C++. While it is an OOP of sorts, implementations vary and the syntax can be asinine.

youtube.com/watch?v=NyUMHEua7-A

>C and C++ are bad

bokay

modern C++ is a bitch, mate

lots to learn besides C with classes

no wonder they call it OOPs

I think the issue with OOP is that it is object ORIENTED when it should just be object permitted. Most things in a program are not fit to be objects.

It's also taught very poorly. Big mistake I see all over the place with OOP users, that most OOP critics fail to point out, is the tendency to make superfluous superclasses. This ends up wrecking their architecture because they think they need to use their superclass for polymorphism, rather than a generic or just making multiple methods, or else the class would be useless.

This is especially bad in game programming where a lot of people try to make a superclass for every single game entity and then work with these entities only through the superclass.

somafm.com

space station groove salad or def con radio
black rock fm if you refuse patrician status

illinois street lounge if you're a lesbian with a dick

but they are

web.cs.ucdavis.edu/~filkov/papers/lang_github.pdf

>Haskell.png

>Haskell
Trash.

bokay

back to /o/ turd

no!

boy i sure can't wait for you to post that copypasta

I'm trying to get a job, the language is c# I'm missing something simple here, I'm just trying to read through a file line by line to search for something in particular then print it out. but I'm missing something here.

replace "C:\\FINIS_IT.txt" with reader

source: i don't know C#

*whips out dong*
suck it jungle boi

- Just like C++, Haskell is very hard to learn, and takes years to master. Things like Monads, Functors, Monoids, Higher-Order Types and a myriad of morphisms are hard to understand, especially without mathematical background. So most programmers probably don't have the ability or will to learn haskell. By all means, Haskell is not ‘simple’ or newbie friendly. Learning its syntax, its libraries, functional programming techniques won't bring you closer to understanding. The true path to understand Haskell lies through Monoid-Functor-Applicative-Arrow-Monad. And even if you mange to learn Haskell, programming it still hogs a lot of brain resources, which could have been put to something more useful, than just showing off about how clever you can be. "Zygohistomorphic prepromorphism: Zygo implements semi-mutual recursion like a zygomorphism. Para gives you access to your result à la paramorphism." -- HaskellWiki
- Haskel is slow and leaks memory. GHC's slow stop-the-world GC does not scale. A good understanding of evaluation order is very important for writing practical programs. People using Haskell often have no idea how evaluation affect the efficiency. It is no coincidence that Haskell programmers end up floundering around with space leaks that they do not understand. "The next Haskell will be strict." -- Simon Peyton-Jones

- Haskell's API lacks higher levels of abstraction, due to absence of variadic functions, optional arguments and keywords. Macros aren't possible either, due to overly complex syntax of Haskell. API documentation is very lacking for newbies: if you want to use regexes, you start at Text.Regex.Posix, seeing that =~ and =~~ are the high level API, and the hyperlinks for those functions go to Text.Regex.Posix.Wrap, where the main functions are not actually documented at all, so you look at the type signatures, trying to understand them and they are rather intimidating (class RegexOptions regex compOpt execOpt => RegexMaker regex compOpt execOpt source | regex -> compOpt execOpt, compOpt -> regex execOpt, execOpt -> regex compOpt where). They are using multi-parameter type classes and functional dependencies. The signature really wont give you any clue to how to actually use this API, which is a science in itself. Haskell is a language where memoization is a PhD-level topic.
- Haskell programming relies on mathematical modelling with type system (a version of mathematical Set Theory). If one does not use the type system for anything useful, it obviously will be nothing but a burden. Programs are limited by the expressiveness of the type system of the language - e.g. heterogeneous data structures aren't possible w/o reinventing explicit tagging. All that makes Haskell bad for prototyping and any new situation, due to need of having design document with all types beforehand, which changes often during prototyping. Any complex project have to reinvent dynamic typing. For instance, Grempa uses dynamic typing because the semantic action functions are put in an array indexing rule and production numbers (Ints) to functions, and they all have different types and so can not be put in an ordinary array expecting the same type for each element.

Daily reminder that probability distributions form a monad

- The IDE options cannot be as good as those of dynamic programming languages, due to absence of run-time information and access to running program's state. Haskell's necrophilia forces you to work with "dead" code. Like other static languages, Haskell isn't well-known for its “reload on the fly” productivity. No eval or self-modifying code. Haskell code can't be changed without recompiling half-of application and restarting the process. GHCI - is the best Haskell's interactivity can get, and still wont allow you to change types during runtime. As said Simon Peyton-Jones, "In the end, any program must manipulate state. A program that has no side effects whatsoever is a kind of black box. All you can tell is that the box gets hotter."
- Type system and compile-time and link-time errors are distracting and make it harder to run and test your code. And type-checking isn't a substitute for testing. Type-checking is about correspondence to mathematical model, which has nothing to do with correctness - i.e. two numbers can be integers, but their quotient can still result into division by zero. Even though you may hear strong static-typing advocates say, “When your program type-checks, you’ll often find that it just works”, this is simply not true for large, intricate programs. Although type-checking may help you find model-related errors, it is not the same as testing. Thus, it is not a suitable substitute for testing.

>variadic functions, optional arguments and keywords

- Absence of dynamic scope, implicit open recursion, late binding, and duck typing severely limits Haskell, since there are things that can't be done easily without these features: you can't implement dynamic scope in general (and be type-safe) without converting your entire program to use tagged values. So in this respect, Haskell is inferior to dynamic typing languages.
- Haskell makes it easy to write cryptic programs that no-one understands, not even yourself a few days later. Rich, baroque syntax, lazy evaluation and a tradition defining an operator for every function - all help obfuscation a lot. As a general rule, Haskell syntax is incredibly impenetrable: who in their right mind thought up the operators named .&., and >>=? And, just like with Python, indentation based syntax makes Haskell unusable for CLI.

>Type-checking is about correspondence to mathematical model, which has nothing to do with correctness

R is a functional language

It didn't work unfortunately.
I'm trying all kinds of stuff. i was hoping another set of eyes could see where I'm messing up.

First line sets up the stream reader for the file

2nd line reads through the filw line by line and adds it to the list
the third line reads through that list for a certain word to ass to a new list

4th line prints out the list of sorted words.

Anyone from here frequents ?

Nope.

No. Your kind is not welcome here.

You are actually passing numArray and demonArray pointers by value, and thus go out of scope and are deconstructed. Since this is C++, pass in the pointers by reference, int* &numArray ect (also, why not use vector instead of int arrays?)

you're in the wrong part of town, buddy.

keep moving

I went there looking for an artist, but after telling him which engine I used, he said he wasn't interested

You have to go back.

I was wondering if it was as infested with meme spouters as /dpt/. I mean just look at the replies I got and factor in barely anyone shows anything non trivial in here.

youtu.be/NbAjiLz26zM
This

If you're bothered by such things you will likely not find satisfaction anywhere. Take the good, ignore the bad. /agdg/ has some great discussion, some interesting games, some people work on their own engines, even some work on their own languages. But also a lot of memery and shitposting. But for the specific programming topics that come up in gamedev, it's a fine resource, just don't expect too much.

I see, thanks for the feedback.

I think that functional languages are used by people who give a fuck. OOP is used by pajeets

What is the licensing of code in media like films? Pic related, from Ex Machina. It's a really slow sieve, apparently written in Python, but reusable instead of a generator.

Trying to learn python here but I have no idea why this code isn't working. The text file contains days. Trying to take the first line in the text file and put it in ReadLines label.
from Tkinter import *

def Last():
Read = open('filename.txt', 'r')
firstLine = Read.readline()
ReadLines.config(text=firstLine)
Read.close()

def main():
root = Tk()
root.title("Sayings")
root.geometry('500x230')
w1 = Label(root, text="Line")
w1.pack()
ReadLines = Label(root, text='', width=50)
ReadLines.pack()
LastButton = Button(root,text="Last", width=9, command=lambda:Last(firstLine))
LastButton.pack(side=LEFT, padx=5, pady=5, anchor=SE)
root.mainloop()

if __name__ == '__main__':
main()

using System;
using System.IO;
using System.Linq;

namespace FileSorter {
public class Class1 {
public static void Main(string[] args) {
try {
using (var file = new StreamReader(@"c:\finis_it.txt")) {
foreach(var line in file.ReadToEnd().Split('\n').Select(line => line.Trim()).Where(line => line.Equals("start"))) {
Console.WriteLine(line);
}
}
} catch(Exception e) {
Console.WriteLine(e);
}
}
}
}

I'm going to hell for this.

Can I pause a Javascript function until a condition is changed, rather than pause the function for a specified time?

The problem is that there's an animation I run with recursive requestAnimationFrame, but the function that began the animation doesn't wait for the animation to finish to continue, resulting in things finishing in the wrong order.

no, write a few small applications in idiomatic C++ and do all the C++ challenges on hackerrank. You'll be less fucked during interviews.

ReadLines in main isn't in the scope of Last. Also make regular variables lowercase.

>using System;
>using System.IO;
>using System.Linq;
>namespace FileSorter {
> public class Class1 {
> public static void Main(string[] args) {
> try {
> using (
>
> } catch(Exception e) {
> Console.WriteLine(e);
> }
> }
> }

awful boilerplate

Yeah, I'm fucking retarded. Is there a way I can make the last button switch to the next line every time clicked?

don't hate on brackets, blocks are important to denote

You just saved my life wtf how.

I'm really sorry to ask but
could I possibly get a 30 second explination of this?

Why does the try and catch make such a huge difference? The rest of the changes I think i understand.

I was trying to use a lambda equation to shorten it to 3 lines. But I guess thats a nono?

>Open image
>Oh guess someone is asking for help with their babby's first assignments again, cannot even read the errors
>"I'm trying to get a job"
>There's even another bigger retard here solving that shit for him
THE STATE OF THE INDUSTRY

was meant for
but now I'm getting this error.
Currently googling the error.

Well, help me out.

C# isn't my language.
I picked it up literally yesterday.
I do python and c++ and java ruby and sql

This job wants c# so I'm going to give them C#

>6 levels of indentation just to print some shit

welcome to oop son

Well teach me.
Its not like C++ or python like I'm used to.

I wan't to learn this stuff, and I'd like to learn it right. But youtube/Google can only take me so far.

this was an excellent anime btw

It's called OOPs for a reason

>i do many programmings yes sir
>cannot even tell what's wrong when the fucking IDE is telling you exactly what's wrong
>literally cannot read
Fuck off deadweight pajeet, if you get stuck with trivial shit i don't want you anywhere near anyone's production codebase

Yes the IDE tells me whats wrong, but the IDE doesn't give a specific solution. it just gives me an error and a description.

but "the name 'file' does not exist in the current context." isn't exactly a solution now is it?

Thank you to everyone that actually provides the help. It means a lot.

>The name 'file' does not exist
yeah, thats a solution pajeet.

>Argument 1: Cannot convert from 'String' to 'System.IO.Stream'
>the name 'file' does not exist in the current context
I don't even, how the fuck do you jump from that conclusion from that first line?

I've been trying to fix the problem.
Came to this.