/dpt/ - Daily Programming Thread

JavaCPP edition

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

Other urls found in this thread:

doc.rust-lang.org/std/ops/trait.Mul.html
hackage.haskell.org/package/units
hackage.haskell.org/package/quantities
hackage.haskell.org/package/dimensional
discord.gg/fdnVwmX
twitter.com/SFWRedditVideos

>there is nothing wrong with

There is nothing wrong with Java

Cross platform GUI library that works on top of SDL and opengl for Common Lisp.

Asked in the previous thread but didn't really get an answer apart from >reddit

I'm thinking unironically learning go, any serious reason why I shouldn't?

>any serious reason why I shouldn't?
Yes, a lot, see

...

...

I don't just want to parse numbers, I want to turn any char into an integer.

(int) 'a'

You should all use my new and improved programming language, Crust. It's way safer than Rust. It prevents programming errors like this:
f32 energy = object.position.x + object.acceleration.x;
How? Well, we all know arithmetic is unsafe because it lets you add together quantities in ways that make no sense, and most Crust programmers don't need arithmetic anyway, so it's disallowed by default. For the rare cases where adding quantities is required, you can download a third party library or use and unsafe block, guaranteeing the correctness of Crust projects.

Threadly reminder to ignore the "unsafe rust" autist if you don't want to ruin yet another thread.

It's literally designed to churn out brainlet coders so google can push down the average salary.

I'm a beginner "programmer" doing HTML with some JS. Got my first coursework to do, and as soon as I sit down and look at it and try to logically figure out what I have to do my brain goes completely dead. It's all so confusing to remember, then when I do remember it it doesn't work because I put a bracket or a semicolon in the wrong place. I know I'm a retard but I don't want to work in retail forever.

Does it get easier or am I a lost cause?

thinking of using kdevelop as my debugger

You need to learn what these brackets and semicolons signify and when to use them rather than "oh yeah the tutorial kinda used something like this here so I'm gonna try maybe this is going to work?". Also, in JS, semicolons are completely optional so you can just forget about them.

Reminder for everyone to ignore Rust and Rust-related (social justice) posts.

it'd be nice to have statically typed quantities tho

like type1 * type2 = type3

Name 1 thing that is wrong with java

No. Arithmetic is inherently unsafe.

You mean constant?

system.out.println

>Does it get easier?

Absolutely. First hill to climb is usually the hardest but after that all the pieces start to fit together really quickly. Keep pushing yourself, and you'll get there.

define neckbeard lang

Turing-complete

what programs don't need safety?

A program crashing sim

fuck opengl, though

Threadly reminder that Rust allows inherently unsafe operations like arithmetic, and is, therefore, unsafe. You should use Crust instead.

doc.rust-lang.org/std/ops/trait.Mul.html
impl Mul for Velocity {
type Output = Distance;
[..]
}

No: run-time numeric values, but tagged at compile-time with something akin to their SI unit, and some kind of compile time sanity check that you can also disable. You know, like how adding together a length and a weight is considered inherently absurd in physics even tho both are real numbers ?

let energy = velocity + acceleration; // BOOM!

Arithmetic is inherently unsafe, brainlet.

Clonable

Oh wow I love this! Can you do relatives vs absolutes too?

It's not C#

Daily reminder that this is how the average rust core team member looks like

...

This is how the average Scala programmer looks like.

Yeah structs aren't numbers that you can add you fucking retard

I'm not sure that you mean, but you can have something like
impl Add for AbsoluteTime {
type Output = AbsoluteTime;
}

Basically, you can wrap every unit into a separate wrapper type a-la Haskell's newtype, and then define only valid operations with correct types. It would involve a lot of boilerplate, but you can use macros to limit it. None of this will have any effect on the efficiency of the resulting code.

But you can selectively implement the addition operator for those terms it makes sense to add. Would be nicer with dependent typing tho

>rustlet: manual memory management is inherently unsafe! muh dangling pointers! muh double free
>pluslet: just wrap it in smart pointers
>rustlet: it's still unsafe programmers can and do fail to use them
>crust developer: arithmetic is inherently unsafe. it lets you add quantities in ways that make no sense
>rustlet: just wrap it in custom structs
The absolute state of safetylets...

Yes, that's what I wanted. I expected it to be boilerplaty but you know...

>compiler gives an error message exactly when you are proposing it should
>THAT'S WRONG

This is intrinsically trivial in any language with a decent type-system. Any ML-family or most-any purely FP language comes to mind.

Go back to no-macros no-typedefs Java you codemonkey! There's nothing wrong with wanting the compiler to work for you.

>There's nothing wrong with wanting the compiler to work for you.
Exactly. It should simply refuse to compile inherently unsafe code, like code containing arithmetic. You should use unsafe blocks if you want to do unsafe things.

Including arbitrary products of exponents of all basics units? With canonicalization?

haskell programs
your fizzbuzz

You could also do it more generically:
use std::ops::Add;

struct Abs(T);
struct Rel(T);

// absolute + absolute -/>

// absolute + relative -> absolute
impl Add for Abs {
type Output = Abs;
// fn add...
}

// relative + absolute -> absolute
impl Add for Rel {
type Output = Abs;
// fn add...
}

// relative + relative -> relative
impl Add for Rel {
type Output = Rel;
// fn add...
}

>haskell still doesn't have native totality checking

Go back to walking in circles all day you low functionning sperg slow-in-the-mind manchild ok? This is the industry and we have real world problems to solve for likely-optimal solutions, not ideal ones. Not that you would understand any way, so I will stop responding right here.

Whenever you prefer undefined behaviour (corruption, vulnerability, etc.) over a descriptive crash.

how is addition of two floats unsafe?
Is it because addition of integers might cause an overflow? This doesn't matter to floats.
Why can't rust define what they consider unsafe?

He's just a butthurt C fizzbuzz tier programmer, just ignore him.

floats can overflow too.

>can't address the argument
>spergs out
Arithmetic is inherently unsafe because it can be used to add quantities in ways that make no sense. Crust is superior. Rust is broken.

>how is addition of two floats unsafe?
Because it allows you to add quantities in ways that make no sense, which lets you write broken programs that could do anything.

Daily reminder that a language without multimethods is incomplete. Multimethods are the true link between the functional and OOP styles of writing programs.

Classes are a lie which only limit your understanding of what true OOP should look like.

give me an example of addition that would break things.

Not him, but it's clear for everyone except you that less ways to fuck things up is preferable to more. Do you not want airbags in your car? Driving is dangerous anyway so why bother...

Multimethods have nothing whatsoever to do with OOP. A "method" is simply the way an encapsulated object responds to a message.

Absolutely. It's blatant how single dispatch is stupidly limited.

>less ways to fuck things up is preferable to more
That's why arithmetic should generate compiler errors by default and only used in unsafe blocks.

What the fuck were they thinking?

>give me an example of addition that would break things.
let back_account_balance_usd = 3;
let yens = 1140000;
bank_account_balance_usd += yens;

Inherently unsafe.

It would be difficult in Haskell, but I bet you could manage, given the success of things like data types a la carte and algebraic effects. With dependent types it would be trivial; you'd have a generic quantity type that depends on a dictionary from units to integers (0 if the unit isn't in the dictionary), and operations with dictionary and integer operations in their types to keep everything valid. If your units are constant at compile time (most likely), you won't need to write any explicit proofs, either.

It's not inherently unsafe in Rust. It's a logic error, but can't lead to a memory error. At most it will lead to a panic. If it interacts with unsafe code, that's a different story. That being said, Rust can prevent unit errors if you have the types.

I agree, but literally everyone will switch off this "default", so it shouldn't be the default because it wastes more time and effort than putting the default the other way around. This is a result of pragmatism, or, as hipsters say, it's Huffman coding.

What about it?

rust shills are so deep in false flagging that nothing makes sense anymore.

>It's not inherently unsafe in Rust. It's a logic error, but can't lead to a memory error
Double free is not inherently unsafe in C. It's a logic error, but can't lead to hardware damage.

Can we just delete this thread

My legs are OK

Actually, the spec doesn't rule that out.

floating point is scientific notation.
64 bit means 11 bit exponent, means it handles ranges from 2^-1023 - 2^1023
if you add numbers larger than that or smaller than that, it goes to infinite but it doesn't overflow.
adding two floats usually means calculating the sum.
I am not an expert in rust but wasn't the example of the addition fail two structs that was inherited from a float?
If the problem is that the + operator was undefined, then the error should say that instead.

nah
module Main

%default total
add : (x : Double, y : Double) -> Double
add x y = x + y

safe : 1140000 + 3 = 1140003
safe = Refl

main : IO ()
main = print (add 1140000 3)

>it shouldn't be the default because it wastes more time and effort than putting the default the other way around
The story of Rust.

>if you add numbers larger than that or smaller than that, it goes to infinite
That is overflow.

>not anime thread
shit thread

It's not even difficult. Also please stop saying dependent types to everything: they are great but they are 99% of the time more powerful than anything people in these threads talk about: most of the problems here are pretty much trivial and can be done without big issues in most languages with more than very basic type systems…


Some examples
hackage.haskell.org/package/units
hackage.haskell.org/package/quantities
hackage.haskell.org/package/dimensional

>manual memory management can break things
Nah:
unique_ptr foo(new Foo());

No. That does not differentiate between functions and methods.

A Method is something which exhibits runtime polymorphism on one or more of its arguments. In languages like Java or smalltalk, a single argument is singled out, but you can have much more power if you let your methods dispatch on more than one argument.

>int *ip
Should've been int* ip, abusing the type declaration.
Say your float guarantees 6 significant digits. You have 2 accounts. Put $10000.00 in account A. Transfer $0.01 to account B. Account A still has $10000.00. Repeat this process, you've now duplicated money. Also fucks up auditing.

>has no operator overloading it would be extremelly usefull, instead doing string.charAt one cound do string[pos].

I like everything else.

pointers are for brainlets.

>Should've been int* ip, abusing the type declaration.
It's easier to reason about when you declare multiple pointers:
int *p, *q; // q is a pointer

vs
int* p, q; // q is not a pointer

no pointer arithmetic
slow
dependencies
oop

c# is a ridiculous piece of shit, a disgusting mix of java and c++ and married by force to the .NET piece of shit (what would you expect from a pajeet marriage)

auto foo = std::make_unique();

Do you recommend any decent, entry level book/tutorial/paper do get into programming AI?

no.
An overflow is when you add two numbers and the value overflows the bit length of the container.
Eg, if you have an unsigned char and you add 100 + 100, you get -56.
Infinite + infinite = infinite will not destroy any application.

You don't understand what OOP is. You have encapsulated entities called objects, which only interact with the rest of the program by responding to messages. Nowhere in this story do multimethods logically fit in.

They should have changed that part of the language, that's bad form anyway. You should either do
int* p;
int* q;

or
int* p; int* q;

They tried to simplify it but failed miserably and caused a lot of headaches for a lot of people

Anyone familiar with CMake? I have two versions of a library installed on my system, I'd like to point a specific CMake project to a specific version of the library rather than the default one, how do without modyfing the cmake module for finding the library?

>pointers as a good thing

could you be more specific? ai means a lot of things, particularly these days
the general reference is russell-norvig

you are moving the goalpost.
Nobody have ever claimed that floating point should be used for your banking information, obviously you need fixed decimal points for that, kids know this, why would you think otherwise?

need a safe language that won't return infinity when I add two floats

i've had a thought to make a physics simulation at 1/20th speed with precise muscle control letting you have slow motion kung fu fights.
discord.gg/fdnVwmX
studying up on physics now, then gonna decide on a language once i realize my information requirements so that i can go maximum scale.

any suggestions? comments, advice, help is all appreciated.

if a team of us could put this together i have a couple other ideas which coupled with this would put us on the map as "the team that fixed technology in a decade."

everything from augreality to read/write protocols that turn old hard drives into turing machine-style superindexes using ramcrossing to detect chaotic arrangements which simplify storage through geometry within ram, using the storage to sequence the ram in a matrix which has pointers ran through it at different patterns to recreate large files with noise algrorithmicly.
[and then we collect the date of which files can be stored within the same matrix index, letting you make sure you load the proper one letting all of those files be grabbed at the same time, in a registry of hashmaps that will lead us into the future.]

god i fucking hate computers.
and i really mean that.
math too.
i just want the future.
and nothing else.

What books do you guys recommend so I can self-teach programming? I took 3 programming courses in college, Java, C++ and Visual Basic, but I want more.