/dpt/ - Daily Programming Thread

old thread: What are you working on, Sup Forums?

Other urls found in this thread:

nim-lang.org/),
dlang.org/)?
en.wikipedia.org/wiki/Runge–Kutta_methods#Explicit_Runge–Kutta_methods
en.wikipedia.org/wiki/List_of_Runge–Kutta_methods#Forward_Euler
en.wikipedia.org/wiki/List_of_Runge–Kutta_methods#Classic_fourth-order_method
riscos.com/support/developers/bbcbasic/
reddit.com/r/cscareerquestions/comments/7vxid2/i_am_steven_skiena_cs_professor_and_author_of_the/
en.cppreference.com/w/cpp/filesystem/directory_entry/directory_entry
gitgud.tv/watch/?u=4452
twitter.com/SFWRedditVideos

Reimplementing haskell in fortran

The poster below is unsafe { }. Don't trust him.

Want to learn a natively compiled language that's easy to use.

Should I choose Nim(nim-lang.org/), D(dlang.org/)? Already tried Go and Rust but neither I liked.

Why can't we just make programming voice based and without the syntax bullshit?
>"Computer, new project, titled 'test game'"
>"Draw a square"
>"Now move it to the bottom left corner"
>"Make it red"
>"Allow me to make it move left and right with the A and D keys"
>"Alright let's adjust the speed variable, show me the current value"
>Etc

Crosspost from: C++ needs to make the class constructors be able to have exit codes so you can see that the code in them were successful to execute.

C++ class error handling at it's current is totally shit

What if you want to do something other than draw a square?
What if you want to draw a rhombus?
What if instead of drawing shapes, you want to write a daemon that feeds the requesting program SQL results?
What if you want to implement your own programming language in your dumbed down voice language?

Foo foo;
if (init(&foo))
// error
fuck ctors

>whataboutism

nim

I thought so yea, can you elaborate why you personally would choose it above D?

Nim is almost perfect but the super-small community is a bit troubling. Also D's LDC is quite an achievement.

So you are saying we are all programs?

Threadly reminder that if you're still shilling for pre-canned C++ game engines, you're a beginner.

>he fell for the write your own engine meme
not gonna make it

Finding largest duplicated substring in the bible.

king of Israel sent to Amaziah king of Judah,
saying, The thistle that was in Lebanon sent to the cedar that
was in Lebanon, saying, Give thy daughter to my son to wife:
and there passed by a wild beast that was in Lebanon, and
trode down the thistle.


Please shit all over my non-idiomatic code:

import Data.Foldable
import Data.List
import Data.Ord
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as T

sortedSuffixes :: Text -> [Text]
sortedSuffixes = sort . T.tails

adjacentElements :: [a] -> [(a, a)]
adjacentElements xs = zip xs (tail xs)

takeCommonPrefix :: [(Text, Text)] -> [(Text, Text)]
takeCommonPrefix =
map ((\(a, b) -> (T.pack a, T.pack b)) . unzip . takeWhile (uncurry (==)) . uncurry T.zip)

fstEq :: Eq a => (a, a) -> a
fstEq (a, b) | a == b = a
fstEq _ = error "mistake"

findLargestPrefix :: [(Text, Text)] -> Text
findLargestPrefix = fstEq . maximumBy (comparing (T.length . fst))

findLargestRepetition :: Text -> Text
findLargestRepetition =
findLargestPrefix .
takeCommonPrefix .
adjacentElements .
sortedSuffixes

main :: IO ()
main = do
allText

nobody can stop me from trying :^)

still trying to understand how windows draws

> Somewhat off topic, but I'm increasingly finding that Qt is the last remaining reason to use C++. Qt is amazing, but C++ isn't a very productive language to code in, even if you're good at it. OS-less microcontroller stuff is probably better done with plain C, and everything else (games, system programming, embedded programming with an OS, etc) has mature and better options available such as Rust, Go, Nim, and (particularly for gamedev) C#.
What did they mean by this?

>mature and better options available such as Rust, Nim
lmao

why shouldn't I just write Ruby then compile it w/ crystal-lang?

Is this python? Its all wrong

Python doesn't have pointers wot

It's very obviously not Python. It's Haskell.

Don't use Python

Is it pythonic enough? Can we do better?

>doesn't know how to write a game engine
>seriously believes it's hard to do a better job than pre-canned C++ engines
>projects his ignorance and insecurity onto others

What is the best language to write Python extensions in when Python is too slow?

class foo {
foo (std::error_code &ec);
};

Have to study PHP for a student's job position (fuck I forgot the real word) on my uni,
create a wordpress fully functional web page for tomorrow (It is shit and I just want to program on javascript/sql/php/ you know),
Do a numpy assigment for algebra,
Do a java assigment about a managment app for universities; it should create and delete assigments and Degrees with lots of ibformation, fuck it fuck,
Next week I have 2 exams (one is about OOP and the other fucking microcontollers with that ASM arduino CPU)
Im a freshman and currently having a fever (39°C): Is this how a wageslave feels like?
>tfw no cute gf who takes care of you

Try scheme.

Already did, looking for my next one! Thank you for the suggestion though, can't go wrong with a lisp.

is HTML programming?

Unless you have extensive opengl/directx knowledge it's going to take long while to make it.

I would just use SDL. Don't worry about interfacing to the OS too much that varies even between versions of windows. Once you grab an OpenGL context that is where you should start learning how things draw.

But basically for opengl the graphics driver writes to a "framebuffer" which the operating system takes and writes where the window should be. The framebuffer is basically a 2D array of colors.

Writing a game engine is a great way to learn opengl though. Its how I learned.

Not really no, it's more like labeling elements.
It's almost an essential skill in some areas these days.

this, obtaining the opengl context takes a lot of boilerplate on windows

It feels more like doing the same thing over and over again.

>hyper text markup language
>markup

>sdl
>not valgrind clean
pls

What's even the point of a constructor at this point? This breaks RAII.

>Unless you have extensive opengl/directx knowledge
If you don't have extensive OpenGL/DirectX knowledge, you're going to produce shit even with a pre-canned engine unless you stick to pre-canned materials/shaders. On the other hand, if you only care about the basics anyway, you don't need "extensive" knowledge. Especially if you're writing a 2D engine. Sprite batching is not that hard.

I can get a context with their API. I don't know what to do with it or what format it is or where do I shove my bitmap.

Read a book then user. I read the opengl superbible.

extremely powerful metaprogramming capabilities.
very opinionated main developer with strong vision.
*it just feels nice*

the 1.0 release is soon, so you can expect some community growth.

I've been digging trough windows documentations for that. Probably will if I find more time.

Proof that traps are dangerous:
use std::mem::transmute as crossdress;

struct Boy;
struct Girl;

fn main() {
let hime: Girl = unsafe { crossdress(Boy) };
}

programming challenge: write a function that accepts a butcher tableau and returns a function that executes the corresponding explicit runge-kutta method. use it to compute three steps of the approximate the solution to (dx/dt = -y, dy/dt = x / 2) with an initial value of (0, -1) and a step size of 1/2 with the forward euler method, and the original runge-kutta method. additionally, benchmark the latter by computing 1000 steps of the same system with a step size of 0.01.

en.wikipedia.org/wiki/Runge–Kutta_methods#Explicit_Runge–Kutta_methods
en.wikipedia.org/wiki/List_of_Runge–Kutta_methods#Forward_Euler
en.wikipedia.org/wiki/List_of_Runge–Kutta_methods#Classic_fourth-order_method

Don't ask me, this is what they do even in the STL.

>butcher table
>rutta kutta
>forward euler
>runge bunge
tf is this cooking show bullshit

shut up

...

How can I use this to write a kernel?

>not Vulkan

>what is portability

Programming challenge: write a program in BBC BASIC

Reference manual: riscos.com/support/developers/bbcbasic/

Use the Brandy interpreter (available for windows and linux) if you don't have RISC OS

>you have to know vulkan to make a decent game engine
Wrong. OpenGL is still sufficient for most purposes (unless you're planning to make the next CoD clone).

Plusmonkeys and Javascript artisans are the reason actual programmers can't have good things.

kotlin

At least JS artisans have a job

>js artisans having jobs
>this is a good thing somehow

dumb frogposter

[spoiler]umm[/spoiler]

>frogposter
t. brainlet

is that way, loser

Go back to

>implying i don't have a job
>implying you have a job
>implying it's good that people with your low mental capacity can get a job as "programmers"
The absolute state of aspiring JS artisans...

Go back to /mlp/

t. developer advocate

>get called out on being a dirty redditor frogposter
>accuse your opposition of being a brony
are you a brony as well as a frogposter?

t. reddit

this professor cant stop shilling his book lmao. What a shitty ama

reddit.com/r/cscareerquestions/comments/7vxid2/i_am_steven_skiena_cs_professor_and_author_of_the/

sad!

oops that's the shite version.

nobody cares

where in STL is this done?

enjoy your pajeetified education.

en.cppreference.com/w/cpp/filesystem/directory_entry/directory_entry

Here, and in a couple more places in the filesystem library.

>games, systems programming
>Rust, Go, Nim, C#
Hahahahahahahahahahahaha!

>Qt is amazing
How can anyone be this distasteful

>Nobody in the programming thread cares about programming
Sounds right.

>(since C++17)
Glad to see that C++'s innovating with fresh new blunders.
> The overload that does not take a std::error_code& parameter throws filesystem_error on underlying OS API error
I'm not sure what's worse.

So again, what's wrong with std::error_code init(directory_entry*) noexcept;?

I'd rather be homeless than having to use a shit-tier language on a daily basis.

look at the thing i made it's a webtorrent based livestreaming thingydoohicky

gitgud.tv/watch/?u=4452

Rust and Nim are both superior to C++ for games and systems programming, though.

hey guys
I'm currently using debian
best software for C programming?

clang/llvm
inb4 gcc

clang has better qol but gcc can often generate better code
compile with clang for your debug cycle then benchmark with gcc to see which is better for production

doing that is asking for problems with gcc in production
1 compiler only, anything else is bogus.
intel's compiler is pretty sweet i've heard.

clion

What does cogl actually do when I invoke it from the command line?
All I can tell is that it seems to invoke gcc to compile my C program.

I've actually knitted a pair of programing gloves. Doesn't look as fancy though, but I can recommend it was nice.

Post pics.

I guess when you go with free functions, there's no reason to have a directory_entry class with methods inside.

How the fuck do I not get fucked by my boss?

I'm supposed to write a new tool on a big IIS server with a shit ton of applications already on it. I know literally nothing about web programming.

How can I learn JQuery, SAP UI5 (some weird API for use in visual studio) and how to use stuff like the Entity framework correctly?

Up until yesterday I've never heard of MVC and the only thing I've managed today at work is creating a button in the XML view file and a corresponding function in a controller

I've seven weeks

ur fugged yo

Applied mathematicians should apply themselves to the inside of an oven.

what the purpose of the tool
froma business perspective

user, how do you serialize struct to JSON in C?
Not having reflection is pretty bad limitation. Are there any workarounds?

Except writing serializer for specific structure.

Member functions are a mistake anyway.

Write a separate program that parses the structures and serializes them to JSON.