/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Old thread:

Attached: 1519358030758.jpg (567x800, 44K)

Other urls found in this thread:

packtpub.com/application-development/rust-essentials
docs.microsoft.com/en-us/visualstudio/debugger/crt-debug-heap-details?view=vs-2017.
stackoverflow.com/questions/19684190/how-to-compile-c-file-in-visual-studio
twitter.com/NSFWRedditVideo

first for Eiffel

ganbarimashou

for me, it's zig

Attached: For me, it's Zig.png (4824x1527, 118K)

>use Ubuntu
>working in some GUI (VScode in this case)
>permission denied every 5 seconds
>get tired of clicking "save as Admin and typing in password everytime"
>"B-but you can't just run the GUI itself with sudo because then you're not being safe!"

How the fuck does anyone work in Linux?

inb4 that autist spamming his /dpt/ discord server

>not taking the rust pill
You are not even based or redpilled

Attached: Screenshot from 2018-10-19 04-59-36.png (3840x2160, 500K)

Also, I have to say, inconsolata is the only font that actually let's me focus. Too bad the font feels a bit too small.

Lisp is the most powerful programming language.

What do you think about common lisp?

>rust

Attached: qeq.png (1137x639, 56K)

My fave is Source Code Pro, but the whole Consolas/Inconsolata family are good too.

I am just beginning to learn Python as my first programming language. Yesterday, I made a very basic calculator. What are some sort of beginner projects I can work on to improve my skills? I keep finding lists of ideas that are far too advancced for me.

Attached: maxresdefault (4).jpg (960x720, 26K)

Attached: 1525869252115.png (1920x1080, 549K)

Lisp is not a programming language. It's millions of programming languages.

Cringe

Go on codewars or hackerrank

Hey guys. I have a Spring Boot and Angular application I need to deploy on OpenShift. What's the general process for doing that?

I think I need some kind of custom build environment for the Angular application and the Spring Boot application is built with Gradle, which isn't supported by OpenShift out of the box.

Attached: anime question 2.png (404x404, 118K)

Looks like yourlanguagesucks.com is pretty desperate.
>Safety
I don't quite care, same goes for performance too. I'm not writing a kernel/driver. I write desktop apps, I'll probably just use Arc/Rc and call it a day.
Fuck, gtk itself is not thread-safe and all I ever do is gtk.

>Vec
Similar to std::vector
>Cell
lol IDK why they call it Cell
>6 string types
Eh, don't care either. C's string and Rust's string are not the same. str and String are pretty different too and the difference is damn clear. OsStr(ing) have their purposes too.
"String" is not a universal class, there are different implementations of it. C++ has
char*
wchar_t*
std::string
std::wstring
std::string_view
std::wstring_view
std::u16string_view
std::u32string_view
etc etc
They all have their different uses.

>rustc is slow
yes, there is a room for improvement
>because it statically links ...
>because it statically links ...
You can link dynamically too. The writer is being purposefully disingenuous
>hello world size
see above. also, I don't care, I do GUI
>auto complete slow
>less IDE support
>others
yes, there's room for improvement

I'm no Rust expert but the writer is disingenuous to say the least. I just want a C++ with proper package management and maybe some modern language features.
Don't go to hackerrank either. At this point, do a whole lot of programming, learn different python features and exercise those features while you automate boring stuff with python. This is true for other languages as well.

Attached: 1539433114811.gif (410x480, 126K)

I'm realy trying to learn rust, just in case it's good. But I guess because it's so new the documentation is completely shit. What's the best place to learn rust? Any good tutorial or book?

What's cringe in that pic?

packtpub.com/application-development/rust-essentials

not with ubuntu obviously
also if you try to edit a protected file, it will block you
obviously

n was not initialized, look at its value
post context

Are you trying to write shit outside of your home directory? Of course it asks for password

are you ok user?

Stop samefagging. Your charts are total garbage.

>go do these shitty math programming tasks bro
die

I don't think so, I just installed go in its standard location.

What even is the home directory when compared to windows?

calm your tits autist

Write a python program that looks for occurrences of a given keyword (case insensitive) within files under a specific directory and its children.
The program has to be fast enough to search for a keyword in the whole Linux project under 10 seconds.
It should print out the number of occurrences and each of the line that contains the keyword with file and line number.

Linux works in a very different way than Windows. You should not have to install shit manually with download/click/install.

You use ubuntu, right? Just install VS Code with
$ sudo snap install vscode --classic and save all your files under ~/Documents/

cute vampire

don't you just wish she'd suck you dry

Already to late, I set up go already and have a deadline soon. If I change it now I'll probably fuck things up.

I'll better just kill myself.

I got a distinction on my first programming assignment.

Refining my Haskell

Attached: 1539512554866.jpg (443x455, 96K)

Use other editors then, make sure you install it through the snapstore or ubuntu repo. No PPA shit because PPA is a genuine garbage.

Seeing as it's packt it's propably full of errors, but I'll take what I can get.

I just started, but the overly terse shit is already annoying
>Function - fn
>Implement - impl
>Transform - Trans

I don't know what any of those words mean. I just do "apt-get install whateverIwanttoinstall"

>Trans
There's no Trans, there's trait

Interesting, can you post a screenshot when it asks for a password and where you are saving the file?

I don't know it's on my other pc which I don't have right here. It's probably not in /home/ but I already set up all the go shit. I'll try to move it tomorrow and lose even more time that I don't have to get this shitty job I don't want.

looks like someone is taking the Terry route with their meds

Trans is from a crate, a lot of the types from 3rd parties also use theses short names and that's also annoying.

Just copy and paste your shit to the Documents folder, bro

>/home/
No not /home/, use Documents, it's already there

How do I learn computer organization in a day?!?!?

>still samefagging
You are really defensive about those charts aren't you

How do you program an efficient inner JOIN?
Not use SQL JOIN, but program an implementation?
If you leave tables unsorted, it gonna take O(n^2) time. So what do you do, sort tables first?
Efficient sort is, like, O(n log n), right? You sort both tables, and, probably, should take O(n) time.
Can there be more efficient way?

Attached: 1488961674122.png (1057x717, 412K)

File a bug report to the crates that have them

Maybe you should look it up, faggot

Too much black space, user saw his own face in the monitor

Attached: 1521387203418.jpg (480x480, 16K)

I'm gonna make the greatest wheel this world has ever seen

so you want him to make a kind off grep like program?

>Also, it is 100% certain that "n->children" is either explicitly set to NULL or is properly allocated.

n is 0xcdcdcdcd. This means that you're running a debug build with the MSVC heap debugging enabled. This special value means n is allocated (new'd or malloc'd) but its member are not initialized. See docs.microsoft.com/en-us/visualstudio/debugger/crt-debug-heap-details?view=vs-2017.

JavaScript rocks!

Attached: 1539204102299.png (1000x494, 394K)

Trying to solve my linear algebra homework through Julia.

Anyone know why I can't take the pseudoinverse of a transposed matrix? Im' getting the weird error in the picture.

Here's the code that leads to the issue:
function prob6SolveRow(xMatr, yMatr, rowNum)
# print(xMatr)
println(size(xMatr))
result = pinv(xMatr) * yMatr * unitVector(rowNum)
print(result)

return transpose(result)
end

function solveProb6(xMatr, yMatr)
A_Matr = zeros(nRows(xMatr),
nRows(yMatr));
xMatr_t = transpose(xMatr)
yMatr_t = transpose(yMatr)

for rowNum in 1:nRows(A_Matr)
A_Matr[rowNum,:] = prob6SolveRow(xMatr_t, yMatr_t, rowNum)
end
end

Attached: Screen Shot 2018-10-18 at 1.07.09 PM.png (1856x800, 242K)

Someone explain to me how Call/CC works in scheme

does lazy evaluation have any performance advantages in real world programs

I have absolutely no numbers to back this up, but people don't use lazy evaluation because it performs better; it's probably worse.
It's just useful because it makes infinite data types actually useful.

selective LE does, default LE is awful, and just one of many reasons why haskell is shit.

>actually useful.
surely you mean "actually possible"

check it out ;)

print("Welcome")

username=input("Enter username: ") #PRINT QUESTION AND TAKE USER INPUT
print("Hello",username)

currentYear=input("What year is it? ")
userAge=input("How old are you? ")

currentYearToInt=int(currentYear) #CONVERT STRING TO INT
userAgeToInt=int(userAge)

print("So you were born in year",currentYearToInt-userAgeToInt)

print("How tall are you",username,"?")
userHeight=input()
userHeightToNum=int(userHeight)
toMeters=100
userHeightInM=userHeightToNum / toMeters

print("So you are",userHeightInM,"meters tall")
if userHeightInM < 1.80:
print("Manlet")
if userHeightInM == 1.85:
print("Thats not bad")
if userHeightInM > 1.85:
print("Giant man...")


userSays=input("Do you have anything to say? ")
if userSays=="yes":
A=input("Say it ")
print("Sorry more luck next time ")
if userSays=="Yes":
A=input("Say it ")
print("Sorry more luck next time ")
if userSays=="YES":
A=input("Say it ")
print("Sorry more luck next time ")

if userSays=="no":
print("GOOD ")
if userSays=="No":
print("GOOD ")
if userSays=="NO":
print("GOOD ")

if I aim to work with backend where do I go once I learn basics and I'm comfortable writing java? will I have to learn jsp, servlets, spring mvc, spring boot, spring data, spring cloud, hibernate, tomcat, maven/gradle, jenkins, eclipse ide, junit/mockito/jmeter, maybe docker, kubernetes, sonarqube?

the implementations or the concept?

i dont know julia, nor do i know what a pseudoinverse of a matrix is

but i can tell you in pseudocode
matrix a;
transposed_a = a.transpose()
pseudoinverse = transposed_a.pseudoinverse()

you dont even need to know what a pseudoinverse is to implement the above in a language

so your error is most likely a programming eror, meaning your implementation of prob6solverow is wrong

Cay I want to insert string2 into string1 and that sting1+sting2 exceeds the size of sting1.
Once array declared in C,it has fixed size.
What are my options here besides creating third array namely VLA that can take any sting1 size.

call/cc accepts one function as an argument. It calls that function with a continuation as the only argument.
A continuation (in Scheme's semantics) is a pseudo-function that instantly transfers control flow to the point of the call/cc, as though returning from the call/cc. This pseudo-function never returns at its call site. The argument passed to the continuation is also the value that the call/cc appears to evaluate to.
(define (infinite-loop)
(infinite-loop))

(display
(call/cc
(lambda (continuation)
(continuation "Hello, world!")

; control flow never reaches this point
(infinite-loop))))
The continuation can be used at any time, including after the program has already returned from the call/cc. You will of course resume the program at the site of the call/cc again.
Scheme interpreters usually translate Scheme programs into continuation passing style (a programming style in which functions never return and control flow is expressed by passing continuation functions as parameters) as an intermediate step anyway, so implementing call/cc is trivial.

Dynamic allocation.

>Cay I want to insert string2 into string1 and that sting1+sting2 exceeds the size of sting1.
dont worry bro, whenever the size of string1+string2 is the same as string1 you can just return string1

Newbie to vs code, how the fuck do I compile C?

And why is this useful?

You can implement complex control flow constructs this way, since it essentially makes control flow a first class language element.
You can implement coroutines in about 10 lines of Scheme using continuations, for example.

i found the answer using a search engine

That's exactly what I'm doing though...
xMatr_t = transpose(xMatr)

corresponds to taking the transpose, and
pinv(xMatr)

corresponds to taking the inverse... I don't really see how the pseudocode is different from what I wrote.

Seems cool I guess. I'm gonna play around in scheme until I really get this

fuck

It's not hard.
cosnt char *str1 = "whatever th";
const char *str2 = "e fuck";

char *str3;
asprintf(&str3, "%s%s", str1, str2);
asprintf is a GNU extension, but it's really easy to implement yourself with vsnprintf and friends.

I didn't, atleast not in a format I can understand as a new user

from the error message
>no method matching pinv(::Transpose{Float64 etc.etc.

the pinv you are calling on your argument doesn't exist
so you need to actually read some documentation on what argument pinv expects

or alternatively read what tranpose(matrix) actually returns in terms of type of object

it could be pinv expects a matrix and you are giving it a row or a vector (implemented as some array) and not a matrix

it's just my guesses

i once implemented matrices and some operations for neural nets - and you gotta be careful what's a matrix, what's an array, what's a vector

does windows send my images to microsoft servers to tag them?

Attached: Capture.png (569x305, 115K)

Yes, and this is the programming thread, you idiot.

I don't care thqh

just have your source file end in ".c"
and compile as if compiling a c++ file (meaning ending in .cpp)
>how do i compile as if it's a c++ file though
stackoverflow.com/questions/19684190/how-to-compile-c-file-in-visual-studio

i cant help you any further, since i don't use VS, and nor do i use C++
i just use gcc to compile c source files into executable programs

I use VS code, but I don't use any of the features beyond the text editor. I just have a separate console where I compile using make.

You realize VSC has an integrated shell right?

I don't trust it. I want VS code to just be a text editor. I also have all the sidebar and activity bar shit hidden.

>I don't trust it.
it quite literally just invokes your system's default shell, you're a fucking idiot.

>not trusting a trivial abstraction built on literally 1000 other abstractions
you fucking moron

It's a joke, it's not that I actually don't trust it, I just prefer my default terminal app, since I have that open anyway.

>I just have a separate console where I compile using make.
Same, but mostly because I couldn't be bothered to learn the build shit with Code, pointless since I already have my own setup.

>I just prefer my default terminal app
VSC
literally
fucking
uses
that
inside
itself
You're literally just wasting time and effort switching back and forth.
Fucking hell where do you mongs come from?

So this "n->children = NULL;" (pic related) statement is bad practice? In other words, am I forced to allocate memory for "n->children" (as well as n->end)?
This also means that this MSVC heap debugger is some extra security/memleak checker that unix doesn't care about while windows does, and of course that would be the reason why I can run it fine on unix?
This also still doesn't excuse how a single newline in the code would affect the behaviour of the debugger, but I guess that's just "classic microsoft".

Attached: Capture.png (1022x202, 13K)

Can someone with college algebra level math skills learn to program?

Attached: 1539579279160.gif (600x600, 495K)

hey Jow Forumsuys.
Yesterday I started programming an algorithm in C I created which first (well after a malloc() call) fills all indicies with a double equal to 1/n. After that, it does some operations on the array all referencing the indices via pointer arithmetic.
I'm fairly new to pointer arithmetic and am not very comfortable with it, so i wouldn't mind switching to referencing the indices directly.
Anyone here know how to do pointer arithmetic and can inform me what i'm doing wrong? Aside from pointer arithmetic, all other statements are working correctly.
pic related is snippets of my code that are relevant
>inb4 why didn't start without pointer arithmetic

Attached: code 01.png (1040x196, 24K)

Wouldn't I need to switch to the terminal within the window anyway? If I wanted to use the build command shortcut I would need to buy into their whole system, which I don't want to do.

probably

you set a keybind, you can set a keybind for just about fucking anything. If you install the vim extension, you have even more.
Is this literally, quite literally your first time using a program on a computer that's not your internet browser?

Sure.

Based and redpilled

But I would need a different set of build instructions based on which file I'm currently editing, or potentially which folder I'm in.

pointers are just indices from the null pointer