/dpt/ - Daily Programming Thread

>Old thread:
>What are you working on, Sup Forums?

Other urls found in this thread:

sstewartgallus.com/git?p=linted.git;a=blob;f=src/ada-core/src/linted-lock_free_queue.adb;h=8baa5b79ea4d9fddaa083f30a1f3b2968318290d;hb=560164b922249a14ba65d5c6028f8758829d2182
killercup.github.io/trpl-ebook/trpl-2016-10-01.a4.pdf
youtube.com/watch?v=vOGK3TveDDk&list=PLDi4E9q-lu_sedsHQJjG2LhrlIrGzokuy
manning.com/books/type-driven-development-with-idris
twitter.com/SFWRedditImages

Learning Python and my friend showed me lambda.

Why should I def functions instead of making everything lambda and just assigning them to variables?

fucking around with file transfer protocols

felt like making something that would let me transfer my files around fast on LAN

(yes there are probably programs out there that can do it better than I could but fuck that)

You may want a function that doesn't return something unlike lambda

That's pretty much what a function is under the hood.

I finally got the lock-free queue from "Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms" working right.

The code is sstewartgallus.com/git?p=linted.git;a=blob;f=src/ada-core/src/linted-lock_free_queue.adb;h=8baa5b79ea4d9fddaa083f30a1f3b2968318290d;hb=560164b922249a14ba65d5c6028f8758829d2182 and is Ada SPARK.

A lambda doesn't have to return anything. Is python different?

So what's the point of def? Looks overly verbose and wastes lines which in Python actually matters since it has to read every line during runtime.

Well as far as I know, unlike def functions lambda returns are implicit and generally the result of the proccess, meanwhile in a def fuction you could for example modify a list but not return anything sorta like sort like sorted().
But hey I could be wrong, I just started Python this year

>be me
>spend spare time over the past 3 years learning java and android studio for the apps i want to make (never had any formal schooling, just tinkering with fizzbuzz and shit so far)
>know that i will later have to learn iOS shit and remake apps there, or hire someone to copy to iOS
>just learn that VS/Xamarin now is free and open source and will create native apps for android ios and windows and more...
should i now drop java and android and start learning C# and program on Xamarin? would there be any benefit from sticking with my original plan?

Why would you? Just because you can?

Try to keep to the philosophy of using functionality as it was intended to be used because that makes your code more readable. Lambda functions are mostly designed for quickly describing part of a behavior that is used by a more generic behavior (such as sort, find, filter). You shouldn't really be using lambdas for complex tasks which are used for many reasons.

Also doesn't Python only support single-line lambdas?

c# is my fav language desu

ok, great.
but if you can put your bias aside (not that bias is bad)
objectively, should i abandon all i've worked on so far and switch, or stick it out?

So I've heard of COBOL and FORTRAN still being needed by some, what are some other niche programming jobs?

>Also doesn't Python only support single-line lambdas?
for now...
python just keeps growing, like that stupid snek video gaym

I don't know shit about mobile development but it's probably not a terrible idea to check it out. Three years of programming should have given you a decent enough level of competence that picking up another language won't be incredibly difficult.

>COBOL
Dave Ramsey was on the radio saying he needed a COBOL programmer and promised very nice $

I started with Python and got to an intermediate-ish level, then dove into C and ASM. I did them for a while, learning how to manipulate the stack and all that jazz, and it's pretty cool.
But now I'm looking at Python again and holy shit...it's so easy. Attractively easy. It feels modern, clean, and just fucking nice. I'll never leave you again baby

3 years of /spare/ time...
i work 80 hours a week as a truck driver lmao
i haven't gotten too deep yet.
i WISH i could go back to age 18 and take programming in college.

I love C#. Also C# and Java are pretty fucking similar you won't have much to learn syntax wise. HOWEVER C#'s greatest strength is the .Net framework libraries and those are fucking monoliths.

You don't need to know everything though and your knowledge will expand with time. I've been programming for less time than you though so maybe my opinion is non-factual. Programming seems to be more of a literacy type thing than anything. The more you use programming the better you get, it doesn't really matter what language it is or anything, you just get better at stuff.

Until you get good enough that you actually need to study and understand specific programs, algorithms and fields that is.

I tried xamarin for a few weeks when working on a personal project.

One thing I notice is that it lags behind live android by a bit.

Maybe I am retarded but it took a long time to get the right wrapped library for the hamburger menu I wanted.

In java it would have taken me maybe 2 minutes to figure it out and make it work.

Python 3 here.
Making a tic tac toe game
The problem is, that i have a function that runs everyturn, and if gameend = True that function SHOULD stop and display the winning message
but it doesn't, i don't know the fuck why
def askinput(P,N):
def printboard():
board = """
1 2 3 -x
---------
1 | %s | %s | %s |
---------
2 | %s | %s | %s |
---------
3 | %s | %s | %s |
| ---------
y""" % (space1x[0],space1x[1],space1x[2],space2x[0],space2x[1],space2x[2],space3x[0],space3x[1],space3x[2])
print(board)
printboard()
if gameend == True:
winner()
return
elif gameend == False:
atemp = ([a for a in list(input("Enter Coordinate(Player %s)(Like X,Y): "% (P))) if a != ","])
print(atemp)
if len(atemp) == 2:
Yeah before you ask, gameend is True, i make it prints and it comes out as True
1 2 3 -x
---------
1 | X | O | O |
---------
2 | X | O | O |
---------
3 | X | X | X |
| ---------
y
-1
-1
3
True
True
3
True
True
-1
Don't know what the fuck is wrong
pls help

Reading my code makes me so fucking ashamed holy shit
what the fuck was i thinking

lol I was cleaning it up for you then saw you put a function inside of a function and I stopped

how long ago, cuz new thing in latest xamarin...
can yo ushare the hamburger thing? i think i'd like to use that too.
i'm mainly just worried that certain things won't cross over, like smooth integration with firebase, google+ logins, google payments, etc...

>But now I'm looking at Python again and holy shit...it's so easy.

Python is only easy by convention. You can introspect and monkeypatch damn near anything in the language, which will bite you hard if you're not careful.

The hamburger wrapper was made by a pajeet on youtube and I would not suggest you use it. Pretty sure there is support for it in the live library.

I was working with xamarin about 1.5 years ago. Overall it is very clean and I hear it has something like 80% code sharing between ios and android apps which is pretty great.

When dealing with booleans like True or False, Python treats True as "existing", aka you can write this
if gameend == True:
winner()
return
elif gameend == False:
# do whatever


as simply this

if gameend:
return winner()
else:
# do whatever

>You can introspect and monkeypatch damn near anything in the language, which will bite you hard if you're not careful.

aka don't be a bad programmer

>Hur dur look at me I'm retarded!

cool beans.

anyone got any tips for switching from java to c#?

get VS community if you haven't already

Check out Linq (super powerful and used all over)

Check out .NET threading. Parallel looping, Tasks/factories, await/async.

Play around with it and I am sure you will realize just how much nicer it is than java.

is rust good yet?

no

It's already better than most of the languages, including C++

He said good, not "better than C++"

Reread

What's the point of C again?

I still don't see anything in your post describing Rust as good

Being a NEET, role-playing as an super (((expert))) kernel hacker etc

Is Tcl used for anything at all anymore?
At first glance I like the idea of using it, but I don't want to adopt a dead language.

If it truly is dead/dying, what would be some similar alternatives?

someone help me im going retarded

java
2 ints
need 2nd ints percentage of first int

for example, int A = 2500 int b = 96

need 96% of 2500

only way i can think of doing it is retarded 5 step process of 96/100 into a float and then casting it back to an int after multiplying (it needs to end as an int, rounded obviously)

if I am given an issue number, how do I go to that issue on github?

Direct control of the memory, easy integration of Assembly language, relatively straightforward conversion from code into machine code language. Which is why it's used for programming drivers and firmware for embedded systems (since often those things will be necessary).

Beyond that it's just a minimalism thing for some people.

2500 * 96 / 100.0
The .0 is important as it tells the compiler that it's a double and thus doesn't use integer division.

Order of operations with casting can be subtle at times but 99% of the time, you will only need to cast the divisor into a double/float.

why is programming so difficult to get good enough to build large complex applications on whatever you like instead you are stuck building small meme programs like build a small network that manages a database

That's like asking "why is it so easy to understand a neuron, but so hard to understand the central nervous system." Complex systems are complex.

Learn to love libraries.

>tfw too dumb for Rust
>tfw have to settle with C

learn to love 3d traps

why do you think theres such a correlation between loving traps and programming

int x = (int)(A*(b*0.01))

(a*b)/100 right?

>start learning iOS development
>Swift has computed properties
holy shit why doesn't Python have these

Casting into ints is truncation, not rounding, silly Billy.

For learning rust you have to learn C first. Otherwise you won't start discover the niceties of Rust.

However if you are a Rust purist I suggest you start with
killercup.github.io/trpl-ebook/trpl-2016-10-01.a4.pdf
I hope you know the basics of programming.

discovering*

I enjoy spreading bad practices.

are any employed as software engineers and if so, how many of you work on open source for money?

>software engineers
Glorified title, but yes.

>open source for money
I contribute on occasion to smaller projects, but I'd never expect to get paid for it. You couldn't pay me enough to tend to the needs of how autistic the communities are

Google, intel, Mozilla, Microsoft, HP, IBM etc employ thousands of engineers in open source projects

normally you scratch your own itch, you don't need to deal with randos telling you what to add.

I work for a company doing open source work; I was wondering if anyone else here did.

Yoooooooooooooooooo
I'm drunk

I can't begin to express how envious I am of mathematically-capable programmers. And I don't mean people who are competent at math and just get along: I mean people who's entire repo consists of maths-related programming with endless applicability, who solve P. Euler problems for fun, who's profile consists of an anime avatar, states their location as a major city, and links to a fleshed-out website with even more showcased work perfectly categorized and an evidently self-hosted email domain. I'm so sick of the reality of my own incompetence.

C programmers using rust be like
unsafe {
//program goes here
}

get off Sup Forums and go build something

>C programmers
>using rust
It isn't shitskell though.

I also would like to get someone else's opinion around this matter since Im in a similar situation

I don't know much about Xamarin, but I will mirror the sentiments of the other guy who said that C# and Java are extremely similar as languages.

You should have a pretty easy time learning C# and an easy time going back to Java if you decide Xamarin isn't for you (though you'll miss C#'s extensive framework).

Hi dpt, pleb here. PLEASE REPLY.

So I've learned enough about a few programming languages to understand basic syntax and can generally understand what is happening in a piece of code. Now I've only dabbled in a few things when it comes to actually making a piece of software, messed around with a few libraries etc.

I want to actually make something, probably a GUI with some data stored in .ini files. But what language should I do it in? And how do I structure my program?

I know this is some babby shit but pls help me out

youtube.com/watch?v=vOGK3TveDDk&list=PLDi4E9q-lu_sedsHQJjG2LhrlIrGzokuy

QT and C++

or it didn't work and I fixed it - why did it not work in the first place.

These safety fags piss me off.

C#

>unironically locking yourself into the microsoft ecosystem with Cshart

Damn, think how many individual instruction lines your CPU has to read at runtime. Python is far more efficient.

It does tho

Yes

What's the difference between
my_array.len()
and
len(my_array)?

As far as I understand the fist example implies that the struct which (my_array an example of) has a method called x.len()

However len(my_array) is just a function, not a method.

what language?

In a general sense.

If you HAVE to think about a language, it's Go

I'm at the end of my rope with motherfucking Selenium and Chromedriver.

I'm using the latest versions for everything, everything works fine in Windows, but when I run the same tests in CentOS, there is always one chromedriver process hanging, stopping the whole run until I manually kill it.

I've tried killing them from the code with .quit(), .close(), .close() then .quit(), but nothing kills that last one.

Does anyone know any fixes or stable version combinations?

Some languages (Python, go) have a builtin len() function, others do not and usually have len() method or something similar. There's no deeper meaning.

in some languages they are the same

Usually you can use the len function for something that may be null (since that function should check that first). If you used a method called len on a null value (i.e. dot into it like val.len()), then that would throw an error/exception on nulls.

Is undecidability even real? Can someone please show me some simple and undecidable code?

yes, but compilers stop compiling when they find it. I.e. template shit with C++

Surely there must be some legal yet undecidable code.

Oh, so they predict whether or not that program will halt and if it doesn't they stop compiling?

It's finally time we moved to dependent types

manning.com/books/type-driven-development-with-idris

90% of programmers haven't accepted even HM or similar yet

>Types as a first-class language construct
sounds interesting.

Well I think learning Idris is easier than learning Haskell

Good for you. If you stay in your LAN you could even bypass tcp/ip and bang your stuff through raw ethernet frames, saving bandwidth through header omission.

From scratch you mean? What if you already know Haskell?

Remind again when the book is actually out, I'm going to pirate it.

even from java to python it just feels like you can do anything with it

>Can someone please show me some simple and undecidable code?
The term "undecidable" is applied to classes of problems, not to specific computer programs. If you want an example of something that's undecidable, try to make a program that accepts a computer program as input, and can determine in a finite amount of time whether for a given input to said program, it will halt, or wind up in some infinite loop. If you make a program that matches that description, I can guarantee you with 100% certainty that I can make a program that your program cannot accept.

When people say parsing C++ is undecidable, what they mean to say is that it is impossible to create a program that can determine in a finite amount of time if any given C++ program is legal, because there is a possibility that it might enter an infinite loop, and therefore the problem of parsing C++ is said to reduce to solving the halting problem. The solution C++ compilers use, however, is simply to not accept all legal C++ code. If it could generate an infinite loop, the compiler will simply complain that the recursion depth is too great.

i need to cut a chunk of data from a chunk of data and then discard everything that's not the chunk that i've just cut out. can i do that somehow without actually making a copy of the data?

char* temp = data;
data = new char[cut_chunksize];
memcpy(data, temp+chunkstart, chunksize);
delete[] temp;

currently doing this

how do I level up?