[ 3 / biz / cgl / ck / diy / fa / g / ic / jp / lit / sci / tg / vr ] [ index / top / reports / report a bug ] [ 4plebs / archived.moe / rbt ]

Maintenance is complete! We got more disk space.
Become a Patron!

/g/ - Technology

View post   

[ Toggle deleted replies ]
File: 166 KB, 1280x720, 1523920114325.jpg [View same] [iqdb] [saucenao] [google] [report]
65615641 No.65615641 [Reply] [Original] [archived.moe] [rbt]

What are you working on?
Previous thread: >>65606120

>> No.65615652

thank you for using an anime image

>> No.65615661

Trying to get Boot to work for Clojurescript.

>> No.65615669

working? im working to learn a fucking language thats what im working on. im self learn guy, any idea how to make money after learning python/C/ruby ? im interested in penetration testing any stuff i should know

>> No.65615675

Just lost a shitload of my bigass program due to corruption. Reminder to always keep backups and always eject external harddrives before unplugging them. Don't be an idiot. It can and will happen to you. Looking for music recommendations or something to listen to while I rebuild everything.

>> No.65615684

>always eject external harddrives before unplugging them
WTF? Are you actually using FAT for anything at all other than interchanging files between different operating systems?

>> No.65615693

Just bought an external drive to carry my shit around on between computers anon. I just used the default. Dumb of me, I know. But not keeping a backup was dumber.

>> No.65615700

Is there any benefit in looking into hipster languages like Haskell, Rust, Ruby and Lisp instead of just sticking with C, C++, Java or C#?

>> No.65615703

Can anyone explain me this sentence
> If you were a good enough programer you wouldn't worry about the OS you run you could ssh into your server

help, what does ssh into your server means

>> No.65615708

>But not keeping a backup was dumber.
Perhaps, but on any real filesystem, you shouldn't have to worry about corruption, at the very least.

>> No.65615711

Learning Haskell or Lisp will make you a better programmer, even if you never use them outside of hobby projects.

>> No.65615714


>> No.65615716

you probably wont go far with your logic
not learning new things to improve your skills because youre on 4chan and ppl with anime backgrounds call Ruby a hipster language is just braindead shit buddy.

>> No.65615725

Ruby shill spotted.

>> No.65615733

You forgot your anime girl anon.

>> No.65615743
File: 2.02 MB, 300x169, yuyu-15.gif [View same] [iqdb] [saucenao] [google] [report]

Just wrote a Python library for easier testing of various audio waveforms.
>>> from sox import dplay, sine
>>> dplay(sine(f=sine(f=1, amp=200, bias=500), amp=0.5), T=2.0)

Thanks for using a great image, OP.

>> No.65615754

>Can anyone explain me this sentence
Yeah: the guy's a moron.
Being able to ssh into a server running your OS of choice has nothing to do with being a good programmer.
Also, if the requirements say your program needs to run on ShitOS, and there are portability issues, that shit won't help you one bit.

>> No.65615768

>on any real filesystem, you shouldn't have to worry about corruption, at the very least.
ah, to be young and naive

>> No.65615771

No probelm. There is a high chance you are the one who posted it.
Different PL don't offer magic.
Just learn the abstract of what every PL has to offer you'll notice every PL is just different syntax with possibly different limitations.
E.g: creating a variable, functions, lambdas, basic system calls like console output and file IO...etc
>interested in pen testing
Learn C and then python
How mastering the general purpose ones (at least one high and one low PL) and then getting into FPL for fun? Learning something new won't give you cancer.
Besides, if you want a job, you better learn the PL popular in your area.

>> No.65615785

oh tell me how i should limit my programing skills for the shake of society anon, we should just all learn python and c and call ourselves the gods of programing right. get lost

>> No.65615799
File: 259 KB, 1280x960, 1506932291819.jpg [View same] [iqdb] [saucenao] [google] [report]

No. Just C.

>> No.65615874

I'd let Maki give my ding-dong a tug

>> No.65615903

Fun, learning; they might not have the community or libraries of bigger languages, but they're fine otherwise.

>> No.65615987

Can someone explain to me how something like Haskell can be useful in the real world, outside of really niche stuff?

I understand and enjoy the functional programming paradigm; however, "pure" functional programming is free of side-effects. However, in real applications it seems to me like side-effects are the most important part. You will wait for input from a user, then draw to the screen, change state (because software that's being interacted with does have state), send a network request, write to disc, access a database... Sure, between those endpoint, there'll be some processing of the data. But in the end, it seems that "look at this data and decide what to do based on it, then interact with the real world (read: throw out a whole bunch of side-effects) accordingly" is much, much more common than "take in this data as input, process through it functionally and spit out the processed data".

So, is there a way to use Haskel for programming typical desktop applications, or is it really more of a niche thing for times when the business logic is relatively free of side-effects and more about processing data correctly?

>> No.65616000

Haskell models side effects using monads. The gist of it is that all your side effects can be contained to stuff like I/O while the majority of your code is pure functional.

>> No.65616002

In fifteen years, I haven't had any corruption whatsoever on ext3/4, XFS or ReiserFS that wasn't caused by the underlying hardware. Admittedly I don't know about NTFS, but surely it can't suck that badly.

>> No.65616048

>haven't had any corruption whatsoever on ext3/4, XFS or ReiserFS that wasn't***
that has nothing to do with the original point: keep backups (see also: don't skip leg day)
the fact that your FS dindu nuffin ain't gonna get your data back

>> No.65616074

translating >>65616000 to english:
haskell uses one huge global variable, and only modifies that
smug haskell weenies love to pretend that this makes their programs side effect free, which is their preferred way of training their self-delusion muscles

>> No.65616081

/dpt/ anons, do you use docker for team work?

>> No.65616088

>love to pretend that this makes their programs pure
much like "I'm still pure because he only did me up the arse"
Haskell is a religion after all, so you'll notice more of these similarities.

>> No.65616099

I never denied that. Nevertheless, in this particular case, backups shouldn't have been necessary.

>> No.65616109
File: 85 KB, 1024x845, 377248cc3632c98867e1e6c050ee85_jumbo.jpg [View same] [iqdb] [saucenao] [google] [report]

What is this, madlibs?

>> No.65616148

1. you kinda implied that it ain't that important
2. but it sure would've helped

>> No.65616152
File: 344 KB, 1333x1000, Vo7SwyIdfd.jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.65616157

>haskell uses one huge global variable, and only modifies that
I thought a monad was a way of chaining functions, not a variable to mutate.

>> No.65616192

a monad is a burrito
exactly that, and completely interchangeable
nothing less, nothing more

>> No.65616205

Yeah but like, say looking at my company's code I'm working on right now, the IO and other side-effects are so closely linked to the functional bits that separating them basically means chucking at the very least 50%, and possibly more like 80% of the code into an "IO layer" and then being smug that the remaining 20% are "pure".

Sure, I can see some modules which heavily process data - we have a lexer-parser for an in-house simple language, which could easily be implemented purely functionally - but outside of bits like that, it really seems superfluous.

>> No.65616206
File: 1.21 MB, 500x281, tumblr_o0a3wrvSLX1tzlep2o1_500.gif [View same] [iqdb] [saucenao] [google] [report]

A monad is just a monoid of the category of endofunctors

>> No.65616212

Didn't a guy with a monad get into Smash 4?

>> No.65616241
File: 90 KB, 706x690, 1498579043005.jpg [View same] [iqdb] [saucenao] [google] [report]

>this one tool is the only tool, the best tool, for every problem I might encounter
I too make sushis using only a hammer.

>> No.65616246

>what's the problem?

>> No.65616248

This. Simple really.

>> No.65616260

>A monad is just a monoid of the category of endofunctors
's a classic really

>> No.65616273

It's just that people love saying how Haskel is actually great for real world applications and all that. I never contested that it would work in envornments tailored to functional processing (like a lexer-parser, for instance), I'm asking for clarification on that particular claim.

I take in the answer is just "it's really not"?

>> No.65616297

I was implying that it shouldn't have been necessary in this particular case. The hardware didn't actually fail.

>> No.65616322

see >>65616074

>> No.65616337

not necessary, but sufficient
and let's drop the autism for a bit - the most realistic and pragmatic approach

>> No.65616355

I still don't know what Docker actually is/does. And I don't care to find out.

>> No.65616371

>1972 - Dennis Ritchie invents a powerful gun that shoots both forward and backward simultaneously. Not satisfied with the number of deaths and permanent maimings from that invention he invents C and Unix.
I love this

>> No.65616379
File: 55 KB, 770x600, docker.jpg [View same] [iqdb] [saucenao] [google] [report]

he cute

>> No.65616381
File: 256 KB, 518x487, download.webm [View same] [iqdb] [saucenao] [google] [report]

I'm making a twitter image downloader because twitter is fucking garbage by default for downloading cute grills.

I'm going to use the text boxes for tags so I can make searching for images easier. The rest of the filename is so that I can build the original post's URL since the default filename makes it impossible to find the original source.

>> No.65616387

Your inability to comprehend that 'real world problems' might be much more than what you've encountered in your particular shitty career has nothing to do with Haskell.
Even among the IO heavy applications some can benefit a lot from Haskell.

You're just the nth obvious bait wanting to start another stupid language flamewar on a dead thread. If you really were curious you'd just google 5mins and read on why some businesses decided to use haskell.

Kys you're self already.

>> No.65616393

I used docker for a university group project, we spent three days right before the deadline sorting out problems related to it.
Apparently addressing the host machine from inside the container in a platform-independent way is such an outlandish problem that they only just added support for it, and we literally didn't have it available before the deadline. The workaround? Running docker in a virtual machine.
I wish I was joking.

>> No.65616400

>Kys you're self already.
*your :')

>> No.65616407

>being this new

out with you

>> No.65616419

post the cute grills already! nobody cares about the wem.

that's actually a nice idea. I like it, you're going to share the code ?

>> No.65616427
File: 41 KB, 336x476, ebin.jpg [View same] [iqdb] [saucenao] [google] [report]

>wasting dubs that hard

>> No.65616557


>> No.65616642

Does anyone here use VS Code on Linux? I just read an article about it, and it sounds really nice. Only the name Microsoft discourages me a bit.
I'd mostly use it for C/C++ and Python development. At the moment I'm using JetBrain's stuff (CLion etc.).

>> No.65616823

Focus on the product (and disable telemetry).
It has an amazing performance for a program running on electron.
Wouldn't use it for things other than .net core, haskelly and python.

>> No.65616836

anyone here do any game dev? (either in industry or just hobby projects)

any good resources for a noob like myself?

>> No.65616865

Unreal, Unity or monogame are the easiest.
Unity has dozens of resources given it is taught at uni and has a huge base of non enterprise or even solo devs.

>> No.65616881

Anyone here have experience with reading in packets using libpcap?

reading in live packets with pcap_next, seg faults if it runs out of packets and I'm looping through to find the one I need (comparing the recieved ip with the one I'm expecting) so if I don't get a response fast enough it just crashes, currently using sleeps to get around this but it causes some major delay.
Anyone know a better way?

>> No.65616919

>learn nothing but c
[brainlet (1).png.jpg.exe]

>> No.65616921

Damn. I want a cute comfy programming club.

>> No.65616970

use pcap_next_ex and see some examples online for live capture.
pcap_next doesn't distinguish between error and packet getting fitered and whatnot but it doesn't cause seg fault.
Make sure you have the latest lib version.

>> No.65617011

C/C++ and Python are both really suited to custom dev environments built on top of vim or emacs. Or if you're lazy, download one of the pre-made packages with a bunch of plugins included - spacemacs being one example, but there are tons including pure vim ones.

What you need an IDE for is Java. I've also not found a good way to use a javascript debugger in an editor, so you need a browser for that. For most other things, get rid of bloat.

>> No.65617165

You realize that tw*tter is one of the worst places on the internet to download anime art from right? Everything uploaded there gets fucked into a <100KB jpeg with horrible compression artifacts. It's honestly become the bane of my existence. Nothing pisses me off more than finding a good artist who uploads exclusively to tw*tter.

>> No.65617170

ah yeah that would work so much better, thanks.

>> No.65617291

If only retarded god tier nip artists would stop posting there.

>> No.65617304
File: 111 KB, 660x680, wc7u8noqs1t01.png [View same] [iqdb] [saucenao] [google] [report]

What keeps you going, /dpt/?

>> No.65617312

At this point I just write them off no matter how good they seem. If they don't care about their art, why should I?

>> No.65617336

Any way I can limit precision of floats in Python? During computation I'd like certain changing parameters to be always rounded to n decimal points not only during logging but also during computation.
Or is my only option to round them whenever assigning new values?

>> No.65617366

Why would you ever want to do this?

>> No.65617404

pickup violent python

>> No.65617450

Create new functions for arithmetic and use those instead.

>> No.65617498

>Yeah but like, say looking at my company's code I'm working on right now, the IO and other side-effects are so closely linked to the functional bits that separating them basically means chucking at the very least 50%, and possibly more like 80% of the code into an "IO layer" and then being smug that the remaining 20% are "pure".
What is your company's product? Don't need names, but what does it do? That just sounds like shit code to me.

>> No.65617525

They teach you new ways of thinking about programming.
Lisp and Ruby are highly likely to even become your preferred hobby language over C/C++/Java/C#, because they're just so joyous to program in.
And lots of people find benefits in using Haskell or Rust in their hobby projects too -- such as less frustration in the long run because the compilers and typing are so strict.

>> No.65617551

those things are, as you say, at the endpoints. and it depends on the application, but in my experience, there can be quite a bit in between, and much of it can and should either be pure or at least limit side effects strictly to objects directly taken by mutable reference (and of course global mutable state should be avoided at all costs in favor of context objects), because it's consistently good for code and helps you avoid a lot of pain. without global mutable state, taking objects by mutable reference can still form very useful guarantees to users and compilers, since it makes the scope of potential side effects known to a user, and keeps them as few and as local as possible. at that point, functions on such objects are still deterministic; just think of it like part of the input to the function is the values of the parts of the object's state it reads, and part of the output is the new values of the parts it mutates. given an object with the same state (or same relevant portion of state), the function will yield the same output. this determinism guarantee propagates outwards into calling scopes, and is even strong enough (and keeps the amount of relevant information small enough) that nonlocal/overall determinism becomes rather trivial to detect/enforce over a broader context. that's how constexpr in C++ works; by enforcing rules not much stricter than usual (primarily "no global mutable state, no undefined behavior"), it becomes manageable for the compiler to guarantee determinism for arbitrary/nontrivial code, using potentially any of a vast majority of language features (in a feature-heavy, imperative language), in contexts where the overall necessary/relevant inputs are known (it basically lets you embed pure functional programs written in C++ as compilation stages)

>> No.65617573

Wasn't there a nip alternative to twitter? Does it also compress images?

>> No.65617579

You'd probably be surprised at how much can be refactored to not rely on state and side effects. That's why Haskell is considered so enlightening to learn: you get really good at thinking about programming without relying on side effects and state.

>> No.65617587
File: 230 KB, 3840x2160, ansible_work.png [View same] [iqdb] [saucenao] [google] [report]

I don't know if you count this as programming but I wanted to try out feedbin for RSS but found out there's no easy way to deploy it with all bells and whistles so I'm working on an ansible playbook that will configure it and all of its sub-services using docker.

>> No.65617591

Did you mean Pixiv? Its not really twitter, more their DA.
And it has some, but an option to get the original (albeit compressed) image.

But for some reason tons of nip and western artists love using twitter to post their work and never upload them elsewhere. ITs weird.

>> No.65617622

For a while some artists linked to their patreon and no, I am not talking about pixiv.
I recall reading posts about twitter banning lolis and some said nips would just switch to their nip version of twitter but I forgot the name.
I honestly gave up on twitter and fucking puke everytime I see a twitter image on google. Seeing sachiko full of lossy shit drives me angry.

>> No.65617630

I don't recall that happening, twitter is still the main place for most nip artists still and I know a few still post their loli (then instantly delete) there.

>> No.65617669

hot women and hot assembly

>> No.65617697

holy wall of text, batman

>> No.65617701

Superior genes. I'm just a naturally positive and motivated person. I have no idea what a depression is and I just enjoy my life as it goes.

>> No.65617706

I think they use twitter because of the (You)s you could get there and interactivity with comments.
I just browse pixiv now and then and booru when I feel bored. If they have a patreon, you can find them on pixiv and booru otherwise just fuck their lossy shit.

>> No.65617709

The dream of formal verification with types.

>> No.65617726

>browsing 4chan
>superior genes
Pick one and only one.

>> No.65617736
File: 211 KB, 600x600, alijeres.jpg [View same] [iqdb] [saucenao] [google] [report]

>butthurt lowly peasant

>> No.65617738

I refuse. Also, this idea that only lowlife scum of society come to 4chan is silly. Just look at some of the battlestation showoff threads. Some people here are pulling pretty amazing money at a reasonably young age.

That might have been true in the formative years of 4chan on most boards, but nowadays I think it's mostly contained to places like /r9k/ and so on.

>> No.65617779

BPM/CRM with a heavy js-based webapp frontend and basically a LAMP stack with heavier data (basically all the actual business process definitions, cases, submissions, etc.) stored in AWS. Most of the frontend code is event handlers either modifying local state and DOM, or calling backend APIs. Most of the backend code is housekeeping the data in the database, or interfacing with AWS APIs (or APIs between internal components), plus boilerplate for authentication, access control, session management, and all that - with various transforms and business logic stuck in between. Really, most of the code at all layers is concerned with putting the right data in the right places at the right time, and while functional is good for getting "the right data", imperative seems better for satisfying the "right places" and "right time", so maybe our product isn't a good example. I'm in no way an experienced dev - this is my first and only job so far.

>> No.65617786

bst makes me think I am the only one falling for the linux meme and the rest of /g/ are getting comfy uasing win10

>> No.65617799

Nah man, linux is the only way. Unless you think your PC waking up at 3 am in the morning without your consent or knowledge to do "updates" is normal.

>> No.65617812

Okay, so it's UI and glue code. Haskell is definitely not a good choice for that kind of work. It would be much more suited to actually implementing the back end.

>> No.65617818

>implying you aren't a peasant to the elite

>> No.65617832

i highly recommend C# as a starting language (it's easy to learn like Java, but is better for a number of reasons, especially in the context of game dev), along with MonoGame, or maybe SFML.Net. both are simple and intuitive, but also don't hold excessively hold your hand or get in your way, which is good for actually learning and understanding how game dev works. i recommend avoiding Unity, because it's bloated and heavily integrated (not to mention it runs like absolute garbage - both the editor and the assemblies it generates); it tries to do way too much for you (which also means it makes a lot of assumptions, and limits what you can do), and hides everything away, meaning you'll learn the Unity way of doing things (which often isn't very transferable), not so much how things actually work. note that code from XNA 4.0 books/tutorials/etc will work for MonoGame with only minor changes (if any), because their interfaces are almost identical (the MonoGame documentation lists the few differences)

>> No.65617835

that looks dangerously close to a jizzface, anon

>> No.65617845

Damn, now I know it's bait.

>> No.65617854
File: 61 KB, 584x585, bog.jpg [View same] [iqdb] [saucenao] [google] [report]

>implying the elite doesn't answer to bogs

>> No.65617887
File: 16 KB, 384x320, running in the 90s.jpg [View same] [iqdb] [saucenao] [google] [report]

You are new.
If you looked around more on 4chan you will find out lowlife scum still resides here.


>> No.65617901

The backend is basically along the lines of "here's a submission of this stage of the business process from the frontend; now I will proceed to send off the contents to AWS and stick metadata into the MySQL database", or "the frontend is requesting the continuation of that case, I will not look it up from the relevant metadata storage in MySQL, retrieve relevant data from AWS, package this into a JSON return and send it back", or "the frontend is requesting a list of everything assigned to user X, I will aggregate the relevant data from the databases and send it back". The only other thing are small bits like the lexer-parser I mentioned. Yeah, it's mostly glue code, but what kind of applications would be more suited to Haskell?

>> No.65617940

>If you looked around more on 4chan you will find out lowlife scum still resides here.
I've been here since the second year of 4chan's existence anon. Of course there are scum here, but not ONLY scum. I think 4chan overall has a pretty nice mix of different kind of people from different places, social strata, income brackets, education levels and so on. But do you really think 4chan has more lowlifes than reddit or twitter?

>> No.65617960

Not the backend, I guess, I mean actually implementing the database itself, the server itself, etc. "Systems" programming. That said, some of those tasks you mention could be organized as pure functions composed into pipelines, but that would only be worth doing if you had Haskell APIs to the services you are using. Haskell is good for gluing together other bits of Haskell. Not so much otherwise.

Really, lots of things are suited to Haskell as long as they can be entirely Haskell. Haskell's main weakness is interfacing with languages that are not like Haskell, which is to say most languages.

>> No.65617968

Can someone explain me free monads? Are they solving the same problem as mtl?

>> No.65618030

Free monads only relate to monad transformers because free monads are used in algebraic effects. Both MTL and algebraic effects are ways to combine multiple effects into one monad, but they work in different ways and have different tradeoffs.

>> No.65618107

Fair enough. Sounds logical.

>> No.65618117

So I'm writing a PowerShell script that finds and replaces a word in Publisher through a loop.

I'm launching Publisher and opening the files with

$Publisher = New-Object Microsoft.Office.Interop.Publisher.ApplicationClass
$OpenDoc = $Publisher.Open($PubFileName)

This is what's inside the loop.

"Looping through " + $Array[$i]
if ($i -eq 0)
$OpenDoc.Find.FindText = "FirstName-LastName"
$OpenDoc.Find.FindText = $Array[$i-1]
$OpenDoc.Find.ReplaceWithText = $Array[$i]
$OpenDoc.Find.ReplaceScope = $pbReplaceScopeAll

It's basically going through a list, replacing names one after another.
But the piece of shit doesn't replace ANYTHING, not even the first one.
I'm 100% sure "FirstName-LastName" exists in the publisher file.
The file recognizes the name array fine.
I don't understand WHAT's shitting the bed.

Please help, I'm retarded.

>> No.65618168

The trick is that there is actually a large class of Haskell-like languages: domain-specific languages embedded in Haskell (usually with monads and do notation). A Haskell database API, for example, wouldn't use SQL for queries, but rather a query-building monad.

>> No.65618189

Wew. Is powershell more powerful than bash?

>> No.65618244

don't you need to save? or somehow commit your changes

>> No.65618248

Looks like the same shit to be honest.
I mean I started this last saturday but it looks pretty much the same.
Of course, Microsoft™ PowerShell will work perfectly for Microsoft™ Publisher and other Microsoft™ Office products.

>> No.65618255
File: 154 KB, 1718x972, Screenshot from 2018-04-21 02-09-22.png [View same] [iqdb] [saucenao] [google] [report]

std::idiomatic C++ only

>> No.65618288

No you see, I'm replacing the word I want and then exporting as PDF, everytime I run the script I know what's the original word I want ("FirstName-LastName"), then from the second iteration onwards the word I'll look for is Array[i-1].

Anyway, apparently $pbReplaceScopeAll is not a defined constant, I just replaced it with a 2 (That's what it's supposed to be valued at) and it's working fine now. But if there's something else you guys can point out, please do.

>> No.65618310

>What are you working on?
world domination

>> No.65618315

How's that working out?

>> No.65618333
File: 16 KB, 720x718, 28056566.jpg [View same] [iqdb] [saucenao] [google] [report]

You can dominate me if you want <3

>> No.65618373
File: 343 KB, 720x1280, Screenshot_2018-04-20-13-21-42.png [View same] [iqdb] [saucenao] [google] [report]

this one?

>> No.65618389
File: 123 KB, 707x1000, -r2I-Xjc1d8.jpg [View same] [iqdb] [saucenao] [google] [report]

guys i failed my IT course because i couldnt figure out how to programming so i became a trap but then i failed the same course again :(
did i not trap properly?

>> No.65618475


>> No.65618478
File: 487 KB, 680x445, hmm.png [View same] [iqdb] [saucenao] [google] [report]

why does this have a time limit of 8 seconds

>> No.65618493

post ur programming socks. Did you wear engineering panties, what about ur tech plug ?

>> No.65618494

Good luck

>> No.65618508

maybe huge test cases, idk

>> No.65618520
File: 56 KB, 900x900, help.jpg [View same] [iqdb] [saucenao] [google] [report]

>tfw can't stop using for loops
Help me pls

>> No.65618533

thos are just normie scum falling for the cheap materialism.

>> No.65618556


>> No.65618565

The people who wrote that problem decided that the time limit would allow an efficient algorithm and a good implementation (i.e. what they themselves consider to be the solution) would take less than 8s to process the most difficult test case on whatever machine they're running it on.

>> No.65618598

yes, but that would imply like absolutely massive test cases
I guess I'm just not used to it since the ones we got at uni were usually 1 second max

>> No.65618611

What is a good tutorial site for getting into Python?

>> No.65618637


>> No.65618869
File: 119 KB, 708x631, 1523173139460.jpg [View same] [iqdb] [saucenao] [google] [report]

That's C++, right? I don't understand any of it. Should I give up on C++?

>> No.65618899

How long have you been learning C++ for?

>> No.65618912


>> No.65618913

Probably, if your goal is to understand any of it.
No one who uses C++ understands it. Not even the standards committee.

>> No.65618918

like 2 weeks.

>> No.65618930


>> No.65618931
File: 47 KB, 1257x537, Typical Clojure programmer.png [View same] [iqdb] [saucenao] [google] [report]

>Can someone explain to me how something like Haskell can be useful in the real world, outside of really niche stuff?
See pic.

>> No.65618936

That's normal.

>> No.65618949

>Uncle Bob

>> No.65618965


>> No.65618972

unsigned int8_t

>> No.65618977

Well whoever wrote that is as stupid as he is.

>> No.65618981
File: 1.19 MB, 1777x1012, 764296.png [View same] [iqdb] [saucenao] [google] [report]

>secure trip code
LOL just take a look at this massive faggot

>> No.65618988

Because ruby's syntax is god tier and bullshit free

>> No.65618996

Blatant lies. Nothing is static in Clojure because Clojure is in Java and Java is not a compiled language. It's an interpreted language that has to be translated into a NON-ASSEMBLY intermediate language in order for its VERY bloated interpreter to understand it.

>> No.65619000

Also, you cut off the last part of their post:
>Now RUST is king for me in the static type languages. To statically prove proper memory management, while preventing the overhead of a runtime GC is a real concrete benefit. Proving the lack of deadlocks and race conditions in parallel code is another one. These kind of defect prevention is much more practical and beneficial from my perspective, then realizing 10 minutes earlier that you passed a string to a function expecting an int.
So they're not only stupid but they're also self-contradictory.

>> No.65619001

What? Since when did ruby have a syntax?

>> No.65619003

>Because ruby's syntax is god tier and bullshit free
top kek
friend i love ruby but:

>> No.65619014

Had a few days of bugfixing and it's forming pretty nicely now. Decided to make this open source after I have finished some cleaning.


>> No.65619020

The JVM continues to add bytecode support for dynamic languages. You're retarded.

>> No.65619024

>everything based on jvm is java with more makeup
Surprise surprise!

>> No.65619032

end.call {|x| x.call &:puts}
end << a[b[c + d[e[f {|g| h}]]]]

>> No.65619033

I'm sorry that you're autistic and hate organized things

>> No.65619065

map, filter, reduce.

>> No.65619085

Python is shit language.
It's used in computational science for a reason: scientists aren't programmers.
Use a language made for programmers, like Ruby.

>> No.65619099

>Java is not a compiled language
gcj('s ghost) and JET bag to differ.
>has to be translated into a NON-ASSEMBLY intermediate language
So what? Lots of compilers use intermediate representations.

>> No.65619128

First of all, if I were autistic and hated organized things, Ruby would be the perfect language for me, because you literally do not even have to organize your method parameters with respect to the methods:
puts 'Hello world!'
# no ()


is not any more organized than:

It's just uglier and more verbose.
>inb4 'b--b--but anon you can use curly brackets hurrrr'
oh yeah, sure, and what? and do this?
define_method(:what_the_fuck_is_this_garbage?) {|seriously_holy_shit|
loop {
puts "The worst part is you actually have to put the parentheses around the method name"

>> No.65619131

nesting like this is bad design and you shouldn't do that anyways
function foo(bar)
if bar > 1 then
-- do stuff
return result
return false

function foo(bar)
if bar <= 1 then
return false
-- do stuff
return result

(it's Lua, but it doesn't matter)

>> No.65619132

Aren't they both vaguely similar though?
I'm a complete rookie to programming, so I'm not sure where to start.

>> No.65619151

I'm rocking a light color scheme for over a week now and I'm surprised how easy it is on the eyes. I used to have eye strain when I'm conjuring code late at night, but that's all gone. I can also focus better on the code.

>> No.65619161
File: 255 KB, 730x730, 1523760571516.gif [View same] [iqdb] [saucenao] [google] [report]

Chilling in /g/dpt on 4/20, contemplating writing documentation for my C++ project.

>> No.65619177

hint: it's #/g/dpt on rizon

>> No.65619186

If Ruby code is like this, the problem isn't Ruby, it's a shit programmer.
Idiomatic C code:

It's just shit code either way.

>> No.65619200

>Idiomatic C code:
> }
> }
> }
> }
Thanks for proving my point, since this is clearly the superior way of doing deeply nested code. Which, as you point out, is bad practice regardless, but, unlike what you seem to think, that's irrelevant.

>> No.65619203


>> No.65619219

They're pretty similar, except Python's for brainlets.
See: >>65609869

>> No.65619233

being so autistic to think brackets vs. 'end' makes a difference.

>> No.65619238

Foo* foo[];
why is this an array of pointers and not a pointer to an array?

>> No.65619243

It does, objectively, irrefutably make a difference. That difference is so tangible you can actually measure it. Its measurement: 2 bytes per delimiter.

>> No.65619254

because the C ptr/array notation is brain-damaged

>> No.65619265

Oh, there's also this one from that thread too

>> No.65619274

it's a pointer to an array of pointers
Foo** foo;

is an equivalent declaration

>> No.65619279

Also, because of the way arrays work, a pointer to an array is the same thing as a pointer to the first element of the array, and therefore "pointer to array of T" and "pointer to T" are two names for the same type, so it doesn't make sense to have two different ways to declare them.

>> No.65619281

Because of operator precedence. [] has higher precedence than * and it binds to the identifier rather than the type id.

>> No.65619299
File: 56 KB, 645x729, brainlet.png [View same] [iqdb] [saucenao] [google] [report]

>Foo** foo; is an equivalent declaration

>> No.65619316

care to make any corrections?

>> No.65619329

static in c++ is really annoying. java does it so much better

>> No.65619341

It is an array of Foo pointers.

>> No.65619342

Foo* foo;
Is a pointer to an array

>> No.65619345

Arrays are not pointers.

>> No.65619361

Just playing around with Ruby some more...

# coding: utf-8

class Point
include Comparable
attr_accessor :x, :y
def initialize(x,y); @x, @y = x, y; end
def +(other); Point.new(@x+other.x,@y+other.y); end
def *(scalar); Point.new(@x*scalar,@y*scalar); end
def ==(other); @x==other.x && @y==other.y; end
def [email protected]; Point.new([email protected],[email protected]); end
def to_s; "(#{@x},#{@y})"; end
def to_a; [@x,@y]; end
def quadrant
case [@x>0, @y>0]
when [true, true ] then 1
when [false, true ] then 2
when [false, false] then 3
when [true, false] then 4

The next one I had some trouble with, because I was getting error messages that were not at all intuitive. Then I realized the hash variable needed to be global (probably a common beginner mistake)...

# coding: utf-8
# Hashing algorithm for strings

$hash = []
0.upto(10) { |i| $hash[i] = Array.new }

# Place input string in the table
def place(value)
address = value[0].ord % 10
$hash[address][$hash[address].length] = value

# Determine if input string is present
def search(value)
address = value[0].ord % 10
$hash[address].each do |key|
if key == value then return true

I'd appreciate comments or critiques on my Ruby programming style/ability, since it's still a relatively new language for me, and it's got a lot of quirks that I haven't quite grokked yet.

>> No.65619362

Zero-cost abstractions

>> No.65619368
File: 124 KB, 571x618, 1523619489879.jpg [View same] [iqdb] [saucenao] [google] [report]

>arrays are not pointers

>> No.65619378

Null-terminated byte arrays

>> No.65619396

Spiffy workspace, and neat waifu insert as well. I wish my room looked like that.

>> No.65619409

Fearless concurrency

>> No.65619412

Positive attitude and a passion for everything in life.

>> No.65619415
File: 10 KB, 320x235, qv8cu.jpg [View same] [iqdb] [saucenao] [google] [report]

Is this bait?

>> No.65619416

and why is std::memcpy in cstring?

>> No.65619424

What makes you think that?

>> No.65619432


>> No.65619439

It's true though. Arrays are not pointers. Arrays are accessed through pointers, but they are not themselves pointers.

>> No.65619440

because memcpy is in string.h

>> No.65619442

I fucking hate C's schizophrenic everything.

>> No.65619457

Yes please
No thanks

>> No.65619460

C is secretly a practical shitlang.

>> No.65619465

>Zero-cost abstractions

>Null-terminated byte arrays

>Fearless concurrency

Wtf are you doing?

>> No.65619473

yes why?

>> No.65619491




>> No.65619493

Foo foo[] = malloc(sizeof(Foo) * 5);

wtf am i doing wrong i thought arrays weren't pointers??

>> No.65619514
File: 56 KB, 621x702, brainlet.png [View same] [iqdb] [saucenao] [google] [report]

>doesn't compile

>> No.65619532

I'm glad that, if I really want, I'm not forced to even acknowledge C's existence beyond struct layout and calling conventions.

>> No.65619543

Is the Sedgewick's Algorithms in C worth reading? Should I bite the bullet and read the Java version(It looks nicer, and it has an online course, as well)? I just want to learn about without getting too mathy about it( I haven't taken discrete math yet).

>> No.65619708

the war stories were kinda interesting

>> No.65619765
File: 499 KB, 320x220, D049B142-84B2-4B2A-B9CC-A42DF1F01E03.gif [View same] [iqdb] [saucenao] [google] [report]

What do people use to make GUIs these days

>> No.65619778

I think you are confusing Sedgewick's Algorithms, with Skienna's "The Algorithm Design Manual".

>> No.65619830

Funny how a hipster language (Crystal) does Ruby better than Ruby.

>> No.65619835

They decay to pointers

>> No.65619859


>> No.65619928
File: 124 KB, 400x400, rainy_mood.jpg [View same] [iqdb] [saucenao] [google] [report]

>tfw you can't find a book's pdf

>> No.65619988

>S-guy's algorithms book
Could be, they're blurring together nowadays.

>> No.65619991

M = unsigned int8_t

So they are purposely trying to make this as ugly as possible.
>auto months_of_30{std::set<M>{4,6,9,11};

They are literally just trying to make it as ugly as possible.

constexpr std::optional<unsigned> days(intmax_t year, unsigned month){
constexpr unsigned days_in_month[13] = {0, 31, 28, 31, 30, 31, 30, 31,31,30,31,30,31};
if(!year || !month || month>12) return std::nullopt;
if(month == 2 && (year%4 ==0) && ( year%100!=0 || year%400==0))
return 29;
return days_in_month[month];

>> No.65620001

not on libgen either, huh?

>> No.65620025

Nope, I am falling into the pits of despair.

>> No.65620026

Showcase algo:
f(x) = (x + x-1)\\2;

func sum(n):
ret n*(n+1)/2;

func print(items...):
items + "" --> 0x21, 0x9;

int a, b = 5, 10;
b += f(a);
a + ":" + b --> 0x21, 0x9;
<- a
<- b
-> a
-> b
a + ":" + b --> 0x21, 0x9;
sum(3) + off 48 --> 0x21, 0x9;
print(a, b, " "+(sum(3) off 48));

15:5 6

Have i made an abomination?

>> No.65620031

post book title, edition, isbn whatever

>> No.65620040

>inspired by C's "slide to" operator
you're alright in my book, anon

>> No.65620047

Does anyone know where to start studying bootloader's, linking, ELF files and shit like that?
I'm doing some stuff with the RISC-V architecture and I'm completely lost

>> No.65620050

Data Structures In C 1st Edition, by Noel Kalicharan.
ISBN-13: 978-1438253275
ISBN-10: 1438253273

>> No.65620051

much more readable

>> No.65620065

I'm a bit lost on what I should be doing now. It's a program for CS50 that wants you to display a hashtag for a brick depending on the user input, with the input being the bottom row of the pyramid increment one less block as you go up. I'm trying to add spaces to the rows as there are less hashtags, but it's not coming out. Does anyone mind taking a look?

#include <stdio.h>
#include <cs50.h>

int main(void)
//Prompt user for valid number
int height;
string block = "#";
string space = " ";
height = get_int("Positive Number for Blocks less than 23: ");
//While n is less than 0, a negative, or greater than 23, which is the maximum allocated
while (height < 1 || height > 23);
//Print out this many rows
//initialize at 0, runs while rows is less than height, adds one to rows everytime
for (int rows = 0; rows < height; rows++)
//Objective after printing rows is to add spaces to those rows
for (int columns = 0; columns < rows - height; columns --)
printf("%s", space);
printf ("%s\n", block);

>> No.65620067

Just point me a good book and I will start right away
I'm studying by myself, so I can't rely on professors or college

>> No.65620087

>Noel Kalicharan
oof, that's pretty
>literally who
tier. Threedat & Tobacco, it seems.
Gonna be a difficult one m8. If it's uni stuff, look for someone with a copy and scan / upload dat shit.

>> No.65620092

The JVM compiles Java bytecode to actual bytecode and optimizes it dynamically.
JVM is comparable to native code performance wise.

>> No.65620094
File: 76 KB, 1533x872, 1505601364751.png [View same] [iqdb] [saucenao] [google] [report]

Don't code while drunk, kids, or else you'll do something like pic related

>> No.65620095

b-but its not a slide to operator...
Never even knew C had that, originally it was to be used to declare loop ranges:
10 --> 0 OR 0 --> 10 which would load the starting value into ecx, and then changing the jnz, jge, jle, jg, jl commands according to the break operator, or if no break operator were defined, according to the direction of the arrows.

>> No.65620100

would the classic Linkers and Loaders help?

>> No.65620109

>display a hashtag for a brick depending on the user input, with the input being the bottom row of the pyramid increment one less block as you go up

>> No.65620116

Yeah, seems like this dude is not really well known. Not uni stuff, just self-studying. Thanks anyways, anon. I appreciate the effort.

>> No.65620117

Explain this:
Foo foo[69];
Foo *bar = foo;

>> No.65620121

>ecx, and then changing the jnz, jge, jle, jg, jl
so is like reinventing the 60s proglang wheel type of project, a brainfuck-COBOL combo or something?

>> No.65620130

Pretty clearly anon is trying to do:

>> No.65620137

Implicit conversions. int x; char c = x; does not mean char and int are the same type.

>> No.65620138

This seem exactly what I need
Thank you kind anon, I'll be reading this book

>> No.65620145

Sorry, it's just trying to display a pyramid from Mario using input, might have muddied my explanation.
I'm lost on two things: how to increment the spaces, and how to nest my for loops in each other.

>> No.65620149


>> No.65620154

>reinventing the 60s proglang
the what?

>brainfuck-COBOL combo or something?
More like a direct-systems lang, definitely not cobol that's for certain.

>> No.65620155

You're only drawing one block per row.

>> No.65620161


>> No.65620169


>> No.65620176

I don't get it.
Does Opengl let me create windows and butons or is it just for graphics and games?

>> No.65620177
File: 334 KB, 995x681, el atrocidad.png [View same] [iqdb] [saucenao] [google] [report]

el goblino...

>> No.65620186

OpenGL just puts contents in windows, you have to create the window (and OpenGL context) with something else. You can draw regular GUIs with OpenGL if you like. There are libraries that make this easier.

>> No.65620200

Is it "better" than a GUI toolkit like gtk or Qt?

>> No.65620234

It depends on the look and feel you are going for, and how much you care about what the API is like (e.g. any IMGUI library is very different from either GTK or Qt). You can create OpenGL contexts in either GTK or Qt if you want to mix their GUIs with your own arbitrary rendering.

>> No.65620258

>Since 2007, the usage of the symbol to introduce metadata tags on social media platforms has become so universal that such metadata tags are now widely called hashtags[5] and the symbol itself is often called a "hashtag".
oh you fucking wastes of oxygen

>> No.65620276

Just because I know what normies mean by "hashtag" doesn't mean I use the expression myself.

>> No.65620281

So these toolkits don't use OpenGL but rather use the platform API or do the draw their own? I know windows has win32 for creating a gui and many other things to interact with the OS but what does linux use? OpenGL?

>> No.65620282

arrays have extra metadata

>> No.65620285

whoa momma
it looks like the rape child of some negress that got PREDATORED

>> No.65620289

Completely different things.
OpenGL can have the same end result, but it's goal is to be way lower level.
Even game programmers aren't going to use OpenGL, although a game programming company might have a team that develops the 3D engine using OpenGL that the game programmers themselves use (and there may be crossover).
Gtk and Qt are purpose-built for creating GUIs. They're much higher-level than OpenGL.

I don't know what Gtk and Qt use at the lower level, but there's no reason a GUI Toolkit can't utilize OpenGL to draw to the screen.

>> No.65620294

arrays are strings

>> No.65620302

there's your problem


int main(){
int height=0;
while(height>23 || height < 1){
std::cout << "Positive Number for Blocks less than 23: ";
std::cin >>height;
for(int row = 1; row <= height; ++row){
for(int space = row; space < height; ++space)
std::cout<<" ";
for(int hash = 0; hash < row; ++hash)

If you want it to be symmetric like >>65620130


int main(){
int height=0;
while(height>23 || height < 1){
std::cout << "Positive Number for Blocks less than 23: ";
std::cin >>height;
for(int row = 1; row <= height; ++row){
for(int space = row; space < height; ++space)
std::cout<<" ";
for(int hash = 0; hash < row; ++hash)
for(int hash = 1; hash < row; ++hash)

>> No.65620305

On Linux, it depends on your display manager. Usually, X11. Sometimes Wayland nowadays.

>> No.65620315

r8 me /g/:
/* Convert roman numerals to base-10 */
#include <iostream>
#include <string>
#include <stack>

#define INVALID_CHAR -1
typedef std::string str_t;

int full_to_base_10(str_t&);
int to_base_10(char&);

for(;;) {
std::cout << "Enter a roman numeral string: ";
std::string roman;
std::cin >> roman;

std::cout << roman << " to decimal: " << full_to_base_10(roman) << '\n';
return 0;

int full_to_base_10(str_t &roman)
std::stack<int> numbers;
int biggest_seen=0;

for (int i=roman.length()-1; i>=0; i--)
int current_num = to_base_10(roman[i]);

if (current_num == INVALID_CHAR) {
std::cout << "Invalid character, aborting!\n";
if (current_num > biggest_seen) {
biggest_seen = current_num;
else if (current_num < biggest_seen)

unsigned num=0;
while (!numbers.empty())
if (numbers.top() < 0)
num -= (-numbers.top());
num += numbers.top();
return num;


int to_base_10(char &c)
/* Basic roman numerals */
case 'I': return 1;
case 'X': return 10;
case 'C': return 100;
case 'M': return 1000;
/* Auxiliary roman numerals */
case 'V': return 5;
case 'L': return 50;
case 'D': return 500;


>> No.65620329

a suggestion of how to write your question next time so more people answer it:

hey folks, I need to write a program that does this:
$ ./mario
Height: 5

$ ./mario
Height: 3

Here's my code:
yer code here

but it's wrong:
$ ./mario
Height: 3
<yer fucked output here>

I think it's either X, Y, or Z or I don't understand how to do A, B, or C.
Can anyone give me a hint of where I'm being retarded?

>> No.65620344

Is there a "linux api"/.so file I can use to invoke things like getting current OS and hardware info or is it just certain systemcalls?

>> No.65620354

>for(int hash = 0; hash < row; ++hash)
> std::cout<<"#";
>for(int hash = 1; hash < row; ++hash)
> std::cout<<"#";

Or you could not be retarded and do:

for(int hash = 1; hash < row; ++hash)

>> No.65620357
File: 23 KB, 645x773, 1523386635027.png [View same] [iqdb] [saucenao] [google] [report]

>arrays have...metadata

>> No.65620371

Usually graphical Linux software is distributed with different versions for different environments. I.e. your source code has some #ifdefs somewhere where one branch supports X11, another branch supports Wayland, etc.

>> No.65620379


>> No.65620385
File: 1.92 MB, 400x224, 1521047236517.gif [View same] [iqdb] [saucenao] [google] [report]

>Not even 1 (you)
What happened to /dpt/? You don't even get triggered by Rust anymore.

>> No.65620389

yeah when you do sizeof on an array it gives you the size of the array but when you do sizeof on a pointer it gives you the size of the pointer

>> No.65620410

>Programming for anything to use a GUI
You're part of the problem anon.

>> No.65620443

No, it's not.
Most graphical software use a toolkit such as gtk, Qt or SDL.
The X11/Wayland support is at the toolkit level and can usually be enabled or disabled with an environment variable or some other runtime configuration.

>> No.65620448
File: 188 KB, 347x414, 1496559360261.png [View same] [iqdb] [saucenao] [google] [report]

I'm a programming newbie and I'd like some help, if possible.

I need to read an input file an write N bytes of it to different output files, until we reach EOF. For example, if I have "abcdefghijklmnop" in the input file and each output file can store 4 byes, I'll have 4 files with the following:
f1 = "abcd"
f2 = "efgh"
f3 = "ijkl"
f4 = "mnop"

How can I achieve this? I'm using Python 3.

>> No.65620449

I understand that, I was answering:
>So these toolkits don't use OpenGL but rather use the platform API or do the draw their own?
And then how they distinguish between display managers.

>> No.65620472

sizeof is evaluated at compile time idiot

>> No.65620477

with open("in", 'r') as fin:
nr = 1
while not done:
with open("out" + nr, 'w') as fout:

>> No.65620488

Thanks, I'll try to be better about format in the future.
Working with C as the course itself wants us to use C until it switches to Python midway through. Thank you for the help with the logic though, I believe I see now what I was fucking up with.

>> No.65620494

should've been read_up_to_4_bytes

>> No.65620498

doesn't matter

>> No.65620512

I just like 3D shit and shiny things. Flame... dear flame....

>> No.65620514

Something like this, maybe:
input = None
with open("infile.txt" , 'rb') as f:
input = f.read()

i = 0
in_slice = input[:4]

while len(in_slice) > 0:
with open("outfile_{}.txt".format(i), 'wb') as f:

i += 1
in_slice = input[i*4:i*4 + 4]

>> No.65620518

int foo(int x)
return sizeof(int[x]);

>> No.65620545

I like the Kotlin version on rosetta code
fun romanDecode(roman: String): Int {
if (roman.isEmpty()) return 0
var n = 0
var last = 'O'
for (c in roman) {
when (c) {
'I' -> n += 1
'V' -> if (last == 'I') n += 3 else n += 5
'X' -> if (last == 'I') n += 8 else n += 10
'L' -> if (last == 'X') n += 30 else n += 50
'C' -> if (last == 'X') n += 80 else n += 100
'D' -> if (last == 'C') n += 300 else n += 500
'M' -> if (last == 'C') n += 800 else n += 1000
last = c
return n

>> No.65620553

If compile-time information about pointers/arrays counts as metadata, then pointers have metadata too (base type, qualifiers). In fact arrays have all the same "metadata" as pointers, plus a constant length.

So yes, I guess if you consider all known information about a thing to be data or metadata, then pointers and arrays differ in "metadata". But metadata actually means that something is stored.

>> No.65620558

Yep, it was exactly like this. I just need to know what the "input" keyword means, but I'll just look it up.

>> No.65620563

input is not a keyword, just a variable

>> No.65620564
File: 67 KB, 189x262, 1523334199673.png [View same] [iqdb] [saucenao] [google] [report]

How do I put this... I think you're the brain damaged one.

>> No.65620566


>> No.65620567

>ask some question like "How do you do X"
>get response like "Why would you ever want to do X?"

does this piss you off aswell?

>> No.65620587

Why would you be pissed off by that ?

>> No.65620594

I know, right. I've been trying to shill Ruby, needing people to get triggered by its mention because bad publicity is still publicity, but no bites.

>> No.65620616

yeah, I mean the people that are usually pissed off are doing things the wrong way anyway

>> No.65620623

I need help with my final two programming assignments in college. One is in web services, things like php and servers. Other is Android development using content providers. I'll pay someone 100$ to do them for me, and it would only take a few hours for someone who actually knows what they are doing.

>> No.65620645

The only way I will ever respond like that is as a disclaimer attached to an actual answer. People who say that without answering as well are just virtue signalling, but you shouldn't ignore them entirely in all cases.

>> No.65620654

>#define INVALID_CHAR -1
Why the fuck aren't you using constexpr?
>typedef std::string str_t;
Why not "using std::string;"?
>int to_base_10(char&);
Just copy the char
>std::stack<int> numbers;

constexpr int INVALID_CHAR = -1;

constexpr int to_base_10(const char c)
/* Basic roman numerals */
case 'I': return 1;
case 'X': return 10;
case 'C': return 100;
case 'M': return 1000;
/* Auxiliary roman numerals */
case 'V': return 5;
case 'L': return 50;
case 'D': return 500;
default: return INVALID_CHAR;

constexpr int full_to_base_10(const char* roman)
int last_seen = to_base_10(roman[0]);
if (last_seen == INVALID_CHAR) {
std::cout << "Invalid character, aborting!\n";
int number = last_seen;

for (int i=1; roman[i]!='\0'; ++i)
int current_num = to_base_10(roman[i]);

if (current_num == INVALID_CHAR) {
std::cout << "Invalid character, aborting!\n";
number += current_num;
if (current_num > last_seen) {
number -= last_seen<<1;
last_seen = current_num;
return number;

>> No.65620659

>I'll pay someone
>1.5 hours' worth of money
you're gonna get quality

>> No.65620668


int array_len(int arr[]) {
return sizeof(arr) / sizeof(int);

int main(int argc, char* argv[]) {
int array[50];
printf("%d", array_len(array));

oy vey they stole my metadata

>> No.65620687

Tried to translate it to Rust. It is almost exactly the same, except pattern matching (?) in Kotlin seems to be non-exhaustive
fn roman_decode(roman: &str) -> u64 {
if roman.is_empty() { return 0; }
let mut n = 0;
let mut last = 'O';

for c in roman.chars() {
match c {
'I' => n += 1,
'V' => if last == 'I' { n += 3 } else { n += 5 },
'X' => if last == 'I' { n += 8 } else { n += 10 },
'L' => if last == 'X' { n += 30 } else { n += 50 },
'C' => if last == 'X' { n += 80 } else { n += 100 },
'D' => if last == 'C' { n += 300 } else { n += 500 },
'M' => if last == 'C' { n += 800 } else { n += 1000 },
_ => panic!("Invalid numeral: {}", c),
last = c;

>> No.65620690

It would seriously take not even 2 and a half hours for someone who knows mobile or web development. I'm just stupid.
Also. Where the fuck do you get that much money? All the programmer jobs here are not even close to that much

>> No.65620717

what is objectively the most hipster language

>> No.65620728

>lmgtfy hourly wage developer
>Software Engineer $31.37
that's salaried
You'd have to be retarded to work for less than 2x (realistically more) without a permanent contract.

>> No.65620750

For fun, slightly more idiomatic + Error handling:
struct InvalidNumeral;

fn roman_decode(roman: &str) -> Result<u64, InvalidNumeral> {
if roman.is_empty() { return Ok(0); }
let mut n = 0;
let mut last = 'O';

for c in roman.chars() {
n += match c {
'I' => 1,
'V' => if last == 'I' { 3 } else { 5 },
'X' => if last == 'I' { 8 } else { 10 },
'L' => if last == 'X' { 30 } else { 50 },
'C' => if last == 'X' { 80 } else { 100 },
'D' => if last == 'C' { 300 } else { 500 },
'M' => if last == 'C' { 800 } else { 1000 },
_ => return Err(InvalidNumeral),
last = c;

>> No.65620752

>It would seriously take not even 2 and a half hours for someone who knows mobile or web development
Given that
>I'm just stupid.
I recommend skimming this:

>> No.65620762

>if roman.is_empty()
redundant, no?

>> No.65620770

gid gad the verbosity

>> No.65620776

because it's a pointer now lol

>> No.65620777

>{ 3 }
Don't tell me Rust is autistic enough to disallow curly-free if/else blocks?

>> No.65620786

>curly-free if/else blocks

>> No.65620787

No. This is the price you pay for not requiring parens around the if expression.

>> No.65620789

kill yourself

>> No.65620793

When should I prefer to use references vs pointers?

>> No.65620802

You're right, i just blindly copied the Kotlin code.
No. If-else in Rust demand curly braces, but can omit the parentheses

>> No.65620810

oh lawdy who knew rust's patmat is that shit
non-shitlangs don't need such garbage

>> No.65620824

>If-else in Rust demand curly braces, but can omit the parentheses
A curious choice, but it might be for the better.

>> No.65620831

That's not even part of pattern matching. If/else in Rust are expressions, not statements.

>> No.65620841

No more goto fail bugs, for instance.

>> No.65620916

because im not a retard

>> No.65620924

new thread when? :3

>> No.65620934

when we're at page 10, or at least 8+, preferably

>> No.65620945

What exactly does Rust give you that smart pointers + move semantics in C++ don't already give you?

>> No.65620951

Sane smart pointers & move semantics. Also checked references.

>> No.65620957

In Java if you have a method1 that throws an exception and you put the throws tag in the signature and then you use this method1 in another method2, do you also need to specify in that signature that you might throw an exception or is it enough if you do it in method1?

>> No.65620958

Proper ADTs and pattern matching for once, not the std::variant/visit abomination. Also traits, not duck-typed templates

>> No.65620961

Compiletime checks that you're properly following lifetime semantics. Thread safety because fucking everything is immutable.

>> No.65620965

Every method until you catch it.

>> No.65620970

>for once

>> No.65620977

>fucking everything is immutable.
when the memes go too far

>> No.65620986

English is not my first language, what do ye even mean?

>> No.65620996
File: 14 KB, 627x554, 1511282567970.png [View same] [iqdb] [saucenao] [google] [report]

>have a bunch of classes in a header file
>forward declaration for all of them
>in the first class where I use another class compiler complains that this type is undefined

>> No.65621005

>Thread safety because fucking everything is immutable.
Are you thinking of Haskell, anon?

>> No.65621015

Declaration =/= definition
Forward declared types can only be used behind pointers, since the compiler doesn't know their layout in memory until they are defined.

>> No.65621020

Rust does not allow multiple mutable references. Not unless they're mutexed. That goes even for thread-local references.

>> No.65621030

sooo no references? or is there a solution?

>> No.65621034

>Rust does not allow multiple mutable references. Not unless they're mutexed. That goes even for thread-local references.

that is retarded

>> No.65621036

That doesn't make everything immutable. Now, I will agree that Rust often forces you to use (or at least makes it painful to work around) shared immutable references (don't forget about "interior mutability" though) but that's another issue.

You should be able to use them behind references.

>> No.65621038

Replace the references with pointers and you're sorted.

>> No.65621051

It does so to prevent certain kinds of undefined behaviour. Don't like it, go unsafe.

>> No.65621054
File: 2 KB, 109x159, file.png [View same] [iqdb] [saucenao] [google] [report]

well fugg :DDD

>> No.65621059

>what do ye even mean
>English is not my first language
au contraire, you can't fool me, Shakespear
shitpost aside, it ought to be 'for one'

>> No.65621092

really hope this is bait.

>using heap-allocated sets (constructed/destroyed on each call) instead of constexpr arrays for a *fixed-size set of literal constants*
>using find/iterators instead of unrolling/folding arrays over a variadic lambda which folds comparison over || operator
>using a default template argument for a deduced argument (gonna be ignored generally)
>inverting leap year logic (straightforward way ends up the same number of ops for me)
>using forwarding references for primitives/integers (unnecessary)
>using forwarding references and then never forwarding them
>unsigned int8_t (there's a uint8_t)

i'd do something more like

constexpr std::optional<int> days(int year, int month)
constexpr std::array<int, 4> months_of_30 { 4, 6, 9, 11 };
constexpr std::array<int, 7> months_of_31 { 1, 3, 5, 7, 8, 10, 12 };

constexpr auto contains = [](const auto& arr, int val) {
auto fun = [val](auto... i) { return (... || (i == val)); };
return std::apply(fun, arr);

contains(months_of_31, month) ? 31
: contains(months_of_30, month) ? 30
: month == 2
? year % 4 == 0 && !(year % 100 == 0 && year % 400 != 0) ? 29 : 28
: std::optional<int>{};

this is much more efficient (and constexpr). templating arguments will only give or take a few instructions depending on argument types. tested by returning from main instead of printing out and used optional::value_or() to keep iostream and optional's shit out of the assembly:

your code:

extern int y;
extern int m;
int main() { return days(y, m).value_or(0); }
// asm: ~400 lines

int main() { return days(2100, 2).value_or(0); }
// asm: ~350 lines

my code:

extern int y;
extern int m;
int main() { return days(y, m).value_or(0); }
// asm: ~70 lines

int main() { return days(2100, 2).value_or(0); }
// asm: 3 lines (returns 28)

>> No.65621140

wtf does this code work?
can you declare an array as an argument?
what does sizeof(arr) return?

>> No.65621172

The declaration might refer to an array, but it's silently reinterpreted as a pointer declaration instead.

That's a very good reason never to use "arrays" as parameters.

>> No.65621173

>"Arrays are not pointers."
>This is what happens when we let retards code

>> No.65621175

>can you declare an array as an argument?

Kinda, but don't ever do it. int[] arg becomes int *arg. It is extremely misleading and hides what actually goes on.

>> No.65621188

What's wrong with >>65619991

>> No.65621196

what language should i learn if i want to help cracking games/consoles?

i kinda want to contribute the scene

>> No.65621212

probably a bit hard to get into nowadays

>> No.65621214

digital circuit logic, verilog, fpga, C.

>> No.65621215

Whats the difference between an array and a pointer other than how sizeof behaves?

>> No.65621241

& is the only operator beside sizeof which behaves differently for arrays and pointers.
As an operand to other operator, an array lvalue decays to a pointer rvalue.

>> No.65621264

The difference between pointers and arrays in C becomes quite clear when you don't conflate variable declarations with parameter declarations.

>> No.65621277

C,ASM / and Sepples if you want to contribute to Dolphin or the like.

>> No.65621291

AMD64, PPC for last gen

>> No.65621296
File: 9 KB, 250x190, 1515539183139s.jpg [View same] [iqdb] [saucenao] [google] [report]

>The difference between pointers and arrays in C

>> No.65621302

int *p;
int a[N];

>> No.65621309

Now pass arrays to functions, safely.

>> No.65621316

Can't. C lacks first class arrays.

>> No.65621321

and that's my point.

>> No.65621322

>when you don't conflate variable declarations with parameter declarations

>> No.65621330

>arrays are not first class values
>therefore arrays and pointers are the same

>> No.65621333
File: 63 KB, 638x558, 1521912231368.jpg [View same] [iqdb] [saucenao] [google] [report]

>if C doesn't have first class arrays it must mean pointers and arrays are the same thing in C

>> No.65621335

>oh boy i can declare """""""""""""arrays""""""""""""
>but i can't use them safely in any real capacity because they are just bare-bones sugar.

>> No.65621344
File: 13 KB, 290x180, Moving-The-Goalposts[1].jpg [View same] [iqdb] [saucenao] [google] [report]


>> No.65621392

Your original statement doesn't really mean anything though. You're simply saying a very loaded remark that has lots of implications and problems. You're like the person at cons who interrupt the speaker to state an AKSHULLY

>> No.65621393

>get CS degree at end of semester
>still haven't learned how to shoot up a school

>> No.65621408

>Your original statement doesn't really mean anything though.
int a[N]; // declare an array variable of length N
void foo(int a[]) // declare a pointer parameter

>> No.65621414

Absolute state of yuropoor education

>> No.65621456


>> No.65621479

an array is a pointer to an allocated segment of memory plus a calculated offset (that being, the index).

You'd have to be retarded to think an array is anything but a pointer and an offset.

>> No.65621496

oh haha. that works. there were so many general semantic/idiomatic/practical mistakes i got focused on those in the abstract and forgot to think about the actual problem lol. but for what it's worth, the ideas there extend well to nontrivial use cases, and it's definitely possible to write idiomatic/expressive/high-level code that performs well

>> No.65621507

>an array is a pointer to an allocated segment of memory plus a calculated offset (that being, the index).
No. That's your pov, it;s written nowhere in the C spec.

>> No.65621575

>No. That's your pov, it;s written nowhere in the C spec.
You are a code monkey, because you know nothing about the underlying system or how memory is stored/retrieved. You've gotten lost in abstraction, you fucking code monkey.

>> No.65621616

>you know nothing about the underlying system or how memory is stored/retrieved
You're changing subject. Where in C spec is it written about the underlying system or memory model? Please, could you pinpoint it in the spec?
>You've gotten lost in abstraction
So you can't into abstraction? And you think you're not a code monkey, don't you? How funny.

>> No.65621640

>Where in C spec is it written about the underlying system or memory model?
wtf do you think happens when C compiles, you absolute retard?

>So you can't into abstraction?
I can into abstraction easily, but i'm not some retard who forgets the underlying system or what's actually happening behind the emerald curtains.

>> No.65621687

>wtf do you think happens when C compiles, you absolute retard?
Absolutely unrelated to the C language. You can interpret C if you want.
>I can into abstraction easily
Clearly no. You failed twice in a row.

>> No.65621738
File: 57 KB, 600x600, You right now.jpg [View same] [iqdb] [saucenao] [google] [report]

>Absolutely unrelated to the C language.
I'm gonna do what your mom did and give up on you, anon. You're too much of a brainlet

>You failed twice in a row.
if by into abstraction you mean treat shit as something its not (like treating a char as a character, rather than a byte) then i wan't nothing to do with that, dumbass.

>> No.65622122

>sets (constructed/destroyed on each call) instead of constexpr arrays
item lookup in sets are O(log n) whereas with arrays it's O(n)
> auto fun = [val](auto... i) { return (... || (i == val))
Again, O(n)

>> No.65622255

>if by into abstraction you mean treat shit as something its not (like treating a char as a character, rather than a byte) then i wan't nothing to do with that, dumbass.
No. It means treating C as a language with a semantics and not the concrete implementation of your concrete compiler on your concrete hardware.

You really can't into abstraction.

>> No.65622639

pawoo.net, based on mastodon, which is based of gnu social (or at least uses the same backend). They don't seem to compress images.

I really want twitter to die and get replaced by mastadon.

>> No.65622896

O(1) if you do it like >>65621092

Name (leave empty)
Comment (leave empty)
Password [?]Password used for file deletion.