|
the correct type for main is () -> ()
|
# ? Jul 23, 2016 20:56 |
|
|
# ? May 24, 2024 14:10 |
|
I mean I guess you could very carefully extend the bare minimum from the baseline of C in order to get the job done. Just templates and RAII and virtual methods, no exceptions and absolutely no loving operator overloading. Well, except you'll probably want a custom smart pointer class in order to do the RAII thing, so ok, maybe a tiny little bit of operator overloading. No constructors, just assume that every new'ed object gets memset to 0 and make sure your destructors can handle that if your _init() methods fail, which is basically what you'd do in sensible C anyway. Well, except in C something is either uninitialized memory or a valid "object"; if your _init() function fails then it is the _init() function itself that is responsible for calling _fini() to undo the mess and return the object to being a mass of uninitialized junk that is no longer holding any resources. In this minimal C++ situation you'd instead have a pile of abortion waste on your stack that you have to be careful not to do anything with until it goes out of scope. eh. constructors can't return an error code in c++ because that would break so much of the language, you have to throw an exception instead, and then, well you have to deal with all the myriad problems of exceptions in a non-garbage-collected language. this one aspect of c++ is a fount of aggravation and misery. GCC has a nonstandard C extension instead that arranges for a cleanup method to be called whenever a stack variable (and only a stack variable) goes out of scope and it's a much nicer solution to this problem. the systemd guys use it extensively and it actually makes for rather nice code. but there's still no nice way to do vtables in C. and you can't do just vtables in c++ without constructors and virtual destructors, and as described above you can't do those without exceptions. c++. not even once.
|
# ? Jul 23, 2016 21:01 |
|
http://250bpm.com/blog:4
|
# ? Jul 23, 2016 21:04 |
|
rust doesn't have constructors or exceptions it also yells at you if you forget about handling an error
|
# ? Jul 23, 2016 21:11 |
|
comedyblissoption posted:rust doesn't have constructors or exceptions How are panics which you can catch not the same as exceptions?
|
# ? Jul 23, 2016 21:41 |
|
Mr Dog posted:constructors can't return an error code in c++ because that would break so much of the language, you have to throw an exception instead, and then, well you have to deal with all the myriad problems of exceptions in a non-garbage-collected language. this one aspect of c++ is a fount of aggravation and misery. learn2raii noob -C++ zealots
|
# ? Jul 23, 2016 21:47 |
gonadic io posted:How are panics which you can catch not the same as exceptions? That's sort of a philosophical question, but panics are intended to be used for logic errors and not normal flow control. So stuff like division by zero would panic, and stuff like failure to open a file would return the Err part of a Result. The rust community mostly sticks to this as well. Actually, can you catch panics on stable now within the panicking thread? They used to be sort of like a thread-local abort.
|
|
# ? Jul 23, 2016 21:54 |
|
hobbesmaster posted:learn2raii noob idk what you think the second 'i' in 'raii' does besides call a ctor
|
# ? Jul 23, 2016 22:06 |
|
NihilCredo posted:if you really need those nested generics but don't want to type them everywhere, you can sometimes "alias" them depending on how you use them agh gently caress i didn't realize I could make interfaces that inherited interfaces. poo poo
|
# ? Jul 23, 2016 22:07 |
|
AWWNAW posted:or you can alias them using a using statement at the top of the file like using Dick = System.Tuple<Pussy,Taint> shiiit
|
# ? Jul 23, 2016 22:08 |
|
i like modern c++ and currentjob is absolutely dependent on it for cross platform stuff and libraries but it's still way too easy to gently caress up
|
# ? Jul 23, 2016 22:11 |
|
fritz posted:idk what you think the second 'i' in 'raii' does besides call a ctor learn 2 raii noob -stroustrup quote:6 Handling of Constructors please ignore the words just before the bolded ones (page 12)
|
# ? Jul 23, 2016 22:14 |
|
yes this is rather impractical
|
# ? Jul 23, 2016 22:16 |
|
gonadic io posted:How are panics which you can catch not the same as exceptions? or at least that's the intention and guideline if it's not being enforced somehow using types at least the rust idioms avoid the criticisms of c++'s exception model listed in that article (I think) edit: I guess you can catch panics wherever now: https://doc.rust-lang.org/std/panic/fn.catch_unwind.html i guess only time will tell if people abuse the hell out of this like exceptions there's actually some limitations on what you can do when you catch a panic: https://doc.rust-lang.org/std/panic/trait.UnwindSafe.html comedyblissoption fucked around with this message at 23:25 on Jul 23, 2016 |
# ? Jul 23, 2016 23:18 |
|
I'm a terrible programmer, I cannot finish World CodeSprint 5 using Java 7. I keep getting timeouts on the palindromes, meh.
|
# ? Jul 24, 2016 03:54 |
|
but can you with the same algorithm in a different language or is your algorithm just too slow? like for example for the "easy" string construction one to not time out you need to have a set of characters you've seen
|
# ? Jul 24, 2016 03:58 |
|
its probably isn't a hackerrank issue with the language but it could be
|
# ? Jul 24, 2016 04:00 |
|
I guess it's my crap algo Java code:
MrMoo fucked around with this message at 04:17 on Jul 24, 2016 |
# ? Jul 24, 2016 04:11 |
|
HoboMan posted:wait, what? please elaborate so i don't have to learn the hard way as well ok so here is the original code to generate the test cases. the IEnumerable<object[]> part is the stupid bullshit that XUnit requires for a Theory code:
|
# ? Jul 24, 2016 04:18 |
|
the chome/mome/lomarf thing is more annoying for you than it is for me but my employer is loving insane about IP e: i meant more annoying for me. because i had to go through and replace all that poo poo so that nobody could crack my code. lomarf GameCube fucked around with this message at 04:28 on Jul 24, 2016 |
# ? Jul 24, 2016 04:19 |
|
MrMoo posted:I guess it's my crap algo uhhhh O(n^4)?!
|
# ? Jul 24, 2016 04:23 |
|
Jealous? It was worse. Highly dependent upon String.indexOf() performance. The inner two loops are more linear than the outer two.
MrMoo fucked around with this message at 04:41 on Jul 24, 2016 |
# ? Jul 24, 2016 04:38 |
|
i just looked at one of the sample problems and it made no sense, authored by a guy named ZeroCool
|
# ? Jul 24, 2016 04:48 |
|
tfw you start investigating ur test failures and discover that the test case generation algorithm u stayed up all night writing is producing invalid test cases
|
# ? Jul 24, 2016 04:57 |
|
how do i add a local git hook that checks my commits for profanity before letting me commit? tia
|
# ? Jul 24, 2016 05:04 |
|
ok after fixing my test case algorithm my test passes for all 8,162 test cases
|
# ? Jul 24, 2016 05:24 |
|
MrMoo posted:I guess it's my crap algo just peeped this it is some nerd poo poo
|
# ? Jul 24, 2016 05:36 |
|
there's a lot of good "learn _____ concept" things on hackerrank but the more "advanced" problems are usually simply poorly phrased and convoluted even more so for the contests
|
# ? Jul 24, 2016 05:41 |
|
LordSaturn posted:we need to stop expanding C++, it's 2016 and you can just use a good language if you loving want to that is not c++. maybe this was the joke
|
# ? Jul 24, 2016 08:50 |
|
hobbesmaster posted:there's a lot of good "learn _____ concept" things on hackerrank but the more "advanced" problems are usually simply poorly phrased and convoluted The Java advanced set include some great examples of how not to code, annotations is hosed up, and lambda expressions is clear the author has no idea what lambdas are for. MrMoo fucked around with this message at 17:04 on Jul 24, 2016 |
# ? Jul 24, 2016 14:29 |
|
linq is so neat. i love linq. i want to marry linq
|
# ? Jul 24, 2016 16:53 |
|
same. if you don't like LINQ, gently caress you
|
# ? Jul 24, 2016 17:13 |
|
Gul Banana posted:that is not c++. maybe this was the joke no actually it just looked like standard issue C++ porpoise hork to me
|
# ? Jul 24, 2016 17:25 |
|
i've been doing nothing but c++ for like 6 years so all my c# looks like c++
|
# ? Jul 24, 2016 17:33 |
|
the last time i had to professionally care about c++ was 2011 and i am very thankful for that
|
# ? Jul 24, 2016 18:09 |
|
GameCube posted:linq is so neat. i love linq. i want to marry linq
|
# ? Jul 24, 2016 18:12 |
|
GameCube posted:linq is so neat. i love linq. i want to marry linq epic thissery
|
# ? Jul 24, 2016 18:14 |
|
java 8 streams are an acceptable substitute for linq never want to go back to earlier versions of java
|
# ? Jul 24, 2016 18:25 |
|
linq is extremely good right up until you try to put the ?. operator in an Expression<Func<T,bool>> (e.g. the parameter to IQueryable.Where<T>) then it gives you a compile error because adding support for newer language features to the AST would be backwards-incompatible :/
|
# ? Jul 24, 2016 18:48 |
|
|
# ? May 24, 2024 14:10 |
|
Mr Dog posted:java 8 streams are an acceptable substitute for linq java 8 adds proper collections libraries java 9 is adding a repl now all we need is for java 10 to get rid of the checked exceptions and java will finally be pleasant to work with
|
# ? Jul 24, 2016 18:56 |