/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

en.wikipedia.org/wiki/Term_of_patent_in_the_United_States
en.wikipedia.org/wiki/£sd
cs.rochester.edu/~nelson/courses/csc_173/review/gdb.html
twitter.com/SFWRedditGifs

i've got to get child processes to compute a value in a 2 dimensional matrix and then have the parent plug it in to the correct place. i can't pass any extra information about the index it goes in to the child, and then have the child report it back to the parent. is the only way to do this a hash table to store and look back up the right index for its pid? i can't run the child processes one at a time

I wish I could become a program

Java has no place in academia

Just fork() them all in turn, storing their pids somewhere and then join() them in the same order? I don't see the problem.

Java has no place

Java has

Java

For some reason I always misspell Java as Jave

Ya blew it

heard you were talking shit

I don't know what but there's something about this post I don't like

the point is to allow the multiple processes to compute them in parallel, so doing them one at a time wouldn't give any benefit

listen here punk if you want someone to solve your homework you better learn to read posts, now fuck off

How do I call SIMD intructions from scala(java)?

why are you mad?

Use JNI to enter the realm of C.

Question about C

My programming experience is java, c#, and a few web languages. I'm looking at some lessons and I see people using malloc when building arrays. Why is this necessary? Working through the ansi c book, I've been making arrays without doing this just fine. Is it dangerous to define arrays without malloc/calloc, or is it redundant?

Fucking this.
In my uni one of the IT programs have fucking JavaScript course

in the past you weren't able to write something like int a[n]; this is mandatory in c99 but optional in c11

PROGRAMMING CHALLENGE

Make a £sd calculator. It must be able to add, subtract in £sd, multiply and divide by decimal fractions. Lowest coin is farting.

Making a tool to design serializing/deserializing programs to export to different languages.

malloc puts the array in the heap. normally it'd just be allocated in the stack frame, and destroyed when the function exits. as i understand it, may be mistaken

has the patent actually expired?? fuck i wish i had a lawyer

>en.wikipedia.org/wiki/Term_of_patent_in_the_United_States

Two reasons.
>size
Prior to C99, it was invalid to make an array of a size which isn't a compiletime constant. malloc allows that without problems.
>lifetime
An array allocated on the stack (i.e. the regular way) is only valid until you leave its scope. You cannot legally, for example, return a pointer to an array declared locally within a function. Anything you malloc is valid until you explicitly free it.

more like
>do my homework for me

>£sd
what

Name ONE (1) cross platform C/C++ GUI kit that doesn't suck balls.

>maki poster
As usually, he's dumb.

en.wikipedia.org/wiki/£sd

Pre-decimal UK coinage

...

Don't know if this belongs here or on /sqt/.
How am I supposed to debug (using gdb/lldb) if I don't know where my program is fucking up?
I get a segfault but I don't know exactly what the problem is. So how do I set breakpoints?

IUP

too much to explain in a post

Qt.

if you're segfaulting then just run it through valgrind after compiling with -g

dear imgui. but it's immediate mode, so it's only really suitable for realtime applications. and immediate mode kits are the only ones which ever don't suck balls, regardless of language. event-based approaches are forced to design themselves around requiring you to fragment the fuck out of your code

Where would you start?
Well yeah but I need to be able to debug a program in general.

cs.rochester.edu/~nelson/courses/csc_173/review/gdb.html

Thanks. I'm guessing lldb is more or less the same shit with different commands

Yes

Simple reminder that Java is the best language to start with if you're a beginner.

I hate occultists

rude

Occultists are pagans in denial.

Common Lisp.

Scala.

Nah. Python is better. Teaches you good style and doesn't get you bogged down in immediately understanding types or the differences between compile- and run-time. Then introduce the student to functional programming with Haskell and assembly with MIPS. Introducing students to multiple programming paradigms early on helps them from becoming inflexible later on. Migrate to C and teach algorithm design and data structures, then finally to OO/interfaces with Java or C#. Then teach large-scale software architecture principles.

Noob question: I know int, string etc. are types, but is Base type the same as Base class? For example in Visual Studio:

public class Card: Deck

and in the class view it says Card > Base Types > Deck

Option 1 -> declaring a constant int variable at compile time and sizing your array with that variable. No problem, the size of the array is defined assigned in the stack at compile time.
Option 2 -> Defining an array at run time with a variable is dangerous and incorrect.
Option 3 -> dinamically allocating memory to satisfy the need of variable space ar run time. OK.

Yes

you mean nuklear

thx

Then go segfault yourself

I do not at all understand C++ iterators, nor can I find decent documentation on implementing them yourself. Unfortunately I do not care enough to put in a real attempt to figure it out, and might just make an equivalent class. Which is an ugly, disgusting, hack. Probably just like iterators themselves, ultimately.

More or less I've created a simple ring buffer and want a relatively clean way to traverse it. Pretty much everything looks ugly, decadent, and degenerate to me at the moment. I do not know why I won't just die.

If I told you I'd have to kill you

You need a lot of setup to get started with Java.

They look and feel like pointers.

Ok. I'll suicide by information.

Like?

i prefer dear imgui myself, but nuklear is also immediate mode, so it reaps the same benefits in terms of API design

$ gdb ./my-program
(gdb) r
bla bla bla
segfault ....
(gdb) bt


"bt" is short for "backtrace", and will show you the exact line where the segfault happened

why would you use c++

Pointers are iterators. Just use them.

Kill yourself Pythonfag.

Install jdk, install ide, setup PATHs.

redpill me on git merge vs git rebase

both are useless
just save to the cloud from time to time

Git rebase keeps your tree pretty and avoids superfluous commits just for the merge

You don't need an IDE to code Java. The same applies to any other language.
pacman -S jdk8-openjdk is all you have to type to get the JDK and set up the PATH variables.

no, C is.
it's very minimalistic so it's easy to learn
with proper guidance most rookie errors are avoidable
you get some under the hood understanding
it gives a basis to other C family languages (+90% of the market share)
you can even slip in some basic debugging knowledge
makes you appreciate higher level languages

>this whole post

thanks but no thanks

is that the only benefit?

>outdated shit
>becoming less and less relevant as time goes on
>"""best to start with"""
lol

>you get some under the hood understanding
I'm not a C hater, but what do you mean by this?

>he didn't implement the most commonly used constructs in his c++ class
before we used something from the std namespace we implemented it first (with the exception of cin and cout)

Writing in C++ like it's C is more comfortable than writing in C.

Daily reminder. C is no more "under the hood" than C++. The techniques that tend to stem from each are good to know, but as a whole, C really is just a more limited C++.

I don't follow the meaning.

Is K&R decent?

Yes

how memory is laid out, how pointers work, you can implement you own linked lists, trees etc

it's almost like you should learn basic concepts first, and then move on to the applicable stuff
you don't use long division, but you still learn it to understand what is going on in the background

It is , but it can be a bit dense if you are just starting out.

>C really is just a more limited C++.
What can't I do in C++?

>to other C family languages (+90% of the market share)
This is wrong.

Ideal learning path:
C (basic computing) -> C++ (OOP) -> Java AND Scheme/Haskel (FP) -> domain specific stuff (python, R, mathlab, JS etc)

C is irrelevant now. With Java 8 you can go straight to Java and give yourself the best opportunity of getting a job.

>Java (FP)

>how memory is laid out
malloc does all that magic for you, unless you write your own.
>how pointers work
That's true though.
> you can implement you own linked lists, trees etc
I can do the same in JavaScript, so I don't see why this is unique to C.

c, c++, java, c#, go, d, rust
all of them a pretty similar in terms of syntax

C will never be "outdated". The underlying logical constraints any given computational machinery, whether the human brain, a "computer" (which is not aptly named, and is actually a broader signal processor), a cell, or a group of humans, the underlying logic that drives the universe imposes slavery to certain constraints. You see it in every machine, and at every scale. C's symbolic grammar is close enough to these constraints that you're unlikely to ever see it truly outdated.

Haskell.

>C is irrelevant now
Then why all CS programs still have it?

it would be easier to go C -> python -> C++ -> FP so you can get the idea of OOP before you dive into the sea of C++

You work on Haskell

Well if we are talking Linux, all you need to do to start using python is type python.

I want to be relevant learning path:
Java/C# -> Python ->

That's not even an argument.

No, YOU work on Haskell

I'm just saying that, in school we implemented our own iterators, before we used them on std objects

>implying python is not closely as hacked together as c++
I'd rather put java instead of c++ desu

By looking pretty I mean there won't be multiple branches forking and merging over and over. I usually create a branch, work there and rebase to master if there's other changes from someone else. Then I merge fast forward master so there's no merge commits.

If someone else has to merge your changes though, doing a rebase before the merge will ensure they don't have to deal with the conflicts themselves.