/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/No_true_Scotsman
twitter.com/SFWRedditGifs

I'm reading (modern) OpenGL tutorial, this shit is dense.

lol don't even bother if you're not prepared to go full autismo

Functional programming thread:

I think I'm prepared, sometimes it even looks like I can see the rationale behind the design and understand the logic of it.

...

Working on mesh protocols for making my own modular alarm system more convenient.

anime filter to scan MAL and then auto hide messages and images on Sup Forums that have a >75% correlation to anything in it's database

The forums? I don't understand.

I don't think my Anime list forum users intersect that much here.

whats the best way to store structured text data in java, without the need for external libraries?

My bad, should have clarifed. It logs the cast list of the currently airing series, searches the series name into google images and stores a handful as reference. If a post on Sup Forums mentions a name or posts an image of one of said series it auto-hides the post.

JSON.
> without the need for external libraries
Stop being a NIH retard.

what do you mean like storing each word of a text? Or blocks of text files as whole unit

So basically you don't want to see people who save Anime images for later use?

this is what I have right now. it will become unwieldly if I add much more.

public static Map parameterkeys = new HashMap();
static {
parameterkeys.put("Substance", new String[] { "R", "Node ID", "CAS Code", "EU Index Code", "EINECS Code", "GADSL Duty to declare", "GADSL isUnwanted", "GADSL isProhibited",
"isReach", "isHidden", "isDeleted"});
parameterkeys.put("SubstanceSynonym", new String[] {"RN", "Node ID of basic substance", "Synonym ID", "ISO Language", "Synonym"});
parameterkeys.put("Company", new String[] {"FI", "Company ID", "Company Name", "Street", "Postbox", "Country Code", "Postal Code", "City", "Is Deleted",
"Is OEM", "Duns - Number"});
}

>store structured text
Store it as a text file in the working directory of the application and read it in.
>this specific case
Yes. Read it in then parse it into an array of strings. I suggest you use newline as delimiter.

>finished core stuff
>time for the ui

UI is the most fun part. Or is it?
What are you using?

its a webapp, so doing the UI means css, javascript and other hilarities

eeeh ... still better than having to learn Qt, I guess

Can anyone recommend a python gui? I was using tkinter but the documentation is poor; There must be something that is still in active development.

Is this language that bad? I mean, it must have some redeeming qualities, considering how widespread it is.

>it must have some redeeming qualities
No, not really.

I've heard Python have decent qt bindings.

>Is Java that bad?

>having to learn Qt
What do you mean by this?
You have to add the moc to the cmake, and learn the structure of signals and slots, but other than that, it is the same as everything else.

> it must have some redeeming qualities

Makes it difficult to fuck up
Easy to find and hire programmers in it

>I mean, it must have some redeeming qualities

It is:
- portable to multiple devices
- not too high-level, not too low-level
- very enterprisey, only C# has similar commercial forces behind it

> not high-level enough, not low-level enough
ftfy

Qt is awful.
Luckily there are alternatives.

> Qt is awful.
y tho

it's literally one of the best languages, the hate it gets is mostly hipster fedora tipping and mad jelly butthurt memes

Bloated, improper use and abuse of c++, redundancies, etc.

nice autism

Is Smalltalk the only true OOP?

en.wikipedia.org/wiki/No_true_Scotsman

No, message-passing is an inherently retarded way of doing OOP.
The true OOP is Simula -> C++ -> Java/C#/Most of the languages out there.

> improper use and abuse of c++
Like what?

It's stuck with the idioms that were popular during C++98/03.

OOP

And whats wrong with that? New != good

Huge inheritance trees aren't fun, and the whole memory management in Qt looks as if you were leaking memory everywhere.

>message-passing is an inherently retarded way of doing OOP
Message-passing is one of the things that defined OOP, idiot.

What's better than QT?

He doesn't actually know what OOP is.

"->" does not mean "is greater than"

There are no better alternatives, that's the problem.

> whole memory management in Qt looks as if you were leaking memory everywhere.
Only looks like or does it actually leaking that mach of memory? Im not really into Qt's innards. Also I do agree that garbage collection is never a good idea.

Why os Open Source so shit for everything not ultra low level/simple?

>The first OOP language, Simula, has no message-passing
>The most popular OOP languages, Java and C++, have no message-passing
Are you these retards who think Smalltalk invented OOP and CLOS perfected it?

>The first OOP language
That's like saying Adam was the first Christian

You use new everywhere, and it cleans it up somewhere under the covers, but I like the way of smart pointers which Qt doesn't embrace.

A method call is a form of message passing.

Adam wasn't christian though.

Well done user

Well done

:)

If it's just a map, use Properties.
If you need lists, but nothing more fancy than that, use Properties, and split on '\0'.
If you need to have a full on hierarchical database, use XML. Java comes with parsers, both SAX and DOM.

How viable is learning programming to do freelance for some extra cash?

I'm living with my mom right now while I'm trying to get into college and our health insurance rates go up by a lot if the household makes 15 more dollars a month than we do so I can't get a normal job, but if I were able to get money through paypal or something it wouldn't be on the books so I could actually do something and programming seems like it could work for that purpose but idk

pic unrelated

Message-passing implies that an object dispatches method calls dynamically by their name, up to responding to non-existent methods on the fly. This approach prevents any optimizations while adding nothing useful. In contrast static dispatch + vtable in modern OOP languages reduces costs of abstraction almost to zero without loosing much of an expression power.

>Message-passing implies that an object dispatches method calls dynamically by their name
no

not really

also
>optimisations
>abstraction cost
nothing to do with OOP

Not that hard to make money on freelance. I would suspect the IRS takes a close look at most freelancing sites though...

>Message-passing implies that an object dispatches method calls dynamically by their name, up to responding to non-existent methods on the fly
No it doesn't.

Well, I've looked it up and I guess I was wrong, message-passing is quite a general them.
That I meant is over-reliance on dynamic dispatch in Smalltalk, with classes having no fixed sets of methods they're able to respond to, combining with dynamic typing.

The language as of Java 8 (and Java 9's preview) is pretty good.

The problem is that the community is filled with retards that can't get shit done, and compensate with adding shitty classes everywhere to make it look like they're doing something.

You might want to do
shitpostDao.shitpostsFrom(someTripfag).parallelstream()
.map(Shitpost::getText)
.map(String::toLowerCase)
.map(TextAnalyzer::removeStopWords)
.map(sp -> new TextAnalyzer.analyze())
.forEach(paraCollection.add(a));


And think that this is an excellent way of programmatically removing shitposts.
Just make sure that paraCollection can handle parallel additions in some way. You can now use more cores than AMD itself can throw at you. And you only had to figure out what collection to use.

But no. People still write code as if Java 5 was new, and the simplified for-loop is a bit too new for them. It's saddening.

>hurr durr nobody uses FP
>hurr durr FP is shit

>lambdas are almost universally accepted and praised

>mfw I'm practicing Java 8 features now on my Starcraft Brood War AI

I obviously meant

> .map(sp -> new TextAnalyzer.analyze(sp))
> .forEach(a -> paraCollection.add(a));

Whoops.

Are there any other neat additions to Java besides lambdas?

Collections, Time APIs, and other utilities for the Object classes and other shits that I barely use

C++
>[&](int x) { return x + 1; }

Java
>x -> x + 1

Why is C++ so verbose?

You don't need & in your example.

>>lambdas are almost universally accepted and praised
says who? they're mostly irrelevant outside of cs101 and FP langs

>new TextAnalyzer instance for every shitpost
>Java is slow and uses many RAMs

Haskell
> (+1)

kys

Why so mad?

I am making bash script which scans webservers(on port 80) which:
>loads an IP list
>scans several common places where the "phpinfo()" config file is stored
>extracts founded servers' "System"(IE. kernel version) when they are found(200)
>saves them to file with the IP, kernel version, documentroot location and eliminates honeypots

I am not a great programmer so some parts are a bid tricky. I have the basic scanner for the "phpinfo()" file down which saves founded configs(status code: 200 & correct title information) but actually making it
quick, and scraping the config file hard.

The only way I can think of doing it with bash is using:
-wget to grab the entire config file
-greping the lines I need
-saving the correct information to file
-rming the config file
-repeat until it has reached the bottom of the ip list

:|

What I don't get is the languages that use the literal 'lambda'. Like, how Common Lisp's (lambda (x) (+ x )) is a good idea?

java.time.* comes to mind.

the JDBC classes got better too.
If I want to store, say a UUID on a PostgreSQL database, I can define my table with the uuid datatype, and use setObject to set a java.util.UUID directly. None of that retarded casting via string shit. If the database engine supports the datatype directly I can now often just setObject it, and life is better for it.

There's also default methods for interfaces, which means you can do this:

package ...;
import com.google.gson.Gson;

public interface Jsonable {

default public String toJson() {
Gson gson = new Gson();
return gson.toJson(this);
}
}


And now all you need to do to get a Json-representation of your object is to have its class implement Jsonable.
And if you need to wiggle some waggles because Gson doesn't do the right thing, just override the method for that usecase.

Collections and Arrays now have parallel sorting, so you can go for MOAR COARS if you want to without having to specify it yourself.

All in all, a whole bunch of neato concurrency stuff has been added, along with cryptographic enhancements nobody on Sup Forums will really care about.

Those are the ones I can remember off of the top of my head.

But Java 7, 8 and 9 are really mostly about making your life easier and comfier. There are still people out there that don't use the java.nio.* packages ffs. I blame outdated learning material. People google how to do things and they find old shit on StackExchange from 2007 or whatever.

And then one day, you stumble across a package that solves every annoyance you had, which had been there for ages. Kinda like Unix in that regard. Suddenly you find that one command that does exactly what you need.

It's a bit verbose, but to be fair that is kind of asking like why languages use a literal "for" or "if"

> Object creation is cheap in Java.
> You need a new object, because every shitpost-analyzer will have its own state that cannot be shared.
> We're running on fixnum cores.
At worst, I'm trading RAM for speed.
Also, if I'm using the generational garbage collector, then the analyzers won't necessarily make it out of the nurseries, and will be collected unceremoniously, depending on how much work is being done by the analyzer.

It's not all black and white, user.

Oh, I was just curious, I'm more of a C++ guy, but that's nice to hear.

JavaScript uses lambdas all the fucking time.
But they're called function in JavaScript.

JavaScript has been called many things, but overly academical is not one of them.

Check out BeautifulSoup for Python.
There's versions of the same thing for other languages too.

But thank you for not just using regex and thinking it's good enough.

javascript is webdev faggotry

lambdas are almost never used in real languages like C/C++ and java

C++ makes heavy use of lambdas in the STL.

They're used all the time in Java.
In fact, one of the main reasons Swing sucked was that you didn't have syntax for it.

Lambdas are used all the time in Java now that there is a specific operator for it.

bar -> foo(bar)

is the syntax for a lambda in Java. You see it all the time now.

I think the C++ syntax is better.

LINQ
I
N
Q

C# is disgusting shit

You can write it as
(x) -> { return x + 1;}

if you want to make it look more like C++
But Java stole some ideas from Haskell and will use type inference in lambdas so you don't have to explicitly type the arguments.

C# is fine.

I disagree, but everyone is welcome to their opinion.

> lambdas are almost never used in real languages like C++
You have no idea that you're talking about.

>But Java stole some ideas from Haskell

in C++ you just have to put auto everywhere
you can even do constexpr variadic polymorphic lambdas

[what gets captured and how](typed parameters){ function; body; }

C++ is always ugly as hell, but it has generally been about flexibility and being fucking explicit.

sure, it's "explicit" when convenient, and "verbose" when inconvenient