/dpt/ - Daily Programmmming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

nogenerics.info
dummies.com/programming/java/10-differences-between-javafx-and-swing/
strawpoll.me/14512622/r
haskellbook.com/
0x0.st/sXhZ.pdf
twitter.com/NSFWRedditVideo

What is a good language-independent data structure and algorithm book? (preferably not reference type)
I want to learn about piece table but I haven't been introduced to a data structure book/resource yet.

Is it normal to be disgusted when I read C code which isn't my own?

Yes. C is inherently disgusting. Due to its lack of abstractions, programmers come up with all sorts of weird approach to do the same thing. C programmers, like others don't focus on documenting their projects (mostly because of the lack a sophisticated standard doc tool). Thus the project becomes an unreadable mess.

You should be disgusted with yourself for the reason that you're still using C in 2018.

What maths books does /dpt/ recommend?

...

I don't know, but I'd recommend Arithmetic for Dummies and Logic for Beginners to most of /dpt/.

Sepples doesn't even have traits.

Real life version

>rust memes are more real-life than cars
The absolute state of /r/rust...

C++ can't even split strings lmao

I'm just disgusted by trash like this.
typedef enum {FALSE, TRUE} Boolean;
Which is referenced in header files that aren't included by this one.

Nice one, retard. I'm really impressed with that pointless compilation error.

Will learning programming paradigms like functional and procedural make me a better programmer?

All my I've been taugh POO.

0 and 1 or bust

Yes.

Hi, i want to start learning python in my free time. I am a student in the biology field so i haven't got much experience in programming, just want i know from doing arduino projects and basic matlab. So now i want to go deep in a lenguage. Can someone recommend me some books for python?

>Data available even after move within the scope
This just goes to show why std::move is BROKEN

>Will learning programming paradigms like functional and procedural make me a better programmer?
Judging by Sup Forums, it'll probably make you a smug perma-fizzbuzzer.

It's not though, only an empty string exists after the move.

>move

Don't learn python. It won't do you much good.
Learn something deeper like C++ that has an actual use in your field.

Is it Deep Copy? Damn, C++ is even shittier than I thought.

>C++ is "deep"
>C++ has any use in an actual scientific field like biology
Yeah, no. He's fine with R, matlab, Python etc.

>use a shitlang that errors on trivial examples
>think the analogous C++ code crashes
>it doesn't. it actually compiles and runs as one would expect
>w-wow t-that's actually WORSE

Matlab already does everything he could need Python for.
And yes, C++ is "deep" in the sense that it's much more backend orientated and closer to the system. If he wants to do actual research and write his own sims, which is what you'd primarily use programming for in that field anyways, then C++ will get him way farther.

The Rust way is correct though. Generally, moved-from isn't a valid state you want an object to be in. A resource handle shouldn't be able to exist in a null state.

Get over it, C++ doesn't know how to move. Here let me show how it's done.
Nice selfies btw
fn main()
{
let s1 = String::from("test");

let s2 = s1.clone(); // Both s1 and s2 are accessible
let s3 = s1;
// By default, any non primitive structure (i.e. vectors) are moved
//this makes s1 inaccessible
}

are you really comparing a compiler error to a runtime error?

lol

There's a tutorial included in the official documentation. Since you're already somewhat familiar with programming in C++ and Matlab, it should be more than enough for you to get started with Python. After that, learn Numpy, which is somewhat similar to Matlab in functionality.

C++'s primitive move semantics conventionally leaves the moved-from object in an empty state. In the case of std::string, it holds an empty string.

Wouldn't you agree it's better to detect errors at compile time than to wait until runtime to find them?

Hmm. Would you like to point me how your claim holds true?
#include
#include

int main() {
auto s1("test");
auto s2 = s1;
std::cout

Rustlets please leave, you're just as bad as the nodejs shills.

>Can't argue without spouting nonsense and memes
>"please leave my safe space alone"

rust prevents this like this

auto s1 * = new ...;
auto s2 = s1;
delete s2;
cout

You need to declare a string, not a char *.
You need to use std::move or else you get a deep copy.

Here's the code you're looking for.
#include
#include

int main() {
std::string s1{"test"};
auto s2 = std::move(s1);
std::cout

Little bit of correction. That's a C-string.
#include
#include

int main() {
std::string s1("test");
std::string s2 = s1;
std::cout

I see. Two problems I have:
1. C++ hasn't made s1 unreachable at compile time
2. Default is a copy constructor.

>1. C++ hasn't made s1 unreachable at compile time
I agree. In this case you're lucky because std::string has a reasonable "empty" state that can be entered after it has been moved-from, but that's not desirable for all types.
>2. Default is a copy constructor.
That's a matter of preference, not an objective failing.

Sup Forumsuys, what's going wrong here?
does anyone have this and willing to seed a while?

Why would you download that
You are never going to touch 99% of those books anyways

>Those ad spaces
>Using ad space OS
Normies are full of cringe.

i don't drive my car most of the time either.
but i like to know i have it just in case.
i do in fact desire to read a portion of it.

trying to learn to not be a normie, thank you

>C++ is "deep" in the sense that it's much more backend orientated and closer to the system
There's nothing "deep" about slapping a bunch of half-assed features on top of C. You're confusing depth with breadth here.

> If he wants to do actual research and write his own sims, which is what you'd primarily use programming for in that field anyways, then C++ will get him way farthe
Pure delusion. He's just going to glue together a bunch of general-purpose components written in C++.

This is the only admirable thing any user can strive for according to /dpt/.

Make us proud!

I felt like I dodged a bullet. My github profile picture was meme man and I realized this the minute before interview. I quickly changed my picture with a selfie.

Will they hire me?

thanks man - gonna DL this myself - just the one SICP book alone is $120, there's likely to be $1,000,000.00 worth of books there.
i'll be a millionaire in a few hours.

Improbable. They could have checked your tub long before the interview and thus seen the infamous pic. But it's note like it's pepe: they would have thought it's an obscure surrealist painting because that's what it looks like to the unfamiliar eye. Ergo you half-dodged a nearly nonexistent bullet, so imho you didn't really increase your chances of being hired.

K, tard.
It is not strictly needed, but static typing even on the FFI layer is very desirable. The compiler can then at least partially assert the correctness of your handwritten wrappers.
>type overloaded functions
This can be achieved in any language that is at least partially backwards compatible with the C ABI, like C++, Go and Rust.

To begin with, that was my opinion, and "False" is not a valid dismissal.

>False
It wasn't me.

tbf your point is defensible. I kinda strawmanned you with this idea of 1-to-1 mapping of ABI types up to the application logic. The wrappers have to deal with it like you said, but their job is to abstract it away, be it via a different static type system or a dynamic type system depending on the language. And static vs dynamic is ultimately subjective, so I guess we can agree to disagree

Has the print statement changed for python?
Because i noticed that when I use Python 2 now, the print() function works with the brackets now. It didn't use to.
really bizzare

I know that was not you. Unlike the tard posting feels memes and dismissing arguments, he can't comprehend, you make some valid points.

Agreed.

Thanks i'll check it out.i also downloaded Learning python by Mark Lutz, seems like a good reference.

#define DEBUG or constexpr bool DEBUG = true?

Maybe idk. afaict print () in Python 2 should be interpreted as the print statement being passed the empty tuple, and thus should output "()", but maybe they special cased it. Or maybe you are actually a tard who uses 3 thinking it's actually 2 or activated the forward-compatibility options of 2 and forgot about it, I can't tell

version(Debug)

It's not 2018 yet.

define. If it's for passing information to header files or source files at compile time, tulle preprocessor can't be beat

It seems that my new job will require me to use Go, any learning resources for the language?

No but it's getting Concepts which are far more powerful than traits.

Of course it can, it's just not in the standard library.

Official Go tour and Effective Go.

Python 2.7.6 (default, Nov 23 2017, 15:49:48)
[GCC 4.8.4] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> print("hi")
hi
>>> print "hi"
hi
>>>

If i did "from __future__ import print_function", then print "hi" wouldn't work because it gets overridden.
It's been like that since the update (Nov 23, 2017), but i don't see why they should change that.

-> nogenerics.info
The official tutorials are good enough at least for me because it's a mehlang which poorly repackages concepts you know already. Not an esolang that takes 10 years to understand the dependent monadic functoids

Unless I can make trait objects, I'm not interested.

Agreed, your environment is sane.

I believe print ("hi") had always worked since it's just the print statement with superfluous parenthesis.

Maybe this will make you go "I get it":
if ("hi") == "hi":
print "I get it"

>still arguing with mentally ill rustoddlers
It's like you guys never learn.

>people got so butthurt a language with no generics is more popular and thus objectively better by industry standards than their favorite shitlang that they registered a domain about it

It didn't use to work without the space.
I'm not even sure if it used to work with the space, but i'll take your word for it.

"Industry standards" is in no way linked to popularity, tard. An obsolete gun can still kill you but that doesn't contradict the fact that the newer ones are improved.

>It didn't use to work without the space.
I don't believe you. The space is meaningless there, I added it just for highlighting purposes. Unless you can confirm this by trying out an older Python, please consider that you've misremembered.

Maybe print"hi" changed when the tokenizer was modified to accept Unicode literals, but not with the parens

Delicious tears

>The space is meaningless there
So if you write return("hi") at the end of a function, it will work?
What even is the point of from __future__ import print_function if it always worked?

It already has concepts. You're thinking about syntactic extension for named concepts support.

>So if you write
>return("hi")
>at the end of a function, it will work?
Yes try it

>print_function
Under print_function print and print "a" don't work but print("some", "stuff") prints "some stuff" like it should've always done, and more generally print is an ordinary function like it should've always been.

>he thinks argumentum ad populum is valid and acts ultra-confident about it
You're the textbook Dunnig-Kruger patient. kys

I am writing a Civilization-esque game in JavaFx.

getSQLArray(map[string]interface{}{
"key": 3,
"anotherkey": "somevalue",
}, " ORDER BY `id` LIMIT 5")

Does this look like a good (or at least decent) way of handling simple SQL queries in Go, rather than having to put in a huge string?

What is the difference between JavaFX and Swing/AWT?

CLRS

It's kinda like "reference type" because it covers so many topics (>1000 pages), but you don't have to read it cover to cover. It has well separated topics so you can jump over to computational geometry or graph theory even if you didn't even glance over the rest of the book.

Is this supposed to be a select query or an array literal? Don't bother answering, I just proved to you that it's unreadable

JavaFx has the following perks:
1. UI that more closely resembles that of the native UI than Swing
2. Improved EventHandling
3. Can be skinned with CSS

I find this article to be very helpful on the topic: dummies.com/programming/java/10-differences-between-javafx-and-swing/

A select query that returns an array. That would be more obvious from the context

Whats better for learning haskell between the wikibook and Learn you a haskell?

I'm learning Python! Check out this cool program I made today:
10 PRINT "HELLO WORLD"
20 GOTO 10

the wikibook is more up to date
LYAH is faster (also LYAH has a few bugs)

i didn't find it much fun

What language has the most smug one liners?

haskell

Not smug enough. C me after class.

swing doesn't have a future

Check out this strawpoll that i hx0red.
am i ebin now?
strawpoll.me/14512622/r

it's a 1000 pager, but very through
haskellbook.com/

a cheeky share
0x0.st/sXhZ.pdf

>not smug enough

Thanks.

thanks mate

Mercury.