/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Previous thread:

Attached: Surrexit_Christus_vere,_alleluia.jpg (884x1028, 228K)

Other urls found in this thread:

learnprolognow.org,
bfilipek.com/2018/04/deprecating-pointers.html?m=1#
erkaman.github.io/posts/junior_graphics_programmer_interview.html
en.wikipedia.org/wiki/Segmentation_fault
twitter.com/SFWRedditImages

nth for why haven't you installed Shen yet?

Thanks for no anime. Also, team peeps rules.

A unity application that reads map data and sketchup objects to produce virtual city replications

Team creme and team C#

Decode flavor Oreo.
Post your IP % 5
My result is 4

mine is 69

My IP end in 69
69 % 5 = 4

Throwing together a constants header file for my C++ webserver library.
>but why
Sure most of these will take just as many keystrokes, but using constants instead of strings means typos will be compile errors. The header's completely optional.

Attached: Screen Shot 2018-04-01 at 1.47.23 AM.png (1392x1638, 583K)

>my ip end in 69
you're supposed to convert your IP to a long and mod that

What would happen in C++ if you also defined any_ip and loopback_ip as references even though they're initialized to string literals?

Some error about reference-to-rvalue most likely

Learning the Windows API. Please kill me.

Well it actually compiles but the assembly has a comment that there's a reference to a temporary so that makes me wonder if GCC just simply fixes that problem for you or if there's any side effects that it could potentially have.

Lisp vs. Prolog?

Which should I learn my friends?

What are you planning on using Prolog for?

I'm using it now in an AI course, but I don't know if people use it for real world stuff. Also it seems to be pretty similar syntax-wise to Erlang, which sees some real world use for servers and stuff.

Interesting, makes me realize I should check to see if this actually works with more than one compilation unit.
>the assembly has a comment
whut

one of you awesome folks wanna give me a chance? i need a job programming. i've been teaching myself C#, XAML, SQL, a lil JS and CSS. zero experience though. and no exp using team services.

Attached: Come on baby I love you long time.png (1366x768, 1.7M)

wtf is the team shit?
i am a loner

Firstly what's with all the different teams (yes i'm new)?

Secondly, i'm a java brainlet and can't find out why i'm getting null pointer errors for this code:
import java.util.Random;

public class RandomDrawing_Driver {

@SuppressWarnings("null")
public static void main(String[] args) {
RandomDrawing intBox = null;
RandomDrawing stringBox = null;

//test intbox
System.out.println(intBox.isEmpty());
intBox.add(7);
System.out.println(intBox.drawItem());
System.out.println(intBox.drawItem());
Random rand = new Random();
for(byte i = 0; i < 5; i++) {
intBox.add(rand.nextInt());
}
for(byte i = 0; i < 5; i++) {
System.out.println(intBox.drawItem());
}
//test stringbox
System.out.println(stringBox.isEmpty());
stringBox.add("This ");
System.out.println(stringBox.drawItem());
System.out.println(stringBox.drawItem());


}

}


and base class:

import java.util.ArrayList;
import java.util.Random;

public class RandomDrawing {//wont compile, don't know why
private ArrayList box;
private Random rand;

//mutator
public void add(T obj) {
box.add(obj);
}

//getter
public T drawItem() {
int element = rand.nextInt();
if(isEmpty())
return null;
T obj = box.get(element);
box.remove(element);
return obj;
}

//boolean
public boolean isEmpty(){
if(box.size()

experiment with NLP stuff or take a weekend or two to use it as the general go-to programming language for all my hobby stuff to see if its fun.

>that formatting

Attached: 1522204994658.jpg (640x480, 24K)

Because intBox and stringBox are null, but you're trying to access their member functions.

Should be:
RandomDrawing intBox = new RandomDrawing();
RandomDrawing stringBox = new RandomDrawing();

Also work on your indenting. Make sure your Text Editor is using only one of tabs/spaces. No one wants to read broken indents.

>RandomDrawing intBox = new RandomDrawing();
>RandomDrawing stringBox = new RandomDrawing();

"
Exception in thread "main" java.lang.NullPointerException
at Assignment9.RandomDrawing.isEmpty(RandomDrawing.java:27)
at Assignment9.RandomDrawing_Driver.main(RandomDrawing_Driver.java:13)
"

Going from Win32 to .NET was the best day of my life. C# > C++

I like Haskell.

I assume it's a comment and not actually a part of it?
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:reference temporary #0 for test
mov edi, OFFSET FLAT:std::__cxx11::basic_string::~basic_string()
call __cxa_atexit
lea rax, [rbp-17]
mov rdi, rax
call std::allocator::allocator()
lea rax, [rbp-17]
mov rdx, rax
mov esi, OFFSET FLAT:.LC2
mov edi, OFFSET FLAT:reference temporary #0 for test
call std::__cxx11::basic_string::basic_string(char const*, std::allocator const&)
mov QWORD PTR test[rip], OFFSET FLAT:reference temporary #0 for test
lea rax, [rbp-17]
mov rdi, rax
call std::allocator::~allocator()

Applies to everything you make. You gotta initialize all variables before you use them:

private ArrayList box = new ArrayList();
private Random rand = new Random();

Your box private member is null, dumbfuck. Try writing a proper constructor.

Prolog is weird. If you think Lisp is weird, like using recursion for everything and stuff, Prolog is weird beyond that.

Here's some example Prolog code:
append([],L,L). % base case
append([H|L1],L2,[H|L3]):- % recursive case
append(L1,L2,L3).

(H is for head of a list and L1/L2/L3 are for the rest of each list.)

So this is code for append/3, a function taking 3 arguments such that append(X, Y, Z) means X appended to Y gives Z. That's how Prolog works; it's declarative, so essentially you can give lists for X and Y, and pass in a free variable for Z and it will unify Z to X+Y appended together. If you pass in 3 lists, it will return true if Z is in fact X and Y appended together, otherwise false.

Prolog tries to 'satisfy' append by checking each 'rule'. So in most cases, the base case is not satisfied because the first argument isn't an empty list. So it moves on to the other case, which is only satisfied if the head (H) of the first and last arguments match (which is specified by how the arguments are defined) and if append can be satisfied for the recursive case, using just the tails of the first and third lists (this is specified after the ":-", which basically denotes something like an if, where the conditional is the whole body of the function).

That's a base level of what Prolog code looks like, just to let you know. If you really want to learn it though, I wouldn't be intimidated. From what I've seen so far, it's a good choice for learning AI. The course I'm taking uses the slides and other content from learnprolognow.org, and that explains most stuff pretty well imo.

While I do think it's good for AI, I probably wouldn't choose it for general side projects (where I might consider Lisp a viable option).

Just wrote all this and you deleted your posts or were removed. (Sad!) I'll still post this for anyone curious though.

Thank you for posting an Easter image!

oh hey its starting to work!

Why can't prolog be used for general projects? Can't it do everything?

so if i'm uncomfortable and struggling with lisp syntax and ways of doing things ill be even worse in prolog?

Fucking peanut butters

dont respond to peanut butters
keep their yours low

please explain what is up with the teams?
I am not sure what is going on?

Yes you stupid peanut butter. Feed me more yous

I know how to get (you)'s, and i fucking will you nigger.
BRB, suck my cock

What the fuck are with these flavors and how do I choose one?

team creme!!!
we will win the annual Jow Forums passes!

Peep street

it's just random per board on your IP.
lots of threads are spotty with showing them on (chomium) browsers though.

Yes, it's turing complete, just like any real programming language, but there are tasks it's suited for, and many tasks it's not suited for, imo. Maybe I just don't have enough experience writing code in Prolog, but certain things that would be trivial in other languages required a lot of thought to implement in Prolog. And while some of them turn out short and elegant, others feel kind of hacky and weird. Personally, at this stage, my brain doesn't quite "think" in Prolog, whereas I've sort of learned to think in Lisp, despite it being hard to grok at first. And I'd still use an imperative language for most stuff, because that's just how I think.

I wouldn't say it's objectively harder to use than Lisp; just different. So I can't say if you'd struggle more or less than with Lisp. Although I guess I understood Lisp a bit more easily than Prolog.

But there's something to be said for leaving your comfort zone and learning different ways of thinking. E.g. I think it's worth learning a Lisp just for the experience, because it teaches you to think in list comprehensions and immutability. Even if I never touch Lisp again, those are helpful to understand, and beyond that it's good to know when using those is a good choice.

Attached: saf80acefcb0f1i000700000bb92020.png (640x400, 26K)

There's a lot of stuff I could write in python or C that I just can't do at all in lisp and it's insanely frustrating
I tried to write fibonaccis and couldn't work it out. I don't think there's a worse hell than knowing what to do but being unable to express it in the language.

I have a bit more of a mathy/theory background sometimes I do wonder if Prolog would be easier for me.

No, I'm creme on every board I've tried.

Prolog is worth it because it shows you a new way of thinking. One of my favorite languages.

Prolog's great for understanding unification and problem decomposition, though I do think it's kind of useless if we're talking about it from utilitarian standpoint. It does make you think differently, which is why it's worthwhile anyway.

>static const std::string
why not a constexpr char*

none of your skills are useful

mostly because I'm a retard

ok

hey peanut butter, don't be jelly!
also, you-ing yourself doesn't count in the contest.

Is it practical/preferable to produce a header-only library that can be built to a dedicated translation unit at the user's discretion? Something like this.
>mylib_inline_impl.h
#define MYLIB_IMPL inline
#include "mylib_protos.h"
#include "mylib_defs.h"

>mylib_extern_impl.h
#define MYLIB_IMPL
#include "mylib_protos.h"

>mylib_extern_impl.c
#include "mylib_extern_impl.h"
#include "mylib_defs.h"

>mylib_protos.h
MYLIB_IMPL void my_function();

>mylib_defs.h
MYLIB_IMPL void my_function()
{
// function body
}

Attached: output.webm (683x1024, 964K)

I'm writing a CursorMania clone in Delphi, anyone got some Cursor Sets (I've only got Cursor Mania 1&2). I've got a basic preview going (which I need to change to a Grid system) & System Parameters setting down. Gonna have to write some .ani file parser next up so I can get the framecount & timing info since you can't get it from a Cursor Handle. It uses a decent amount of WIN32 api calls, I don't know what these guys are complaining about, its easy.

can you fall in love with a github account ?

installing gentoo

How's Delphi? Last time I programmed on it was in Turbo Delphi. Did Embarcadero actually make a usable language for production?

>Turbo Delphi
I mean Turbo Pascal, of course.

Attached: 267px-Turbo_Pascal_7.1.png (267x182, 56K)

What would Turbo C++ look like

RIP

Attached: 3x-79273d6b68a02608429ca95a942b2223-Turbo%20CPP%203.0%20-%20About.png (720x400, 6K)

Swift Algorithms Clubs.

import Foundation

class Node {
var value : T
var children : [Node] = []
weak var parent : Node?

init(value: T) {
self.value = value
}

func add(child: Node) {
children.append(child)
child.parent = self
}
}

// Custom printing functionality for Node
extension Node : CustomStringConvertible {
var description : String {
var text = "\(value)"

if !children.isEmpty {
text += " {" + children.map { $0.description }.joined(separator: ", ") + "} "
}

return text
}
}

extension Node where T: Equatable {
func search(value : T) -> Node? {
if value == self.value {
return self
}

for child in children {
if let found = child.search(value: value) {
return found
}
}

return nil
}
}

Its a nice language, with a massive corporate backing (so libraries available for everything), it builds & runs fast, but its really expensive (and the Free option is very limited). There's quite a few companies around me that use it, mainly older ones that are focused on Windows Application development. It feels like its on the wayout so you might wan't to use FreePascal instead, but people have been saying that for years.

One way to find out.

I've heard some people say that latest Delphis are better at writing crossplatform programs (both desktop and mobile) than even Xamarin. Is it true, or just marketing talk?

team chocolate rules!

What the fuck is going on?

I haven't tried yet it, I've only stuck to Windows development.

I do Delphi at work and you struggle at even getting reliable x64 applications (all standard library types use Integer for indexing for example) so I wouldn't bet on cross-platforms.

You are literally a brainlet if you can't write a fibonacci in lisp

which is ?

Are SIMD intrinsics worth it outside of big loops?

Just keep forking them until you get bored and find another account to fork repos from. If you don't get tired of forking the same old account's repos after time then you know they are the right one.

Is graphics programming a good field to specialize in?

If you can do it well there's certainly a high enough demand for it, but hope you like Linear Algebra at the very least. Far more if you're actually into signal processing and not just random plug and play shaders and rendering pipelines.

Why is it necessary for a dynamically linked linked library to use position independent code where a statically linked one does not?

Why is a static linker able to relocate code and a dynamic linker unable?

bfilipek.com/2018/04/deprecating-pointers.html?m=1#

Where were you when pointers were kill?

erkaman.github.io/posts/junior_graphics_programmer_interview.html

raw pointers were a huge mistake

A dll doesn't know where it will be loaded in the binary, so the code must be position independent.
A statically linked library is always at the same place in the binary, so the position are known.

Any good tutorial for CMake?

The static library is "relocated" at compile time, and after that, it won't change.
A dynamic library needs to be able to mapped anywhere.

Jesus christ, what a fucking joke of a language.

>The static library is "relocated" at compile time,
Don't you mean link time?
If you compile two static objects a.o and b.o then link them statically, and both objects use the same region of the address map, then the linker must relocate some objects.
I don't see what the difference is whether the linking is done statically or dynamically.

Glad to see C++ is finished.

No. Code monkeys are still a thing.

>Don't you mean link time?
Right, I should have been more careful with my terminology.
I noticed my mistake after I posted, but couldn't be bothered to correct myself.

A "static library" is just an archive of completely normal object files. They're exactly the same as the ones you're using for your own source files.
The linker has all of the information about where in memory it is able to put everything, and can resolve symbols to concrete memory locations.

Dynamic linking does not have that luxury.

>01 April 2018

Attached: 1458780613244.jpg (704x528, 25K)

Oh right, I fucking forgot about that garbage.
It really does seem like something the C++ standards committee would be stupid enough to do, though.

not stupid at all. there is no more reason to still use the obsolete raw pointers.

Yes he meant link time. But the difference is (full) linking creates a completed, runnable executable. Dynamic libraries are linked at runtime, their symbols linked to arbitrary locations in the program's address space. This isn't just used for libraries — think plugins. You have a config file that's loaded at runtime that gives some names of dynamic "libraries" to load, each of which has symbols for XYZ, and the program then loads & links them to different places.

:^)

It pains me to think that C++ programmers are actually this stupid.

readan sum K&R

Attached: IMG_20180401_122611.jpg (4000x2992, 3.26M)

>stuck in the seventies

en.wikipedia.org/wiki/Segmentation_fault

the gnome himself has said KISS when you don't need it

You are aware that CPUs still use pointers, right?

No. CPU uses addresses, not pointers.

wrong, they are using (raw) addresses. a pointer is the association of an address with a type: it's a typed address.