/dpt/ - Daily Programming Thread

Previous thread: What are you working on Jow Forums?

Attached: code_master.png (1164x1738, 2.17M)

Other urls found in this thread:

youtube.com/watch?v=4jh94gowim0
twitter.com/SFWRedditVideos

Been messing around with Electron all day, it's glorious.

SHOULD I LEARN FORTH OR COMMON LISP??

so whenever i look at some books or tutorials half of the scripts are wrapped in try/except functions
but whenever i code shit on my own i never do that or i can't find a reason to
is it a good practice to wrap everything you can in try/except? how do i learn where i should do that optimally?

clojure

i want to nakadashi iori

install Shen.

N O
stop writing code intended to fail.

Libraries should only handle exceptions they can/should handle. e.g: it is really stupid to check if a given filename exists and throwing a file not found exception if it doesn't but a csv parser should raise an invalid format exception if a given file is not a valid csv file.
Programs should log all exceptions and try to prevent an invalid state (e.g UI programs can disable certain settings combo) and only handle exceptions that they can recover gracefully from by cancelling the related task that caused it.
I don't know who that slut is but it looks like she loves anal.

Set A = A -> Bool
Multiset A = A -> Nat

In JS, when should I ever create a function (not a class/obj method, an independent function) that mainly works on "this"? Except in cases where you get fuckiness with primitives like in the case of e.g. String.prototype.toUppercase.call(str) and you need to call, I can't think of a reason why I should still create the weird call and apply based functions in 2018 the early JS devs were infatuated with.

Just found out you can do this in C# with the help of some classes and defining the variable plus:
Int s = 5 6
It will set s to 11 as expected. You can do it for any tipes, and most operators, but operator name without symbols must be unique. "Something" *conc* "other" for some special concatenate operator, can also use different tipes: "X" -repeat- 10 can be used to create the string "XXXXXXXXXX" of you define repeat correctly. Sometype +-+SpecialOperator+-+ othertype also wprks, or more condensed like 7 11 for example. This is amazing, propably slow and error prone, but amazing.

i wanna fug iori

understand how this actually works lol

C# is amazing

in nim this is just
proc ``(x: int, y:int):int =
result = x + y

echo 12

Trying to make a very simple neural network for a trading bot

How do I learn how to OO?

Hello guys brainlet here again. I cannot get my hand around Buddy String challange:
Given two strings A and B of lowercase letters, return true if and only if we can swap two letters in A so that the result equals B.


So i thought i cannot return something before iterating whole string cause there could last two chars at the end. So i came with integer to show "state" and return true, if it replaced those chars only once. BUT i have no idea why it keeps printing false for strings "aaaaaaabc"
"aaaaaaacb"
char* swap (char* A, int i, int j) {
char temp = A[i];
A[i] = A[j];
A[j] = temp;
return A;
}





char buddyStrings(char *A, char *B) {
int w;
for (int i=0;i

hey guys, longtime lurker here, and i'm just wondering if anyone here has broken into the field without a degree/with a completely unrelated degree. i'm in a ba/md program and i've realized i do not want to become a doctor at all, and my ba is in something silly because i was guaranteed a spot in med school. i've always loved to program and web design though, so i wanted to try to get into it. switching majors would be too much money and time that i don't have.

just go into systems programming and work on cool medical hardware.

>anal idol
Thanks you based OP.

What does the `as` keyword do in Rust?

If you were to learn full stack, what would be the progression?
html -> CSS -> javascript -> python?

>K&R C
>anal idol
Makes sense

Working on some numerical software for function approximation in high dimensions at the moment.

For swaps in consecutive positions but not all possible results I think (last shifted with first, etc). You need a second "for".

html -> css -> js -> node -> babel(es6+staging, sass, react, etc)

Yes, and by going to university and learning Java for 4 years

I have, degrees are for chumps

i've just got my MSc degree and the only time we used java was in the gui course when they taught us javafx
most of the time we were able to choose the language for our projects

>javafx
lol

indeed

Does node beat python for back end?

The internet says yes

If you want to go with scripting language for backend you might as well go with js. I don't really know how do they compare, but with node you can get common code base, easy server side rendering, common tools and other nice stuff. It works pretty well together and I suppose python can only do as good at best.

I mean, sure? But why learn a new language when javascript can do everything?

You're better off learning programming fundamentals so you can pick up both node.js and python relatively easy.

Nigga. Make the function return a bool and if the string compare returns true once, return true on the function. wtf.

Become a doctor. Programming is a meme. Women love doctors anyway, programming is makes you a simp.

i'm a programmer and i have a med gf

I'm a programmer and have no gf.

Attempts to cast the type

why is it so hard to talk to girls?

damn :(

Well, that's what I do.
But not every new programmer, especially webdev, have time and motivation to learn what programming really is about. But if he wants to go fullstack, he might need it anyway.

What happens if it fails?
Like if I wanted to cast something like this:
let v = vec![1, 4, 5, 3, 34];
let t = 3;
v[t as usize];

Does that correctly cast it?
Does it guarantee as compile time that it is able to cast it?

They are full of nondeterminism and lack of proper documentation and standardization. Literally worse than Android.

I'm mid 20s, programmer and I've never had a gf :(
So I spend all day programming trying to forget the sadness.
Because you have low self esteem.

Attached: anime_hug_feels.jpg (640x480, 56K)

you're gonna make it bruh i believe in you

how do I get self esteem?

>learn language enough to get to error handling parts
>get completely bored of programming and mind blanks on anything to work on

might do that, systems programming really does interest me.
good to hear at least one person made it!
to be honest, i've really explored my options in the med field, and doctoring isn't just for me. honestly, i'm more interested in becoming a nurse or a physical therapist if i do want to get involved in the med field, but i do want to at least explore the opportunity of tech.

bye, quitter

transfer to some bs in cs. don't take any break from school because it's really hard to get back in once you step out. depending on how deep you're in or how many credits you have, you might be able to transfer into a cheaper/public school with what you have.
>switching majors would be too much money and time that i don't have.
this might be a sunk cost fallacy. if you are going to finish soon you might be able to meet with a school about getting an ms in comp sci which would require ~2-3 semesters of bridge classes (the important cs undergrad you might have missed) and then your grad level courses.

does anyone else get aroused by boilerplate and the excessively engineered configuration?

if you needed a degree to become a software engineer, you're absolutely a braincel

As I've gotten older I've come to appreciate some boilerplate over a bunch of hard to understand code, if I'm reading someone else's codebase. I don't particularly enjoy writing much boilerplate but I recognize some of it as a necessity for understanding my work in the future or there's simply no way around it in the tools I'm using.

i got a degree so i could pretend that i'm doing something for a few more years while my parents paid for my shit

Writing JS frameworks was always more entertaining than doing actual web development.

I'm graduating this December with no CS classes, a meme degree, and a basic 3.0 GPA with 30k in the hole. Plus, I need some sort of income somehow in the next 9-12 months. I'd be absolutely fine with doing a year and a half of classes to get into a Master's program, but I don't think I'd be a great candidate.

not really. When you have "aaaaaaaaaabc" and "aaaaaaaaacb" and you compare swap(A,0,1) and B, it returns true because "aa"=="aa" but it never comes to comparing "cb" with "bc". Btw char is same as bool, 0 is false, 1 is true so its not about that if thats what you implying

>writing meaningless shit helps me understand it better
I guess you just need a mental cue to remember shit, eh old man?

That is a rough spot. You say you don't think you'd be a good candidate but I knew a guy who got a BFA roughly 15 years before he did that for an MS.

Work on some projects for a portfolio to demonstrate you can learn and you shouldn't have too much of a problem with a smaller, local university. In the spring you could look at taking a few CS classes in a community college to knock some classes you won't have to take later (although it's likely you'll be limited to some bs fundamentals classes which are usually 2 semesters long). Talk to people there who can help you get in contact with local admissions or find out if it's actually something you want to study. The CC step is optional though, I'd recommend looking at a curriculum of the school you'd want to get the MS or double bachelor's in to see what gaps you have from classes you've taken. Most importantly, start a communication with some admissions and maybe some professors if you can. No one's gonna do it for you.

I took 5 years to get my bachelors, did nothing for two years, spent 1.5y on a masters, and after another year finally got a job solely due to connections.
Meanwhile I have a friend who started undergrad one year after me and is still not a full doctor who gets paid despite being smart and having good time management. And let's not even get into his debt.

Don't go doctor unless you've got indian connections up the ass and are being paid full ride.

But the point is to compare the string as a whole with strcmp() in which all characters are compared faggot. Not just consecutive chars. Also your strings have different lengths. Might as well start with that. If they were the same size, assuming two for's, once i got to the index of b and j to the index of c on A and a swap was made, then strcmp() would return zero and user could return true on the function.
Im not referring directly to what he has written but to what it could be.

Why is Jow Forums so bad at programming? Your average Jow Forumsentooman can barely fizzbuzz

>But the point is to compare the string as a whole with strcmp() in which all characters are compared faggot. Not just consecutive chars

I mean If instruction is achieved after first (compare swap"aa", "aa"), so if i put return true in If statement as you suggest i think it will return true, and end whole function, without checking next letter in strings, no? And i tried with two arrays, and its still havent worked, even more - i get "Time Limit" after 19/21 correct results, and getting like "aaaa...400times...bc"

Jow Forums is /v/ trying to get a job

Electron a shit. Do it properly you lazy slackers!

What's the difference between a Monad and a free Monad?

I just committed and tested all my changes, and realized I'm at exactly 4096 lines of code. What a pretty number.

Attached: Screen Shot 2018-08-10 at 6.41.37 PM.png (489x98, 14K)

Tell me how to properly deploy to multi-platform in a timely fashion the non-lazy way.

autotools

Why haven't you switched to Java yet?

it's outdated. C# is java+C++ on esteroids

I have been making a stock simulator game for android. I just discovered that I could put the UI on a timer instead of a button to progress. Now Both modes are in the game, but with different requirements to access them. Also I built a little bot to randomly trade stocks, as well as one that only buys lower than the last time they sold the same stock, and sells higher than the last time they bought. It gets locked out of some stocks for long periods occasionally when they sell in a bull market or buy in a bear market.

This is a video of the random buyer and seller after 6000+ game days, starting at $100.

Attached: 20180810_022643 (1)_1 (2).webm (720x480, 424K)

Because it is inferior to Haskell.

I like Kotlin.

C# wishes it could be java. Its a C++ mutant straight out of fucking Chernobyl.

lol no. C# >>>>>>>>> java

Valid answer.

Best answer.

Meme answer.

Clojure exists.

scala is strictly better

slower compile times

OK thanks, I'll try and take a look. So would it be best to make a portfolio, then show it to the Masters Programs admissions to showcase my ability, then go through the classes as best as I can while getting the prereqs for the program done? I think I'd have to take the math classes at my CC, because the only university near me is expensive as god all.

technically not a facet of the language

OK MR SMARTYPANTS
LEMME REPHRASE THAT FOR YOU

"LENDS ITSELF TO COMPILERS WITH SLOWER COMPILE TIMES"

fuck sake

a language is useless without its tooling, in particular its compiler (and for scala, the compiler *is* the language)

????
what did he mean by this

youtube.com/watch?v=4jh94gowim0

what a spastic turd

Wow, nice ddr game user!

trying to write my first neural net in c++

its running at something like 8 games days every second, just to test the bot. The timed mode for humans starts at 2 days per second and increases to 4 days per second linearly from 0 until day 2695.

don't tell me you actually think scala is a good language

I do, Paul Philips is a genius and it's his favorite language so it must be good

just saying the speaker seems autistic which I find quite fitting for an FP retard

My question is about dynamic linking- particularly DLLs on Windows, but I assume the same applies to other platforms. My understanding of the actual DLL loading process, relocation, etc is a bit hazy so I might be missing something basic.

Most DLLs seem to come with a corresponding "import library"- a small static library that seems to be intended as a "helper" for implicitly linking to the DLL, usually with a naming convention such as .dll.a.

Where such a library is not available, a common alternative is a .def file which seems to be literally just a list of all the exported symbols in the DLL- information which is already present in the DLL itself (as evidenced by dumpbin etc).

However, I have found that neither an import library nor a def file is actually needed. Both gcc/mingw and tcc (I haven't actually tried MSVC) happily accept a "-lFoo" argument to link against Foo.dll, no other files required.

I can think of two possible explanations:
* The lib/def is only actually required in unusual situations (maybe for Windows system DLLs, which seem to use some unusual name decoration compared to others) but are provided for all DLLs nonetheless as a matter of convention
* The information in the lib/def would normally be required but gcc/tcc/etc are able to do some funky magic to recover the info and proceed without the file

What is actually going on here? Why do these files exist if I don't need them?

(Me)
Oh wow, that's some pretty bad reddit spacing. Don't know why I did that.

The def and lib files have equivalent information. For what I remember, .lib encodes a part of the calling convention information on Windows 32 bit. The toolset has some ability to reverse this information from dll but isn't entirely reliable.