[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Search] [Home]
Board
Settings Home
/g/ - Technology


Thread archived.
You cannot reply anymore.



File: 1562871331943.jpg (561 KB, 700x1000)
561 KB
561 KB JPG
Old thread: >>71834158

What are you working on, /g/?
>>
Daily offer to prove that C++ is actually no really guys I'm serious capable of performing outstanding memory allocation optimisations:

>Then why don't you go ahead and run some C++ program with an overloaded malloc implementation that counts how many 64-Bytes-or-less allocations have been performed? And with a corresponding free overload you can see how long they survived. I also don't care about your synthetic benchmarks for a simple program, all right? I want real-world applications.

, and that's why it's better than C.
>in4 cnile
>still no data
>still winning

¯\_(ツ)_/¯
>>
>>71840086
Going through Automate the Boring stuff right now. What job can I land if I become semi-proficient at Python?
>>
nth for writing disgusting code because you're too much of a brainlet to think of a proper solution
>>
File: 0.png (29 KB, 112x112)
29 KB
29 KB PNG
>>71840100
i know that feel, anon
>>
>>71840089
overloading malloc is going to ruin optimisations
>>
Working on libqmi. Implementing firmware selection on Telit modems so I can switch this America-only modem to work in the rest of the world.
>>
>>71840112
How, if the symbol is preloaded at runtime?
>>
I sure hope you are coding your next project on a flavor of Lisp, anon.
>>
>>71840128
not a sepplesfag but look, if you have something simple like printing every malloc, that means the compiler can't do multiple mallocs at once without changing the behaviour of the program
>>
What was that site with the free books again?
>>
>>71840136
>that means the compiler can't do multiple mallocs at once
>the compiler
>the compiler doesn't run at runtime

You're aware of that?
>>
>>71840136
and it can't be as aggressive or effective with a user defined malloc as it can with standard malloc
>>71840137
bible dot com
>>
>>71840089
>muh malloc
The difference in speed is unnoticable, but your program will be more likely to leak or crash
>>
>>71840137
https://g.sicp.me/books/
>>
>>71840089
t. never wrote software anyone cares about
>>
>>71840144
you're either stupid, an ESL, or arguing in bad faith
>code says allocate a byte 8 times
>allocate 8 bytes at once instead
again this is a dumb example, i'm not a sepplesfag
>>
>>71840147
>what is LD_PRELOAD
>what is symbol injectio
>what does it have to do with compiler optimisations?

The very purpose of overloading malloc/free is so that you see the "optimisations" the oh so powerful compiler unleashes upon the runtime environment. If it can do that properly there's not going to be that many 64-Bytes-or-less allocations.

>>71840167
>mad for being wrong
>too incompetent to proof he's right
>ad hominem attacks

Predictable response. I'm gonna go get a shower, because I need to get ready for work - developing software that people care very much about running properly.
>>
>>71840154
I meant the russian one, lib.io or something
>>
>>71840190
>The very purpose of overloading malloc/free is so that you see the "optimisations"
i'm telling you that overloading malloc can make some of those optimisations more difficult for the compiler
>>
>>71840191
https://libgen.is/
>>
>>71840206
Thanks man
>>
>>71840200
And I'm telling you that the fucking compiler doesn't have ANYTHING TO DO with symbol overloading at runtime, and if you had any idea how program execution worked you wouldn't keep spouting that nonsence. Google "LD_PRELOAD" and prove me wrong, I'm gonna get me that shower.
>>
>>71840154
Dude this looks awesome.
Guess I'm downloading this.
>>
>>71840216
don't hoard a bunch of books on wildly varying topics, you'll never open any of them.
Pick one field/topic and start a book at a time.
>>
>>71840231
I count on basically downloading this and referring to this list whenever I need to learn something. That's a good plan right?
>>
>>71840216
Most books are outdated though, that link is as old as /g/
>>
>>71840247
I guess I'll only refer to old material for mature stuff and research a bit more when it comes to newer stuff then. Some stuff really doesnt change imo
>>
>>71840212
you mean if it's dynamically linked?
>>
>>71840247
Someone should update this list with newer books then.
>>
>>71840274
You can't just update a torrent
>>
>>71840283
Make new torrents every months with an updated list.
>>
>>71840255
>you mean if it's dynamically linked?
Dynamically linked, yes. Like real-world applications. Literally the second post in this thread.

The point is this: the new operator is *likely* to just call malloc itself (and if not, then I'm already wrong and C++ managed to get some actually proper fucking management in the meantime; now they only need to disclose the pools via public interface or whatever). In any case: whatever the compiler is going to optimise - whatever is going to be written in the binary - still has functions that are resolved dynamically.

I want you to see the result of that optimisation, not whatever the compiler churns out because it cannot apply those optimisations. Maybe then people will release that those "optimisations" are not nearly as impressive as a properly coded C program.
>>
>>71840314
>release
Realise. In my defence I just woke up.
>>
File: 1562797697966.png (663 KB, 1055x945)
663 KB
663 KB PNG
Why do programming books feel much more comfy to go through than random tutorials on the internet?
>>
>>71840410
because books are the best
the only people who dislike books are absolute brainlets who read slower than people speak
>>
I thought it was a meme, but I'm starting to think that LISP might actually be the most powerful programming language.
>>
>>71840762
They say it for a reason.
>>
>>71840410
Books are often more thorough. I don't really mind either way, what makes me uncomfy is when a book/other resources is trying to teach me something without giving me exercises.
Some people haven't understood that working by yourself is the most important step in learning, and a good teacher helps you work a lot on your own.
>>
>>71840762
>dude like i can make my own syntax!
zzzzzzz
>>
>>71840769
And what is that reason?
>>
>>71840775
It's close to true, if not outright true. Once you learn Lisp you will see what is missing in most other languages.
>>
>>71840785
and that is?
>>
>>71840762
LISP stands for Language is Incredible Super Power
>>
>>71840790
read/eval/print (many langs claim to have this but get it wrong), good metaprogramming primitives with homoiconicity to make it smooth and straightforward
>>
>>71840410
book:
>Hi, I'm Dennis Ritchie and I'm going to teach you about the programming language I invented.
video:
>hello sirs it is rajeesh and today i will show net beans tutorial for windows 7
>>
Can anyone explain to a brainlet like me how to use stb_rect_pack?
I'm trying to get it to work but I can't figure out how I'm supposed to initialize this stuff.
Here is a link to the library https://github.com/nothings/stb/blob/master/stb_rect_pack.h
>>
>>71840762
>5 times slower than C++
No thanks.
https://benchmarksgame-team.pages.debian.net/benchmarksgame/fastest/sbcl-gpp.html
>>
>>71840770
Is this why I loved David Touretzky's book about Common Lisp that much? That book was so thorough, yet simple, and proposed exercises. It felt like I was getting stuff. Maybe I should read books more.
>>
File: Capture.png (6 KB, 641x150)
6 KB
6 KB PNG
What does this & I highlighted mean for this overloaded operator?
>>
>>71840855
no one knows really, it just works so we do it
>>
>>71840835
oh no mah nanoseconds
>>
>>71840855
It returns a reference. You do this a lot with streams so you can chain operators, you can also do it with regular methods e.g. when doing builders.
>>
>>71840813
none of those things are special.
>>
>>71840835
That's less than I expected. 1/5 the speed of C++ is fast enough for most applications.
This doesn't even take into consideration the difference in simplicity in implementing better algorithms or keeping track of threads.

In the end it's hard for any language to beat super trimmed C++, but my hunch is that given equal and limited development time many applications can be made to perform better in something like LISP. I have nothing to back up this statement with though.
>>
>>71840855
(ostream&) operator<<((ostream&) out, (const Complex&) c)
i dunno if the parens will break it, anyway & is doing the same thing throughout - i.e.
a reference
>>
>>71840895
these things are done best in lisp. as I said most languages botch the idea of read/eval/print, and most languages don't have simple enough syntax to make metaprogramming comfortable.
>>
>>71840924
Why are they best in Lisp?
Because of easy AST access?
You seem like someone who's just started Lisp and in the honeymoon phase, but doesn't actually understand the language enough to elaborate/defend on the specifics of your very bold claim.
>>
>>71840100
you could ask for suggestions
>>
>>71840940
because printed expressions are also readable expressions, and because evalable expressions are also evalable.
>>
>>71840975
that's not exclusive to Lisp.
>>
>>71840982
I don't presume it to be, but I don't know many other languages where it is true, and I find it hard to believe that such a thing would be comfortable to use since lisp's AST simplicity is such a boon
>>
File: splash.png (197 KB, 450x338)
197 KB
197 KB PNG
If you successfully badger someone who needs a lot of badgering to adopt your language, does it improve your community?
>>
>Ya, I always compile with -Wall -Werror -fsanitize=memory
>>
>>71841064
If your community is ill
>>
>>71840410
Books have editors who have learned, either by experience or education, how to recognize what people will find accessible. They will demand an author write and rewrite and rewrite a section until it's just right.
>>
https://bellard.org/quickjs/
The mad lad does it again.
>>
Why does the C++ standard forbid type punning via union? It's legal in C and already allowed on every major C++ compiler anyway.
>>
>>71841230
C++ values have to be constructed to be valid.
>>
>>71841245
But why? Explain a situation where type punning via a union would make some important optimization impossible.
>>
>>71841230
C++ has some strange opinions on what it means for an object to exist or be destroyed. It's why naive use of malloc is undefined behaviour, for example.

Use appropriately aligned arrays of unsigned char instead.
>>
>>71841277
It's not about optimization, it's about values not being initialized properly and thus having an invalid state.
>>
What languages do you think will be popular in 10 years from now surpassing Java, C, Python and JavaScript?
>>
>>71841300
Kotlin, Rust, Python, JavaScript.
>>
>>71841307
Python and JavaScript are already the most widely used.

Rust is already dead.

Kotlin could go either way. Java programmers might actually take it up, or it will meet the fate of all languages that try to be "Java but better".
>>
>>71841319
> Rust is already dead.
Except Facebook has just launched its cryptocurrency written in Rust, while the language took the top position in 5 out of 6 techempowered benchmarks.
>>
>>71841342
>shiny new startup projects mean industry wide adoption
No
>>
>>71841292
But like >>71841287 said, it's fine to cast an object to/from a byte array. It's also fine to memcpy between POD objects of different types. I don't see any good reason why those things shouldn't violate what you're saying but type punning should.
>>
>>71841358
Because there could be invariants about the internal state of an object which you can't guarantee with a union.
>>
>>71841380
There could be invariants about the internal state of an object which would get BTFO by memcpying some random bytes onto it as well but that's allowed. It's up to the programmer to avoid doing such stupid things.
>>
>>71841300
C will stay on the trend of decline but still alive.
c++ will still be standard but also stay with c on the downward trend.
Java will go the way of C.
Rust will be the "popular" language that's forever stuck in the grassroots phase. And I also see a splinter lang happening from someone/people in the Rust community.
JS will go the way of C as newer langs and WASM trend higher even.
Haskell and FP will be much more popular as well.
>>
>>71841407
I don't think it's allowed to memcpy into non-POD object.
>>
>>71841319
>Rust is already dead.
?
>>
>>71841407
The C++ standard ensures that when an object is built the constructor is run and when an object is destroyed the destructor is run. Anything else is undefined behaviour, and any other invariants don't matter.
>>
>>71841413

>Haskell will be more popular
Opinion discarded.
>>
>>71841413
> Haskell and FP will be much more popular as well.
Oh boy, I've been hearing this for 15 years now, I even learned myself a real-world haskell for great good back in 2008. I still write in C++ for money, waiting to capitalize on my knowledge of monad transformers any day now. Meanwhile, I'm getting an offer for a Rust position every couple of months just because I have some on my github.
>>
>>71841414
>>71841418
I'm not talking about non-POD objects, I'm talking about POD objects which the standard already considers safe to memcpy.
>>
>>71841446
>getting an offer for a Rust position every couple of months
where do you live?
>>
File: 1552822104960.png (401 KB, 550x783)
401 KB
401 KB PNG
>>71841431
this, haskell already is the most popular
>>
>>71841450
Wow, that is a SLUTTY skirt!
>>
File: file.png (57 KB, 1207x826)
57 KB
57 KB PNG
Rust is all marketing. They claim that Rust has both safety and performance, and that it has basically solved the most difficult problem in programming. This is hogwash of course.

If they were more honest I might give it a try but right now it's another crappy language that doesn't do anything better than what's already out there.
>>
File: 1547388956269.png (1.17 MB, 1280x720)
1.17 MB
1.17 MB PNG
>>71841449
in his mother's basement.
>>
>>71841447
I dunno why you're fixated on memcpy. It's irrelevant. The standard is clear, objects can only be accessed if they are initialized. That happens in declarations which aren't unions or with new expressions. That's all there is to it.
>>
>>71841449
Russia, the latest one was from Kaspersky, they want to use Rust (specifically with tokio) to write an elaborate QA framework for their OS, which is a kinda weird choice of language desu: https://careers.kaspersky.com/job/Developer-%D0%BD%D0%B0-Rust-(QA-Team%2C-KasperskyOS)/561880800/?locale=en_EU . Maybe they just want a test project to evaluate the langue.
>>
it's funny because I never heard all of these bold claims from rust (mostly because I just don't care about the language, I admit) except on here by all our woke anons (>>71841457) who just can't shut up.
It's almost as if they were paid to shill false outrage on falsehoods.
>>
>>71841497
Literally watch any talk on Rust and they spend half the time talking about how great Rust is without showing why.
>>
>>71841467
If I have a byte array and cast it to a POD struct Foo*, when was my Foo initialized? How is this different than having a union containing a Foo and a same sized POD Bar, assigning to the Bar, and reading from the Foo?
>>
>>71841505
>fags telling other fags how much they like to be fags
shocking
>>
>>71841508
>If I have a byte array and cast it to a POD struct Foo*, when was my Foo initialized?
I believe that's still undefined behaviour, even though it'll work on most any compiler. You need to create an object with a placement new expression, even if it's a NOP.
>>
>>71841505
Literally watch any talk on C... Oh, right, there are no talks on C, no one cares about it besides the suckless faggots.
>>
>>71841524
It's not UD according to the standard.
>>
>>71841594
>An object is created by a definition, by a new-expression, when implicitly changing the active member of a union, or when a temporary object is created.
If you don't create a Foo object with one of these methods you can't access it via a Foo*. It's that simple.
>>
>>71841555
wrong C is an excellent codegen target language
>>
>>71841645
Only if you're too dumb to learn how to use LLVM.
>>
>>71841605
Someone correct this tard, I'm busy at the moment.
>>
>>71841684
BLOAT
>>
>>71841699
And having a C compiler as a dependency somehow isn't?
>>
>>71841706
llvm is considered harmful software
>>
>>71841712
LLVM saved us all from the unintelligible mess the gcc code is, it's literally the best thing to happen to the PL theory and practice, now anyone can use the state-of-the-art codegen and optimizer for their language.
>>
>>71841737
I don't.
>>
I just don't understand how I can avoid loops and redefining variables in Lisp... How do I rewrite this with lambdas?

    (loop [i 0]
(when (< i (count inputs))
(let [input (get inputs i)]
(def derivatives (feed input derivatives)))
(recur (inc i))))


What this does is basically update 'derivatives' by passing 'feed' each input and the previous value of 'derivatives'.
>>
>>71841485
wow, nice
>>
>>71841958
Have you learned the `reduce` function yet?
>>
>>71841958
(reduce (fn [derivatives input]
(feed input derivatives))
derivatives
inputs)
>>
>tfw fell for the rust meme
>>
>>71842028
Thank god for my irrational aversion to <>s. It keeps me away from shitlangs.
>>
>>71841992
>>71842000
It turns out the problem is that my parameters are not standard lists or vectors, but matrix data structures, and the compiler is misinterpreting the way I want the mapping to work.
>>
>>71842071
Do you know how to solve your problem?
>>
>>71842065
Real langs don't need parens, braces, square brackets or pointy brackets.
>>
>>71842112
>pointy brackets
lol I like this new term
>>
>>71842112
good luck with that, because now you're getting into eso-lang territory of aliasing words.
>>
>>71842097
Nope. Is there any way to specify which values are used on each iteration of the map/reduce? With a loop I can specify like this (see like 3)
 (loop [i 0]
(when (< i (count inputs))
(let [input (get-row inputs i)]
(def derivatives (feed input derivatives)))
(recur (inc i))))
>>
>>71842139
actually you're just writing haskell now
>>
>>71842154
Haskell has all types of brackets and parens though
????
>>
>>71842151
If you can't `seq` the matrix, could you map `get` over the indices?
Could I ask what matrix library you're using and what your goal is?
>>
>>71842235
>`get`
or nth or get-row if appropriate
>>
>>71841230
>it's fine to cast an object to/from a byte array
"to", not "to/from". and because that's the only way of directly accessing object representations / untyped memory that is actually well-defined across implementations/platforms, since endianness and alignment requirements may vary

>It's also fine to memcpy between POD objects of different types
which it does by casting to byte arrays and copying bytes (or else something provably equivalent to such)

>>71841407
>It's up to the programmer to avoid doing such stupid things
indeed, but better that doing such things require explicit acknowledgement of the removal of guarantees regarding the structure of such data - which the semantics of reinterpret_cast to byte array express quite accurately

>>71841508
>If I have a byte array and cast it to a POD struct Foo*, when was my Foo initialized?
that is undefined behavior. you can cast *to* a byte array to examine an object representation, and you can copy between object representations by casting both the source and destination objects to byte arrays and copying values from one to the other, but casting a byte array to a pointer to some other object type (or, more accurately, dereferencing such a pointer) is UB

for what it's worth, C++20 is adding std::bit_cast(), a long-overdue concise solution for common type punning scenarios
>>
>>71842167
{-# LANGUAGE BlockArguments #-}
*blocks your path*
>>
>>71842382
You literally can't write a haskell program without parens
>>
Which is more pajeet, C# or Java?
>>
>>71842407
challenge accepted
>>
>>71842408
Java obviously
>>
File: 1557384757804.png (1.35 MB, 1920x1080)
1.35 MB
1.35 MB PNG
>>71842408
What kind of question is that? They're the same language.
>>
>>71842408
C#, pajeets love microsoft
>>
>>71842235
I'm using core.matrix and and the goal is very basic matrix multiplication stuff. I've actually already implemented everything in MATLAB for testing purposes, right now I'm just trying to get the hang of clojure.
>>
If I need to make an UDP server that accepts a connection, reads some data, executes a query then sends some reply back and disconnects the client, what would be the best language to do this in to achieve the best efficiency:productivity ratio while making it so that a query executing and waiting for DB doesn't block the server/other connections?
>>
>>71842431
try compiling this in both langs.
80085.toString()
>>
>>71842463
Whatever you say, Rahul.
>>
>>71842459
unironically, probably Go, if you just want to get it done quick and have ok code quality
>>
>>71842475
That's what I was actually considering but figured I'd ask if there's something else that I should keep an eye on, not a big fan of Go but I'd be fine using it for this regardless if there's no other thing that would be much better than it.
>>
>>71842473
wonderful response, mr. has classes so they are all the same legend sir nataraj US returned.
>>
>>71842487
Just depends how much time you want to spend on it.
Writing network stuff in FPLs can be fun, but it'd be a bit more time consuming.
D + Vibe.d is bretty good, and probably has only slightly longer dev time than Go for the project.
Could try Elixir if you don't mind dynamically typed langs.
>>
>>71842463
Main.java:12: error: ')' expected
System.out.println(80085.toString());
^
Main.java:12: error: -> expected
System.out.println(80085.toString());
^
Main.java:12: error: not a statement
System.out.println(80085.toString());
^
>>
>>71840086
Lisp is the most powerful programming language.
>>
>>71842567
No
>>
>>71842463
>>71842555
explain?
>>
>>71842448
I see
>>
File: file.png (85 KB, 299x168)
85 KB
85 KB PNG
>>71842416
where is your code nigger ?
>>
>>71842463
CL-USER> (write-to-string 80085)
"80085"
>>
>>71842646
what are you trying to prove you cum guzzler
>>
>>71842645
he tried for about 5 minutes and then gave up.
>>
>>71842555
So this is the intelligence of racist posters.
>>
Name a more brainlet major than cs.
>>
>>71842671
dumb paki/pajeet
>>
>>71842555
>>71842626
Ok, you know something like `0` is considered an `int` in Java? Well, it turns out it isn't anything unless you assign it to a variable of type int and even "this is not a string yet".replace(...) won't work because it is not an object yet.
>>
>>71842656
CL-USER> (format t "~R" (parse-integer (write-to-string 80085)))
eighty thousand eighty-five
>>
>>71842693
um okay
>>
Madoka
>>
>>71842690
Oh wait, String example does work because it is a class and not a primitive.
>>
>>71842700
a slut
>>
>>71842719
No u
>>
>>71842693
Why would anyone want such bloat in their standard libraries?
>>
File: 1542324471954.gif (119 KB, 480x270)
119 KB
119 KB GIF
>>71842407
>>71842645
>>71842660
fizzbuzz = fromMaybe <$> show <*> fuck
where
rule n m i = case i `mod` n of
0 -> Just m
_ -> Nothing

fuck = fold [rule 3 "Fizz", rule 5 "Buzz"]

main = sequence_ $ putStrLn . fizzbuzz <$> [1..100]
>>
>>71842753
GHCi, version 8.6.3

main.hs:1:12: error:
Variable not in scope: fromMaybe :: String -> a0 -> b
|
1 | fizzbuzz = fromMaybe <$> show <*> fuck
| ^^^^^^^^^
main.hs:7:12: error:
• Variable not in scope: fold :: [Integer -> Maybe [Char]] -> t
• Perhaps you meant one of these:
‘foldr’ (imported from Prelude), ‘foldl’ (imported from Prelude)
|
7 | fuck = fold [rule 3 "Fizz", rule 5 "Buzz"]
| ^^^^
<interactive>:3:1: error:
• Variable not in scope: main
• Perhaps you meant ‘min’ (imported from Prelude)
>>
>>71842730
Imagine if you were programming before the internet. You would want everything in your standard libraries.
>>
>>71842765
import Data.Maybe
import Data.Foldable

kys brainlet
>>
>>71842766
Thank god this isn't 1984 anymore.
>>
>>71842769
i expect complete programs, double nigger
>>
Is this a good idea for passing around, creating and deleting dynamically sized arrays in functions?
typedef struct {
uint8_t *data;
size_t size;
} ByteArray
>>
>>71842730
I never felt like a standard lib I used was bloated, but I often felt like a language lacked obvious functions.
It is completely incomprehensible to me how not every standard lib has unionWith.

That being said, that probably has more to do with bad taste on the language designer's part than them trying to keep the size down.
>>
>>71842753
Also show uses parens in its implementation, try again.
>>
>>71842808
>typedef
Disgusting.
struct byte_array {
size_t size;
uint8_t data[];
};

is a better way to define that. Maybe splitting capacity vs used is justified, depending on how it's used.
};
>>
>>71840086
I want to cum on Hiro-san’s hair!!!
>>
>>71842787
Who cares about brainlet's expectations, lol. Neck yourself.
>>
>>71842730
>my favorite language can't do this so that's bloat!
>>
>>71842815
kys
>>
>>71842753
use
rule 3 "Fizz" <> rule 5 "Buzz"
and
enumFromTo 1 100
to get rid of the []s
>>
>>71842959
At least my favorite language has threads and concurrency primitives in the standard library.
>>
>>71842997
most if not all implementations support these.
>>
>>71842996
parens aren't brackets
>>
>>71843043
>wanting ugly []s in your code
>>
>>71843059
ur mom's uglier
>>
>>71842753
nice attempt, but
rule res d a = res <$ guard (a `rem` d == 0)
fizzbuzz = foldMap (putStrLn . f) [1..100]
where
f i = fromMaybe (show i) (g i)
g = mconcat . sequence [rule "Fizz" 3, rule "Buzz" 5]
>>
>>71843167
but?
>>
>>71843167
>parens
>>
File: Capture.png (17 KB, 720x387)
17 KB
17 KB PNG
https://github.com/adafruit/Adafruit_Python_DHT/blob/master/source/Raspberry_Pi_2/pi_2_dht_read.c#L75
Is this kind of thing normal in embedded programming? Will people laugh at me if I do this? It seems weird.
>>
>>71843178
but you've got some room for improvements

>>71843184
i don't give a shit about your brainlet problems, go circlejerk on sepples or rus about how much visual clutter they have, or better yet - enlighten us by your "muh p-parens" argument when you cry about that time you had to use lisp in uni.
oh noooo i forgot that you're a fucking neety beety with nothing better to do and who never even went to uni, I'm sorry guess you just prefer to live out the fantasy of being in uni and having such struggles as your live spirals into nothingness and everyone around you forgets about your pathetic existence.
It's okay anone - there's plenty of people akin to yourself on one particular board.
>>>/r9k/
and make yourself at home, we won't miss you
>>
>>71843220
Also I notice they don't do that volatile for loop for the beaglebone. Why?
>>
>>71843249
read the fucking thread before throwing a tantrum, you dumb autistic cock sucker
>>
>>71843273
I've read it and simply don't give a shit shlong gobbler
>>
>>71843279
then don't post, no one gives a shit about you're non-improvements, there are millions of ways to write this better, that wasn't the point.
kys
>>
>>71843249
seething
the only improvement in your code is using <$ and guard, everything else is worse
>>
>>71842876
do not
>>
Reminder that C is better than your language because it has malloc and memcopy and because your computer is actually implemented in C because it’s abstract machine is a 1-to-1 match with 2019 hardware and your language can’t even overload malloc, haha sad.
>>
>want to learn Bash because I wanna get better at doing stuff on Linux
>It will not help me get a job
Why is it like that with everything I want to learn god damn
>>
>>71844015
Bash isn’t that useful, I only use it for scripts of a dozen or so lines. Python or Perl (if boomer) are for anything longer.
>>
>>71844010
Not even C compilers are implemented in C nowadays, and my machine isn't PDP-11-but-faster, grandpa.
>>
>>71844034
I don't wanna whip out Python for simple scripting stuff though.
>>
>>71844015
>It will not help me get a job
My colleague who is responsible for devops uses bash constantly, look into that?
>>
>>71844040
Only because the compiler writers are retarded. Its obvious that C code at -O0is better than your shitlang which can’t even into inline assembly or pointers. Your computer isn’t a PDP because of the liberal-intel-kike conspiracy to push rust and $9 hr poojins while galaxy-brain C programmers solve the biggest problems out there, like overloading malloc which your tranny lang doesn’t even have senpai try again.
>>
>>71844069
I don't think I actually get what DevOps is, or why you need bash for it. I'm a brainlet pls be patient. Still trying to find my calling in life.
>>
>>71844135
Devops is about doing the work of two jobs (developer and operations) and being on call 24-7 to fix whatever whenever something is happening.
>>
>>71844152
So being everyone's nigger and the "fix this" guy.
Sure why not that sounds challenging.
>>
>>71843220
afaik it can happen that you need to wait for a few clock cycles for some reason, and just spin in a loop for a bit to achieve that.
I'm not sure if I would trust my compiler to not optimize this out.
I'm not a 100% on the semantics of volatile though, so it might be fine.
>>
>>71844169
The point of volatile is that the compiler can’t touch it because the variable is assumed to be changeable outside of the program. Making a bare for loop like that requires a good understand of what the assembly will look like.
>>
>>71843220
Its the kind of thing you can do when you target specific hardware and aren’t using an optimizer. It’s retarded otherwise.
>>
give me project ideas for my oop class
>>
>>71844233
your oop class or your oop class?
>>
>>71844185
yeah looks like it works. I think the drawback would be that you need to allocate storage space for the loop variable. If you can use inline assembly a regular for loop with a no-op as the body might be more efficient.
>>
>>71844261
yes
>>
>>71844233
implement your own object system in your favorite scheme
>>
File: retardAct2.png (776 KB, 2048x2048)
776 KB
776 KB PNG
Hey guys, long time lurker here, just started to learn programming, so I was pleased to see that this thread is definitely not as cancerous as the rest of the board (Also I'm having a blast).

I made a little program to compute the Fibonacci sequence iteratively but it's taking longer than expected. I've seen some people online saying they can get to fibo(200000) without much trouble, but it took me all night to get to fibo(180000), and I'm using a rendering machine, so hardware is definitely not the problem.

Someone suggested I use @jit, but when I do, the output is all fucked up. Anyone knows what's going on?

Thanks in advance.
>>
>>71844480
By default it's using arbitrary precision integers.
@jit doesn't support that instead just using a normal int (probably 64 bit), which causes the value to overflow and wrap around back to the negatives.

Also, define "rendering machine". 3D rendering is done mostly on the gpu and that program is going to run purely on the cpu.
>>
>>71844373
that ain't gonna cut it
i need to make a legitimate program using java, possibly a client-server restful application that communicates using http(s) through xml/json files, with several clients doing different things, external configuration files, a sql/nosql database, also using some kind of encryption and integrating at least 3 third party apis
it cant be an android app
>>
>>71844480
You're calculating the whole sequence every time, which is pointless. You can put the print statement in the loop in fibo(n) and it'll print all of them up to n. Or make it a generator:
while True:
a, b = a+b, a
yield a

Which will return the next number every time you call it.
>>
>>71844552
I see. Is there a way to compute the sequence differently to get around that problem?

>3D rendering is done mostly on the gpu

Indeed, 3D rendering is slowly moving toward GPU altogether, but it's still mostly realtime graphics that solely use the GPU. Pre-rendered graphics (especially if you didn't update your rig / softwares in the last 3 years) still use the CPU.

Not sure if you're too much into CG shit, but I'm really hyped for the next Arnold installment, since they're going to move mostly to GPU.
>>
>>71844621
I'll try that. Do I have to use that snippet of code inside the function? If so, wouldn't the while True: make the rest of the code unreachable?
>>
>>71842463
>toString()
no such method in c#
>>
File: Java_POOP.jpg (38 KB, 600x689)
38 KB
38 KB JPG
>>71842690
is this the power of Java's OOP?
>>
Hello /g/entoo's, I need a help. I made a simple bot for a game using PyAutoGui and PIL and wanted some feedback.

https://pastebin.com/bBAnNQWZ
>>
>>71844680
That's the replacement for the loop to make it a generator. The idea of a generator is that "yield" returns from the function with the value, but calling the function restarts it from there. So each time you call fibo() you get the next number. The "while True" means you can keep calling it as many times as you like.
>>
>>71844718
Oops, link for the game is http://tanksw.com/impossible-rush/
>>
>>71844480
To fix that weird output, you have to fix the integer overflowing. The way to do that would be to initialize the a and b variables like this:
a, b = np.int64(0), np.int64(1)
>>
>>71844737
wait my brain small
fib(104) is too big for a 64 bit integer
>>
>>71844480
use the O(log n) algorithm if you want speed
the @jit doesn't do big integers as far as I know
>>
>>71844635
In general there isn't really a way to get around the overflow problem besides using arbitrary precision integers (which come with a lot of performance loss). If you do what the the other anon said, it should be fine.

And huh, I do barely any rendering myself so I haven't kept up date, but I had assumed that Arnold was just going to be stuck on the cpu forever, with people eventually transitioning to rendering engines that were intended for the gpu from the go, but that's really cool to see.
>>
>>71844233
make a lisp
>>
File: peaBrainKnowsNoBounds.png (14 KB, 524x471)
14 KB
14 KB PNG
>>71844727
which loop are you talking about? The one in the function or the one that calls the function under it?
>>
>>71844997
(I'm trying to read up on generators to understand how to use yield, but it's still pretty foggy to me.)
>>
>>71844977
full guide to making a clojurey lisp
https://github.com/kanaka/mal/blob/master/process/guide.md
>>
File: python.jpg (194 KB, 1614x576)
194 KB
194 KB JPG
Stated the python course on udacity and just completed the final quiz in the first module.

r8 my solution vs the official solution
>>
>>71844997
That's the right place, though notice fibo no longer uses its argument, so remove that. Also make sure you only call it once per iteration by assigning it to a variable first. And don't call it "length", because that's confusing.

>>71845033
They're not complicated. "yield" acts like "return", except it remembers the function's state and when you call the function again it restarts from that point.
>>
>>71845114
its fine. now dont come back until you know why its fine.
>>
>>71845114
Should have used regex.
>>
>>71840314
Nobody? I now even have code (for glibc on Linux) that compiles into a library that you can inject into programs via LD_PRELOAD.

If you need such help, that is. Uses __libc_malloc and __libc_free for that matter.
>>
File: p.jpg (166 KB, 1000x1500)
166 KB
166 KB JPG
>want some pretty symbols in my printfs
>mfw printing unicode in C involves invoking this mess
wchar_t arrow = 0x2192;
wprintf(L"a %lc b\n", arrow);
>>
>>71845380
Use a lib.
>>
>>71845197
I see. Thanks for the help anon.

Google has no answer for that problem though, so sorry if I'm stretching your patience, but what do you make of this output?
>>
>>71845380
#include <stdio.h>
int main() {
printf("\n");
}

works for me
>>
File: file.png (7 KB, 194x138)
7 KB
7 KB PNG
>>71845430
I put an arrow in there lol
>>
>>71845430
anon, I'm not sure you understand.
>>
File: 9UPP38D.jpg (76 KB, 438x750)
76 KB
76 KB JPG
>>71845451
A straight printf containing unicode doesn't work on my terminal, it's probably locale dependent.
>>
>>71845427
replace cmd with cmd(). generators are called like functions. I think you can also do:
for fib in cmd:
>>
>>71845515
probably, I have mine set to en_US.utf8
>>
>>71845427
Like the other anon said, the problem is you're getting the generator object rather than asking the generator for a value. I'm not sure why you're using the cmd = fibo indirection in the first place though. Oh, is that what you think I meant by assigning it to a variable? No, I meant because your previous version used (and calculated) it twice each iteration, and you want to assign the value to a variable if you want to re-use it. Because the point of the generator is it gives you a new value each time.
I'd suggest playing with it in the interactive prompt
>>
>>71841450
>>71841455

How do I find a slutty skirt casual sex Haskeller like this plz?
>>
watching some god emperor tushar roy videos to get a better handle on system design
>>
>>71845515
the font may also count
>>
>>71844686

https://docs.microsoft.com/en-us/dotnet/api/system.int32.tostring?view=netcore-2.2#System_Int32_ToString
>>
>>71846168
>2.2
3.0 fucking when?
>>
import Library.Examples.Fizzbuzz
int main() -> FizzBuzz()
>>
for backend should I choose Java or go with something like Python/Django? is the Microsoft/C# stack worth it rather than Java?
Java and C# has the most jobs in my area but employers usually ask for a degree and experience, also I believe competition is huge; scripting languages like JS/Nodejs, Python/Django and PHP/Laravel don't always ask for a degree and I believe competition is not that big as in Java or C#, they seem like the perfect choice to get foot in the door but I'm afraid I'll be forever stuck with it
I intend to work as a backend dev but I have no degree or experience. I need a job anons
>>
>>71846282
Java jobs imply disgusting and/or old tech.
>>
>>71846282
>I intend to work as a backend dev
asp core or nodejs depending your language of choice.
>>
>>71846168
>toString()
>ToString()
see the difference?
Java can't C# (see sharp)
>>
File: put down the ibad anon.jpg (152 KB, 750x561)
152 KB
152 KB JPG
>>71846365
>see the difference?
>Java can't C# (see sharp)
>>
>>71846259
from fizz import buzz
from buzz import fizz
for range 1 to 10
consider fizz
consider buzz
print buzz fizz where fizz not buzz
>>
>create an algorithm to solve the below problem:
>a 3x3 binary matrix consists of 1s and 0s
>call this matrix M
>find an M such that M^n for all n > 1 = M^2 and n is an integer
>I is not a viable answer
>recall binary matrices consist of solely 1s and 0s; if you multiple two binary matrices, truncate >1 to 1

why is this in a first year class. i dont evne know what a matrix really is
>>
>>71846456
>consider fizz
>consider buzz
consider suicide
>>
>>71846483

To clarify:

>M^5 = M^4 = M^3 = M^2 etc

I can't use an identity matrix, one entirely of 1s or one entirely of 0s.
>>
>>71846483
write it out as a system of equations
>>
>>71846483
that's only about 2^9 combinations right? should be quick to check.
>>
>>71846483
use induction
>>
>>71846489
consider your grammar
>>
>>71846483
It's just an idempotent matrix. Also that question is worded horribly.
>>
>>71846609
consider sex
>>
File: consider the following.png (264 KB, 1000x1000)
264 KB
264 KB PNG
>>71846633
consider dilation
>>
>>71846341
I'm aware anon, most job descriptions for Java here in my area asks for all those old Java stuff, it is a nightmare but I don't think I'm in a position to choose if I want to get a job and make money. also those jobs asks for a degree and experience, right now that is a barrier against me
thanks

>>71846361
ASP Core is a great choice but from what I've read in rbt archive it is not mature enough
I learned Nodejs already, built some shit with it but I feel incomplete, I need to git gud using a scalable 'enterprisey' langauge so I can be attractive to employers
thanks, anon
>>
How many of you do NOT use GitHub or a similar public service for their code?
>>
>>71846762
fuck off, data miner
>>
File: 1562953424590.jpg (476 KB, 1920x1080)
476 KB
476 KB JPG
>>
>>71846682
>it is not mature enough
huh? it is pretty mature and has more features and analyzers than pretty much anything else.
>>
>>71846682
You shouldn't be asking yourself how to be attractive to employers. You should be asking yourself what it is that they want.

If they'd dismiss someone who's only knowledgable in Java, and not in like C (which, like it or not, is a great entry language because so much else has been derived from it), or if they only want someone experienced and thus not willing to train them, then their need simply isn't big enough, and there's a big question mark as to whether or not it's the right place for you.

There's enough incompetent white Pajeets being churned out of universities that couldn't implement a key exchange even if they wanted to. Believe me, I've seen enough of them. I used to work for a company where the applicants couldn't use a proper fucking regex for their dear lives.
>>
pls help fix my code
knapsack problem >>71847515
>>
Almost went insane trying to figure out why a command I copied from online wasn't working.

It was using '–' instead of '-'.
>>
>>71840089
Have sex
>>
File: angry.jpg (68 KB, 633x758)
68 KB
68 KB JPG
>maintenance guy saw my programming dress + socks
>>
Given the following:
void f(unsigned int);
void f(int);
void f(char);

Which overload gets called by the following?

char x = 1;
char y = 2;
f(x + y);
>>
>>71848110
Git gud.
>>
>>71848146
void f(char)?
>>
>>71848146
Who cares.
>>
>>71848146
void f(char)
is called because there is no conversion from char to int in the expression
(x + y)
. A char is just a small integer.
>>
>>71846483
This can be reduced to SAT quite easily.
>>
>>71848146
f(int)
>>
>>71848189
no

>>71848165
not specified by the standard

>>71848208
maybe
>>
>>71848146
int
all shorter integer ops get default promoted to int
>>
Why isn't this shit working?
int * merge(int * a, int as, int * b, int bs) {
if(!a) return b; if(!b) return a;
int * r = malloc((as + bs) * sizeof(int));
int ac = 0, bc = 0, rc = 0;
while(1) {
if (ac == as && bc == bs) break;
else if (ac == as) r[rc++] = b[bc++];
else if (bc == bs) r[rc++] = a[ac++];
else r[rc++] = a[ac] <= b[bc] ? a[ac++] : b[bc++];
}
free(a); free(b);
return r;
}

int * msort(int * k, int s) {
if (s == 0) return NULL;
if (s == 1) return k;

int s1 = s/2, s2 = (s/2) + (s%2) ? 1 : 0;
return merge(msort(memcpy(malloc(s1*sizeof(int)), k, s1), s1), s1,
msort(memcpy(malloc(s2*sizeof(int)), k+s1, s2), s2), s2);
}
>>
>>71848316
what you mean?
>>
File: example.png (729 KB, 1831x799)
729 KB
729 KB PNG
Doing image to ascii in java. It works perfectly fine for lighter images but has weird errors in darker images. I've narrowed it down to being an error in this portion but I'm blanking on what's wrong. Would appreciate a second perspective.
>>
>>71848316
I think the memcpy(malloc(... thing is unnecessary.
Tell us how it's not working (not sorted? segfault? garbage output?)
Try testing the merge routine on its own, with parameters you know are correct and that you know what the result should be.
>>
>>71848351
its not returning what I want (i.e. a sorted array)
>>
>>71848405

You need to use fixed-width fonts, bud. Proportional fonts will not work for this.
>>
>>71848431
that surely sucks
>>
>>71848430
It is necassary otherwise I'd get free errors
With memory leaks allowed, it somewhat outputs correct stuff, but now the output is garbage
1 9 -2 7 
0 1 254 0

first line is array malloced in main and set to those values
second line is return of msort
>>
File: Untitled.png (10 KB, 835x605)
10 KB
10 KB PNG
Given any arbitrary shape specified by a set of points (and size), is there a way to efficiently tile a rectangular region with them while minimizing both the number of shapes and overlap between them? You can go outside the rectangle for the borders like pic related.
>>
>>71848461
I'm using monospace.
>>
>>71848483
>It is necassary otherwise I'd get free errors
I just love it when people have no idea how to handle memory anymore.
>>
>>71848499

Alright, well then how often does
System.out.println(currentBrightness)
run? You should never see this message, since you'll have an ASCII char for every pixel in the image, presumably. You are getting those waves since you're skipping pixels (somewhere).
>>
File: Untitled.png (84 KB, 1151x583)
84 KB
84 KB PNG
>>71848405
>>71848461
https://pastebin.com/qHPvN9fC

Here is the code for the class. I'm using spring and displaying the result in the browser with a <pre> tag.

It works 100% fine for other things
>>
>>71848511
Dude, if I didn't malloc and memcpy'd, this would happen
1 9 -2 7 
free(): invalid pointer
Aborted (core dumped)

that's because i'm then freeing the original array twice

what am I supposed to do, allow memory leaks?
>>
>>71848316
>s2 = (s/2) + (s%2) ? 1 : 0;
pretty sure + has higher precedence than ?:, try adding parentheses around the ternary
>>
>>71848552
It never runs.
>>
>>71848562
Pastebin.com is under heavy load right now :(
>>
>>71848565
>what am I supposed to do, allow memory leaks?
How about you do it zero copy?
>>
File: honor.jpg (94 KB, 852x461)
94 KB
94 KB JPG
>>71848405
Perhaps 'brightness'/value isn't what you imagine because the value of a pixel isn't necessarily related to human perception of how high the value is. https://en.wikipedia.org/wiki/HSL_and_HSV

Also, especially in dark areas there might be compression artifacts that influence how the value is calculated.
>>
>>71848580
https://paste (dot) ee/p/wrbBX
>>71848588
I'll look into that, thanks. I didn't just average the rgb values though, I got a formula for brightness from stackoverflow.
>>
File: DtmRyXEUUAEQ0Ur.jpg (23 KB, 460x459)
23 KB
23 KB JPG
>>71848616
>I got a formula for brightness from stackoverflow.
>>
>>71848583
what??
>>
>>71848565
pretty sure that's because you're freeing random pointers into your original array, coming from the s==1 case. I think a simple solution is to have merge and msort accept a pointer to write the result to and allocate one output buffer before calling msort from outside (or provide a wrapper to do it)
Or you could just not free a and b is their size is 1
>>
>>71848622
lmfao it was just the ratios that red blue and green contribute to percieved brightness. About 21.2% for red, 7.2% for blue and 71.5% for green
>>
>>71848630
>what??
Exactly. Is there any need for you to copy your input data? Can't you sort it in-place?

If you ask
>what??
again, please refrain from programming ever again.
>>
>>71848655
wut
>>
>>71848572
that helped but the output is now random seeeming (i.e. it seems memcpy isn't working)
>>
File: 1562795884627.jpg (58 KB, 456x578)
58 KB
58 KB JPG
>>71848616
>I didn't just average the rgb values though, I got a formula for brightness from stackoverflow.
I'd suggest outputting the values in that region of pixels and see if what it looks like it should be. It could be all kinds of things, maybe the chorma in that area was crushed to save space since it's black anyway or something, I dunno.
>>
>>71848676
well memcpy is for copying bytes, so you probably want to multiply the size by sizeof(int)
>>
>>71848576

I built and ran this in the console and it looks good to me.
>>
>>71848689
>chorma
*chroma
>>
File: BGRB7227.jpg (708 KB, 910x1365)
708 KB
708 KB JPG
>>71848738
Would you mind trying it with this image please?
>>
>>71848405
does the image look jagged at the right edge because the lines are different lengths or does it print spaces there?
>>
>>71848760

I reckon I already figured out what it is.. try changing '&' to 'B' in your charGradient.
>>
File: lainwilljudgeyou.jpg (82 KB, 1008x720)
82 KB
82 KB JPG
What do professional computer programmers do on a daily basis?
>>
>>71848706
thank you very much, this has fixed my code
>>71848655
there is a need, it's merge sort dude
>>
>>71848809
>surfing heise
>turning on the power adapter of label printers
>giving up on cross-compiling Windows CE 6.0
And how was your day?
>>
>>71848798
The lines are different lengths. No spaces where they shouldn't be.
>>71848807
Thanks man that worked.
>>
>>71848815
>there is a need, it's merge sort dude
That's no reason. You can implement merge sort very well without additional copies.
>>
>>71848807
how come this worked?
>>
>>71848862
what, swapping? yikes
i'd only do that if I really need to sort if I really cared about performance
>>
>>71848884
That's a good question, I'm curious too. I would have never thought of it.
>>
>>71848911
>i'd only do that if I really need to sort if I really cared about performance
As I said, please refrain from programming ever again.

Pajeet.
>>
>>71848928
>>71848928
>>71848928
>>
File: 1562880316703.jpg (577 KB, 1358x1825)
577 KB
577 KB JPG
>>71848809
>screen at eye level but angled backwards
>terrible keyboard ergonomics
>touchpad is angled up
>to open cd lid have to move back keyboard
navis are shit
>>
>>71848930
i care more about clarity right now
le ebin 300 loc for le really fast code is not what I'm seeking, therefore
>>
>>71848954
>i care more about clarity right now
>redundancy is clarity
>ignorance is strength



Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.