/dpt/ - Daily Programming Thread

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

Other urls found in this thread:

realworldocaml.org/v1/en/html/objects.html
strawpoll.me/10985214
papers.nips.cc/paper/5548-discriminative-unsupervised-feature-learning-with-convolutional-neural-networks.pdf
learncpp.com/
news.ycombinator.com/item?id=12288375)
twitter.com/pythontrending)
geeksforgeeks.org/virtual-functions-and-runtime-polymorphism-in-c-set-1-introduction/
drbio.cornell.edu/pl47/programming/TICPP-2nd-ed-Vol-one-html/Chapter15.html
codingunit.com/cplusplus-tutorial-polymorphism-and-abstract-base-class
amazon.com/Primer-Plus-6th-Developers-Library/dp/0321776402
amazon.com/C-Programming-Language-4th/dp/0321563840/ref=sr_1_1?s=books&ie=UTF8&qid=1471262564&sr=1-1&keywords=The c++ programming language
amazon.com/Programming-Principles-Practice-Using-2nd/dp/0321992784/ref=la_B000AQ349S_1_2?s=books&ie=UTF8&qid=1471262581&sr=1-2
gitgud.io/vc/vcaim
unknowncheats.me/forum/counterstrike-global-offensive/181878-linux-basehook.html
twitter.com/SFWRedditImages

how do you ignore the output of a haskell function

like ignore function from Ocaml

Yes, it is blantly obvious that you believe C is the best. That is still ignoring the core issue of what is bothering you mentally enough that you must release such negativity and aggression upon others?

Thank you for not using an anime image.

I read over it again and its starting to make a bit more sense, thanks user.

What is decent, good, mediocre, too simple and bad final year project, it has to be in C++ or python, I prefer C++ tho.

Is vehicle register plate library + id of the owner etc. register program good enough ? Most of my peers are doing calculators and such, but I've done things like that in second year, so I was wondering...

What have you done for your project ?

I'm trying to make an interpreter I build rewind state when there are parse/vm errors.

Machine learning + image recognition for identifying plants by their leafs and flower.

A small Turing complete interpreted scripting language.

>Turing complete
>scripting language
Are you looking for trouble?

A finite state machine that accurately portrays a woman's mood swings.

You can build a lisp?

:P it's not really that complex. Need I remind you that brain fuck is turing complete?

tell me my dudes, how "objective" is Ocaml?
do libraries use objects for everything like java/python?
I like haskell and doing "low level" stuff so I thought I'd learn it
(also I was looking for the book Modern Compiler implementation in ML but didn't find it)

hey Sup Forums

Does java have something similar to function pointers, or lambdas?

I have Class 1 and Class 2. I need to pass Class1.Method1(), to Class2.Method2()

Return type is void, and it Class1.Method1() doesn't take any arguments.

not at all dude, it isn't like scala
it's basically just ML

just pass it, in java every passing is done with pointers anyway, its just done in hidden way

realworldocaml.org/v1/en/html/objects.html

Not really that noticeable. It's basically Lisp with object constructs.

Have your function return an empty tuple (), or an IO () if your function has IO side effects.
example in ghci:
>let f x = do print "hello world"; return x + 3
>f 2
"hello world"
5
> do f 3; return ()
"hello world"

Tbh do notation makes it a bit _too_ easy to ignore the result of a computation, to the extent that it can be a gotcha in some situations.

As what type? In C++ I could just pass it as a templated type, e.g.
template
function foo(T bar){
// do stuff
bar()
// more stuff
}

I should mention i OCaml as a general rule of thumb objects are not used unless there is a specific reason for it (Records of functions with polymorphic types, open recursion, row polymorphism / subtyping).

Also, without do notation it'd be f 3 >> pure ().

is it worth to learn haskell?

I wrote my own ls in [spoiler]java[/spoiler]

Java has lambdas. To hold a reference to one, you need a variable of the type of a functional interface whose method matches the signature of the lambda expression or method reference you want to store in it. Easier to explain by example:

// One-liner
Runnable run = () -> System.out.println("spicy cocks");

// Block
Consumer cons = (str) -> {
final String uc = str.toUppercase();
System.out.println(uc);
}

// Method reference
Function

As any type. Almost everything is a boxed pointer.

Thanks.

yea

nah

no

looks good, thanks

Also worth noting is that you can use lambdas or method references in place of any "functional interface" (ie., an interface with a single abstract method). That's actually what's going on in the examples above.

So, all of the following are functionally identical:
public class DickPanel extends JPanel {
public DickPanel() {
Button button = "Share on Reddit";
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println("upboated");
}
});
}
}

public class DickPanel extends JPanel {
public DickPanel() {
Button button = "Share on Reddit";
button.addActionListener(() -> System.out.println("upboated"));
}
}

public class DickPanel extends JPanel {
public DickPanel() {
Button button = "Share on Reddit";
button.addActionListener(this::onButtonClick);
}

private void onButtonClick(ActionEvent e) {
System.out.println("upboated");
}
}

No problem.

yes

Now make it run as a daemon/client to avoid the JVM startup delay.

strawpoll.me/10985214

How would I get metadata for an mp3 file without the PHP ID3 library?

ffmpeg or mp3lame, Pajeet.

using PHP, specifically.

in other words, what in the fuck are the ID3 tags, and how are they accessed..?

in other words, on a website... without installing extra libraries

Why is visual studio so horrible?

I'm considering just saying fuck it and doing everything in emacs + mono.

>the Soros meme
the (((Koch))) brothers have more money in a single pac than George's Soros net worth times a thousand. and they support (((Trump))) via indirect contributions.

Write an mp3 decoder in PHP :^)

ditch the personal home page hack from 1995 get node-lame

I downloaded 2500 images from flickr, for each of hem found a 32x32 patch that is the most interesting, and am generating 49 variations of it. I altter horizontal/vertical position of patch a bit, rotate the picture a bit, change contrast, and change hue, saturation, lightness.

Pictured is original 32x32 patch(0.png) and its 50 variations.

I'll use this set of images to do unsupervised learning and create some nice convolution kernels that I'll later use for image identification.

Spent 2 hours porting c++1z project from visual studio to cmake on linux. This was most painful setup i have ever done. Freakin experimental c++14 features, old version of g++ on gentoo and retarded clang.

Ditch the hipster web designer's excuse to be backend and use Go.

use codeblocks

the sensible thing to do would be to use the PHP ID3 library but sure have fun programming it yourself in PHP

>Why is visual studio so horrible?
Well, that's like, your opinion, man.

Takes forever to open, but nothing compares to the feature set. I couldn't imagine dealing with some of these huge projects without the integrations it has.

I suppose if you're doing trivial

What's wrong with this code?

class NDouble : public NExpression {
public:
double value;
NDouble(double value) : value(value) { }
virtual llvm::Value* codeGen(CodeGenContext& context);
};


It throws:
undefined reference to `vtable for NDouble'


Using g++ Parser.cpp Tokens.cpp Main.cpp `llvm-config-3.8 --cxxflags --ldflags` `llvm-config-3.8 --libs core executionengine interpreter analysis native bitwriter mcjit --system-libs` -o Kaleidoscope -std=c++11

You don't call the function, or if it's in monadic code, you use void, or just return ()

did you implement virtuals?

I'll just fricking download it and see what I can do with it.

The freaking thing uses some kinda ".inc" file. IDEK what that is.
I wonder if it can be converted to PHP easily...
Some of the code looks similar...

Fuck it for the time being, though. I've been wasting too much time with this atm.

I am so tired of these types of comments, in specific...
"Don't use X, use Y!! huehuehuehue!!!!111 it's so funni, becuz u wanna... use X, so... heuheuheu!!!1!!eleven SO... SO Y is funnieeeee!"

That's pretty interesting.

This is my first attempt at C++ and I don't know the language. This is third party code.

Do I need to implement virtuals for what?

Pajeet plz

The same thing I've been doing for the last few months, working on my crappy fps.
I have to finally get the friggin' map editor done. After that it should be enough to just make a few maps, add "campaign" support and I should finally be done with this shit.
I mean, it's fun to playtest, but it's been 18 months so far and I'm getting tired by the fact it's still far from release-ready.

If you're interested, I'm following steps described in papers.nips.cc/paper/5548-discriminative-unsupervised-feature-learning-with-convolutional-neural-networks.pdf

undefines for vtables means a virtual in CLASS has no implementation.

You're trying to use a source that doesn't exist, only a declaration.

Every virtual function needs to have its implementation in child class else you get vtable errors

class A {
virtual void foo();
};
class B : public A {
//has to implement foo
void foo() {printf("bar");}
};

Neat, thanks! I'll save it and check it out when I have time.

Why in the fuck do you keep calling me "Pajeet"?

I'm like one of the few people here who gets called this regularly.
What in the shit sounds Indian about me at all?
I live in fucking New York, and my heritage lies nowhere South of Austria and nowhere East of Ukraine.

There are virtual functions declared in NExpression, or one of its superclasses, and you need to overwrite them.

Every *abstract* function needs to be implemented in the child class.
Virtual functions implemented in the parent can be inherited.

here

This guy is right. I should have said *pure* virtual.

Pure virtual functions are denoted by an "= 0" after the closing parenthesis of the method, e.g.
class foo {
virtual void bar() = 0;
};

class NExpression : public Node {
};

class NStatement : public Node {
};

class NInteger : public NExpression {
public:
long long value;
NInteger(long long value) : value(value) { }
virtual llvm::Value* codeGen(CodeGenContext& context);
};

class NDouble : public NExpression {
public:
double value;
NDouble(double value) : value(value) { }
virtual llvm::Value* codeGen(CodeGenContext& context);
};

class NIdentifier : public NExpression {
public:
std::string name;
NIdentifier(const std::string& name) : name(name) { }
virtual llvm::Value* codeGen(CodeGenContext& context);
};


codeGen is overriding it on every method isn't it? Can a virtual override a virtual?

You're only making it worse by responding to them. If you don't respond there's a chance they'll get bored and stop. If you provide them with the response they yearn so dearly for, even one, that fuels shitposting for days.

Ah yes you are right, freakin terminology but its important nontheless

You have a point.

They must just be fucking trolling faggots...

there is no implementation for codeGen, if this is your first brush with c++ i suggest you to drop that code and start small

Because there is literally no excuse to using PHP or Java in what seems to be a personal project. There are problems with every language, but Java and PHP are universally agreed to be an absolute clutrefuck and only have ad populum arguments going for them. The only reason anyone would is because they can't use anything else, thus Pajeet. Quack!

>Can a virtual override a virtual?
Yes. Also, if a function is declared virtual in the base class, then it is implicitly virtual in all derived classes. Also, what this guy said

hey white boy... call him pajeet one more time and you'll have to deal with me...

>Java and PHP are universally agreed to be an absolute clutrefuck and only have ad populum arguments going for them
You are misinformed. Plenty of people are cordial towards Java. Including me. And I wrote programs in plenty of languages. I'm fairly fluent in C, C++, Java, C#, Perl, Javascript, Python (python to a lesser extent). My opinion is that Java is a good language.

What are some good tutorials then? Preferably >C++11

P A J E E T
A
J
E
E
T

None of them have a actual implementation for codeGen.

You should be doing something like this

class Base {
virtual returnType codeGen(argType* arg) = 0;
};

class Foo : public Base {
virtual returnType codeGen(argType* arg)
{
doShit();
};

learncpp.com/

No good video tutorials that i know of but for modern c++ this book:
Programming: Principles and Practice Using C++ (Bjarne Stroustrup)

Inb4 I leave out a brace..

class Base {
virtual returnType codeGen(argType* arg) = 0;
};

class Foo : public Base {
virtual returnType codeGen(argType* arg)
{
doShit();
}
};

This is Base btw

class Node {
public:
virtual ~Node() {}
virtual llvm::Value* codeGen(CodeGenContext& context) { return NULL; }
};

m8, stop using code you don't understand.
learn the language first and come back to it. That way you can understand whether you can do it better or improve it.

>tfw your project got highlighted in hackernews(news.ycombinator.com/item?id=12288375) and python trending(twitter.com/pythontrending)
>tfw daily visitor count increased to 2700 from 40

Just checked again, it's around 2900. What a joyful day to be in

Why is C++ better than C?

this won't fix your problem but
if Node will never be used itself (i.e. it's just an abstract base class), set them to = 0
virtual ~Node() = 0;


he's got a moustache now

C++ is not universally better. If you need oop than it is better yea

Namespaces, templates, type inference and ad hoc polymorphism
And soon (ish) modules, coroutines, concepts

>if you need OOP
please stop slandering C++

>turkey
how's turkey? do you know anzu?

Either way when you define the function in a class that inherits from Node you overwrite the default definition.

I'd suggest doing some research on C++'s implementation of polymorphic classes before trying to use them.

geeksforgeeks.org/virtual-functions-and-runtime-polymorphism-in-c-set-1-introduction/

drbio.cornell.edu/pl47/programming/TICPP-2nd-ed-Vol-one-html/Chapter15.html

codingunit.com/cplusplus-tutorial-polymorphism-and-abstract-base-class

amazon.com/Primer-Plus-6th-Developers-Library/dp/0321776402

amazon.com/C-Programming-Language-4th/dp/0321563840/ref=sr_1_1?s=books&ie=UTF8&qid=1471262564&sr=1-1&keywords=The c++ programming language

amazon.com/Programming-Principles-Practice-Using-2nd/dp/0321992784/ref=la_B000AQ349S_1_2?s=books&ie=UTF8&qid=1471262581&sr=1-2

More power and tools to use.
You don't have to waste your time implementing basic tools yourself.
You no longer need to think in hacky workarounds for OO stuff. Because everything is right there for you.

C++, like most things gets a bad rep for bad users and their parroting to create more bad users.

Most of C++'s problems are actually because of legaC support.

I was lazy to type... point is if you need c++ features you should use it otherwise its no better for that task

yea it was just for benchmarking and making sure it runs since lazy

This guy recommended some fine books You should listen to advice you got

gud shit
you know anything about linux csgo cheats? and x64 offsets?

gitgud.io/vc/vcaim
unknowncheats.me/forum/counterstrike-global-offensive/181878-linux-basehook.html

>do you know anzu?
No, I don't know him. But he must be suffering a lot, considering that he's going bald.
>how's turkey
Packed my luggage already in case of an HABENING, that's how it is

Nice. Thanks.

C++17 looks pretty cool from what I'm reading.

it's a girl, there are pictures already

>it's a girl

That's rich, mate.

No, unfortunately. I've only tried cheating on a few games since I'm new at linux. I'll try to involve in serious challenges as soon as this project finishes. Btw I've written many CE scripts for winshit, including an aimbot for soldat.

Ok, boss. If you say so

Holy shit, MIT literally has a whole course on SICP.